diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2015-07-30 13:51:24 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:58:53 +0300 |
commit | d753d3448c63bcadcced3a807fe21bcd85dc515d (patch) | |
tree | f19f293d31ca8949cd9eb81001b0e03b5089ed3a /routing | |
parent | 4fb687a3794a06b1d33b5d8766497fc7f4370846 (diff) |
Changing in cpp part of turn notification programming interface and some changes in implementation.
Diffstat (limited to 'routing')
-rw-r--r-- | routing/routing_session.cpp | 38 | ||||
-rw-r--r-- | routing/routing_session.hpp | 6 | ||||
-rw-r--r-- | routing/routing_settings.hpp | 9 | ||||
-rw-r--r-- | routing/routing_tests/turns_tts_text_tests.cpp | 1 | ||||
-rw-r--r-- | routing/turns_sound.cpp | 7 | ||||
-rw-r--r-- | routing/turns_sound.hpp | 8 | ||||
-rw-r--r-- | routing/turns_tts_text.cpp | 1 | ||||
-rw-r--r-- | routing/turns_tts_text.hpp | 2 |
8 files changed, 65 insertions, 7 deletions
diff --git a/routing/routing_session.cpp b/routing/routing_session.cpp index bc35a48d4d..22b0cf1ef4 100644 --- a/routing/routing_session.cpp +++ b/routing/routing_session.cpp @@ -210,7 +210,8 @@ void RoutingSession::GetRouteFollowingInfo(FollowingInfo & info) (distanceToTurnMeters < kShowPedestrianTurnInMeters) ? turn.m_pedestrianTurn : turns::PedestrianDirection::None; // Voice turn notifications. - m_turnsSound.UpdateRouteFollowingInfo(info, turn, distanceToTurnMeters); + if (m_routingSettings.m_soundDirection) + m_turnsSound.UpdateRouteFollowingInfo(info, turn, distanceToTurnMeters); } else { @@ -282,18 +283,49 @@ bool RoutingSession::AreTurnNotificationsEnabled() const return m_turnsSound.IsEnabled(); } -void RoutingSession::SetTurnSoundNotificationsUnits(routing::turns::sound::LengthUnits const & units) +void RoutingSession::SetTurnNotificationsUnits(routing::turns::sound::LengthUnits const & units) { threads::MutexGuard guard(m_routeSessionMutex); UNUSED_VALUE(guard); m_turnsSound.SetLengthUnits(units); } -routing::turns::sound::LengthUnits RoutingSession::GetTurnSoundNotificationsUnits() const +routing::turns::sound::LengthUnits RoutingSession::GetTurnNotificationsUnits() const { threads::MutexGuard guard(m_routeSessionMutex); UNUSED_VALUE(guard); return m_turnsSound.GetLengthUnits(); } +void RoutingSession::SetTurnNotificationsLocale(string const & locale) +{ + threads::MutexGuard guard(m_routeSessionMutex); + UNUSED_VALUE(guard); + m_turnsSound.SetLocale(locale); +} + +string RoutingSession::GetTurnNotificationsLocale() const +{ + threads::MutexGuard guard(m_routeSessionMutex); + UNUSED_VALUE(guard); + return m_turnsSound.GetLocale(); +} + +void RoutingSession::ResetRoutingWatchdogTimer() +{ + if (m_routingWatchdog) + { + m_routingWatchdog->Cancel(); + m_routingWatchdog->WaitForCompletion(); + m_routingWatchdog.reset(); + } +} + +void RoutingSession::InitRoutingWatchdogTimer(uint32_t timeoutSec) +{ + ASSERT_NOT_EQUAL(0, timeoutSec, ()); + ASSERT(nullptr == m_routingWatchdog, ()); + + m_routingWatchdog = make_unique<DeferredTask>([this](){ m_router->ClearState(); }, seconds(timeoutSec)); +} } // namespace routing diff --git a/routing/routing_session.hpp b/routing/routing_session.hpp index 7464b4f5cc..cf759c2532 100644 --- a/routing/routing_session.hpp +++ b/routing/routing_session.hpp @@ -88,8 +88,10 @@ public: // Sound notifications for turn instructions. void EnableTurnNotifications(bool enable); bool AreTurnNotificationsEnabled() const; - void SetTurnSoundNotificationsUnits(routing::turns::sound::LengthUnits const & units); - routing::turns::sound::LengthUnits GetTurnSoundNotificationsUnits() const; + void SetTurnNotificationsUnits(routing::turns::sound::LengthUnits const & units); + routing::turns::sound::LengthUnits GetTurnNotificationsUnits() const; + void SetTurnNotificationsLocale(string const & locale); + string GetTurnNotificationsLocale() const; private: struct DoReadyCallback diff --git a/routing/routing_settings.hpp b/routing/routing_settings.hpp index efae323b27..e10141aee3 100644 --- a/routing/routing_settings.hpp +++ b/routing/routing_settings.hpp @@ -15,6 +15,9 @@ struct RoutingSettings /// If m_matchRoute is equal to false GPS bearing is used while /// the current position is matched to the route. bool m_matchRoute; + /// \brief if m_soundDirection is equal to true an end user get sound notification + /// before directions. + bool m_soundDirection; /// \brief m_matchingThresholdM is half width of the passage around the route /// for route matching in meters. That means if a real current position is closer than @@ -25,11 +28,13 @@ struct RoutingSettings inline RoutingSettings GetPedestrianRoutingSettings() { - return RoutingSettings({ false /* m_matchRoute */, 20. /* m_matchingThresholdM */ }); + return RoutingSettings({ false /* m_matchRoute */, false /* m_soundDirection */, + 20. /* m_matchingThresholdM */ }); } inline RoutingSettings GetCarRoutingSettings() { - return RoutingSettings({ true /* m_matchRoute */, 50. /* m_matchingThresholdM */ }); + return RoutingSettings({ true /* m_matchRoute */, true /* m_soundDirection */, + 50. /* m_matchingThresholdM */ }); } } // namespace routing diff --git a/routing/routing_tests/turns_tts_text_tests.cpp b/routing/routing_tests/turns_tts_text_tests.cpp index d123089291..b2bba62050 100644 --- a/routing/routing_tests/turns_tts_text_tests.cpp +++ b/routing/routing_tests/turns_tts_text_tests.cpp @@ -5,6 +5,7 @@ #include "std/string.hpp" + namespace { using namespace routing::turns; diff --git a/routing/turns_sound.cpp b/routing/turns_sound.cpp index ba4ffc90a5..b8b38602d6 100644 --- a/routing/turns_sound.cpp +++ b/routing/turns_sound.cpp @@ -37,6 +37,13 @@ namespace turns { namespace sound { +string TurnsSound::GenerateTurnText(uint32_t distanceUnits, uint8_t exitNum, bool useThenInsteadOfDistance, + TurnDirection turnDir, LengthUnits lengthUnits) const +{ + Notification const notification(distanceUnits, exitNum, useThenInsteadOfDistance, turnDir, lengthUnits); + return m_getTtsText(notification); +} + void TurnsSound::UpdateRouteFollowingInfo(location::FollowingInfo & info, TurnItem const & turn, double distanceToTurnMeters) { diff --git a/routing/turns_sound.hpp b/routing/turns_sound.hpp index 74c1e2b7c0..91851bcff0 100644 --- a/routing/turns_sound.hpp +++ b/routing/turns_sound.hpp @@ -2,6 +2,7 @@ #include "routing/turns.hpp" #include "routing/turns_sound_settings.hpp" +#include "routing/turns_tts_text.hpp" #include "std/string.hpp" @@ -50,7 +51,12 @@ class TurnsSound /// m_nextTurnNotificationProgress == Second. PronouncedNotification m_nextTurnNotificationProgress; uint32_t m_nextTurnIndex; + /// getTtsText is a convector form turn notification information and locale to + /// notification string. + GetTtsText m_getTtsText; + string GenerateTurnText(uint32_t distanceUnits, uint8_t exitNum, bool useThenInsteadOfDistance, + TurnDirection turnDir, LengthUnits lengthUnits) const; public: TurnsSound() : m_enabled(false), m_speedMetersPerSecond(0.), m_settings(), m_nextTurnNotificationProgress(PronouncedNotification::Nothing), m_nextTurnIndex(0) {} @@ -59,6 +65,8 @@ public: void Enable(bool enable); void SetLengthUnits(LengthUnits units); inline LengthUnits GetLengthUnits() const { return m_settings.GetLengthUnits(); } + inline void SetLocale(string const & locale) { m_getTtsText.SetLocale(locale); } + inline string GetLocale() const { return m_getTtsText.GetLocale(); } void SetSpeedMetersPerSecond(double speed); /// \brief UpdateRouteFollowingInfo updates information about the next turn notification. diff --git a/routing/turns_tts_text.cpp b/routing/turns_tts_text.cpp index 69292a2dfe..1105c36574 100644 --- a/routing/turns_tts_text.cpp +++ b/routing/turns_tts_text.cpp @@ -34,6 +34,7 @@ namespace sound { void GetTtsText::SetLocale(string const & locale) { + m_locale = locale; m_getCurLang.reset(new platform::GetTextById(platform::TextSource::TtsSound, locale)); ASSERT(m_getCurLang && m_getCurLang->IsValid(), ()); } diff --git a/routing/turns_tts_text.hpp b/routing/turns_tts_text.hpp index e7e29af89a..9c54cce5e3 100644 --- a/routing/turns_tts_text.hpp +++ b/routing/turns_tts_text.hpp @@ -23,6 +23,7 @@ class GetTtsText public: string operator()(Notification const & notification) const; void SetLocale(string const & locale); + inline string GetLocale() const { return m_locale; } /// SetLocaleWithJson is used for writing unit tests only. void SetLocaleWithJson(string const & jsonBuffer); @@ -30,6 +31,7 @@ private: string GetTextById(string const & textId) const; unique_ptr<platform::GetTextById> m_getCurLang; + string m_locale; }; /// Generates text message id about the distance of the notification. For example: In 300 meters. |