# Path: ogn/parser/utils.py
# FPM_TO_MS = FEETS_TO_METER / 60     # ratio fpm to m/s
# 
# HPM_TO_DEGS = 180 / 60              # ratio between half turn per minute and degrees/s
# 
# Path: ogn/parser/aprs_comment/tracker_parser.py
# class TrackerParser(BaseParser):
#     def __init__(self):
#         self.beacon_type = 'tracker'
#         self.position_pattern = PATTERN_TRACKER_POSITION_COMMENT
#         self.status_pattern = PATTERN_TRACKER_STATUS_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) & 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
#         if match.group('turn_rate'): result['turn_rate'] = float(match.group('turn_rate')) * HPM_TO_DEGS
#         if match.group('flight_level'): result['flightlevel'] = float(match.group('flight_level'))
#         if match.group('signal_quality'): result['signal_quality'] = float(match.group('signal_quality'))
#         if match.group('error_count'): result['error_count'] = int(match.group('error_count'))
#         if match.group('frequency_offset'): result['frequency_offset'] = float(match.group('frequency_offset'))
#         if match.group('gps_quality'):
#             result.update({
#                 'gps_quality': {
#                     'horizontal': int(match.group('gps_quality_horizontal')),
#                     'vertical': int(match.group('gps_quality_vertical'))
#                 }
#             })
#         if match.group('signal_power'): result['signal_power'] = float(match.group('signal_power'))
#         return result
# 
#     def parse_status(self, aprs_comment):
#         match = self.status_pattern.match(aprs_comment)
#         if match:
#             result = {}
# 
#             if match.group('hardware_version'): result['hardware_version'] = int(match.group('hardware_version'))
#             if match.group('software_version'): result['software_version'] = int(match.group('software_version'))
#             if match.group('gps_satellites'): result['gps_satellites'] = int(match.group('gps_satellites'))
#             if match.group('gps_quality'): result['gps_quality'] = int(match.group('gps_quality'))
#             if match.group('gps_altitude'): result['gps_altitude'] = int(match.group('gps_altitude'))
#             if match.group('pressure'): result['pressure'] = float(match.group('pressure'))
#             if match.group('temperature'): result['temperature'] = float(match.group('temperature'))
#             if match.group('humidity'): result['humidity'] = int(match.group('humidity'))
#             if match.group('voltage'): result['voltage'] = float(match.group('voltage'))
#             if match.group('transmitter_power'): result['transmitter_power'] = int(match.group('transmitter_power'))
#             if match.group('noise_level'): result['noise_level'] = float(match.group('noise_level'))
#             if match.group('relays'): result['relays'] = int(match.group('relays'))
#             return result
#         else:
#             return {'comment': aprs_comment}


import unittest
from ogn.parser.utils import FPM_TO_MS, HPM_TO_DEGS
from ogn.parser.aprs_comment.tracker_parser import TrackerParser
        self.assertEqual(message['address_type'], 3)
        self.assertEqual(message['aircraft_type'], 1)
        self.assertFalse(message['stealth'])
        self.assertEqual(message['address'], "2FD00F")
        self.assertAlmostEqual(message['climb_rate'], -58 * FPM_TO_MS, 2)
        self.assertEqual(message['turn_rate'], 1.1 * HPM_TO_DEGS)
        self.assertEqual(message['flightlevel'], 3.12)
        self.assertEqual(message['signal_quality'], 32.8)
        self.assertEqual(message['error_count'], 0)
        self.assertEqual(message['frequency_offset'], -0.8)
        self.assertEqual(message['gps_quality'], {'horizontal': 3, 'vertical': 5})
        self.assertEqual(message['signal_power'], 12.7)

    def test_status_comment(self):
        message = TrackerParser().parse_status("h00 v00 9sat/1 164m 1002.6hPa +20.2degC 0% 3.34V 14/-110.5dBm 1/min")

        self.assertEqual(message['hardware_version'], 0)
        self.assertEqual(message['software_version'], 0)
        self.assertEqual(message['gps_satellites'], 9)
        self.assertEqual(message['gps_quality'], 1)
        self.assertEqual(message['gps_altitude'], 164)
        self.assertEqual(message['pressure'], 1002.6)
        self.assertEqual(message['temperature'], 20.2)
        self.assertEqual(message['humidity'], 0)
        self.assertEqual(message['voltage'], 3.34)
        self.assertEqual(message['transmitter_power'], 14)
        self.assertEqual(message['noise_level'], -110.5)
        self.assertEqual(message['relays'], 1)

    def test_status_comment_comment(self):

# Path: ogn/parser/utils.py
# FPM_TO_MS = FEETS_TO_METER / 60     # ratio fpm to m/s
# 
# HPM_TO_DEGS = 180 / 60              # ratio between half turn per minute and degrees/s
# 
# Path: ogn/parser/aprs_comment/tracker_parser.py
# class TrackerParser(BaseParser):
#     def __init__(self):
#         self.beacon_type = 'tracker'
#         self.position_pattern = PATTERN_TRACKER_POSITION_COMMENT
#         self.status_pattern = PATTERN_TRACKER_STATUS_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) & 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
#         if match.group('turn_rate'): result['turn_rate'] = float(match.group('turn_rate')) * HPM_TO_DEGS
#         if match.group('flight_level'): result['flightlevel'] = float(match.group('flight_level'))
#         if match.group('signal_quality'): result['signal_quality'] = float(match.group('signal_quality'))
#         if match.group('error_count'): result['error_count'] = int(match.group('error_count'))
#         if match.group('frequency_offset'): result['frequency_offset'] = float(match.group('frequency_offset'))
#         if match.group('gps_quality'):
#             result.update({
#                 'gps_quality': {
#                     'horizontal': int(match.group('gps_quality_horizontal')),
#                     'vertical': int(match.group('gps_quality_vertical'))
#                 }
#             })
#         if match.group('signal_power'): result['signal_power'] = float(match.group('signal_power'))
#         return result
# 
#     def parse_status(self, aprs_comment):
#         match = self.status_pattern.match(aprs_comment)
#         if match:
#             result = {}
# 
#             if match.group('hardware_version'): result['hardware_version'] = int(match.group('hardware_version'))
#             if match.group('software_version'): result['software_version'] = int(match.group('software_version'))
#             if match.group('gps_satellites'): result['gps_satellites'] = int(match.group('gps_satellites'))
#             if match.group('gps_quality'): result['gps_quality'] = int(match.group('gps_quality'))
#             if match.group('gps_altitude'): result['gps_altitude'] = int(match.group('gps_altitude'))
#             if match.group('pressure'): result['pressure'] = float(match.group('pressure'))
#             if match.group('temperature'): result['temperature'] = float(match.group('temperature'))
#             if match.group('humidity'): result['humidity'] = int(match.group('humidity'))
#             if match.group('voltage'): result['voltage'] = float(match.group('voltage'))
#             if match.group('transmitter_power'): result['transmitter_power'] = int(match.group('transmitter_power'))
#             if match.group('noise_level'): result['noise_level'] = float(match.group('noise_level'))
#             if match.group('relays'): result['relays'] = int(match.group('relays'))
#             return result
#         else:
#             return {'comment': aprs_comment}


# Path: tests/parser/test_parse_tracker.py
import unittest
from ogn.parser.utils import FPM_TO_MS, HPM_TO_DEGS
from ogn.parser.aprs_comment.tracker_parser import TrackerParser

        self.assertEqual(message['address_type'], 3)
        self.assertEqual(message['aircraft_type'], 1)
        self.assertFalse(message['stealth'])
        self.assertEqual(message['address'], "2FD00F")
        self.assertAlmostEqual(message['climb_rate'], -58 * FPM_TO_MS, 2)
        self.assertEqual(message['turn_rate'], 1.1 * HPM_TO_DEGS)
        self.assertEqual(message['flightlevel'], 3.12)
        self.assertEqual(message['signal_quality'], 32.8)
        self.assertEqual(message['error_count'], 0)
        self.assertEqual(message['frequency_offset'], -0.8)
        self.assertEqual(message['gps_quality'], {'horizontal': 3, 'vertical': 5})
        self.assertEqual(message['signal_power'], 12.7)

    def test_status_comment(self):
        message = TrackerParser().parse_status("h00 v00 9sat/1 164m 1002.6hPa +20.2degC 0% 3.34V 14/-110.5dBm 1/min")

        self.assertEqual(message['hardware_version'], 0)
        self.assertEqual(message['software_version'], 0)
        self.assertEqual(message['gps_satellites'], 9)
        self.assertEqual(message['gps_quality'], 1)
        self.assertEqual(message['gps_altitude'], 164)
        self.assertEqual(message['pressure'], 1002.6)
        self.assertEqual(message['temperature'], 20.2)
        self.assertEqual(message['humidity'], 0)
        self.assertEqual(message['voltage'], 3.34)
        self.assertEqual(message['transmitter_power'], 14)
        self.assertEqual(message['noise_level'], -110.5)
        self.assertEqual(message['relays'], 1)

    def test_status_comment_comment(self):

        message = TrackerParser().parse_status("Pilot=Pawel Hard=DIY/STM32")