2018-03-10 08:35:51 +00:00
|
|
|
from ogn.parser.pattern import PATTERN_RECEIVER_POSITION_COMMENT, PATTERN_RECEIVER_STATUS_COMMENT
|
2017-09-30 12:17:35 +00:00
|
|
|
|
2017-10-05 08:36:53 +00:00
|
|
|
from .base import BaseParser
|
|
|
|
|
|
|
|
|
|
|
|
class ReceiverParser(BaseParser):
|
|
|
|
def __init__(self):
|
2018-03-10 07:58:32 +00:00
|
|
|
self.beacon_type = 'receiver'
|
2020-05-21 21:14:31 +00:00
|
|
|
self.position_pattern = PATTERN_RECEIVER_POSITION_COMMENT
|
|
|
|
self.status_pattern = PATTERN_RECEIVER_STATUS_COMMENT
|
2017-09-30 12:17:35 +00:00
|
|
|
|
2019-06-03 19:09:57 +00:00
|
|
|
def parse_position(self, aprs_comment):
|
2017-10-04 21:23:41 +00:00
|
|
|
if aprs_comment is None:
|
|
|
|
return {}
|
|
|
|
else:
|
2019-06-03 19:09:57 +00:00
|
|
|
match = self.position_pattern.match(aprs_comment)
|
2017-10-04 21:23:41 +00:00
|
|
|
return {'user_comment': match.group('user_comment') if match.group('user_comment') else None}
|
2017-09-30 12:17:35 +00:00
|
|
|
|
2019-06-03 19:09:57 +00:00
|
|
|
def parse_status(self, aprs_comment):
|
|
|
|
match = self.status_pattern.match(aprs_comment)
|
2020-10-04 10:25:02 +00:00
|
|
|
result = {
|
|
|
|
'version': match.group('version'),
|
|
|
|
'platform': match.group('platform'),
|
|
|
|
'cpu_load': float(match.group('cpu_load')),
|
|
|
|
'free_ram': float(match.group('ram_free')),
|
|
|
|
'total_ram': float(match.group('ram_total')),
|
|
|
|
'ntp_error': float(match.group('ntp_offset')),
|
|
|
|
}
|
|
|
|
|
|
|
|
if match.group('ntp_correction'): result['rt_crystal_correction'] = float(match.group('ntp_correction'))
|
|
|
|
if match.group('voltage'): result['voltage'] = float(match.group('voltage'))
|
|
|
|
if match.group('amperage'): result['amperage'] = float(match.group('amperage'))
|
|
|
|
if match.group('cpu_temperature'): result['cpu_temp'] = float(match.group('cpu_temperature'))
|
|
|
|
if match.group('visible_senders'): result['senders_visible'] = int(match.group('visible_senders'))
|
|
|
|
if match.group('senders'): result['senders_total'] = int(match.group('senders'))
|
|
|
|
if match.group('rf_correction_manual'): result['rec_crystal_correction'] = int(match.group('rf_correction_manual'))
|
|
|
|
if match.group('rf_correction_automatic'): result['rec_crystal_correction_fine'] = float(match.group('rf_correction_automatic'))
|
2020-10-09 07:23:10 +00:00
|
|
|
if match.group('signal_quality'): result['rec_input_noise'] = float(match.group('signal_quality'))
|
|
|
|
if match.group('senders_signal_quality'): result['senders_signal'] = float(match.group('senders_signal_quality'))
|
|
|
|
if match.group('senders_messages'): result['senders_messages'] = float(match.group('senders_messages'))
|
|
|
|
if match.group('good_senders_signal_quality'): result['good_senders_signal'] = float(match.group('good_senders_signal_quality'))
|
|
|
|
if match.group('good_senders'): result['good_senders'] = float(match.group('good_senders'))
|
2020-10-04 10:25:02 +00:00
|
|
|
if match.group('good_and_bad_senders'): result['good_and_bad_senders'] = float(match.group('good_and_bad_senders'))
|
|
|
|
|
|
|
|
return result
|