//Detect the Globalsat (protocol) device public override GlobalsatProtocol Device() { GlobalsatProtocol gdevice = null; FitnessDevice_Globalsat gfdev = this.FitnessDevice; if (gfdev != null) { gdevice = gfdev.Device(); } return(gdevice); }
public string Detect(bool query) { string identification = "Detection Error"; try { if (!query || this.Device().Open()) { FitnessDevice_Globalsat cmpFitness = this; if (this is FitnessDevice_GsSport) { cmpFitness = (this as FitnessDevice_GsSport).FitnessDevice; } //devId and lastDevId should not be null if (cmpFitness.configInfo.AllowedIds == null || cmpFitness.configInfo.AllowedIds.Count == 0) { identification = cmpFitness.Device().devId + " (Globalsat Generic)"; } else { bool found = false; foreach (string s in cmpFitness.configInfo.AllowedIds) { if (cmpFitness.Device().devId.Equals(s)) { found = true; identification = cmpFitness.Device().devId; break; } } if (!found) { identification = cmpFitness.Device().devId + " (" + cmpFitness.Name + " Compatible)"; } } IList <string> s2 = this.configInfo.GetLastValidComPorts(); if (s2 != null && s2.Count > 0) { identification += " on " + s2[0]; } } else { identification = this.Device().lastDevId + " (" + ZoneFiveSoftware.Common.Visuals.CommonResources.Text.Devices.ImportJob_Status_CouldNotOpenDeviceError + ")"; } } catch (Exception e) { identification = Properties.Resources.Device_OpenDevice_Error + " (Detect)" + e; } finally { if (this.Device() != null) { //this.Device().DataRecieved Should not be handled here this.Device().Close(); } } return(identification); }