コード例 #1
0
        public void AddEventSlow(IDeviceGps gpsProvider, float time, float acceleration, float speed)
        {
            // record low frequence samples to get RunResults later on

            if (events.Count == 0)
            {
                // a new run started
                startTime = time;
                // init distance tracker
                runDistance.AddRunLocation(gpsProvider, time, speed, true);
                // add a null event as a start marker
                events.Add(new Event(0, 0, 0, 0, 0));
            }
            else
            {
                // update distance tracker
                runDistance.AddRunLocation(gpsProvider, time, speed, false);
            }

            Event e = new Event(time - startTime,
                                acceleration,
                                speed,
                                runDistance.DistanceFiltered,
                                runDistance.HeightFiltered);

            events.Add(e);
        }
コード例 #2
0
        // ///////////////////////////////////////////////////////////////////////////////////////////

        public PageRun(IRunMode runMode, IDeviceGps gps, IDeviceAcceleromter accelerometer, PageMain parentPage, bool demoMode)
        {
            InitializeComponent();
            Debug.LogToFileMethod();

            NavigationPage.SetHasBackButton(this, false);
            NavigationPage.SetHasNavigationBar(this, false);

            gpsProvider           = gps;
            accelerometerProvider = accelerometer;
            runModeProvider       = runMode;
            pageNavigation        = parentPage;
            isDemoMode            = demoMode;

            var speedoFilter = Settings.GetValueOrDefault(Settings.SpeedoFilter, 1);
            var filterSize   = speedoFilter * 10;

            Debug.LogToFile("filter mode: " + Tools.ToFilterMode(speedoFilter));

            // default = 1*10 = 10 samples = medium // 0 = off // strong = 2*10 = 20 samples
            movingAverageForDisplay = new MovingAverage(filterSize);

            isAccelerationMode = runModeProvider.Mode.Equals(RunModeAcceleration.Mode);

            InitLayout();
        }
コード例 #3
0
ファイル: RunDistance.cs プロジェクト: SebRol/car-performance
        public void AddStartLocation(IDeviceGps gps, float time)
        {
            startLatitudeList.Add(gps.GetLatitude());
            startLongitudeList.Add(gps.GetLongitude());
            startAltitudeList.Add(gps.GetAltitude());

            lastTime = time;
        }
コード例 #4
0
        public void AddStartLocation(IDeviceGps gps, float time)
        {
            // refuse "location of launch" if event data is present
            if (events.Count > 0)
            {
                return;
            }

            runDistance.AddStartLocation(gps, time);
        }
コード例 #5
0
        public PageMain()
        {
            InitializeComponent();
            Debug.LogToFileMethod();

            NavigationPage.SetHasBackButton(this, false);
            NavigationPage.SetHasNavigationBar(this, false);

            // DependencyService decides if to use iOS or Android
            gpsProvider           = DependencyService.Get <IDeviceGps>();
            accelerometerProvider = DependencyService.Get <IDeviceAcceleromter>();
            soundProvider         = DependencyService.Get <IDeviceSound>();

            runModeProvider       = new RunModeAcceleration(accelerometerProvider, soundProvider);
            accelerometerRecorder = new AccelerometerRecorder(true); // true: use queue mode to limit recording size

            // on first start -> use device language -> update our settings
            // on next starts -> use our updated settings
            LocaleId deviceLanguage = DependencyService.Get <IDeviceLocale>().GetLocale();

            // set language, use system language as default
            Localization.isEnglish = Settings.GetValueOrDefault(Settings.Language, deviceLanguage == LocaleId.English);
            Settings.AddOrUpdateValue(Settings.Language, Localization.isEnglish);

            InitLayout();
            InitLocalisation();
            InitHelp();

            bool showDisclaimer = Settings.GetValueOrDefault(Settings.Disclaimer, true);
            bool showTipOfDay   = Settings.GetValueOrDefault(Settings.TipOfDay, true);

            if (showDisclaimer || showTipOfDay)
            {
                Device.StartTimer(TimeSpan.FromMilliseconds(50), () =>
                {
                    if (isStartUpNoteShown == false) // only show once
                    {
                        isStartUpNoteShown = true;

                        if (showDisclaimer)
                        {
                            Navigation.PushAsync(new PageText(PageText.ContentType.Disclaimer));
                        }
                        else
                        {
                            Navigation.PushAsync(new PageText(PageText.ContentType.TipOfDay));
                        }
                    }

                    return(false); // stop timer
                });
            }
        }
コード例 #6
0
        public PageDebugGps(IDeviceGps gps)
        {
            InitializeComponent();
            Debug.LogToFileMethod();

            Title = "Debug Location";
            NavigationPage.SetHasNavigationBar(this, false);

            gpsProvider = gps;

            Device.StartTimer(TimeSpan.FromSeconds(1), () =>
            {
                heartBeat++;
                labelHeartBeat.Text = "Heartbeat: " + heartBeat;
                if (heartBeat % 5 == 0)
                {
                    OnGpsStatusUpdate();
                }
                return(true); // restart timer
            });
        }
コード例 #7
0
        public void Dispose() // IDisposable
        {
            imgBackground.Source = null;
            imgBackground        = null;

            imgGpsStateOk.Source = null;
            imgGpsStateOk        = null;

            imgGpsStateNotOk.Source = null;
            imgGpsStateNotOk        = null;

            imgMountStateOk.Source = null;
            imgMountStateOk        = null;

            imgMountStateNotOk.Source = null;
            imgMountStateNotOk        = null;

            imgVelocityStateOk.Source = null;
            imgVelocityStateOk        = null;

            imgVelocityStateNotOk.Source = null;
            imgVelocityStateNotOk        = null;

            if (Config.Debug.PageRunAdjustEnabled)
            {
                imgDebugRunAdjust.Source  = null;
                imgDebugRunAdjust         = null;
                tgrDebugRunAdjust.Tapped -= OnImageDebugRunAdjust;
                tgrDebugRunAdjust         = null;
            }

            lblGpsState.SizeChanged      -= OnLayoutSizeChanged;
            lblMountState.SizeChanged    -= OnLayoutSizeChanged;
            lblVelocityState.SizeChanged -= OnLayoutSizeChanged;

            lblGpsState      = null;
            lblMountState    = null;
            lblVelocityState = null;

            lytHorizontalTab = null;

            btnTabAcceleration.Image    = null;
            btnTabAcceleration.Clicked -= OnButtonTabAcceleration;
            btnTabAcceleration          = null;

            btnTabBrake.Image    = null;
            btnTabBrake.Clicked -= OnButtonTabBrake;
            btnTabBrake          = null;

            btnTabZeroToZero.Image    = null;
            btnTabZeroToZero.Clicked -= OnButtonTabZeroToZero;
            btnTabZeroToZero          = null;

            btnTabResults.Image    = null;
            btnTabResults.Clicked -= OnButtonTabResults;
            btnTabResults          = null;

            btnHelp.Image    = null;
            btnHelp.Clicked -= OnButtonHelp;
            btnHelp          = null;

            if (Config.Debug.PagePurchaseEnabled)
            {
                btnDebugPurchase.Image    = null;
                btnDebugPurchase.Clicked -= OnButtonDebugPurchase;
                btnDebugPurchase          = null;
            }

            btnConfig          = null;
            btnConfig.Image    = null;
            btnConfig.Clicked -= OnButtonConfig;

            btnSetup.Image    = null;
            btnSetup.Clicked -= OnButtonSetup;
            btnSetup          = null;

            btnRun.Image    = null;
            btnRun.Clicked -= OnButtonRun;
            btnRun          = null;

            btnProfile.Image    = null;
            btnProfile.Clicked -= OnButtonProfile;
            btnProfile          = null;

            gpsProvider           = null;
            accelerometerProvider = null;
            runModeProvider       = null;
            soundProvider         = null;
            accelerometerRecorder = null;
            pageRun            = null;
            pageConfig         = null;
            pageProfile        = null;
            pageResults        = null;
            pageHelp           = null;
            pageDebugRunAdjust = null;
            pageDebugPurchase  = null;
            pageSetup          = null;
        }
コード例 #8
0
ファイル: RunDistance.cs プロジェクト: SebRol/car-performance
        public void AddRunLocation(IDeviceGps gps, float time, float speed, bool isRunStart)
        {
            float deltaTime = time - lastTime;
            float distance  = 0;
            float height    = 0;

            if (isRunStart)
            {
                if ((mode.Equals(RunModeAcceleration.Mode)) || (mode.Equals(RunModeZeroToZero.Mode)))
                {
                    // vehicle launched from zero speed

                    // in mode acceleration OR zerotozero -> we can make the start location more precise
                    if ((startLatitudeList.Count > 0))
                    {
                        // some locations were reported until vehicle launched -> use them as starting point
                        startLatitude  = startLatitudeList.Average();
                        startLongitude = startLongitudeList.Average();
                        startAltitude  = startAltitudeList.Average();
                    }
                    else
                    {
                        // cannot make location more precise -> use given location
                        startLatitude  = gps.GetLatitude();
                        startLongitude = gps.GetLongitude();
                        startAltitude  = gps.GetAltitude();
                    }
                }
                else
                {
                    // vehicle reached target speed in mode "brake"

                    // in mode brake -> use last known location as starting point
                    if (startLatitudeList.Count > 0)
                    {
                        // some locations were reported since vehicle launched in brake mode
                        startLatitude  = startLatitudeList.Last();
                        startLongitude = startLongitudeList.Last();
                        startAltitude  = startAltitudeList.Last();

                        // check if given location is same as last known location
                        if (IsLocationEqual(startLatitude, startLongitude, gps.GetLatitude(), gps.GetLongitude()))
                        {
                            // given location is same as last known location -> add the distance (=speed*time) traveled since last gps update
                            // this is the case in 95% of all cases, because this method is called 20 times a seconds, but gps update is only 1Hz
                            distance = speed * deltaTime;
                        }
                        else
                        {
                            // this is the case in 5% of all cases (more ore less)
                            // given location is the freshest location available
                            startLatitude  = gps.GetLatitude();
                            startLongitude = gps.GetLongitude();
                            startAltitude  = gps.GetAltitude();
                        }
                    }
                    else
                    {
                        // no locations were reported since launch -> use given location as starting point
                        startLatitude  = gps.GetLatitude();
                        startLongitude = gps.GetLongitude();
                        startAltitude  = gps.GetAltitude();
                    }
                }
            }
            else
            {
                // given location is not a start location -> measurement is running

                distanceGps = gps.GetDistance(startLatitude, startLongitude, gps.GetLatitude(), gps.GetLongitude());

                if ((mode.Equals(RunModeAcceleration.Mode)) || (mode.Equals(RunModeZeroToZero.Mode)))
                {
                    if (IsLocationEqual(lastLatitude, lastLongitude, gps.GetLatitude(), gps.GetLongitude()))
                    {
                        // no gps update since last call -> add distance traveled since last gps update to the filter
                        // this is the case in 95% of all cases, because this method is called 20 times a seconds, but gps update is only 1Hz
                        distance = distanceFiltered + speed * deltaTime;
                    }
                    else
                    {
                        // given location is a new one
                        // insert a reference from the gps-driver to the filter (correct our speed/time drift)
                        distance = distanceGps;
                    }
                }
                else
                {
                    // we are in mode "brake" -> just integrate speed by time -> add distance traveled to the filter
                    // inserting a reference from the gps-driver would be more incorrect
                    distance = distanceFiltered + speed * deltaTime;
                }

                // "height since start"
                height = gps.GetHeight(startAltitude, gps.GetAltitude());
                // add to the height-filter
                heightFiltered = heightFilter.Get(height);
                // overwrite to the raw buffer
                heightGps = height;
            }

            if (distance > 0.01) // prevent update of filter if no distance was calculated
            {
                // apply moving average filter
                distanceFiltered = distanceFilter.Get(distance);
            }

            lastTime      = time;
            lastLatitude  = gps.GetLatitude();
            lastLongitude = gps.GetLongitude();
        }