private void UpdateTeamStatus(TrackingData Data) { TeamData td; ListViewItem lvi = new ListViewItem(); try { int _prev_speed = 0; int _prev_direction = 0; if (m_Teams.ContainsKey(Data.CID)) { td = m_Teams[Data.CID]; // The GPS update came - change the status from Delayed to Tracking if (td.Status == TrackStatus.DELAYED) { td.Status = TrackStatus.TRACKING; } _prev_speed = td.Coordinates.Speed; _prev_direction = td.Coordinates.Direction; if (_prev_direction > 180) { _prev_direction -= 180; } } else { td = new TeamData(); td.CID = Data.CID; td.Status = TrackStatus.TRACKING; td.Name = Data.CID; } td.Coordinates = Data.Coordinates; td.Coordinates.MGRS = GPSTrack.FormatMGRS(td.Coordinates.MGRS); td.Coordinates = GPSTrack.MGRS_To_LatLon(td.Coordinates); td.Coordinates.Time = DateTime.Now; td.Coordinates.Speed = (td.Coordinates.Speed + _prev_speed) / 2; if (td.Coordinates.Direction > 180) { td.Coordinates.Direction -= 180; } td.Coordinates.Direction = (td.Coordinates.Direction + _prev_direction) / 2; if (td.Coordinates.Direction < 0) { td.Coordinates.Direction += 180; } m_Teams[td.CID] = td; UpdateTrackingHistory(td); UpdateTeamDisplay(td); m_statusStrip.Items[0].Text = String.Format("{0} is receiving SA updates", m_SerialCommPort.PortName); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.InnerException + ex.ToString()); } }
private void UpdateLatLon() { if (!string.IsNullOrEmpty(MGRS.Text)) { Coords cc = new Coords(); cc.MGRS = MGRS.Text; cc = GPSTrack.MGRS_To_LatLon(cc); Latitude = cc.Latitude; Longitude = cc.Longitude; LatLon.Text = GPSTrack.FormatLatLon(Latitude, Longitude); } }