/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void OnMessageReceived(object sender, MessageReceivedEventArgs args) { // Mark connected true if (!IsConnected) { IsConnected = true; } //Debug.WriteLine(ArrayExtensions.HexDump(args.Message)); if (args.MessageProtocol == MessageProtocol.UBX) { if (args.MessageType == typeof(GeodeticPosition)) { GeodeticPosition message = (GeodeticPosition)args.MessageResult; GeodeticSensorReading.Latitude = message.Latitude; GeodeticSensorReading.Longitude = message.Longitude; GeodeticSensorReading.TimeMillisOfWeek = (int)message.TimeMillisOfWeek; GeodeticSensorReading.VerticalAccuracy = message.VerticalAccuracy; GeodeticSensorReading.HorizontalAccuracy = message.HorizontalAccuracy; GeodeticSensorReading.HeightAboveEllipsoid = message.HeightAboveEllipsoid; GeodeticSensorReading.HeightAboveSeaLevel = message.HeightAboveSeaLevel; // Fire reading changed event GeodeticSensorChanged?.Invoke(this, GeodeticSensorReading); } else if (args.MessageType == typeof(Acknowledge)) { int key = new { Class = args.Message[2], Id = args.Message[3], MessageClass = args.Message[6], MessageId = args.Message[7] }.GetHashCode(); // Add acknowlagement Acknowlagements.Add(key, DateTime.Now); } else if (args.MessageType == typeof(NotAcknowledge)) { //int key = new { Class = args.Message[2], Id = args.Message[3], MessageClass = args.Message[6], MessageId = args.Message[7] }.GetHashCode(); //// Add not acknowlagement //_acknowlagements.Add(key, DateTime.Now); } else if (args.MessageType == typeof(ReceiverSoftware)) { ReceiverSoftware message = (ReceiverSoftware)args.MessageResult; SoftwareVersion = Encoding.ASCII.GetString(message.SoftwareVersion); HardwareVersion = Encoding.ASCII.GetString(message.HardwareVersion); } } }