def run(self):
        logger.info("Transmitter Application Controller starting")

        # Kill broadcast subscriber
        kbsubscriber = NetworkingManager.KillBroadcastSubscriber()
        usb_monitor_pair = NetworkingManager.UsbMonitorPairClient()
        self.router = NetworkingManager.TACParent()

        self.poller = NetworkingManager.Poller()
        self.poller.register(kbsubscriber, NetworkingManager.POLLIN)
        self.poller.register(usb_monitor_pair, NetworkingManager.POLLIN)
        self.poller.register(self.router, NetworkingManager.POLLIN)

        while True:
            self.request_buffer.dispatch_all()
            socks = dict(self.poller.poll(50))

            if self.router.contained_in(socks):
                child_id, string = self.router.recv_string()
                # do some stuff with reply
                app = self.transmitter_applications[child_id]
                if app.last_request == Command.SHUTDOWN:
                    reply = CommandMessage.deserialize(string)
                    self.request_buffer.process_reply(reply)

                    if app.process.is_alive():
                        app.process.terminate()
                    del self.transmitter_applications[child_id]

            if usb_monitor_pair.contained_in(socks):
                # a message from the usb port controller indicates
                # a usb device has been added or removed from the system
                request = DocumentMessage.deserialize(
                    usb_monitor_pair.recv_string()
                )
                logger.info("Request received: " + request.serialize())
                usb_operation = UsbOperation.from_json(request.contents)
                self.process_usb_operation(usb_operation)
                # send a void reply to confirm receipt
                reply = CommandMessage.VoidReply(request)
                usb_monitor_pair.send_string(reply.serialize())

            if kbsubscriber.contained_in(socks):
                message = CommandMessage.deserialize(
                    kbsubscriber.recv_string()
                )
                reply_structure = None
                try:
                    command = Command(message.command)
                    command_processor = CommandProcessor(self)
                    reply_structure = command_processor.process(command)
                except ExitProcess:
                    self.request_buffer.clear()
                    self.stop_all_transmitter_applications()
                    self.request_buffer.dispatch_all()
                    logger.info("Transmitter Application Controller stopping")
                    break
                finally:
                    if reply_structure:
                        pass
    def test_creation_from_json(self):
        """Usb Operation properly created from JSON string"""
        usb_operation = UsbOperation(self.test_operation, self.test_device)

        u_json = self.test_device.to_json()
        json_string = "{\"usb_device\": "+u_json+", "+"\"operation\": {\"value\": \"add\"}}"

        op = UsbOperation.from_json(json_string)
        self.assertEqual(op, usb_operation)