示例#1
0
    def testAreYouThere(self):
        self.server.simulate_connect()

        self.performSelect()

        clientCommandThread = threading.Thread(
            target=self.client.are_you_there,
            name="TestSecsHandlerPassive_testAreYouThere")
        clientCommandThread.daemon = True  # make thread killable on program termination
        clientCommandThread.start()

        packet = self.server.expect_packet(function=1)

        self.assertIsNot(packet, None)
        self.assertEqual(packet.header.sType, 0x00)
        self.assertEqual(packet.header.sessionID, 0x0)
        self.assertEqual(packet.header.stream, 1)
        self.assertEqual(packet.header.function, 1)

        packet = self.server.generate_stream_function_packet(
            packet.header.system, secsgem.SecsS01F02([]))
        self.server.simulate_packet(packet)

        clientCommandThread.join(1)
        self.assertFalse(clientCommandThread.isAlive())
示例#2
0
    def testStreamFunctionSending(self):
        self.server.simulate_connect()

        self.performSelect()

        #send s01e01
        clientCommandThread = threading.Thread(target=self.client.send_and_waitfor_response, args=(secsgem.SecsS01F01(),), \
            name="TestSecsHandlerPassive_testStreamFunctionSending")
        clientCommandThread.daemon = True  # make thread killable on program termination
        clientCommandThread.start()

        packet = self.server.expect_packet(function=1)

        self.assertIsNot(packet, None)
        self.assertEqual(packet.header.sType, 0x00)
        self.assertEqual(packet.header.sessionID, 0)
        self.assertEqual(packet.header.stream, 1)
        self.assertEqual(packet.header.function, 1)

        self.server.simulate_packet(
            self.server.generate_stream_function_packet(
                packet.header.system, secsgem.SecsS01F02()))

        clientCommandThread.join(1)
        self.assertFalse(clientCommandThread.isAlive())
示例#3
0
    def testExceptionFunctionCallback(self):
        self.server.simulate_connect()

        f = Mock(side_effect=Exception("testException"))
        self.client.register_stream_function(1, 2, f)

        self.performSelect()

        system_id = self.server.get_next_system_counter()
        packet = self.server.generate_stream_function_packet(
            system_id, secsgem.SecsS01F02([]))
        self.server.simulate_packet(packet)
示例#4
0
    def testUnhandeledFunctionCallback(self):
        self.server.simulate_connect()

        f = Mock(return_value=False)
        self.client.register_stream_function(1, 2, f)

        self.performSelect()

        system_id = self.server.get_next_system_counter()
        packet = self.server.generate_stream_function_packet(
            system_id, secsgem.SecsS01F02([]))
        self.server.simulate_packet(packet)
示例#5
0
    def testSecsDecode(self):
        server = HsmsTestServer()
        client = secsgem.SecsHandler("127.0.0.1", 5000, False, 0, "test",
                                     server)

        packet = server.generate_stream_function_packet(
            0, secsgem.SecsS01F02(["MDLN", "SOFTREV"]))

        function = client.secs_decode(packet)

        self.assertEqual(function.stream, 1)
        self.assertEqual(function.function, 2)
        self.assertEqual(function[0], "MDLN")
        self.assertEqual(function[1], "SOFTREV")
示例#6
0
# S1F17: Online Request
# S2F41: Remote Command
# S2F45: Limit
# S2F49: Enhanced Remote Command
# S7F1: Process Program Inquiy
# S7F3: Process Program Send
# S2F17: Timer Request
# S2F31: Timer Set

# In[]

if __name__ == '__main__':

    # Request equipment status VID
    print(secsgem.SecsS01F01())
    print(secsgem.SecsS01F02())

    # Request state variable SVID list
    print(secsgem.SecsS01F11())
    print(secsgem.SecsS01F12())

    # Request equipment constant ECID
    print(secsgem.SecsS02F13())
    print(secsgem.SecsS02F14())

    # Change equipment constant ECID
    print(secsgem.SecsS02F15())
    print(secsgem.SecsS02F16())

    # Set trace condition
    #    print(secsgem.SecsS02F23())
示例#7
0
 def handleS01F01(self, handler, packet):
     handler.send_response(secsgem.SecsS01F02(), packet.header.system)