private void OnPageSpecificTrainer(SpecificTrainerPage page, uint counter) { System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; AntManagerState.Instance.CyclistPower = page.InstantaneousPower; AntManagerState.WriteToMemory(); }
private void OnPageBikeCadence(BikeCadenceData page, uint a) { var cad = page.Cadence; Console.WriteLine("CAD : " + cad); AntManagerState.Instance.BikeCadence = (int)Math.Round(cad); AntManagerState.WriteToMemory(); }
private void OnPageHeartRate(HeartRateData page, uint a) { var hr = page.HeartRate; Console.WriteLine("HRM : " + hr); AntManagerState.Instance.CyclistHeartRate = hr; AntManagerState.WriteToMemory(); }
private void OnPageGeneralFE(GeneralFePage page, uint counter) { if (useAsModel) { speedKmh = page.Speed * 0.0036f; AntManagerState.Instance.BikeSpeedKmh = speedKmh; AntManagerState.WriteToMemory(); } }
private void OnPowerPage(StandardPowerOnlyPage page, uint counter) { lastPower = page.InstantaneousPower; var cad = page.InstantaneousCadence; AntManagerState.Instance.CyclistPower = lastPower; AntManagerState.Instance.BikeCadence = (int)Math.Round((double)cad); AntManagerState.WriteToMemory(); }
internal void StopWorkout() { workout = null; AntManagerState.Instance.WorkoutName = null; AntManagerState.Instance.TargetPower = 0; AntManagerState.Instance.NextTargetPower = 0; AntManagerState.Instance.RemainingIntervalTime = 0; AntManagerState.Instance.RemainingTotalTime = 0; AntManagerState.Instance.WorkoutElapsedTime = 0; AntManagerState.Instance.WorkoutMessage = null; AntManagerState.WriteToMemory(); FITRecorder.TerminateLap(); }
public new void Update() { AntManagerState state = AntManagerState.Instance; var t = state.TripTotalTime; int idx = SegmentIndex(t); if (idx == -1) { state.TargetPower = 0; } else { Console.WriteLine("Target power : {0}", Segments[idx].Power.Intensity); state.TargetPower = Segments[idx].Power.Intensity * state.CriticalPower; state.RemainingIntervalTime = Segments[idx].EndTime - t; state.RemainingTotalTime = Segments[Segments.Count - 1].EndTime - t; if (idx + 1 < Segments.Count) { state.NextTargetPower = Segments[idx + 1].Power.Intensity * state.CriticalPower; } } }
public void Start() { try { usbDevice = new ANT_Device(); usbDevice.ResetSystem(); usbDevice.setNetworkKey(0, NETWORK_KEY); } catch (Exception e) { Console.WriteLine(e.Message); Console.Read(); return; } network = new AntPlus.Types.Network(0, NETWORK_KEY, CHANNEL_FREQUENCY); Console.WriteLine(ConfigurationManager.AppSettings["model"]); if (ConfigurationManager.AppSettings["ridermodel"] == "fec") { Console.WriteLine("Using FEC for physical model."); bikeModel = BikeModel.FEC; } else if (ConfigurationManager.AppSettings["ridermodel"] == "physics") { Console.WriteLine("Using integrated model for physical model."); bikeModel = BikeModel.BikePhysics; } AntManagerState.Initialize(Single.Parse(ConfigurationManager.AppSettings["cp"])); InitHRM(0); InitCAD(1); InitFEC(2); InitBP(3); InitSC(4); InitAC(); InitFIT(); }
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(); } }