示例#1
0
 def send_hls_reply(self) -> Optional[bytes]:
     return self.action(
         method=cosem.CosemMethod(
             enumerations.CosemInterface.ASSOCIATION_LN,
             cosem.Obis(0, 0, 40, 0, 0),
             1,
         ),
         data=dlms_data.OctetStringData(
             self.dlms_connection.get_hls_reply()).to_bytes(),
     )
示例#2
0
def action_request() -> xdlms.ActionRequestNormal:
    return xdlms.ActionRequestNormal(
        cosem_method=cosem.CosemMethod(
            interface=enumerations.CosemInterface.DISCONNECT_CONTROL,
            instance=cosem.Obis.from_dotted("0.0.96.3.10.255"),
            method=1,
        ),
        data=dlms_data.UnsignedLongData(0).to_bytes(),
        invoke_id_and_priority=xdlms.InvokeIdAndPriority(invoke_id=1,
                                                         confirmed=True,
                                                         high_priority=True),
    )
示例#3
0
    def test_transform_bytes_without_data(self):
        data = b"\xc3\x01\xc0\x00\x0f\x00\x00(\x00\x00\xff\x01\x00"
        action = xdlms.ActionRequestNormal(
            cosem_method=cosem.CosemMethod(
                interface=enumerations.CosemInterface.ASSOCIATION_LN,
                instance=cosem.Obis(a=0, b=0, c=40, d=0, e=0, f=255),
                method=1,
            ),
            data=None,
            invoke_id_and_priority=xdlms.InvokeIdAndPriority(
                invoke_id=0, confirmed=True, high_priority=True),
        )

        assert data == action.to_bytes()
        assert action == xdlms.ActionRequestNormal.from_bytes(data)
示例#4
0
    def test_transform_bytes(self):
        data = b'\xc3\x01\xc0\x00\x0f\x00\x00(\x00\x00\xff\x01\x01\t\x11\x10\x00\x00\x1a\x90\xe6\xd2"\x1f\xa2\xfd\x85\xee\xd6\x1a\xcc"'
        action = xdlms.ActionRequestNormal(
            cosem_method=cosem.CosemMethod(
                interface=enumerations.CosemInterface.ASSOCIATION_LN,
                instance=cosem.Obis(a=0, b=0, c=40, d=0, e=0, f=255),
                method=1,
            ),
            data=
            b'\t\x11\x10\x00\x00\x1a\x90\xe6\xd2"\x1f\xa2\xfd\x85\xee\xd6\x1a\xcc"',
            invoke_id_and_priority=xdlms.InvokeIdAndPriority(
                invoke_id=0, confirmed=True, high_priority=True),
        )

        assert data == action.to_bytes()
        assert action == xdlms.ActionRequestNormal.from_bytes(data)