kopia lustrzana https://github.com/glidernet/python-ogn-client
add safesky parser
rodzic
464969a70e
commit
faa73997d7
|
@ -0,0 +1,25 @@
|
||||||
|
from ogn.parser.utils import FPM_TO_MS
|
||||||
|
from ogn.parser.pattern import PATTERN_SAFESKY_POSITION_COMMENT
|
||||||
|
|
||||||
|
from .base import BaseParser
|
||||||
|
|
||||||
|
|
||||||
|
class SafeskyParser(BaseParser):
|
||||||
|
def __init__(self):
|
||||||
|
self.beacon_type = 'safesky'
|
||||||
|
self.position_pattern = PATTERN_SAFESKY_POSITION_COMMENT
|
||||||
|
|
||||||
|
def parse_position(self, aprs_comment):
|
||||||
|
match = self.position_pattern.match(aprs_comment)
|
||||||
|
result = dict()
|
||||||
|
result.update(
|
||||||
|
{'safesky_id': match.group('safesky_id'),
|
||||||
|
'climb_rate': int(match.group('climb_rate')) * FPM_TO_MS if match.group('climb_rate') else None})
|
||||||
|
if match.group('gps_quality'):
|
||||||
|
result.update({
|
||||||
|
'gps_quality': {
|
||||||
|
'horizontal': int(match.group('gps_quality_horizontal')),
|
||||||
|
'vertical': int(match.group('gps_quality_vertical'))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return result
|
|
@ -16,6 +16,7 @@ from ogn.parser.aprs_comment.skylines_parser import SkylinesParser
|
||||||
from ogn.parser.aprs_comment.spider_parser import SpiderParser
|
from ogn.parser.aprs_comment.spider_parser import SpiderParser
|
||||||
from ogn.parser.aprs_comment.spot_parser import SpotParser
|
from ogn.parser.aprs_comment.spot_parser import SpotParser
|
||||||
from ogn.parser.aprs_comment.inreach_parser import InreachParser
|
from ogn.parser.aprs_comment.inreach_parser import InreachParser
|
||||||
|
from ogn.parser.aprs_comment.safesky_parser import SafeskyParser
|
||||||
from ogn.parser.aprs_comment.generic_parser import GenericParser
|
from ogn.parser.aprs_comment.generic_parser import GenericParser
|
||||||
|
|
||||||
positions = {}
|
positions = {}
|
||||||
|
@ -155,6 +156,7 @@ dstcall_parser_mapping = {'APRS': OgnParser(),
|
||||||
'OGSKYL': SkylinesParser(),
|
'OGSKYL': SkylinesParser(),
|
||||||
'OGSPID': SpiderParser(),
|
'OGSPID': SpiderParser(),
|
||||||
'OGSPOT': SpotParser(),
|
'OGSPOT': SpotParser(),
|
||||||
|
'OGNSKY': SafeskyParser(),
|
||||||
'GENERIC': GenericParser(beacon_type='unknown'),
|
'GENERIC': GenericParser(beacon_type='unknown'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,12 @@ PATTERN_TRACKER_POSITION_COMMENT = re.compile(r"""
|
||||||
(?:(?P<signal_power>[+-][\d.]+)dBm\s?)?
|
(?:(?P<signal_power>[+-][\d.]+)dBm\s?)?
|
||||||
""", re.VERBOSE | re.MULTILINE)
|
""", re.VERBOSE | re.MULTILINE)
|
||||||
|
|
||||||
|
PATTERN_SAFESKY_POSITION_COMMENT = re.compile(r"""
|
||||||
|
id(?P<safesky_id>[A-F0-9]{8})\s
|
||||||
|
(?:(?P<climb_rate>[+-]\d+?)fpm\s)?
|
||||||
|
(?:gps(?P<gps_quality>(?P<gps_quality_horizontal>(\d+))x(?P<gps_quality_vertical>(\d+)))?)?
|
||||||
|
""", re.VERBOSE | re.MULTILINE)
|
||||||
|
|
||||||
PATTERN_TRACKER_STATUS_COMMENT = re.compile(r"""
|
PATTERN_TRACKER_STATUS_COMMENT = re.compile(r"""
|
||||||
h(?P<hardware_version>[\d]{2})\s
|
h(?P<hardware_version>[\d]{2})\s
|
||||||
v(?P<software_version>[\d]{2})\s?
|
v(?P<software_version>[\d]{2})\s?
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from ogn.parser.utils import FPM_TO_MS
|
||||||
|
from ogn.parser.aprs_comment.safesky_parser import SafeskyParser
|
||||||
|
|
||||||
|
|
||||||
|
class TestStringMethods(unittest.TestCase):
|
||||||
|
def test_position_comment(self):
|
||||||
|
# "SKY3E5906>OGNSKY,qAS,SafeSky:/072555h5103.47N/00524.81E'065/031/A=001250 !W05! id1C3E5906 +010fpm gps6x1"
|
||||||
|
message = SafeskyParser().parse_position("id1C3E5906 +010fpm gps6x1")
|
||||||
|
self.assertEqual(message['safesky_id'], '1C3E5906')
|
||||||
|
self.assertAlmostEqual(message['climb_rate'], 10 * FPM_TO_MS, 2)
|
||||||
|
self.assertEqual(message['gps_quality'], {'horizontal': 6, 'vertical': 1})
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Ładowanie…
Reference in New Issue