def testTalkingToController(): """ Start RailroadBig and Controller. Start a separate thread to send messages to the railroad. Tell Controller to read layout.xml. Initialize train 1111 at position [5,1] and assume response is virtual slot 5. Tell train to blink lights and change direction five times. Should see messages sent and messages received. """ print("Entering function testTalkingToController") sak = StartAndKill() sak.setPath("../../runSoftware") sak.start("simulator") sak.start("controller") sk = MsgSocket(name="1") sk.connect("localhost", 1235) time.sleep(2) sk.send(DoReadLayoutMsg("../../runSoftware/Layout.xml")) process = TestBlinkLightsViaController(sk) time.sleep(5) process.start() while True: try: sk.receive() except: break sk.close() print("Leaving function testTalkingToController\n")
def testReceive(): """ Start RailroadBig and connect to it at (local host, 1234). Start a separate thread to send messages to the railroad. Register train 1111 and assume response is physical slot 1 Tell train to blink lights and change direction 5 times. Should see messages sent and messages received. """ sak = StartAndKill() print("Entering function testReceive\n") sak.setPath("../../runSoftware") sak.start("simulator") sk = MsgSocket(name="1") sk.connect("localhost", 1234) process = TestBlinkLightsDirectly(sk) process.start() while True: try: sk.receive() except: break sk.close() print("Leaving function testReceive\n")