def decode(self) -> PointRecord: bit_array_2 = BitArray(self.record_data[4:8]) return PointRecord( when=self.bit_array.get_int(4, 21), record_type=self.record_type, depth=ByteConverter.to_uint16(self.record_data[0:2]) / 100.00, ppo2=ByteConverter.to_uint16(self.record_data[2:4]) / 10000.00, no_deco_time=bit_array_2.get_int(0, 10) * 60, ascent_time=bit_array_2.get_int(10, 20) * 60, temperature=bit_array_2.get_int(20, 30) / 10.0, ceiling=ByteConverter.to_uint16(self.record_data[8:10]) / 100.0, he=self.record_data[10], )
def test_event_decoder_8(): event = EventRecordParser( DiveRecordType.Manipulation, BitArray(bytes.fromhex('b30ae1ff')), bytes.fromhex('0800ffffffffffffffffffff'), ).decode() assert event.record_type == DiveRecordType.Manipulation assert event.event_type == EventRecordType.Above_Ceiling assert event.when == 4267
def test_event_decoder_7(): event = EventRecordParser( DiveRecordType.Manipulation, BitArray(bytes.fromhex('636ee0ff')), bytes.fromhex('0700ccf7ffffffffffffffff'), ).decode() assert event.record_type == DiveRecordType.Manipulation assert event.event_type == EventRecordType.Too_Fast assert event.when == 1766
def test_event_decoder_4(): event = EventRecordParser( DiveRecordType.Manipulation, BitArray(bytes.fromhex('410ae0ff')), bytes.fromhex('1a00010000ffffffffffffff'), ).decode() assert event.record_type == DiveRecordType.Manipulation assert event.event_type == EventRecordType.User_Mark assert event.when == 164
def test_event_decoder_11(): event = EventRecordParser( DiveRecordType.Manipulation, BitArray(bytes.fromhex('03a4e0ff')), bytes.fromhex('1500ffffffffffffffffffff'), ).decode() assert event.record_type == DiveRecordType.Manipulation assert event.event_type == EventRecordType.Safety_Miss assert event.when == 2624
def test_event_decoder_10(): event = EventRecordParser( DiveRecordType.Manipulation, BitArray(bytes.fromhex('73d8e0ff')), bytes.fromhex('1400ffffffffffffffffffff'), ).decode() assert event.record_type == DiveRecordType.Manipulation assert event.event_type == EventRecordType.Above_Stop assert event.when == 3463
def test_event_decoder_9(): event = EventRecordParser( DiveRecordType.Manipulation, BitArray(bytes.fromhex('036be0ff')), bytes.fromhex('0900ffffffffffffffffffff'), ).decode() assert event.record_type == DiveRecordType.Manipulation assert event.event_type == EventRecordType.Toxic assert event.when == 1712
def test_event_decoder_6(): event = EventRecordParser( DiveRecordType.Manipulation, BitArray(bytes.fromhex('0100e0ff')), bytes.fromhex('180015000100ffffffffffff'), ).decode() assert event.record_type == DiveRecordType.Manipulation assert event.event_type == EventRecordType.Change_Mode assert event.o2 == 21 assert event.when == 0
def test_event_decoder_5(): event = EventRecordParser( DiveRecordType.Manipulation, BitArray(bytes.fromhex('b312e0ff')), bytes.fromhex('1e004e00ffffffffffffffff'), ).decode() assert event.record_type == DiveRecordType.Manipulation assert event.event_type == EventRecordType.CNS assert event.cns == 78 assert event.when == 299
def test_event_decoder_2(): event = EventRecordParser( DiveRecordType.Manipulation, BitArray(bytes.fromhex('0200e0ff')), bytes.fromhex('0600ffff01ffffffffffffff'), ).decode() assert event.record_type == DiveRecordType.Manipulation assert event.event_type == EventRecordType.Start assert event.reason == DiveStartReason.Manual assert event.when == 0
def test_point_decoder_1(): point = PointRecordParser( DiveRecordType.Point, BitArray(bytes.fromhex('0000e0ff')), bytes.fromhex('7601cf07e803c0cd00000000'), ).decode() assert point.depth == 3.74 assert point.ceiling == 0.0 assert point.ppo2 == 0.1999 assert point.when == 0
def test_point_decoder_3(): point = PointRecordParser( DiveRecordType.Point, BitArray(bytes.fromhex('e80330cb')), bytes.fromhex('a900040ae80330cb00000000'), ).decode() assert point.depth == 1.69 assert point.ceiling == 0.0 assert point.ppo2 == 0.2564 assert point.when == 65598
def test_point_decoder_2(): point = PointRecordParser( DiveRecordType.Point, BitArray(bytes.fromhex('e80360cb')), bytes.fromhex('ca004a0ae80360cb00000000'), ).decode() assert point.depth == 2.02 assert point.ceiling == 0.0 assert point.ppo2 == 0.2634 assert point.when == 62
def test_event_decoder_3(): event = EventRecordParser( DiveRecordType.Manipulation, BitArray(bytes.fromhex('e153e0ff')), bytes.fromhex('1200010000ffffffffffffff'), ).decode() assert event.record_type == DiveRecordType.Manipulation assert event.event_type == EventRecordType.Key_Down assert event.key1 is True assert event.key2 is False assert event.when == 1342
def test_configuration_decoder_3(): cfg = ConfigurationRecordParser( DiveRecordType.Configuration, BitArray(bytes.fromhex('f6ffbf00')), bytes.fromhex('000300010f02000033120000'), ).decode() assert cfg.record_type == DiveRecordType.Configuration assert cfg.configuration_type == ConfigurationType.Version # { "device": 0, # "hwMajor": 3, "hwMinor": 0, # "swMajor": 1, "swMinor": 15, # "swPatchLevel": 2, "swFlags": 0, "swBuild": 4659 } assert cfg.device == 0 assert cfg.hardware_major == 3 assert cfg.hardware_minor == 0 assert cfg.software_major == 1 assert cfg.software_minor == 15 assert cfg.software_patch == 2 assert cfg.software_flags == 0 assert cfg.software_build == 4659