kopia lustrzana https://github.com/glidernet/python-ogn-client
Add missing files for Microtrak parser.
rodzic
d7186de5e6
commit
2c7be3c9cc
|
@ -0,0 +1,23 @@
|
|||
from ogn.parser.pattern import PATTERN_MICROTRAK_POSITION_COMMENT
|
||||
|
||||
from .base import BaseParser
|
||||
|
||||
|
||||
class MicrotrakParser(BaseParser):
|
||||
def __init__(self):
|
||||
self.beacon_type = 'microtrak'
|
||||
self.position_pattern = PATTERN_MICROTRAK_POSITION_COMMENT
|
||||
|
||||
def parse_position(self, aprs_comment):
|
||||
match = self.position_pattern.match(aprs_comment)
|
||||
|
||||
result = {}
|
||||
if match.group('details'):
|
||||
result.update({
|
||||
'address_type': int(match.group('details'), 16) & 0b00000011,
|
||||
'aircraft_type': (int(match.group('details'), 16) & 0b00111100) >> 2,
|
||||
'no-tracking': (int(match.group('details'), 16) & 0b01000000) >> 6 == 1,
|
||||
'stealth': (int(match.group('details'), 16) & 0b10000000) >> 7 == 1,
|
||||
'address': match.group('address'),
|
||||
})
|
||||
return result
|
|
@ -0,0 +1,25 @@
|
|||
import unittest
|
||||
|
||||
from ogn.parser.aprs_comment.microtrak_parser import MicrotrakParser
|
||||
|
||||
|
||||
class TestStringMethods(unittest.TestCase):
|
||||
def test_position_comment(self):
|
||||
message = MicrotrakParser().parse_position("id21A8CBA8")
|
||||
|
||||
self.assertEqual(message['address_type'], 1)
|
||||
self.assertEqual(message['aircraft_type'], 8)
|
||||
self.assertFalse(message['stealth'])
|
||||
self.assertFalse(message['no-tracking'])
|
||||
self.assertEqual(message['address'], "A8CBA8")
|
||||
|
||||
def test_position_comment_relevant_keys_only(self):
|
||||
# return only keys where we got informations
|
||||
message = MicrotrakParser().parse_position("id21A8CBA8")
|
||||
|
||||
self.assertIsNotNone(message)
|
||||
self.assertEqual(sorted(message.keys()), sorted(['address_type', 'aircraft_type', 'stealth', 'address', 'no-tracking']))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -0,0 +1,6 @@
|
|||
# The following beacons are example for Microtrak's APRS format
|
||||
# source: https://github.com/glidernet/ogn-aprs-protocol
|
||||
#
|
||||
MTK895B2D>OGNMTK,qAS,Microtrak:/195300h4849.11N/00216.49E'000/000/A=000472 !W72! id07895B2D
|
||||
MTK895B2D>OGNMTK,qAS,Microtrak:/195300h4849.11N/00216.49E'000/000/A=000472 !W72! id07895B2D
|
||||
MTK6FC895>OGNMTK,qAS,Microtrak:/195346h4849.09N/00216.52E'000/000/A=000295 !W18! id076FC895
|
Ładowanie…
Reference in New Issue