Beispiel #1
0
def _create_log_pass():
    ld = File.LogicalData(BYTES_CHANNEL)
    channels = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    ld = File.LogicalData(BYTES_FRAME)
    frame = EFLR.ExplicitlyFormattedLogicalRecord(4, ld)
    log_pass = LogPass.log_pass_from_RP66V1(frame, channels)
    return log_pass
def test_logical_record_segment_encryption_packet_ctor():
    ld = File.LogicalData(ENCRYPTION_EXAMPLE_BYTES)
    lrsep = Encryption.LogicalRecordSegmentEncryptionPacket(ld)
    assert lrsep.size == 4
    assert lrsep.producer_code == 440
    assert lrsep.encryption_information == b'\x00\x00\x00\x00'
    assert lrsep.bytes == b'\x00\x00'
    assert ld.remain == 0
Beispiel #3
0
def test_iflr_ctor(frame_number, by):
    ld = File.LogicalData(by)
    iflr = IFLR.IndirectlyFormattedLogicalRecord(1, ld)
    assert iflr.lr_type == 1
    assert iflr.object_name == RepCode.ObjectName(O=11, C=0, I=b'0B')
    assert iflr.frame_number == frame_number
    assert iflr.preamble_length == 6
    assert iflr.remain == 36
    assert iflr.remain == ld.remain
Beispiel #4
0
def test_iflr_ctor_zero_not_empty():
    ld = File.LogicalData(IFLR_ZERO_NOT_EMPTY)
    iflr = IFLR.IndirectlyFormattedLogicalRecord(1, ld)
    assert iflr.lr_type == 1
    assert iflr.object_name == RepCode.ObjectName(O=11, C=0, I=b'0B')
    assert iflr.frame_number == 0
    assert iflr.preamble_length == 6
    assert iflr.remain == 36
    assert iflr.remain == ld.remain
Beispiel #5
0
def test_eflr_channel_attributes():
    ld = File.LogicalData(BYTES_CHANNEL)
    eflr = EFLR.ExplicitlyFormattedLogicalRecord(
        Types.EFLR_PUBLIC_SET_TYPE_TO_CODE_MAP[b'CHANNEL'], ld)
    print(eflr)
    print(eflr.str_long())
    assert str(
        eflr
    ) == "<ExplicitlyFormattedLogicalRecord EFLR Set type: b'CHANNEL' name: b'59'>"
    assert eflr.str_long(
    ) == """<ExplicitlyFormattedLogicalRecord EFLR Set type: b'CHANNEL' name: b'59'>
Beispiel #6
0
def test_eflr_frame_attributes():
    ld = File.LogicalData(BYTES_FRAME)
    frame = EFLR.ExplicitlyFormattedLogicalRecord(
        Types.EFLR_PUBLIC_SET_TYPE_TO_CODE_MAP[b'FRAME'], ld)
    assert len(frame.objects) == 1
    # print()
    # print(frame)
    assert str(
        frame
    ) == "<ExplicitlyFormattedLogicalRecord EFLR Set type: b'FRAME' name: b'60'>"
    # print(frame.str_long())
    assert frame.str_long(
    ) == """<ExplicitlyFormattedLogicalRecord EFLR Set type: b'FRAME' name: b'60'>
Beispiel #7
0
def test_eflr_channel_obnames():
    ld = File.LogicalData(BYTES_CHANNEL)
    channels = EFLR.ExplicitlyFormattedLogicalRecord(
        Types.EFLR_PUBLIC_SET_TYPE_TO_CODE_MAP[b'CHANNEL'], ld)
    channel_obnames = [obj.name for obj in channels.objects]
    # print(channel_obnames)
    assert channel_obnames == [
        RepCode.ObjectName(O=11, C=0, I=b'DEPT'),
        RepCode.ObjectName(O=11, C=0, I=b'INC'),
        RepCode.ObjectName(O=11, C=0, I=b'AZI'),
        RepCode.ObjectName(O=11, C=0, I=b'MTTVD'),
        RepCode.ObjectName(O=11, C=0, I=b'SECT'),
        RepCode.ObjectName(O=11, C=0, I=b'RCN'),
        RepCode.ObjectName(O=11, C=0, I=b'RCE'),
        RepCode.ObjectName(O=11, C=0, I=b'DLSEV'),
        RepCode.ObjectName(O=11, C=0, I=b'TLTS'),
    ]
Beispiel #8
0
def test_eflr_frame_channels():
    ld = File.LogicalData(BYTES_FRAME)
    frame = EFLR.ExplicitlyFormattedLogicalRecord(
        Types.EFLR_PUBLIC_SET_TYPE_TO_CODE_MAP[b'FRAME'], ld)
    obj = frame[0]
    channels = obj[b'CHANNELS'].value
    assert len(channels) == 9
    assert channels == [
        RepCode.ObjectName(O=11, C=0, I=b'DEPT'),
        RepCode.ObjectName(O=11, C=0, I=b'INC'),
        RepCode.ObjectName(O=11, C=0, I=b'AZI'),
        RepCode.ObjectName(O=11, C=0, I=b'MTTVD'),
        RepCode.ObjectName(O=11, C=0, I=b'SECT'),
        RepCode.ObjectName(O=11, C=0, I=b'RCN'),
        RepCode.ObjectName(O=11, C=0, I=b'RCE'),
        RepCode.ObjectName(O=11, C=0, I=b'DLSEV'),
        RepCode.ObjectName(O=11, C=0, I=b'TLTS')
    ]
Beispiel #9
0
def _iflr_and_logical_data_from_bytes(by: bytes) -> typing.Tuple[IFLR.IndirectlyFormattedLogicalRecord, File.LogicalData]:
    ld = File.LogicalData(by)
    iflr = IFLR.IndirectlyFormattedLogicalRecord(1, ld)
    return iflr, ld
Beispiel #10
0
def test_eflr_channel_ctor():
    ld = File.LogicalData(BYTES_CHANNEL)
    EFLR.ExplicitlyFormattedLogicalRecord(
        Types.EFLR_PUBLIC_SET_TYPE_TO_CODE_MAP[b'CHANNEL'], ld)
Beispiel #11
0
def test_example_iflr_process():
    log_pass: LogPass.LogPass = _create_log_pass()
    # ObjectName(O=11, C=0, I=b'0B')
    frame_array: LogPass.FrameArray = log_pass[RepCode.ObjectName(
        11, 0, b'0B')]
    frame_array.init_arrays(len(BYTES_IFLR))
    # print()
    for frame_number, by in enumerate(BYTES_IFLR):
        ld = File.LogicalData(by)
        _iflr = IFLR.IndirectlyFormattedLogicalRecord(0, ld)
        # frame_array.read_x_axis(ld, frame_number=0)
        frame_array.read(ld, frame_number=frame_number)
        # print(frame_array)
    # print()
    expected = [
        # X axis
        np.array([
            [0.],
            [75197.],
            [154724.],
            [234606.],
            [311024.],
            [381102.],
            [386839.],
            [428193.],
            [447720.],
            [466339.],
            [489547.],
            [500559.],
            [523772.],
            [538638.],
            [542417.],
            [550409.],
        ]),
        np.array([
            [0.],
            [0.50002027],
            [0.50002027],
            [0.7500017],
            [0.50002027],
            [0.99998325],
            [0.9699998],
            [0.9699998],
            [0.69999975],
            [1.0600001],
            [0.9699998],
            [0.8800001],
            [0.78999996],
            [1.7599998],
            [2.2000003],
            [2.9],
        ], ),
        np.array([
            [0.],
            [0.],
            [0.],
            [0.],
            [0.],
            [0.],
            [200.44],
            [205.45],
            [206.18],
            [208.69],
            [202.7],
            [200.93],
            [255.77002],
            [243.87],
            [241.15],
            [240.7],
        ]),
        np.array([
            [0.],
            [190.99757],
            [392.98987],
            [595.8777],
            [789.96594],
            [967.95013],
            [982.51935],
            [1087.5443],
            [1137.139],
            [1184.4233],
            [1243.3641],
            [1271.3306],
            [1330.2852],
            [1368.0354],
            [1377.6296],
            [1397.9094],
        ]),
        np.array([
            [0.],
            [0.833423],
            [2.596255],
            [4.809544],
            [6.92684],
            [9.256786],
            [9.268364],
            [7.632412],
            [6.981416],
            [6.338459],
            [5.399805],
            [4.980779],
            [4.457969],
            [4.138596],
            [3.98476],
            [3.54544],
        ]),
        np.array([
            [0.],
            [0.833423],
            [2.596255],
            [4.809544],
            [6.92684],
            [9.256786],
            [9.268364],
            [7.632412],
            [6.981416],
            [6.338459],
            [5.399805],
            [4.980779],
            [4.457969],
            [4.138596],
            [3.98476],
            [3.54544],
        ]),
        np.array([
            [0.],
            [0.],
            [0.],
            [0.],
            [0.],
            [0.],
            [-0.043073],
            [-0.735641],
            [-1.049728],
            [-1.387169],
            [-1.841496],
            [-2.009587],
            [-2.565323],
            [-3.338264],
            [-3.632012],
            [-4.421124],
        ]),
        np.array([
            [-9.9925000e+02],
            [7.9068176e-02],
            [0.0000000e+00],
            [3.7815217e-02],
            [3.7815217e-02],
            [8.4224798e-02],
            [3.9912241e+00],
            [2.4064228e-02],
            [1.6329297e-01],
            [2.3032904e-01],
            [7.0473805e-02],
            [1.0141353e-01],
            [3.9362201e-01],
            [7.9411954e-01],
            [1.4060384e+00],
            [1.0347618e+00],
        ]),
        np.array([
            [-999.25],
            [-999.25],
            [-999.25],
            [-999.25],
            [-999.25],
            [-999.25],
            [50.3937],
            [56.4173],
            [58.4252],
            [58.4252],
            [62.4409],
            [62.4409],
            [62.4409],
            [62.4409],
            [62.4409],
            [58.4252],
        ]),
    ]
    for c, channel in enumerate(frame_array.channels):
        # print(channel.array)
        # np.testing.assert_array_almost_equal(channel.array, expected[c])
        assert str(channel.array) == str(expected[c])
Beispiel #12
0
def test_example_iflr():
    print()
    for by in BYTES_IFLR:
        ld = File.LogicalData(by)
        iflr = IFLR.IndirectlyFormattedLogicalRecord(0, ld)
Beispiel #13
0
def test_iflr_str(by, s):
    ld = File.LogicalData(by)
    iflr = IFLR.IndirectlyFormattedLogicalRecord(1, ld)
    assert str(iflr) == s
Beispiel #14
0
def test_eflr_frame_ctor():
    ld = File.LogicalData(BYTES_FRAME)
    EFLR.ExplicitlyFormattedLogicalRecord(
        Types.EFLR_PUBLIC_SET_TYPE_TO_CODE_MAP[b'FRAME'], ld)
Beispiel #15
0
def test_logical_record_segment_encryption_packet_str():
    ld = File.LogicalData(ENCRYPTION_EXAMPLE_BYTES)
    lrsep = Encryption.LogicalRecordSegmentEncryptionPacket(ld)
    assert str(
        lrsep
    ) == "EncryptionPacket: size: 0x0004 producer: 440 code length: 4 data length: 2"
Beispiel #16
0
def _eflr_frame() -> EFLR.ExplicitlyFormattedLogicalRecord:
    ld = File.LogicalData(BYTES_EFLR_FRAME)
    return EFLR.ExplicitlyFormattedLogicalRecord(4, ld)
Beispiel #17
0
def _eflr_channel() -> EFLR.ExplicitlyFormattedLogicalRecord:
    ld = File.LogicalData(BYTES_EFLR_CHANNEL)
    return EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
Beispiel #18
0
def test_eflr_constructs(lr_type, by):
    ld = File.LogicalData(by)
    eflr = EFLR.ExplicitlyFormattedLogicalRecord(lr_type, ld)
    assert eflr is not None
Beispiel #19
0
def test_logical_data_constructs(by):
    File.LogicalData(by)