Esempio n. 1
0
        override public void Update()
        {
            var    time = System.DateTime.Now;
            double dt   = time.Subtract(previousFrameTimestamp).TotalSeconds;

            previousFrameTimestamp = time;

            FITRecorder.AddRecord();
            AntManagerState.Instance.TripTotalKm   += (float)(AntManagerState.Instance.BikeSpeedKmh / 1000 / 3.6 * dt);
            AntManagerState.Instance.TripTotalTime += (float)dt;

            Console.WriteLine("update");

            workout?.Update();
            if (workout?.IsFinished == false)
            {
                AntManagerState.Instance.WorkoutElapsedTime += (float)dt;
            }
            else if (workout?.IsFinished == true)
            {
                StopWorkout();
            }
        }
Esempio n. 2
0
        public void Update()
        {
            var    time = System.DateTime.Now;
            double dt   = time.Subtract(previousFrameTimestamp).TotalSeconds;

            previousFrameTimestamp = time;

            FITRecorder.AddRecord();
            AntManagerState.Instance.TripTotalKm   += (float)(AntManagerState.Instance.BikeSpeedKmh / 1000 / 3.6 * dt);
            AntManagerState.Instance.TripTotalTime += (float)dt;

            // we take the power from power meter (bike power) if the settings tells us so
            bool takePowerFromBP = ConfigurationManager.AppSettings["power_source"].Equals("bp");

            if (takePowerFromBP && (bpCommander?.IsFound ?? false))
            {
                AntManagerState.Instance.CyclistPower = bpCommander.LastPower;
            }
            else if (fecCommander?.IsFound ?? false)
            {
                AntManagerState.Instance.CyclistPower = fecCommander.LastPower;
            }
            else
            {
                AntManagerState.Instance.CyclistPower = 0;
            }

            // Take cadence from cadence, then speed/cadence, then PM
            if (cadCommander?.IsFound ?? false)
            {
                AntManagerState.Instance.BikeCadence = (int)Math.Round(cadCommander.LastCadence);
            }
            else if (scCommander?.IsFound ?? false)
            {
                AntManagerState.Instance.BikeCadence = (int)Math.Round(scCommander.LastCadence);
            }
            else if (bpCommander?.IsFound ?? false)
            {
                AntManagerState.Instance.BikeCadence = (int)Math.Round(bpCommander.LastCadence);
            }
            else
            {
                AntManagerState.Instance.BikeCadence = 0;
            }

            if (hrmCommander?.IsFound ?? false)
            {
                AntManagerState.Instance.CyclistHeartRate = hrmCommander.LastBPM;
            }
            else
            {
                AntManagerState.Instance.CyclistHeartRate = 0;
            }

            if ((fecCommander?.IsFound ?? false) && bikeModel == BikeModel.FEC)
            {
                AntManagerState.Instance.BikeSpeedKmh = fecCommander.SpeedKmh;
            }

            AntManagerState.WriteToMemory();

            workout?.Update();
            if (workout?.IsFinished == false)
            {
                AntManagerState.Instance.WorkoutElapsedTime += (float)dt;
            }
            else if (workout?.IsFinished == true)
            {
                StopWorkout();
            }
        }