/// <summary> /// Creates an Integrated ANT-FS Client object, specifying the USB device number. Baud rate is assumed to be 57600bps. /// </summary> /// <param name="USBDeviceNum">USB device number</param> public ANT_IntegratedANTFSClient(byte USBDeviceNum) : base(USBDeviceNum, 57600) // For FS-enabled parts, Baud rate is 57600 { ANT_Common.enableDebugLogs(); responseBuf = new Queue <ANT_Response>(); if (!this.getDeviceCapabilities().FS) { this.Dispose(); throw new ANT_Exception("Found ANT USB device, but does not support FS"); } }
/// <summary> /// Creates an Integrated ANT-FS Client object, by automatically trying to connect to the USB stick /// </summary> public ANT_IntegratedANTFSClient() : base() // 57600 is tried first { ANT_Common.enableDebugLogs(); if (!this.getDeviceCapabilities().FS) { this.Dispose(); throw new ANT_Exception("Found ANT USB device, but does not support FS"); //TODO This is not a very effective auto init, for example: What happens if FS device is second device and first device isn't? Should we connect to other devices to check? } deviceResponse += dev_deviceResponse; deviceResponse += dev_hostdeviceEvents; }
/// <summary> /// Initialize the demo parameters /// </summary> static void Init() { try { Console.WriteLine("Attempting to connect to an ANT USB device..."); ANT_Common.enableDebugLogs(); // Enable debugging first, to enable ANT-FS specific logging device0 = new ANT_Device(); // Create a device instance using the automatic constructor (automatic detection of USB device number and baud rate) Console.WriteLine("Initialization was successful!"); } catch (Exception ex) { if (device0 == null) // Unable to connect to ANT { throw new Exception("Could not connect to any device.\n" + "Details: \n " + ex.Message); } else { throw new Exception("Error connecting to ANT: " + ex.Message); } } }
public AntPlusDevMgr() { if (antStick == null) { ANT_Common.enableDebugLogs(); findUsableAntDevice(); } numChannelsForDevices = antStick.getNumChannels(); var racer = new List <AntPlusRacerConfig.RacerInput>(); foreach (AntPlusRacerConfig.RacerInputType i in Enum.GetValues(typeof(AntPlusRacerConfig.RacerInputType))) { racer.Add(new AntPlusRacerConfig.RacerInput() { displayName = "", type = i, defaultDeviceId = 0 }); } //Add all devices from config foreach (AntPlusRacerConfig.RacerInput i in racer) { switch (i.type) { //case AntPlusRacerConfig.RacerInputType.ant_BikeCad_UsingSpd: // ds_AntPlus_BikeSpd spdOnly = new ds_AntPlus_BikeSpd(); // deviceList.Add(new AntPlus_Connection(spdOnly)); // deviceList.Add(new AntPlus_Connection(new ds_AntPlus_BikeCad_UsingSpd(spdOnly))); // break; case AntPlusRacerConfig.RacerInputType.ant_BikeCadAndSpd: deviceList.Add(new AntPlus_Connection(new ds_AntPlus_BikeSpdCad())); break; //case AntPlusRacerConfig.RacerInputType.ant_BikeSpd: // deviceList.Add(new AntPlus_Connection(new ds_AntPlus_BikeSpd())); // break; //case AntPlusRacerConfig.RacerInputType.ant_FitEqpmt: // deviceList.Add(new AntPlus_Connection(new ds_AntPlus_Fit())); // break; //case AntPlusRacerConfig.RacerInputType.ant_StrideSDM: // deviceList.Add(new AntPlus_Connection(new ds_AntPlus_StrideSDM())); // break; //default: //Not one of the ant types, ignore // break; } if (i.defaultDeviceId != 0) { deviceList.Last().dataSource.searchProfile.deviceNumber = i.defaultDeviceId; } if (!String.IsNullOrWhiteSpace(i.displayName)) { deviceList.Last().dataSource.customSourceName = i.displayName; } } startNextSearch(); }
public ANTManger() { if (antStick == null) { ANT_Common.enableDebugLogs(); findUsableAntDevice(); } /*if (ANT.FrameworkConfig.getInstance().remoteControlDevNum_negativeIsOff > 0) * { * numChannelsForDevices = antStick.getNumChannels() - 1; * RacerRemoteControl.startRemoteControl(antStick.getChannel(numChannelsForDevices)); * } * else * { * numChannelsForDevices = antStick.getNumChannels(); * }*/ numChannelsForDevices = antStick.getNumChannels(); ds_AntPlus_BikeSpd spdOnly = new ds_AntPlus_BikeSpd(); deviceList.Add(new AntPlus_Connection(spdOnly)); deviceList.Add(new AntPlus_Connection(new ds_AntPlus_BikeCad_UsingSpd(spdOnly))); deviceList.Add(new AntPlus_Connection(new ds_AntPlus_BikeSpdCad())); deviceList.Add(new AntPlus_Connection(new ds_AntPlus_BikeSpd())); //Add all devices from config /*foreach (ANT.FrameworkConfig.RacerInput i in ANT.FrameworkConfig.getInstance().enabledRacerInputs) * { * switch (i.type) * { * case ANT.FrameworkConfig.RacerInputType.ant_BikeCad_UsingSpd: * ds_AntPlus_BikeSpd spdOnly = new ds_AntPlus_BikeSpd(); * deviceList.Add(new AntPlus_Connection(spdOnly)); * deviceList.Add(new AntPlus_Connection(new ds_AntPlus_BikeCad_UsingSpd(spdOnly))); * break; * case ANT.FrameworkConfig.RacerInputType.ant_BikeCadAndSpd: * deviceList.Add(new AntPlus_Connection(new ds_AntPlus_BikeSpdCad())); * break; * case ANT.FrameworkConfig.RacerInputType.ant_BikeSpd: * deviceList.Add(new AntPlus_Connection(new ds_AntPlus_BikeSpd())); * break; * case ANT.FrameworkConfig.RacerInputType.ant_FitEqpmt: * deviceList.Add(new AntPlus_Connection(new ds_AntPlus_Fit())); * break; * case ANT.FrameworkConfig.RacerInputType.ant_StrideSDM: * deviceList.Add(new AntPlus_Connection(new ds_AntPlus_StrideSDM())); * break; * default: //Not one of the ant types, ignore * break; * } * * if (i.defaultDeviceId != 0) * deviceList.Last().dataSource.searchProfile.deviceNumber = i.defaultDeviceId; * * if (!String.IsNullOrWhiteSpace(i.displayName)) * deviceList.Last().dataSource.customSourceName = i.displayName; * }*/ startNextSearch(); }
public AntPlusDevMgr() { if (antStick == null) { ANT_Common.enableDebugLogs(); findUsableAntDevice(); } if (AntPlusRacerConfig.getInstance().remoteControlDevNum_negativeIsOff > 0) { numChannelsForDevices = antStick.getNumChannels() - 1; RacerRemoteControl.startRemoteControl(antStick.getChannel(numChannelsForDevices)); } else { numChannelsForDevices = antStick.getNumChannels(); } //Add all devices from config foreach (AntPlusRacerConfig.RacerInput i in AntPlusRacerConfig.getInstance().enabledRacerInputs) { switch (i.type) { case AntPlusRacerConfig.RacerInputType.ant_BikeCad_UsingSpd: ds_AntPlus_BikeSpd spdOnly = new ds_AntPlus_BikeSpd(); deviceList.Add(new AntPlus_Connection(spdOnly)); deviceList.Add(new AntPlus_Connection(new ds_AntPlus_BikeCad_UsingSpd(spdOnly))); break; case AntPlusRacerConfig.RacerInputType.ant_BikeCadAndSpd: deviceList.Add(new AntPlus_Connection(new ds_AntPlus_BikeSpdCad())); break; case AntPlusRacerConfig.RacerInputType.ant_BikeSpd: deviceList.Add(new AntPlus_Connection(new ds_AntPlus_BikeSpd())); break; case AntPlusRacerConfig.RacerInputType.ant_FitEqpmt: deviceList.Add(new AntPlus_Connection(new ds_AntPlus_Fit())); break; case AntPlusRacerConfig.RacerInputType.ant_StrideSDM: deviceList.Add(new AntPlus_Connection(new ds_AntPlus_StrideSDM())); break; default: //Not one of the ant types, ignore break; } if (i.defaultDeviceId != 0) { deviceList.Last().dataSource.searchProfile.deviceNumber = i.defaultDeviceId; } if (!String.IsNullOrWhiteSpace(i.displayName)) { deviceList.Last().dataSource.customSourceName = i.displayName; } } startNextSearch(); }