/// <summary> /// Called when the connection completes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Wasp_ConnectionEvent(object sender, ConnectionEventArgs e) { if (e.Connection == NorthPoleEngineering.WaspClassLibrary.ConnectionState.Connected) { Wasp wasp = sender as Wasp; // check if not WASP-B if (wasp.ProductType != ProductTypes.WASP_B) { // create a list of ANT radios we want to control List <object> radios = new List <object>(); RadioTypes[] radioTypes = { wasp.Radio1Type, wasp.Radio2Type, wasp.Radio3Type, wasp.Radio4Type }; for (int i = 0; i < radioTypes.Length; i++) { if (radioTypes[i] == RadioTypes.ANT) { // order is radio index, radio mode radios.AddRange(new object[] { i, Wasp.AntRadioModes.Controlled }); // connect to the radio reset event AntRadio antRadio = wasp.GetAntRadio(i); antRadio.ResetEvent += Radio_ResetEvent;; antRadio.Retries = 0; } } if (radios.Count > 0) { // this will reset the radios wasp.SetAntRadioMode(radios.ToArray()); } } } }
private void AntRadio_StatusEvent(object sender, AntRadio.ChannelStatus e) { AntRadio antRadio = sender as AntRadio; // disconnect from the status event antRadio.StatusEvent -= AntRadio_StatusEvent; if (_fitnessEquipment != null) { SetBasicResistance(); } }
/// <summary> /// Called when a radio is reset /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Radio_ResetEvent(object sender, EventArgs e) { AntRadio antRadio = sender as AntRadio; // disconnect from the reset event antRadio.ResetEvent -= Radio_ResetEvent; // the status event will occur when radio initialization is complete antRadio.StatusEvent += AntRadio_StatusEvent; // initialze the ANT radio for continuous scanning mode on channel 57 antRadio.ConfigureContinuousScanningMode(AntDeviceType.UnknownSensor, 57); }