python-ogn-client/ogn/parser/aprs_comment/fanet_parser.py

24 wiersze
910 B
Python
Czysty Zwykły widok Historia

2018-04-30 19:00:08 +00:00
from ogn.parser.utils import FPM_TO_MS
2018-04-10 16:54:30 +00:00
from ogn.parser.pattern import PATTERN_FANET_POSITION_COMMENT
from .base import BaseParser
class FanetParser(BaseParser):
def __init__(self):
self.beacon_type = 'fanet'
2020-08-29 13:05:05 +00:00
self.position_parser = PATTERN_FANET_POSITION_COMMENT
2018-04-10 16:54:30 +00:00
2019-06-03 19:09:57 +00:00
def parse_position(self, aprs_comment):
2020-10-04 09:06:28 +00:00
match = self.position_parser.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) & 0b01111100) >> 2,
'stealth': (int(match.group('details'), 16) & 0b10000000) >> 7 == 1,
'address': match.group('address')
})
if match.group('climb_rate'): result['climb_rate'] = int(match.group('climb_rate')) * FPM_TO_MS
return result