kopia lustrzana https://github.com/glidernet/python-ogn-client
Added Tracker (OGNTRK) and Receiver (OGNSDR) parser
rodzic
dd40892ca4
commit
33a7690f7d
|
@ -11,6 +11,10 @@ from ogn.parser.parse_lt24 import parse as parse_lt24_beacon
|
||||||
from ogn.parser.parse_spider import parse as parse_spider_beacon
|
from ogn.parser.parse_spider import parse as parse_spider_beacon
|
||||||
from ogn.parser.parse_spot import parse as parse_spot_beacon
|
from ogn.parser.parse_spot import parse as parse_spot_beacon
|
||||||
from ogn.parser.parse_skylines import parse as parse_skylines_beacon
|
from ogn.parser.parse_skylines import parse as parse_skylines_beacon
|
||||||
|
from ogn.parser.parse_tracker import parse_position as parse_tracker_position
|
||||||
|
from ogn.parser.parse_tracker import parse_status as parse_tracker_status
|
||||||
|
from ogn.parser.parse_receiver import parse_position as parse_receiver_position
|
||||||
|
from ogn.parser.parse_receiver import parse_status as parse_receiver_status
|
||||||
|
|
||||||
|
|
||||||
def parse_aprs(message, reference_date=None, reference_time=None):
|
def parse_aprs(message, reference_date=None, reference_time=None):
|
||||||
|
@ -50,7 +54,7 @@ def parse_aprs(message, reference_date=None, reference_time=None):
|
||||||
raise AprsParseError(message)
|
raise AprsParseError(message)
|
||||||
|
|
||||||
|
|
||||||
def parse_ogn_beacon(aprs_comment, dstcall="APRS"):
|
def parse_ogn_beacon(aprs_comment, dstcall="APRS", aprs_type="position"):
|
||||||
if dstcall == "APRS": # this can be a receiver or an aircraft
|
if dstcall == "APRS": # this can be a receiver or an aircraft
|
||||||
if not aprs_comment:
|
if not aprs_comment:
|
||||||
return {'beacon_type': 'receiver_beacon'}
|
return {'beacon_type': 'receiver_beacon'}
|
||||||
|
@ -71,13 +75,21 @@ def parse_ogn_beacon(aprs_comment, dstcall="APRS"):
|
||||||
ac_data.update({'beacon_type': 'aircraft_beacon'})
|
ac_data.update({'beacon_type': 'aircraft_beacon'})
|
||||||
return ac_data
|
return ac_data
|
||||||
elif dstcall == "OGNTRK":
|
elif dstcall == "OGNTRK":
|
||||||
ac_data = parse_aircraft_beacon(aprs_comment)
|
if aprs_type == "position":
|
||||||
ac_data.update({'beacon_type': 'aircraft_beacon'})
|
data = parse_tracker_position(aprs_comment)
|
||||||
return ac_data
|
data.update({'beacon_type': 'aircraft_beacon'})
|
||||||
|
elif aprs_type == "status":
|
||||||
|
data = parse_tracker_status(aprs_comment)
|
||||||
|
data.update({'beacon_type': 'aircraft_beacon'})
|
||||||
|
return data
|
||||||
elif dstcall == "OGNSDR":
|
elif dstcall == "OGNSDR":
|
||||||
ac_data = parse_receiver_beacon(aprs_comment)
|
if aprs_type == "position":
|
||||||
ac_data.update({'beacon_type': 'receiver_beacon'})
|
data = parse_receiver_position(aprs_comment)
|
||||||
return ac_data
|
data.update({'beacon_type': 'receiver_beacon'})
|
||||||
|
elif aprs_type == "status":
|
||||||
|
data = parse_receiver_status(aprs_comment)
|
||||||
|
data.update({'beacon_type': 'receiver_beacon'})
|
||||||
|
return data
|
||||||
elif dstcall == "OGLT24":
|
elif dstcall == "OGLT24":
|
||||||
ac_data = parse_lt24_beacon(aprs_comment)
|
ac_data = parse_lt24_beacon(aprs_comment)
|
||||||
ac_data.update({'beacon_type': 'lt24_beacon'})
|
ac_data.update({'beacon_type': 'lt24_beacon'})
|
||||||
|
|
|
@ -10,6 +10,60 @@ PATTERN_NAVITER_BEACON = re.compile("""
|
||||||
(?P<turn_rate>[+-][\d.]+)rot
|
(?P<turn_rate>[+-][\d.]+)rot
|
||||||
""", re.VERBOSE | re.MULTILINE)
|
""", re.VERBOSE | re.MULTILINE)
|
||||||
|
|
||||||
|
PATTERN_TRACKER_BEACON_POSITION = re.compile("""
|
||||||
|
id(?P<details>\w{2})(?P<id>\w{6}?)\s?
|
||||||
|
(?:(?P<climb_rate>[+-]\d+?)fpm\s)?
|
||||||
|
(?:(?P<turn_rate>[+-][\d.]+?)rot\s)?
|
||||||
|
(?:FL(?P<flight_level>[\d.]+)\s)?
|
||||||
|
(?:(?P<signal_quality>[\d.]+?)dB\s)?
|
||||||
|
(?:(?P<errors>\d+)e\s)?
|
||||||
|
(?:(?P<frequency_offset>[+-][\d.]+?)kHz\s?)?
|
||||||
|
(?:gps(?P<gps_accuracy>\d+x\d+)\s?)?
|
||||||
|
(?:s(?P<flarm_software_version>[\d.]+)\s?)?
|
||||||
|
(?:h(?P<flarm_hardware_version>[\dA-F]{2})\s?)?
|
||||||
|
""", re.VERBOSE | re.MULTILINE)
|
||||||
|
|
||||||
|
PATTERN_TRACKER_BEACON_STATUS = re.compile("""
|
||||||
|
h(?P<wtf1>[\d]{2})\s
|
||||||
|
v(?P<wtf2>[\d]{2})\s
|
||||||
|
(?P<wtf3>[\d]+)sat/(?P<wtf4>\d)\s
|
||||||
|
(?P<wtf5>\d+)m\s
|
||||||
|
(?P<air_pressure>[\d.]+)hPa\s
|
||||||
|
(?P<temperature>[+-][\d.]+)degC\s
|
||||||
|
(?P<wtf8>\d+)%\s
|
||||||
|
(?P<voltage>[\d.]+)V\s
|
||||||
|
(?P<wtf9>\d+)/(?P<wtf10>[+-][\d.]+)dBm\s
|
||||||
|
(?P<wtf11>\d+)/min
|
||||||
|
""", re.VERBOSE | re.MULTILINE)
|
||||||
|
|
||||||
|
PATTERN_RECEIVER_POSITION = re.compile(r"""
|
||||||
|
(?:(?P<user_comment>.+))?
|
||||||
|
""", re.VERBOSE | re.MULTILINE)
|
||||||
|
|
||||||
|
PATTERN_RECEIVER_STATUS = re.compile("""
|
||||||
|
(?:
|
||||||
|
v(?P<version>\d+\.\d+\.\d+)
|
||||||
|
(?:\.(?P<platform>.+?))?
|
||||||
|
\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
|
||||||
|
(?:(?P<voltage>[\d.]+)V\s)?
|
||||||
|
(?:(?P<amperage>[\d.]+)A\s)?
|
||||||
|
(?:(?P<cpu_temperature>[+-][\d.]+)C\s*)?
|
||||||
|
(?:(?P<visible_senders>\d+)/(?P<senders>\d+)Acfts\[1h\]\s*)?
|
||||||
|
(?:RF:
|
||||||
|
(?:
|
||||||
|
(?P<rf_correction_manual>[+-][\d]+)
|
||||||
|
(?P<rf_correction_automatic>[+-][\d.]+)ppm/
|
||||||
|
)?
|
||||||
|
(?P<signal_quality>[+-][\d.]+)dB
|
||||||
|
(?:/(?P<senders_signal_quality>[+-][\d.]+)dB@10km\[(?P<senders_messages>\d+)\])?
|
||||||
|
(?:/(?P<good_senders_signal_quality>[+-][\d.]+)dB@10km\[(?P<good_senders>\d+)/(?P<good_and_bad_senders>\d+)\])?
|
||||||
|
)?
|
||||||
|
""", re.VERBOSE | re.MULTILINE)
|
||||||
|
|
||||||
|
|
||||||
# The following regexp patterns are part of the ruby ogn-client.
|
# The following regexp patterns are part of the ruby ogn-client.
|
||||||
# source: https://github.com/svoop/ogn_client-ruby
|
# source: https://github.com/svoop/ogn_client-ruby
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class TestStringMethods(unittest.TestCase):
|
||||||
aprs = parse_aprs(line, datetime(2015, 4, 10, 17, 0))
|
aprs = parse_aprs(line, datetime(2015, 4, 10, 17, 0))
|
||||||
self.assertFalse(aprs is None)
|
self.assertFalse(aprs is None)
|
||||||
if aprs['comment']:
|
if aprs['comment']:
|
||||||
message = parse_ogn_beacon(aprs['comment'], dstcall=aprs['dstcall'])
|
message = parse_ogn_beacon(aprs['comment'], dstcall=aprs['dstcall'], aprs_type=aprs['aprs_type'])
|
||||||
self.assertEqual(message['beacon_type'], beacon_type)
|
self.assertEqual(message['beacon_type'], beacon_type)
|
||||||
|
|
||||||
def test_aprs_aircraft_beacons(self):
|
def test_aprs_aircraft_beacons(self):
|
||||||
|
|
Ładowanie…
Reference in New Issue