Exemplo n.º 1
0
        public async Task CheckAreWeStillOnTheRoadAsync()
        {
            if (waypointChecker.TollPoint != null)
            {
                Debug.WriteLine(waypointChecker.TollPoint.Name);
                BaseStatus statusObject = StatusesFactory.GetStatus(TollStatus);
                _textToSpeech.IsEnabled = true;

                switch (_storedSettingsService.CurrentRoadStatus)
                {
                case TollGeolocationStatus.NearTollRoadEntrance:
                case TollGeolocationStatus.NotOnTollRoad:
                    break;

                case TollGeolocationStatus.NearTollRoadExit:
                case TollGeolocationStatus.OnTollRoad:
                    if (await statusObject.SpeechToTextService.AskQuestionAsync($"Are you still going from {waypointChecker.TollPoint.Name} tollroad?"))
                    {
                        waypointChecker.SetEntrance(waypointChecker.TollPoint);

                        if (waypointChecker.TollPoint.WaypointAction == WaypointAction.Bridge)
                        {
                            waypointChecker.SetExit(waypointChecker.TollPoint);

                            waypointChecker.SetTollPointsInRadius(null);
                            waypointChecker.ClearData();
                            TollStatus = Mvx.Resolve <IStoredSettingsService>().CurrentRoadStatus == TollGeolocationStatus.OnTollRoad
                                               ? Mvx.Resolve <IStoredSettingsService>().CurrentRoadStatus
                                               : TollGeolocationStatus.NotOnTollRoad;
                        }
                        else
                        {
                            TollStatus = TollGeolocationStatus.OnTollRoad;
                        }
                    }
                    else
                    {
                        TollStatus = TollGeolocationStatus.NotOnTollRoad;
                        Mvx.Resolve <IStoredSettingsService>().CurrentRoadStatus = TollStatus;
                    }
                    break;
                }
            }
        }
Exemplo n.º 2
0
        protected async virtual Task CheckTrackStatus()
        {
            Log.LogMessage("Track status is cheking...");

            if (_locationProcessing)
            {
                Log.LogMessage("Ignore location in FACADE because location processing");
                return;
            }

            await _semaphor.WaitAsync();

            if (_locationProcessing)
            {
                return;
            }

            _locationProcessing = true;

            try
            {
                BaseStatus statusObject = StatusesFactory.GetStatus(TollStatus);

                //if (_activity.MotionType == MotionType.Still)
                //{
                //    Log.LogMessage("Ignore location in FACADE because we are still");
                //    return;
                //}
                //else
                //{
                //    if (statusObject.CheckBatteryDrain())
                //    {
                //        Log.LogMessage("Ignore location in FACADE because we are too away from nearest waypoint");
                //        return;
                //    }
                //}

                var statusBeforeCheck = TollStatus;
                Log.LogMessage($"Current status before check= {TollStatus}");

                TollStatus = await statusObject.CheckStatus();

                statusObject = StatusesFactory.GetStatus(TollStatus);

                Log.LogMessage($"Current status after check = {TollStatus}");
                if (statusBeforeCheck != TollStatus)
                {
                    Mvx.Resolve <INotificationSender>().SendLocalNotification($"Status: {TollStatus.ToString()}", $"Lat: {_geoWatcher.Location?.Latitude}, Long: {_geoWatcher.Location?.Longitude}");
                }
            }
            catch (Exception e)
            {
                Insights.Report(e);
                Log.LogMessage(e.Message + e.StackTrace);
            }
            finally
            {
                _locationProcessing = false;
                _semaphor.Release();
            }
        }