Ejemplo n.º 1
0
class FrameGetActivationLogLinesNotification(FrameBase):
    """Frame for Activation Log Line."""

    PAYLOAD_LEN = 17

    def __init__(self):
        """Init Frame."""
        super().__init__(Command.GW_GET_MULTIPLE_ACTIVATION_LOG_LINES_NTF)
        self.logline = None

    def get_payload(self):
        """Return Payload."""
        if self.logline is None:
            self.logline = DtoActivationLogLine()
        ret = self.logline.to_payload()
        return ret

    def from_payload(self, payload):
        """Init frame from binary data."""
        # KLF Returns 0x00 Log Entry if nothing is available
        if payload != b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00':
            self.logline = DtoActivationLogLine()
            self.logline.from_payload(payload)

    def __str__(self):
        """Return human readable string."""
        return (
            '<{0}>{1}</{0}>'.format(
                type(self).__name__, self.logline
            )
        )
Ejemplo n.º 2
0
 def test_str(self):
     """Test string representation of FrameGetActivationLogLineConfirmation."""
     frame = FrameGetActivationLogLineConfirmation()
     frame.logline = DtoActivationLogLine()
     self.assertEqual(
         str(frame),
         '<FrameGetActivationLogLineConfirmation><DtoActivationLogLine timestamp="1970-01-01 01:00:00" '
         'sessionid="0" statusid="StatusId.STATUS_UNKNOWN" index="0" nodeparameter="NodeParameter.NOT_USED" '
         'parametervalue="0" runstatus="RunStatus.EXECUTION_COMPLETED" statusreply="StatusReply.UNKNOWN_STATUS_REPLY" '
         'informationcode="0"/></FrameGetActivationLogLineConfirmation>')
Ejemplo n.º 3
0
 def from_payload(self, payload):
     """Init frame from binary data."""
     # KLF Returns 0x00 Log Entry if nothing is available
     if payload != b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00':
         self.logline = DtoActivationLogLine()
         self.logline.from_payload(payload)
Ejemplo n.º 4
0
 def get_payload(self):
     """Return Payload."""
     if self.logline is None:
         self.logline = DtoActivationLogLine()
     ret = self.logline.to_payload()
     return ret
Ejemplo n.º 5
0
 def test_bytes(self):
     """Test FrameActivationLogLine."""
     frame = FrameGetActivationLogLineConfirmation()
     frame.logline = DtoActivationLogLine()
     self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)