示例#1
0
 def __init__(self, nr):
     CommandFactory.__init__(self)
     
     self.command.append(0x04)
     self.command.append(0x01)
     self.command.append(self.ZERO_BYTE)
     self.command.append(nr)
     self.command.append(self.ZERO_BYTE)
示例#2
0
    def __init__(self, nr):
        CommandFactory.__init__(self)

        self.command.append(0x04)
        self.command.append(0x01)
        self.command.append(self.ZERO_BYTE)
        self.command.append(nr)
        self.command.append(self.ZERO_BYTE)
示例#3
0
    def __init__(self, ASDU, IOA, CONTROL_ACTION):
        """
        Builds the telegram as a list of bytes. CONTROL_ACTION specifies whether the target
        object given by the IOA should be switched \"ON\" or \"OFF\".
        """
        CommandFactory.__init__(self)
        # 1) length of APDU
        self.command.append(10 + 4)

        # 2-5) Control Fields
        # leave them all zero for the moment
        # we need to care about them later, when trying to check whether
        # telegrams arrived and were processed or not
        self.command.append(self.ZERO_BYTE)
        self.command.append(self.ZERO_BYTE)
        self.command.append(self.ZERO_BYTE)
        self.command.append(self.ZERO_BYTE)

        # 6) Type Identification
        self.command.append(self.TYPE_C_DC_NA_1)

        # 7) SQ / Number of Objects
        self.command.append(1)

        # 8) T / P/N / Cause of Transmission
        self.command.append(self.COT_ACTIVATION)
        # COT is always "activation", even if switching off!!!

        # 9) Originator Address
        # this is always zero in our case
        self.command.append(self.ZERO_BYTE)

        # 10-11) ASDU address
        asdu_bytes = int_to_hex_bytes(ASDU)
        # - low octet
        self.command.append(asdu_bytes[1])
        # - high octet
        self.command.append(asdu_bytes[0])

        # 12-n) IOAs + respective Object informations
        ioa_bytes = int_to_hex_bytes(IOA)
        # IOA - low octet
        self.command.append(ioa_bytes[1])
        # IOA - high octet
        self.command.append(ioa_bytes[0])
        # IOA - special - always 0 in our case
        self.command.append(self.ZERO_BYTE)
        # Object Information - always one byte in our case
        if CONTROL_ACTION == "ON":
            self.command.append(self.EXECUTE_UNSPECIFIED_ON)
        else:
            self.command.append(self.EXECUTE_UNSPECIFIED_OFF)
 def __init__(self, ASDU, IOA, CONTROL_ACTION):
     """
     Builds the telegram as a list of bytes. CONTROL_ACTION specifies whether the target
     object given by the IOA should be switched \"ON\" or \"OFF\".
     """
     CommandFactory.__init__(self)
     # 1) length of APDU
     self.command.append(10 + 4)
     
     # 2-5) Control Fields
     # leave them all zero for the moment
     # we need to care about them later, when trying to check whether 
     # telegrams arrived and were processed or not
     self.command.append(self.ZERO_BYTE)
     self.command.append(self.ZERO_BYTE)
     self.command.append(self.ZERO_BYTE)
     self.command.append(self.ZERO_BYTE)
     
     # 6) Type Identification
     self.command.append(self.TYPE_C_DC_NA_1)
     
     # 7) SQ / Number of Objects  
     self.command.append(1)
     
     # 8) T / P/N / Cause of Transmission
     self.command.append(self.COT_ACTIVATION)
     # COT is always "activation", even if switching off!!!
         
     # 9) Originator Address
     # this is always zero in our case        
     self.command.append(self.ZERO_BYTE)
     
     # 10-11) ASDU address
     asdu_bytes = int_to_hex_bytes(ASDU)
     # - low octet
     self.command.append(asdu_bytes[1])
     # - high octet
     self.command.append(asdu_bytes[0])
     
     # 12-n) IOAs + respective Object informations
     ioa_bytes = int_to_hex_bytes(IOA)
     # IOA - low octet
     self.command.append(ioa_bytes[1])
     # IOA - high octet
     self.command.append(ioa_bytes[0])
     # IOA - special - always 0 in our case
     self.command.append(self.ZERO_BYTE)
     # Object Information - always one byte in our case
     if CONTROL_ACTION == "ON":
         self.command.append(self.EXECUTE_UNSPECIFIED_ON)
     else:
         self.command.append(self.EXECUTE_UNSPECIFIED_OFF)
示例#5
0
 def __init__(self, ASDU):
     """
     Builds the general interrogation command as a list of bytes.
     """
     CommandFactory.__init__(self)
     # 1) length of APDU
     self.command.append(14)
     
     # 2-5) Control Fields
     # leave them all zero for the moment
     # we need to care about them later, when trying to check whether 
     # telegrams arrived and were processed or not
     self.command.append(self.ZERO_BYTE)
     self.command.append(self.ZERO_BYTE)
     self.command.append(self.ZERO_BYTE)
     self.command.append(self.ZERO_BYTE)
     
     # 6) Type Identification
     self.command.append(self.TYPE_C_IC_NA_1)
     
     # 7) SQ / Number of Objects  
     self.command.append(1)
     
     # 8) T / P/N / Cause of Transmission
     self.command.append(self.COT_ACTIVATION)
     # COT is always "activation", even if switching off!!!
         
     # 9) Originator Address
     # this is always zero in our case        
     self.command.append(self.ZERO_BYTE)
     
     # 10-11) ASDU address
     asdu_bytes = int_to_hex_bytes(ASDU)
     # - low octet
     self.command.append(asdu_bytes[1])
     # - high octet
     self.command.append(asdu_bytes[0])
     
     # 12-n) IOA is always zero for general interrogation command
     # IOA - low octet
     self.command.append(self.ZERO_BYTE)
     # IOA - high octet
     self.command.append(self.ZERO_BYTE)
     # IOA - special - always 0 in our case
     self.command.append(self.ZERO_BYTE)
     # Object Information - always one byte in our case
     self.command.append(self.GENERAL_INTERROGATION)
    def __init__(self, DT_ACTION):
        """
        Builds the telegram as a list of bytes. DT_ACTION is used to specify whether
        data transfer should be started (\"START\") or terminated (\"STOP\").
        """
        CommandFactory.__init__(self)
        # 1) Apdu length
        self.command.append(self.SHORT_APDU_LENGTH)

        # 2-4) Control Fields
        if DT_ACTION == "START":
            self.command.append(self.STARTDT_BYTE)
        elif DT_ACTION == "STOP":
            self.command.append(self.STOPDT_BYTE)

        self.command.append(self.ZERO_BYTE)
        self.command.append(self.ZERO_BYTE)
        self.command.append(self.ZERO_BYTE)
示例#7
0
    def __init__(self, DT_ACTION):
        """
        Builds the telegram as a list of bytes. DT_ACTION is used to specify whether
        data transfer should be started (\"START\") or terminated (\"STOP\").
        """
        CommandFactory.__init__(self)
        # 1) Apdu length
        self.command.append(self.SHORT_APDU_LENGTH)

        # 2-4) Control Fields
        if DT_ACTION == "START":
            self.command.append(self.STARTDT_BYTE)
        elif DT_ACTION == "STOP":
            self.command.append(self.STOPDT_BYTE)

        self.command.append(self.ZERO_BYTE)
        self.command.append(self.ZERO_BYTE)
        self.command.append(self.ZERO_BYTE)