Ejemplo n.º 1
0
def test_ExplicitlyFormattedLogicalRecord_eq():
    ld = LogicalData(LOGICAL_BYTES_FROM_STANDARD)
    eflr_a = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    ld.rewind()
    eflr_b = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    assert eflr_a == eflr_b
    assert eflr_a != 1
Ejemplo n.º 2
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
Ejemplo n.º 3
0
def test_ExplicitlyFormattedLogicalRecord_key_values(sort_order, expected):
    ld = LogicalData(LOGICAL_BYTES_FROM_STANDARD_SINGLE_OBJECT)
    eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    result = eflr.key_values(
        stringify_function=stringify.stringify_object_by_type, sort=sort_order)
    # print(result)
    assert result == expected
Ejemplo n.º 4
0
def test_ExplicitlyFormattedLogicalRecord_dupe_later_copy(ld):
    """Hmm actually this should fail and only have one object there ???"""
    ld.rewind()
    with duplicate_object_strategy(
            TotalDepth.RP66V1.core.LogicalRecord.Duplicates.
            DuplicateObjectStrategy.REPLACE_LATER_COPY):
        eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
        result = eflr.str_long()
        # print(result)
        expected = """<ExplicitlyFormattedLogicalRecord EFLR Set type: b'CHANNEL' name: b'0'>
  Template [5]:
    CD: 001 10100 L: b'LONG-NAME' C: 1 R: 23 (OBNAME) U: b'' V: None
    CD: 001 10101 L: b'ELEMENT-LIMIT' C: 1 R: 18 (UVARI) U: b'' V: [1]
    CD: 001 10101 L: b'REPRESENTATION-CODE' C: 1 R: 15 (USHORT) U: b'' V: [2]
    CD: 001 10000 L: b'UNITS' C: 1 R: 19 (IDENT) U: b'' V: None
    CD: 001 10101 L: b'DIMENSION' C: 1 R: 18 (UVARI) U: b'' V: [1]
  Objects [2]:
    OBNAME: O: 0 C: 0 I: b'TIME'
      CD: 001 00001 L: b'LONG-NAME' C: 1 R: 23 (OBNAME) U: b'' V: [ObjectName(O=0, C=0, I=b'1')]
      CD: 001 00000 L: b'ELEMENT-LIMIT' C: 1 R: 18 (UVARI) U: b'' V: [1]
      CD: 001 00000 L: b'REPRESENTATION-CODE' C: 1 R: 15 (USHORT) U: b'' V: [2]
      CD: 001 00001 L: b'UNITS' C: 1 R: 19 (IDENT) U: b'' V: [b'S']
      CD: 001 10101 L: b'DIMENSION' C: 1 R: 18 (UVARI) U: b'' V: [1]
    OBNAME: O: 0 C: 1 I: b'TIME'
      CD: 001 00001 L: b'LONG-NAME' C: 1 R: 23 (OBNAME) U: b'' V: [ObjectName(O=0, C=0, I=b'1')]
      CD: 001 00000 L: b'ELEMENT-LIMIT' C: 1 R: 18 (UVARI) U: b'' V: [1]
      CD: 001 00000 L: b'REPRESENTATION-CODE' C: 1 R: 15 (USHORT) U: b'' V: [2]
      CD: 001 00001 L: b'UNITS' C: 1 R: 19 (IDENT) U: b'' V: [b'S']
      CD: 001 10101 L: b'DIMENSION' C: 1 R: 18 (UVARI) U: b'' V: [1]"""
        for a, b in zip(result.split('\n'), expected.split('\n')):
            assert a == b
        assert result == expected
Ejemplo n.º 5
0
 def __enter__(self):
     """Context manager support."""
     self._logical_record_index._enter()
     self.logical_files = []
     for lr_index in range(len(self._logical_record_index)):
         # TODO: This is greedy and for IFLRs we could only read a partial amount for performance.
         #  See FrameArray.x_axis_len_input_bytes
         file_logical_data = self._logical_record_index.get_file_logical_data(lr_index, 0, -1)
         assert file_logical_data.is_sealed()
         if not file_logical_data.lr_is_encrypted:
             if file_logical_data.lr_is_eflr:
                 # EFLRs
                 eflr = EFLR.ExplicitlyFormattedLogicalRecord(file_logical_data.lr_type,
                                                              file_logical_data.logical_data)
                 if len(self.logical_files) == 0 or self.logical_files[-1].is_next(eflr):
                     self.logical_files.append(LogicalFile(self._logical_record_index, file_logical_data, eflr))
                 else:
                     self.logical_files[-1].add_eflr(file_logical_data, eflr)
             else:
                 # IFLRs
                 if len(self.logical_files) == 0:
                     raise ExceptionLogicalIndexCtor('IFLR when there are no Logical Files.')
                 iflr = IFLR.IndirectlyFormattedLogicalRecord(file_logical_data.lr_type,
                                                              file_logical_data.logical_data)
                 if iflr.remain > 0:
                     self.logical_files[-1].add_iflr(file_logical_data, iflr)
                 # else:
                 #     logger.warning(f'Ignoring empty IFLR at {file_logical_data.position}')
     return self
Ejemplo n.º 6
0
def test_ExplicitlyFormattedLogicalRecord_key_value_raises():
    ld = LogicalData(LOGICAL_BYTES_FROM_STANDARD)
    eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    assert not eflr.is_key_value()
    with pytest.raises(EFLR.ExceptionEFLR) as err:
        eflr.key_values(stringify_function=stringify.stringify_object_by_type,
                        sort=True)
    assert err.value.args[0] == 'Can not represent EFLR as key->value table.'
Ejemplo n.º 7
0
def test_ExplicitlyFormattedLogicalRecord_table_as_string(
        sort_order, expected):
    ld = LogicalData(LOGICAL_BYTES_FROM_STANDARD)
    eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    result = eflr.table_as_strings(
        stringify_function=stringify.stringify_object_by_type, sort=sort_order)
    # print(result)
    assert result == expected
Ejemplo n.º 8
0
def test_ExplicitlyFormattedLogicalRecord_dupe_exact_raise(ld):
    ld.rewind()
    with duplicate_object_strategy(TotalDepth.RP66V1.core.LogicalRecord.
                                   Duplicates.DuplicateObjectStrategy.RAISE):
        with pytest.raises(EFLR.ExceptionEFLRSetDuplicateObjectNames) as err:
            EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
        assert err.value.args == (
            "Duplicate Object OBNAME: O: 0 C: 0 I: b'TIME' already seen in the EFLR Set type: b'CHANNEL' name: b'0'.",
        )
Ejemplo n.º 9
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'>
Ejemplo n.º 10
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'>
Ejemplo n.º 11
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'),
    ]
Ejemplo n.º 12
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')
    ]
Ejemplo n.º 13
0
def test_ExplicitlyFormattedLogicalRecord_template(ld):
    ld.rewind()
    eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    assert len(eflr.template) == 5
    # ATTRIB[0]: LR
    assert eflr.template.attrs[0].label == b'LONG-NAME'
    assert eflr.template.attrs[0].rep_code == 0x17
    # ATTRIB[1]: LRV
    assert eflr.template.attrs[1].label == b'ELEMENT-LIMIT'
    assert eflr.template.attrs[1].rep_code == 0x12
    assert eflr.template.attrs[1].value == [1]
    # ATTRIB[2]: LRV
    assert eflr.template.attrs[2].label == b'REPRESENTATION-CODE'
    assert eflr.template.attrs[2].rep_code == 0x0f
    assert eflr.template.attrs[2].value[0] == 0x02
    # ATTRIB[3]: L
    assert eflr.template.attrs[3].label == b'UNITS'
    # ATTRIB[4]: LRV
    assert eflr.template.attrs[4].label == b'DIMENSION'
    assert eflr.template.attrs[4].rep_code == 0x12
    assert eflr.template.attrs[4].value[0] == 0x01
Ejemplo n.º 14
0
def test_ExplicitlyFormattedLogicalRecord_dupe_diff_replace(ld, strategy):
    ld.rewind()
    with duplicate_object_strategy(strategy):
        eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
        result = eflr.str_long()
        # print(result)
        expected = """<ExplicitlyFormattedLogicalRecord EFLR Set type: b'CHANNEL' name: b'0'>
  Template [5]:
    CD: 001 10100 L: b'LONG-NAME' C: 1 R: 23 (OBNAME) U: b'' V: None
    CD: 001 10101 L: b'ELEMENT-LIMIT' C: 1 R: 18 (UVARI) U: b'' V: [1]
    CD: 001 10101 L: b'REPRESENTATION-CODE' C: 1 R: 15 (USHORT) U: b'' V: [2]
    CD: 001 10000 L: b'UNITS' C: 1 R: 19 (IDENT) U: b'' V: None
    CD: 001 10101 L: b'DIMENSION' C: 1 R: 18 (UVARI) U: b'' V: [1]
  Objects [1]:
    OBNAME: O: 0 C: 0 I: b'TIME'
      CD: 001 00001 L: b'LONG-NAME' C: 1 R: 23 (OBNAME) U: b'' V: [ObjectName(O=0, C=0, I=b'1')]
      CD: 001 00000 L: b'ELEMENT-LIMIT' C: 1 R: 18 (UVARI) U: b'' V: [1]
      CD: 001 00000 L: b'REPRESENTATION-CODE' C: 1 R: 15 (USHORT) U: b'' V: [2]
      CD: 001 00001 L: b'UNITS' C: 1 R: 19 (IDENT) U: b'' V: [b'SECONDS']
      CD: 001 10101 L: b'DIMENSION' C: 1 R: 18 (UVARI) U: b'' V: [1]"""
        for a, b in zip(result.split('\n'), expected.split('\n')):
            assert a == b
        assert result == expected
Ejemplo n.º 15
0
def scan_RP66V1_file_EFLR_IFLR(fobj: typing.BinaryIO, fout: typing.TextIO, **kwargs) -> None:
    """Scans the file reporting the individual EFLR and IFLR."""
    verbose = kwargs.get('verbose', 0)
    if not verbose:
        fout.write(colorama.Fore.YELLOW  + 'Use -v to see individual logical data.\n')
    # TODO: eflr_dump is never present
    dump_eflr = kwargs.get('eflr_dump', 0)
    eflr_set_type = kwargs.get('eflr_set_type', [])
    iflr_dump = kwargs.get('iflr_dump', 0)
    iflr_set_type = kwargs.get('iflr_set_type', [])
    # TODO: Use both of these
    # dump_bytes = kwargs.get('dump_bytes', 0)
    # dump_raw_bytes = kwargs.get('dump_raw_bytes', 0)
    # if not dump_bytes:
    #     fout.write(colorama.Fore.YELLOW  + 'Use -v and --dump-bytes to see actual first n bytes.\n')
    with _output_section_header_trailer('RP66V1 EFLR and IFLR Data Summary', '*', os=fout):
        with File.FileRead(fobj) as rp66_file:
            # TODO: use data_table.format_table
            vr_position = 0
            header = [
                f'{"Visible R":10}',
                f'{"LRSH":10}',
                f'{"Typ":3}',
                f'{" "}',
                f'{"     "}',
                f'{"Length":8}',
            ]
            underline = ['-' * len(h) for h in header]
            if verbose:
                fout.write(' '.join(header) + '\n')
                fout.write(' '.join(underline) + '\n')
            for file_logical_data in rp66_file.iter_logical_records():
                if file_logical_data.lr_is_eflr:
                    if file_logical_data.lr_is_encrypted:
                        if kwargs['encrypted']:
                            if verbose:
                                fout.write(colorama.Fore.MAGENTA + f'Encrypted EFLR: {file_logical_data}' + colorama.Style.RESET_ALL)
                            else:
                                fout.write(colorama.Fore.MAGENTA + f'Encrypted EFLR: {file_logical_data.position}' + colorama.Style.RESET_ALL)
                            fout.write('\n')
                    else:
                        eflr = EFLR.ExplicitlyFormattedLogicalRecord(file_logical_data.lr_type, file_logical_data.logical_data)
                        if dump_eflr and len(eflr_set_type) == 0 or eflr.set.type in eflr_set_type:
                            lines = str(eflr).split('\n')
                            for i, line in enumerate(lines):
                                if i == 0:
                                    fout.write(colorama.Fore.MAGENTA + line + colorama.Style.RESET_ALL)
                                else:
                                    fout.write(line)
                                fout.write('\n')
                else:
                    # IFLR
                    if iflr_dump and verbose:
                        if file_logical_data.lr_is_encrypted:
                            if kwargs['encrypted']:
                                if verbose:
                                    fout.write(colorama.Fore.MAGENTA + f'Encrypted IFLR: {file_logical_data}' + colorama.Style.RESET_ALL)
                                else:
                                    fout.write(colorama.Fore.MAGENTA + f'Encrypted IFLR: {file_logical_data.position}' + colorama.Style.RESET_ALL)
                                fout.write('\n')
                        else:
                            iflr = IFLR.IndirectlyFormattedLogicalRecord(file_logical_data.lr_type, file_logical_data.logical_data)
                            if len(iflr_set_type) == 0 or iflr.object_name.I in iflr_set_type:
                                fout.write(str(iflr))
                                fout.write('\n')
Ejemplo n.º 16
0
def test_eflr_channel_ctor():
    ld = File.LogicalData(BYTES_CHANNEL)
    EFLR.ExplicitlyFormattedLogicalRecord(
        Types.EFLR_PUBLIC_SET_TYPE_TO_CODE_MAP[b'CHANNEL'], ld)
Ejemplo n.º 17
0
def _eflr_channel() -> EFLR.ExplicitlyFormattedLogicalRecord:
    ld = File.LogicalData(BYTES_EFLR_CHANNEL)
    return EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
Ejemplo n.º 18
0
def _eflr_frame() -> EFLR.ExplicitlyFormattedLogicalRecord:
    ld = File.LogicalData(BYTES_EFLR_FRAME)
    return EFLR.ExplicitlyFormattedLogicalRecord(4, ld)
Ejemplo n.º 19
0
def test_ExplicitlyFormattedLogicalRecord_len():
    ld = LogicalData(LOGICAL_BYTES_FROM_STANDARD)
    eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    result = eflr.str_long()
    # print(result)
    assert len(eflr) == 3
Ejemplo n.º 20
0
def test_eflr_frame_ctor():
    ld = File.LogicalData(BYTES_FRAME)
    EFLR.ExplicitlyFormattedLogicalRecord(
        Types.EFLR_PUBLIC_SET_TYPE_TO_CODE_MAP[b'FRAME'], ld)
Ejemplo n.º 21
0
def test_ExplicitlyFormattedLogicalRecord_table_shape():
    ld = LogicalData(LOGICAL_BYTES_FROM_STANDARD)
    eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    assert eflr.shape == (3, 5)
Ejemplo n.º 22
0
def test_ExplicitlyFormattedLogicalRecord_reduced_object_map():
    ld = LogicalData(LOGICAL_BYTES_FROM_STANDARD)
    eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    result = EFLR.reduced_object_map(eflr)
    # print(result)
    assert result == {b'TIME': 0, b'PRESSURE': 1, b'PAD-ARRAY': 2}
Ejemplo n.º 23
0
def test_ExplicitlyFormattedLogicalRecord_key_value():
    ld = LogicalData(LOGICAL_BYTES_FROM_STANDARD_SINGLE_OBJECT)
    eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    assert eflr.is_key_value()
Ejemplo n.º 24
0
def test_ExplicitlyFormattedLogicalRecord_smoke_test(ld):
    EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
Ejemplo n.º 25
0
def test_ExplicitlyFormattedLogicalRecord_dupe_exact_default(ld):
    ld.rewind()
    eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    # print(eflr.str_long())
    assert eflr.str_long(
    ) == """<ExplicitlyFormattedLogicalRecord EFLR Set type: b'CHANNEL' name: b'0'>
Ejemplo n.º 26
0
def test_ExplicitlyFormattedLogicalRecord_logical_data_consumed(ld):
    eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    assert eflr.logical_data_consumed == 155
Ejemplo n.º 27
0
def test_ExplicitlyFormattedLogicalRecord_objects(ld):
    ld.rewind()
    eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    assert len(eflr.template) == 5
    assert len(eflr.objects) == 3
    ## Object #1
    obj_index: int = 0
    assert eflr.objects[0].name == RepCode.ObjectName(0, 0, b'TIME')
    assert len(eflr.objects[0].attrs) == len(eflr.template)
    # Attribute 0
    attr_index = 0
    assert eflr.objects[obj_index].attrs[attr_index].label == b'LONG-NAME'
    assert eflr.objects[obj_index].attrs[attr_index].count == 1
    assert eflr.objects[obj_index].attrs[
        attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['OBNAME']
    assert eflr.objects[obj_index].attrs[attr_index].units == b''
    assert eflr.objects[obj_index].attrs[attr_index].value == [
        RepCode.ObjectName(0, 0, b'1')
    ]
    # Attribute 1
    attr_index = 1
    assert eflr.objects[obj_index].attrs[attr_index].label == b'ELEMENT-LIMIT'
    assert eflr.objects[obj_index].attrs[attr_index].count == 1
    assert eflr.objects[obj_index].attrs[
        attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['UVARI']
    assert eflr.objects[obj_index].attrs[attr_index].units == b''
    assert eflr.objects[obj_index].attrs[attr_index].value == [1]
    # Attribute 2
    attr_index = 2
    assert eflr.objects[obj_index].attrs[
        attr_index].label == b'REPRESENTATION-CODE'
    assert eflr.objects[obj_index].attrs[attr_index].count == 1
    assert eflr.objects[obj_index].attrs[
        attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['USHORT']
    assert eflr.objects[obj_index].attrs[attr_index].units == b''
    assert eflr.objects[obj_index].attrs[attr_index].value == [
        RepCode.REP_CODE_STR_TO_INT['FSINGL']
    ]
    # Attribute 3
    attr_index = 3
    assert eflr.objects[obj_index].attrs[attr_index].label == b'UNITS'
    assert eflr.objects[obj_index].attrs[attr_index].count == 1
    assert eflr.objects[obj_index].attrs[
        attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['IDENT']
    assert eflr.objects[obj_index].attrs[attr_index].units == b''
    assert eflr.objects[obj_index].attrs[attr_index].value == [b'S']
    # Attribute 4
    attr_index = 4
    assert eflr.objects[obj_index].attrs[attr_index].label == b'DIMENSION'
    assert eflr.objects[obj_index].attrs[attr_index].count == 1
    assert eflr.objects[obj_index].attrs[
        attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['UVARI']
    assert eflr.objects[obj_index].attrs[attr_index].units == b''
    assert eflr.objects[obj_index].attrs[attr_index].value == [1]
    ## Object #2
    obj_index: int = 1
    assert eflr.objects[0].name == RepCode.ObjectName(0, 0, b'TIME')
    assert len(eflr.objects[0].attrs) == len(eflr.template)
    # Attribute 0
    attr_index = 0
    assert eflr.objects[obj_index].attrs[attr_index].label == b'LONG-NAME'
    assert eflr.objects[obj_index].attrs[attr_index].count == 1
    assert eflr.objects[obj_index].attrs[
        attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['OBNAME']
    assert eflr.objects[obj_index].attrs[attr_index].units == b''
    assert eflr.objects[obj_index].attrs[attr_index].value == [
        RepCode.ObjectName(0, 0, b'2')
    ]
    # Attribute 1
    attr_index = 1
    assert eflr.objects[obj_index].attrs[attr_index].label == b'ELEMENT-LIMIT'
    assert eflr.objects[obj_index].attrs[attr_index].count == 1
    assert eflr.objects[obj_index].attrs[
        attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['UVARI']
    assert eflr.objects[obj_index].attrs[attr_index].units == b''
    assert eflr.objects[obj_index].attrs[attr_index].value == [1]
    # Attribute 2
    attr_index = 2
    assert eflr.objects[obj_index].attrs[
        attr_index].label == b'REPRESENTATION-CODE'
    assert eflr.objects[obj_index].attrs[attr_index].count == 1
    assert eflr.objects[obj_index].attrs[
        attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['USHORT']
    assert eflr.objects[obj_index].attrs[attr_index].units == b''
    assert eflr.objects[obj_index].attrs[attr_index].value == [
        RepCode.REP_CODE_STR_TO_INT['FDOUBL']
    ]
    # Attribute 3
    attr_index = 3
    assert eflr.objects[obj_index].attrs[attr_index].label == b'UNITS'
    assert eflr.objects[obj_index].attrs[attr_index].count == 1
    assert eflr.objects[obj_index].attrs[
        attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['IDENT']
    assert eflr.objects[obj_index].attrs[attr_index].units == b''
    assert eflr.objects[obj_index].attrs[attr_index].value == [b'PSI']
    # Attribute 4
    attr_index = 4
    assert eflr.objects[obj_index].attrs[attr_index].label == b'DIMENSION'
    assert eflr.objects[obj_index].attrs[attr_index].count == 1
    assert eflr.objects[obj_index].attrs[
        attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['UVARI']
    assert eflr.objects[obj_index].attrs[attr_index].units == b''
    assert eflr.objects[obj_index].attrs[attr_index].value == [1]
    ## Object #3
    obj_index: int = 2
    assert eflr.objects[0].name == RepCode.ObjectName(0, 0, b'TIME')
    assert len(eflr.objects[0].attrs) == len(eflr.template)
    # Attribute 0
    attr_index = 0
    assert eflr.objects[obj_index].attrs[attr_index].label == b'LONG-NAME'
    assert eflr.objects[obj_index].attrs[attr_index].count == 1
    assert eflr.objects[obj_index].attrs[
        attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['OBNAME']
    assert eflr.objects[obj_index].attrs[attr_index].units == b''
    assert eflr.objects[obj_index].attrs[attr_index].value == [
        RepCode.ObjectName(0, 0, b'3')
    ]
    # Attribute 1
    attr_index = 1
    assert eflr.objects[obj_index].attrs[attr_index].label == b'ELEMENT-LIMIT'
    assert eflr.objects[obj_index].attrs[attr_index].count == 2
    assert eflr.objects[obj_index].attrs[
        attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['UVARI']
    assert eflr.objects[obj_index].attrs[attr_index].units == b''
    assert eflr.objects[obj_index].attrs[attr_index].value == [8, 20]
    # Attribute 2
    attr_index = 2
    assert eflr.objects[obj_index].attrs[
        attr_index].label == b'REPRESENTATION-CODE'
    assert eflr.objects[obj_index].attrs[attr_index].count == 1
    assert eflr.objects[obj_index].attrs[
        attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['USHORT']
    assert eflr.objects[obj_index].attrs[attr_index].units == b''
    # See above for: NOTE: [RP66V1 Error]
    assert eflr.objects[obj_index].attrs[attr_index].value == [
        RepCode.REP_CODE_STR_TO_INT['SNORM']
    ]
    # Attribute 3
    attr_index = 3
    assert eflr.objects[obj_index].attrs[attr_index].label == b'UNITS'
    assert eflr.objects[obj_index].attrs[attr_index].count == 1
    assert eflr.objects[obj_index].attrs[
        attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['IDENT']
    assert eflr.objects[obj_index].attrs[attr_index].units == b''
    assert eflr.objects[obj_index].attrs[attr_index].value is None
    # Attribute 4
    attr_index = 4
    assert eflr.objects[obj_index].attrs[attr_index].label == b'DIMENSION'
    assert eflr.objects[obj_index].attrs[attr_index].count == 2
    assert eflr.objects[obj_index].attrs[
        attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['UVARI']
    assert eflr.objects[obj_index].attrs[attr_index].units == b''
    assert eflr.objects[obj_index].attrs[attr_index].value == [8, 10]
Ejemplo n.º 28
0
def test_eflr_constructs(lr_type, by):
    ld = File.LogicalData(by)
    eflr = EFLR.ExplicitlyFormattedLogicalRecord(lr_type, ld)
    assert eflr is not None
Ejemplo n.º 29
0
def test_ExplicitlyFormattedLogicalRecord_set(ld):
    eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    assert eflr.set.type == b'CHANNEL'
    assert eflr.set.name == b'0'