private SDGPSData parseNO298ECmd(byte[] buffer, int start, out int cmdLen) { SDGPSData result = new SDGPSData(); cmdLen = buffer[start + 4] + 5; try { string ip; DateTime dt; double Lat, Lon; start += 5; start += ParseField.ParseFieldIP(buffer, start, out ip); start += ParseField.ParseFieldTime(buffer, start, out dt); start += ParseField.ParseFieldLat(buffer, start, out Lat); start += ParseField.ParseFieldLon(buffer, start, out Lon); start += ParseField.ParseFieldSpeed(buffer, start, out result.SOG); start += ParseField.ParseFieldAngle(buffer, start, out result.COG); start += ParseField.ParseFieldPosition(buffer, start, out result.Position); result.Name = getNameByIP(ip); result.Id = ip.Replace('.', '-'); result.Src = ""; result.Time = dt; result.Shape = new GeoPointShape(Lon, Lat); result.Distance = 0; return(result); } catch (Exception) { return(null); } }
public SDGPSData[] Parse(byte[] bytes, int offset, int len) { _buffer.Append(bytes, offset, len); List <SDGPSData> result = new List <SDGPSData>(); int start = 0; int cmdOffeset = 0; int cmdLength = 0; while (tryGetNextNO29Cmd(_buffer.Buffer, start, _buffer.Length - start, out cmdOffeset, out cmdLength)) { start += cmdOffeset; byte cmdType = _buffer.Buffer[start + 2]; SDGPSData tmp = null; switch (cmdType) { case 0x80: tmp = parseNO2980Cmd(_buffer.Buffer, start, out cmdLength); break; case 0x8E: tmp = parseNO298ECmd(_buffer.Buffer, start, out cmdLength); break; } if (tmp != null) { result.Add(tmp); } start += cmdLength; } start += cmdOffeset; _buffer.Remove(start); return(result.ToArray()); }
private void onReceivedData(SDGPSData data) { lock (_tracksData) { var target = new SDGPSTarget(); target.Update(data.Lon, data.Lat, data.SOG, data.COG, DateTime.Now); target.Name = data.Name; target.ReceiverTime = data.Time; _tracksData.UpdateDynamicEvent(target); } }