Exemplo n.º 1
0
        public void OnGpsLocationUpdate() // IGpsListener
        {
            float s = gpsProvider.GetSpeed();

            timeStampLastGps = DateTime.Now.Ticks;

            if (s > 2) // TODO make m/s configurable
            {
                // vehicle is moving
                velocityNotOkTimeout = CONDITION_NOT_OK_TIMEOUT;
            }

            if (accelerometerProvider != null)
            {
                // calibrate accelerometer with gps data
                accelerometerProvider.SetSpeed(s);
            }

            if (gpsProvider.GetStatus() == IDeviceGpsStatus.Connected)
            {
                // gps is ready to go
                if (gpsNotOkTimeout == CONDITION_NOT_OK)
                {
                    // setup final cool down
                    gpsNotOkTimeout = CONDITION_NOT_OK_TIMEOUT;
                }
            }
            else
            {
                // wait for gps
                gpsNotOkTimeout = CONDITION_NOT_OK;
            }
        }
Exemplo n.º 2
0
        public void OnGpsLocationUpdate() // IGpsListener
        {
            timeStampLastGps = DateTime.Now.Ticks;

            accelerometerProvider.SetSpeed(gpsProvider.GetSpeed());

            if (IsResultAvailable() == false)
            {
                // vehicle is standing still before launch -> make location of launch more precise by averaging all locations
                // OR
                // in mode "brake" we are waiting until target speed is reached -> update last known location
                runData.AddStartLocation(gpsProvider, accelerometerProvider.GetTimeStamp());
            }

            // switch distance indicator according to traveled distance
            if (isAccelerationMode == true)
            {
                if (isDemoMode == false) // if demo mode -> distance indicator is disabled
                {
                    float distance = runData.GetDistanceFiltered();

                    if ((distance <= 201) && (imgDistanceOff.IsVisible == false))
                    {
                        // no distance traveled
                        imgDistanceOff.IsVisible     = true;
                        imgDistanceQuarter.IsVisible = false;
                        imgDistanceHalf.IsVisible    = false;
                    }
                    else if ((distance > 402) && (distance <= 804) && (imgDistanceQuarter.IsVisible == false))
                    {
                        // quarter of a mile passed
                        imgDistanceQuarter.IsVisible = true;
                        imgDistanceHalf.IsVisible    = false;
                        imgDistanceOff.IsVisible     = false;
                    }
                    else if ((distance > 804) && (imgDistanceHalf.IsVisible == false))
                    {
                        // half of a mile passed
                        imgDistanceHalf.IsVisible    = true;
                        imgDistanceQuarter.IsVisible = false;
                        imgDistanceOff.IsVisible     = false;
                    }
                }
            }
        }