def test_v026(self): # from 0.2.6 it is sufficent we have only the ID, climb and turn rate or just the ID message_triple = OgnParser().parse_aircraft_beacon( "id093D0930 +000fpm +0.0rot") message_single = OgnParser().parse_aircraft_beacon("id093D0930") self.assertIsNotNone(message_triple) self.assertIsNotNone(message_single)
def test_no_tracking(self): message = OgnParser().parse_aircraft_beacon( "id0ADD1234 -454fpm -1.1rot 8.8dB 0e +51.2kHz gps4x5 hear1084 hearB597 hearB598" ) self.assertFalse(message['no-tracking']) message = OgnParser().parse_aircraft_beacon( "id4ADD1234 -454fpm -1.1rot 8.8dB 0e +51.2kHz gps4x5 hear1084 hearB597 hearB598" ) self.assertTrue(message['no-tracking'])
def test_stealth(self): message = OgnParser().parse_aircraft_beacon( "id0ADD1234 -454fpm -1.1rot 8.8dB 0e +51.2kHz gps4x5 hear1084 hearB597 hearB598" ) self.assertFalse(message['stealth']) message = OgnParser().parse_aircraft_beacon( "id8ADD1234 -454fpm -1.1rot 8.8dB 0e +51.2kHz gps4x5 hear1084 hearB597 hearB598" ) self.assertTrue(message['stealth'])
def test_v024(self): message = OgnParser().parse_aircraft_beacon( "id21400EA9 -2454fpm +0.9rot 19.5dB 0e -6.6kHz gps1x1 s6.02 h0A rDF0C56" ) self.assertEqual(message['software_version'], 6.02) self.assertEqual(message['hardware_version'], 10) self.assertEqual(message['real_address'], "DF0C56")
def test_v025(self): message = OgnParser().parse_receiver_beacon( "v0.2.5.RPI-GPU CPU:0.8 RAM:287.3/458.7MB NTP:1.0ms/-6.4ppm 5.016V 0.534A +51.9C RF:+55+0.4ppm/-0.67dB/+10.8dB@10km[57282]" ) self.assertEqual(message['voltage'], 5.016) self.assertEqual(message['amperage'], 0.534) self.assertEqual(message['senders_signal'], 10.8) self.assertEqual(message['senders_messages'], 57282) message = OgnParser().parse_receiver_beacon( "v0.2.5.ARM CPU:0.4 RAM:638.0/970.5MB NTP:0.2ms/-1.1ppm +65.5C 14/16Acfts[1h] RF:+45+0.0ppm/+3.88dB/+24.0dB@10km[143717]/+26.7dB@10km[68/135]" ) self.assertEqual(message['senders_visible'], 14) self.assertEqual(message['senders_total'], 16) self.assertEqual(message['senders_signal'], 24.0) self.assertEqual(message['senders_messages'], 143717) self.assertEqual(message['good_senders_signal'], 26.7) self.assertEqual(message['good_senders'], 68) self.assertEqual(message['good_and_bad_senders'], 135)
def test_relevant_keys_only(self): # return only keys where we got informations message = OgnParser().parse_aircraft_beacon("id093D0930") self.assertIsNotNone(message) self.assertEqual( sorted(message.keys()), sorted([ 'address_type', 'aircraft_type', 'stealth', 'address', 'no-tracking' ]))
def test_relevant_keys_only(self): # return only keys where we got informations message = OgnParser().parse_receiver_beacon( "v0.2.5.ARM CPU:0.4 RAM:638.0/970.5MB NTP:0.2ms/-1.1ppm") self.assertIsNotNone(message) self.assertEqual( sorted(message.keys()), sorted([ 'version', 'platform', 'cpu_load', 'free_ram', 'total_ram', 'ntp_error', 'rt_crystal_correction' ]))
def test_v021(self): message = OgnParser().parse_receiver_beacon( "v0.2.1 CPU:0.8 RAM:25.6/458.9MB NTP:0.1ms/+2.3ppm +51.9C RF:+26-1.4ppm/-0.25dB" ) self.assertEqual(message['version'], "0.2.1") self.assertEqual(message['cpu_load'], 0.8) self.assertEqual(message['free_ram'], 25.6) self.assertEqual(message['total_ram'], 458.9) self.assertEqual(message['ntp_error'], 0.1) self.assertEqual(message['rt_crystal_correction'], 2.3) self.assertEqual(message['cpu_temp'], 51.9) self.assertEqual(message['rec_crystal_correction'], 26) self.assertEqual(message['rec_crystal_correction_fine'], -1.4) self.assertEqual(message['rec_input_noise'], -0.25)
def test_basic(self): message = OgnParser().parse_aircraft_beacon( "id0ADDA5BA -454fpm -1.1rot 8.8dB 0e +51.2kHz gps4x5 hear1084 hearB597 hearB598" ) self.assertEqual(message['address_type'], 2) self.assertEqual(message['aircraft_type'], 2) self.assertFalse(message['stealth']) self.assertEqual(message['address'], "DDA5BA") self.assertAlmostEqual(message['climb_rate'], -454 * FPM_TO_MS, 2) self.assertEqual(message['turn_rate'], -1.1 * HPM_TO_DEGS) self.assertEqual(message['signal_quality'], 8.8) self.assertEqual(message['error_count'], 0) self.assertEqual(message['frequency_offset'], 51.2) self.assertEqual(message['gps_quality'], { 'horizontal': 4, 'vertical': 5 }) self.assertEqual(len(message['proximity']), 3) self.assertEqual(message['proximity'][0], '1084') self.assertEqual(message['proximity'][1], 'B597') self.assertEqual(message['proximity'][2], 'B598')
def test_v022(self): message = OgnParser().parse_receiver_beacon( "v0.2.2.x86 CPU:0.5 RAM:669.9/887.7MB NTP:1.0ms/+6.2ppm +52.0C RF:+0.06dB" ) self.assertEqual(message['platform'], 'x86')
if match_status: result.update({ 'name': match.group('callsign'), 'dstcall': match.group('dstcall'), 'receiver_name': match.group('receiver'), 'timestamp': createTimestamp(match_status.group('time'), reference_timestamp), 'comment': match_status.group('comment') if match_status.group('comment') else ""}) else: raise NotImplementedError(message) else: raise AprsParseError(message) return result dstcall_parser_mapping = {'APRS': OgnParser(), 'OGNFNT': FanetParser(), 'OGFLR': FlarmParser(), 'OGNTRK': TrackerParser(), 'OGNSDR': ReceiverParser(), 'OGCAPT': GenericParser(beacon_type='capturs'), 'OGFLYM': GenericParser(beacon_type='flymaster'), 'OGINREACH': InreachParser(), 'OGLT24': LT24Parser(), 'OGNAVI': NaviterParser(), 'OGSKYL': SkylinesParser(), 'OGSPID': SpiderParser(), 'OGSPOT': SpotParser(), 'GENERIC': GenericParser(beacon_type='unknown'), }
def test_invalid_token(self): self.assertEqual(OgnParser().parse_aircraft_beacon("notAValidToken"), None)
def test_v025(self): message = OgnParser().parse_aircraft_beacon( "id06DDE28D +535fpm +3.8rot 11.5dB 0e -1.0kHz gps2x3 s6.01 h0C +7.4dBm" ) self.assertEqual(message['signal_power'], 7.4)
def test_v024_ogn_tracker(self): message = OgnParser().parse_aircraft_beacon( "id07353800 +020fpm -14.0rot FL004.43 38.5dB 0e -2.9kHz") self.assertEqual(message['flightlevel'], 4.43)
def test_fail_validation(self): self.assertEqual(OgnParser().parse_receiver_beacon("notAValidToken"), None)
createTimestamp(match_status.group('time'), reference_timestamp), 'comment': match_status.group('comment') if match_status.group('comment') else "" }) else: raise NotImplementedError(message) else: raise AprsParseError(message) return result dstcall_parser_mapping = { 'APRS': OgnParser(), 'OGNFNT': FanetParser(), 'OGFLR': FlarmParser(), 'OGNTRK': TrackerParser(), 'OGNSDR': ReceiverParser(), 'OGCAPT': GenericParser(beacon_type='capturs'), 'OGFLYM': GenericParser(beacon_type='flymaster'), 'OGINRE': InreachParser(), 'OGLT24': LT24Parser(), 'OGNAVI': NaviterParser(), 'OGPAW': GenericParser(beacon_type='pilot_aware'), 'OGSKYL': SkylinesParser(), 'OGSPID': SpiderParser(), 'OGSPOT': SpotParser(), 'GENERIC': GenericParser(beacon_type='unknown'), }
def test_v028(self): message = OgnParser().parse_receiver_beacon( "v0.2.8.RPI-GPU CPU:0.3 RAM:744.5/968.2MB NTP:3.6ms/+2.0ppm +68.2C 3/3Acfts[1h] Lat:1.6s RF:-8+67.8ppm/+10.33dB/+1.3dB@10km[30998]/+10.4dB@10km[3/5]" ) self.assertEqual(message['latency'], 1.6)