Esempio n. 1
0
        public void OnLocationChanged(Location location)
        {
            logDebug(LogLevel.Verbose, $"new loc {locationToString(location)}");

            if (!statistics.CanUpdate())
            {
                // don't alarm because we have already computing distance and it will sends the proper info
                // about if GPS-on alarm is OK
                this.signalTimer.Value.Update(canAlarm: false);
                return;
            }

            double dist = 0;

            try
            {
                dist = updateLocation(location);
            }
            finally
            {
                // alarm about GPS only if there is no off-track alarm
                this.signalTimer.Value.Update(canAlarm: dist <= 0);

                statistics.UpdateCompleted(dist, location.Accuracy);
                MainReceiver.SendDistance(this, statistics.SignedDistance);
            }
        }
Esempio n. 2
0
 private void Receiver_InfoRequest(object sender, EventArgs e)
 {
     logLocal(LogLevel.Verbose, "Received info request");
     if (this.signalTimer.Value.HasGpsSignal)
     {
         MainReceiver.SendDistance(this, statistics.SignedDistance);
     }
     else
     {
         MainReceiver.SendAlarm(this, Message.NoSignalText);
     }
 }