kopia lustrzana https://github.com/glidernet/python-ogn-client
Adopt naming from ruby-client_ogn
rodzic
5bcd04fe20
commit
6e2c59594f
|
@ -56,7 +56,8 @@ def parse_ogn_aircraft_beacon(aprs_comment):
|
|||
'gps_status': ac_match.group('gps_accuracy'),
|
||||
'software_version': float(ac_match.group('flarm_software_version')) if ac_match.group('flarm_software_version') else None,
|
||||
'hardware_version': int(ac_match.group('flarm_hardware_version'), 16) if ac_match.group('flarm_hardware_version') else None,
|
||||
'real_address': ac_match.group('flarm_id')}
|
||||
'real_address': ac_match.group('flarm_id'),
|
||||
'power': ac_match('power')}
|
||||
else:
|
||||
return None
|
||||
|
||||
|
@ -72,16 +73,16 @@ def parse_ogn_receiver_beacon(aprs_comment):
|
|||
'ntp_error': float(rec_match.group('ntp_offset')),
|
||||
'rt_crystal_correction': float(rec_match.group('ntp_correction')),
|
||||
'cpu_temp': float(rec_match.group('cpu_temperature')) if rec_match.group('cpu_temperature') else None,
|
||||
'aircraft_counter_visible': int(rec_match.group('aircraft_counter_visible')) if rec_match.group('aircraft_counter_visible') else None,
|
||||
'aircraft_counter_total': int(rec_match.group('aircraft_counter_total')) if rec_match.group('aircraft_counter_total') else None,
|
||||
'rec_crystal_correction': int(rec_match.group('manual_correction')) if rec_match.group('manual_correction') else 0,
|
||||
'rec_crystal_correction_fine': float(rec_match.group('automatic_correction')) if rec_match.group('automatic_correction') else 0.0,
|
||||
'rec_input_noise': float(rec_match.group('input_noise')) if rec_match.group('input_noise') else None,
|
||||
'total_snr': float(rec_match.group('total_snr')) if rec_match.group('total_snr') else None,
|
||||
'total_fixes': float(rec_match.group('total_fixes')) if rec_match.group('total_fixes') else None,
|
||||
'daily_snr_selection': float(rec_match.group('daily_snr_selection')) if rec_match.group('daily_snr_selection') else None,
|
||||
'daily_devices_selection': float(rec_match.group('daily_devices_selection')) if rec_match.group('daily_devices_selection') else None,
|
||||
'daily_devices': float(rec_match.group('daily_devices')) if rec_match.group('daily_devices') else None}
|
||||
'senders_visible': int(rec_match.group('visible_senders')) if rec_match.group('visible_senders') else None,
|
||||
'senders_total': int(rec_match.group('senders')) if rec_match.group('senders') else None,
|
||||
'rec_crystal_correction': int(rec_match.group('rf_correction_manual')) if rec_match.group('rf_correction_manual') else 0,
|
||||
'rec_crystal_correction_fine': float(rec_match.group('rf_correction_automatic')) if rec_match.group('rf_correction_automatic') else 0.0,
|
||||
'rec_input_noise': float(rec_match.group('signal')) if rec_match.group('signal') else None,
|
||||
'senders_signal': float(rec_match.group('senders_signal')) if rec_match.group('senders_signal') else None,
|
||||
'senders_messages': float(rec_match.group('senders_messages')) if rec_match.group('senders_messages') else None,
|
||||
'good_senders_signal': float(rec_match.group('good_senders_signal')) if rec_match.group('good_senders_signal') else None,
|
||||
'good_senders': float(rec_match.group('good_senders')) if rec_match.group('good_senders') else None,
|
||||
'good_and_bad_senders': float(rec_match.group('good_and_bad_senders')) if rec_match.group('good_and_bad_senders') else None}
|
||||
else:
|
||||
return None
|
||||
|
||||
|
|
|
@ -36,17 +36,19 @@ PATTERN_RECEIVER_BEACON = re.compile(r"""
|
|||
\s)?
|
||||
CPU:(?P<cpu_load>[\d.]+)\s
|
||||
RAM:(?P<ram_free>[\d.]+)\/(?P<ram_total>[\d.]+)MB\s
|
||||
NTP:(?P<ntp_offset>[\d.]+)ms\/(?P<ntp_correction>[+-][\d.]+)ppm\s?
|
||||
NTP:(?P<ntp_offset>[\d.]+)ms\/(?P<ntp_correction>[+-][\d.]+)ppm\s
|
||||
(?:(?P<voltage>[\d.]+)V\s)?
|
||||
(?:(?P<amperage>[\d.]+)A\s)?
|
||||
(?:(?P<cpu_temperature>[+-][\d.]+)C\s*)?
|
||||
(?:(?P<aircraft_counter_visible>\d+)\/(?P<aircraft_counter_total>\d+)Acfts\[1h\]\s*)?
|
||||
(?:(?P<visible_senders>\d+)\/(?P<senders>\d+)Acfts\[1h\]\s*)?
|
||||
(?:RF:
|
||||
(?:
|
||||
(?P<manual_correction>[+-][\d]+)
|
||||
(?P<automatic_correction>[+-][\d.]+)ppm\/
|
||||
(?P<rf_correction_manual>[+-][\d]+)
|
||||
(?P<rf_correction_automatic>[+-][\d.]+)ppm\/
|
||||
)?
|
||||
(?P<input_noise>[+-][\d.]+)dB
|
||||
(?:\/(?P<total_snr>[+-][\d.]+)dB\@10km\[(?P<total_fixes>\d+)\])?
|
||||
(?:\/(?P<daily_snr_selection>[+-][\d.]+)dB\@10km\[(?P<daily_devices_selection>\d+)\/(?P<daily_devices>\d+)\])?
|
||||
(?P<signal>[+-][\d.]+)dB
|
||||
(?:\/(?P<senders_signal>[+-][\d.]+)dB@10km\[(?P<senders_messages>\d+)\])?
|
||||
(?:\/(?P<good_senders_signal>[+-][\d.]+)dB@10km\[(?P<good_senders>\d+)\/(?P<good_and_bad_senders>\d+)\])?
|
||||
)?
|
||||
""", re.VERBOSE | re.MULTILINE)
|
||||
|
||||
|
@ -63,5 +65,6 @@ PATTERN_AIRCRAFT_BEACON = re.compile(r"""
|
|||
(?:s(?P<flarm_software_version>[\d.]+)\s?)?
|
||||
(?:h(?P<flarm_hardware_version>[\dA-F]{2})\s?)?
|
||||
(?:r(?P<flarm_id>[\dA-F]+)\s?)?
|
||||
(?:(?P<power>[+-][\d.]+)dBm\s?)?
|
||||
(?:hear(?P<proximity>.+))?
|
||||
""", re.VERBOSE | re.MULTILINE)
|
||||
|
|
|
@ -28,17 +28,17 @@ class TestStringMethods(unittest.TestCase):
|
|||
|
||||
def test_v025(self):
|
||||
receiver_beacon = parse_ogn_receiver_beacon("v0.2.5.RPI-GPU CPU:0.8 RAM:287.3/458.7MB NTP:1.0ms/-6.4ppm +51.9C RF:+55+0.4ppm/-0.67dB/+10.8dB@10km[57282]")
|
||||
self.assertEqual(receiver_beacon['total_snr'], 10.8)
|
||||
self.assertEqual(receiver_beacon['total_fixes'], 57282)
|
||||
self.assertEqual(receiver_beacon['senders_signal'], 10.8)
|
||||
self.assertEqual(receiver_beacon['senders_messages'], 57282)
|
||||
|
||||
receiver_beacon = parse_ogn_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(receiver_beacon['aircraft_counter_visible'], 14)
|
||||
self.assertEqual(receiver_beacon['aircraft_counter_total'], 16)
|
||||
self.assertEqual(receiver_beacon['total_snr'], 24.0)
|
||||
self.assertEqual(receiver_beacon['total_fixes'], 143717)
|
||||
self.assertEqual(receiver_beacon['daily_snr_selection'], 26.7)
|
||||
self.assertEqual(receiver_beacon['daily_devices_selection'], 68)
|
||||
self.assertEqual(receiver_beacon['daily_devices'], 135)
|
||||
self.assertEqual(receiver_beacon['senders_visible'], 14)
|
||||
self.assertEqual(receiver_beacon['senders_total'], 16)
|
||||
self.assertEqual(receiver_beacon['senders_signal'], 24.0)
|
||||
self.assertEqual(receiver_beacon['senders_messages'], 143717)
|
||||
self.assertEqual(receiver_beacon['good_senders_signal'], 26.7)
|
||||
self.assertEqual(receiver_beacon['good_senders'], 68)
|
||||
self.assertEqual(receiver_beacon['good_and_bad_senders'], 135)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Ładowanie…
Reference in New Issue