示例#1
0
    def test_write_relation_for_existing(self):
        """
        Objective: Test answer for a correct command to a device that does exist and has a related sensor
        (Actuator 22_20 (Type 45: Single Command) will be tested,
        the corresponding(!) sensor 13_20 (Type 1: Single Point Information) changes the value
        and the termination confirmation is returned)
        """
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.settimeout(1)
        s.connect(("127.0.0.1", 2404))

        s.send(frames.STARTDT_act.build())
        s.recv(6)

        self.databus.set_value("22_20", 0)  # Must be in template and relation to 13_20
        self.databus.set_value("13_20", 0)  # Must be in template
        # print str(hex(IEC104.addr_in_hex('13_20')))
        single_command = (
            frames.i_frame()
            / frames.asdu_head(COT=6)
            / frames.asdu_infobj_45(IOA=0x141600, SCS=1)
        )
        s.send(single_command.build())

        data = s.recv(16)
        act_conf = (
            frames.i_frame(RecvSeq=0x0002)
            / frames.asdu_head(COT=7)
            / frames.asdu_infobj_45(IOA=0x141600, SCS=1)
        )
        self.assertSequenceEqual(data, act_conf.build())

        data = s.recv(16)
        info = (
            frames.i_frame(SendSeq=0x0002, RecvSeq=0x0002)
            / frames.asdu_head(COT=11)
            / frames.asdu_infobj_1(IOA=0x140D00)
        )
        info.SIQ = frames.SIQ(SPI=1)
        self.assertSequenceEqual(data, info.build())

        data = s.recv(16)
        act_term = (
            frames.i_frame(SendSeq=0x0004, RecvSeq=0x0002)
            / frames.asdu_head(COT=10)
            / frames.asdu_infobj_45(IOA=0x141600, SCS=1)
        )
        self.assertSequenceEqual(data, act_term.build())
示例#2
0
    def test_write_relation_for_existing(self):
        """
        Objective: Test answer for a correct command to a device that does exist and has a related sensor
        (Actuator 22_20 (Type 45: Single Command) will be tested,
        the corresponding(!) sensor 13_20 (Type 1: Single Point Information) changes the value
        and the termination confirmation is returned)
        """
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.settimeout(1)
        s.connect(('127.0.0.1', 2404))

        s.send(frames.STARTDT_act.build())
        s.recv(6)

        self.databus.set_value('22_20', 0)  # Must be in template and relation to 13_20
        self.databus.set_value('13_20', 0)  # Must be in template
        # print str(hex(IEC104.addr_in_hex('13_20')))
        single_command = frames.i_frame() / frames.asdu_head(COT=6) / frames.asdu_infobj_45(IOA=0x141600, SCS=1)
        s.send(single_command.build())

        data = s.recv(16)
        act_conf = frames.i_frame(RecvSeq=0x0002) / frames.asdu_head(COT=7) / frames.asdu_infobj_45(IOA=0x141600, SCS=1)
        self.assertSequenceEqual(data, act_conf.build())

        data = s.recv(16)
        info = frames.i_frame(SendSeq=0x0002, RecvSeq=0x0002) / frames.asdu_head(COT=11) / frames.asdu_infobj_1(
            IOA=0x140d00)
        info.SIQ = frames.SIQ(SPI=1)
        self.assertSequenceEqual(data, info.build())

        data = s.recv(16)
        act_term = frames.i_frame(SendSeq=0x0004, RecvSeq=0x0002) / frames.asdu_head(COT=10) / frames.asdu_infobj_45(
            IOA=0x141600, SCS=1)
        self.assertSequenceEqual(data, act_term.build())