//set list of active satellites public void setSatellite(GpsPosition position) { if (position.GetSatellitesInSolution() == null) { satelliteList = new List <Satellite>(); } else { satelliteList = position.GetSatellitesInView().ToList(); } }
void UpdateData(object sender, System.EventArgs args) { if (gps.Opened) { string str = ""; if (device != null) { str = device.FriendlyName + " " + device.ServiceState + ", " + device.DeviceState + "\n"; } if (position != null) { if (position.LatitudeValid) { str += "Latitude (DD):\n " + position.Latitude + "\n"; str += "Latitude (D,M,S):\n " + position.LatitudeInDegreesMinutesSeconds + "\n"; } if (position.LongitudeValid) { str += "Longitude (DD):\n " + position.Longitude + "\n"; str += "Longitude (D,M,S):\n " + position.LongitudeInDegreesMinutesSeconds + "\n"; } if (position.SatellitesInSolutionValid && position.SatellitesInViewValid && position.SatelliteCountValid) { str += "Satellite Count:\n " + position.GetSatellitesInSolution().Length + "/" + position.GetSatellitesInView().Length + " (" + position.SatelliteCount + ")\n"; } if (position.TimeValid) { str += "Time:\n " + position.Time.ToString() + "\n"; } } status.Text = str; } }
void UpdateData(object sender, System.EventArgs args) { try { if (gps.Opened) { string str = ""; if (device != null) { str = "Name: '" + device.FriendlyName + "' Svc: '" + device.ServiceState + "', Dvc: '" + device.DeviceState + "'\r\n"; } else { str = "Name: '' Svc:''\r\n"; } if (position != null) { //if all valid if ((((((this.position.LatitudeValid && this.position.LongitudeValid) && this.position.SatellitesInSolutionValid) && this.position.SatellitesInViewValid) && this.position.SatelliteCountValid) && this.position.TimeValid) && (this.position.SatelliteCount > 2)) { m_FixValid = true; if (m_XMLLogging) { this.position2XMLFile(this.position); } } else { m_FixValid = false; } //Latitude if (position.LatitudeValid) { str += "Lat: " + position.Latitude.ToString("00.000") + " "; //str += "Lat (D,M,S): " + position.LatitudeInDegreesMinutesSeconds + "\r\n"; } else { str += "Lat: --.--- "; } //Longitude if (position.LongitudeValid) { str += "Lon: " + position.Longitude.ToString("00.000") + "\r\n"; //str += "Lon (D,M,S): " + position.LongitudeInDegreesMinutesSeconds + "\r\n"; } else { str += "Lon: --.---\r\n"; } //sat in view and in solution if (position.SatellitesInSolutionValid && position.SatellitesInViewValid && position.SatelliteCountValid) { str += "Sat. Count: " + position.GetSatellitesInSolution().Length + "/" + position.GetSatellitesInView().Length + " (" + position.SatelliteCount + ")\r\n"; } //list sats in solution if (position.SatellitesInSolutionValid) { satSol = position.GetSatellitesInSolution(); } //list sats in view and there signal if (position.SatellitesInViewValid) { /* Satellite[] */ sats = position.GetSatellitesInView(); str += "SV:"; foreach (Satellite sat in sats) { str += sat.Id.ToString("00") + " "; } str += "\r\nSN:"; foreach (Satellite sat in sats) { str += sat.SignalStrength.ToString("00") + " "; } str += "\r\n"; panel1.Invalidate(); } else { //panel1.Invalidate(); } //time if (position.TimeValid) { str += "Time: " + position.Time.ToString() + "\r\n"; if (m_FixValid) { SetTimeToGPS(position.Time); } } //fixtype FixType fx = position.eFixType; switch (fx) { case FixType.Unknown: str += "FixType: Unknown\r\n"; break; case FixType.XyD: str += "FixType: 2D\r\n"; break; case FixType.XyzD: str += "FixType: 3D\r\n"; break; } //fix quality FixQuality fq = position.eFixQuality; switch (fq) { case FixQuality.Unknown: str += "FixQuality: Unknown\r\n"; break; case FixQuality.Gps: str += "FixQuality: GPS\r\n"; break; case FixQuality.DGps: str += "FixQuality: DGPS\r\n"; break; } } panel1.Invalidate(); status.Text = str; } } catch (NullReferenceException) { } }
protected void gps_LocationChanged(object sender, LocationChangedEventArgs args) { ControlUpdater cu = UpdateControl; updateDataHandler = new EventHandler(UpdateData); position = args.Position; if (locationfrm != null) { if (position.LatitudeValid) { Invoke(cu, locationfrm.LatitudeLbl, position.Latitude.ToString()); // delgate method,Control on form, value to be updated } if (position.LongitudeValid) { Invoke(cu, locationfrm.LongitudeLbl, position.Longitude.ToString()); } if (position.SatellitesInSolutionValid && position.SatellitesInViewValid && position.SatelliteCountValid) { Invoke(cu, locationfrm.SatelliteInfolbl, satelliteinfo += "Satellite Count: " + position.GetSatellitesInSolution().Length.ToString() + "/" + position.GetSatellitesInView().Length.ToString() + " (" + position.SatelliteCount.ToString() + ")\n"); } } // call the UpdateData method via the updateDataHandler so that we if (!Reminder_Occurs) { Invoke(updateDataHandler); } }