bool ReceviedPacket(byte[] rawpacket) { if (rawpacket[5] == (byte)MAVLink.MAVLINK_MSG_ID.TERRAIN_REQUEST) { MAVLink.mavlink_terrain_request_t packet = rawpacket.ByteArrayToStructure <MAVLink.mavlink_terrain_request_t>(); if (issending) { return(false); } lastrequest = packet; log.Info("received TERRAIN_REQUEST " + packet.lat / 1e7 + " " + packet.lon / 1e7 + " space " + packet.grid_spacing + " " + Convert.ToString((long)packet.mask, 2)); System.Threading.ThreadPool.QueueUserWorkItem(QueueSendGrid); } else if (rawpacket[5] == (byte)MAVLink.MAVLINK_MSG_ID.TERRAIN_REPORT) { MAVLink.mavlink_terrain_report_t packet = rawpacket.ByteArrayToStructure <MAVLink.mavlink_terrain_report_t>(); log.Info("received TERRAIN_REPORT " + packet.lat / 1e7 + " " + packet.lon / 1e7 + " " + packet.loaded + " " + packet.pending); } return(false); }
private bool ReceivedPacket(MAVLink.MAVLinkMessage rawpacket) { if (rawpacket.msgid == (byte)MAVLink.MAVLINK_MSG_ID.TERRAIN_REQUEST) { MAVLink.mavlink_terrain_request_t packet = rawpacket.ToStructure <MAVLink.mavlink_terrain_request_t>(); if (issending) { return(false); } lastmessage = rawpacket; lastrequest = packet; log.Info("received TERRAIN_REQUEST " + packet.lat / 1e7 + " " + packet.lon / 1e7 + " space " + packet.grid_spacing + " " + Convert.ToString((long)packet.mask, 2)); // reset state to block mre.Reset(); System.Threading.ThreadPool.QueueUserWorkItem(QueueSendGrid); // wait for thread to start mre.WaitOne(); } else if (rawpacket.msgid == (byte)MAVLink.MAVLINK_MSG_ID.TERRAIN_REPORT) { MAVLink.mavlink_terrain_report_t packet = rawpacket.ToStructure <MAVLink.mavlink_terrain_report_t>(); log.Info("received TERRAIN_REPORT " + packet.lat / 1e7 + " " + packet.lon / 1e7 + " " + packet.loaded + " " + packet.pending); } return(false); }
public void CheckTerrainReportObject() { MAVLink.mavlink_terrain_report_t data = new MAVLink.mavlink_terrain_report_t(); data.current_height = 1; data.lat = 2; data.loaded = 3; data.lon = 4; data.pending = 5; data.spacing = 6; data.terrain_height = 7; MavLinkMessage message = createSampleMessage(MAVLink.MAVLINK_MSG_ID.TERRAIN_REPORT, data); TerrainReport obj = new TerrainReport(message); Assert.AreEqual(data.current_height, obj.current_height); Assert.AreEqual(data.lat, obj.lat); Assert.AreEqual(data.loaded, obj.loaded); Assert.AreEqual(data.lon, obj.lon); Assert.AreEqual(data.pending, obj.pending); Assert.AreEqual(data.spacing, obj.spacing); Assert.AreEqual(data.terrain_height, obj.terrain_height); TerrainReportDTO dto = DTOFactory.createTerrainReportDTO(obj); Assert.AreEqual(dto.current_height, obj.current_height); Assert.AreEqual(dto.lat, obj.lat); Assert.AreEqual(dto.loaded, obj.loaded); Assert.AreEqual(dto.lon, obj.lon); Assert.AreEqual(dto.pending, obj.pending); Assert.AreEqual(dto.spacing, obj.spacing); Assert.AreEqual(dto.terrain_height, obj.terrain_height); }
public TerrainReport(MavLinkMessage message) : base(null) { if (message.messid.Equals(this.MessageID)) { MAVLink.mavlink_terrain_report_t data = (MAVLink.mavlink_terrain_report_t)message.data_struct; this.current_height = data.current_height; this.lat = data.lat; this.loaded = data.loaded; this.lon = data.lon; this.pending = data.pending; this.spacing = data.spacing; this.terrain_height = data.terrain_height; } }
bool ReceviedPacket(byte[] rawpacket) { if (rawpacket[5] == (byte)MAVLink.MAVLINK_MSG_ID.TERRAIN_DATA) { MAVLink.mavlink_terrain_data_t packet = rawpacket.ByteArrayToStructure <MAVLink.mavlink_terrain_data_t>(); if (issending) { return(false); } double lLat = packet.lat / Math.Pow(10, 7); double lLon = packet.lon / Math.Pow(10, 7); short[] lData = packet.data; // bls: they will all have the same location so // just add one map marker. Perhaps labeled with // the highest value or the range of values? for (int i = 0; i < lData.Length; i++) { short lDataVal = lData[i]; if (lDataVal > 0) { Debug.WriteLine("data at {0} = {1}", i, lDataVal); mFlightData.addPOIatLoc(lLat, lLon, lDataVal.ToString()); } } } else if (rawpacket[5] == (byte)MAVLink.MAVLINK_MSG_ID.TERRAIN_REPORT) { MAVLink.mavlink_terrain_report_t packet = rawpacket.ByteArrayToStructure <MAVLink.mavlink_terrain_report_t>(); log.Info("received TERRAIN_REPORT " + packet.lat / 1e7 + " " + packet.lon / 1e7 + " " + packet.loaded + " " + packet.pending); } return(false); }
bool ReceviedPacket(byte[] rawpacket) { if (rawpacket[5] == (byte)MAVLink.MAVLINK_MSG_ID.TERRAIN_DATA) { MAVLink.mavlink_terrain_data_t packet = rawpacket.ByteArrayToStructure <MAVLink.mavlink_terrain_data_t>(); if (issending) { return(false); } bool lNeedToAddPoint = false; short lMin = short.MaxValue; short lMax = short.MinValue; float lSum = 0; double lLat = packet.lat / Math.Pow(10, 7); double lLon = packet.lon / Math.Pow(10, 7); short[] lData = packet.data; // bls: they will all have the same location so // just add one map marker. Perhaps labeled with // the highest value or the range of values? for (int i = 0; i < lData.Length; i++) { short lDataVal = lData[i]; lSum += lDataVal; if (lDataVal < lMin) { lMin = lDataVal; } if (lDataVal > lMax) { lMax = lDataVal; } if (lDataVal > 100) { Debug.WriteLine("value {0} = {1} ", i, lDataVal); lNeedToAddPoint = true; } } if (lNeedToAddPoint) { float lAverage = lSum / lData.Count(); string lLabel = ""; lLabel += " Max: " + lMax.ToString(); lLabel += " Avg: " + lAverage.ToString(); lLabel += " Min: " + lMin.ToString(); mFlightData.addPOIatLoc(lLat, lLon, lLabel); } } else if (rawpacket[5] == (byte)MAVLink.MAVLINK_MSG_ID.TERRAIN_REPORT) { MAVLink.mavlink_terrain_report_t packet = rawpacket.ByteArrayToStructure <MAVLink.mavlink_terrain_report_t>(); log.Info("received TERRAIN_REPORT " + packet.lat / 1e7 + " " + packet.lon / 1e7 + " " + packet.loaded + " " + packet.pending); } return(false); }