Пример #1
0
def main(reactor, commID, masterIP, masterPort, masterID):
    f = open('/home/rce-user/container.log', 'w')
    log.startLogging(f)
    #log.startLogging(sys.stdout)
    
    manager = ContainerManager(reactor)
    commManager = CommManager(reactor, commID)
    cmdSerializer = CommandSerializer()
    cmdSerializer.registerCommand([ContainerCommand])
    commManager.registerContentSerializers([CommInfoSerializer(),
                                            cmdSerializer,
                                            TagSerializer()])
    
    distributor = ControlDistributor()
    distributor.addHandler(types.CONTAINER, manager.createContainer)
    distributor.addHandler(types.RM_CONTAINER, manager.destroyContainer)
    commManager.registerMessageProcessors([CommInfoProcessor(manager),
                                           CommandProcessor(distributor),
                                           TagProcessor(distributor)])
    
    factory = RCEClientFactory(commManager, masterID)
    factory.addApprovedMessageTypes([msgTypes.COMM_INFO, msgTypes.COMMAND,
                                     msgTypes.TAG])
    reactor.connectTCP(masterIP, masterPort, factory)
    
    reactor.addSystemEventTrigger('before', 'shutdown', manager.shutdown)
    reactor.addSystemEventTrigger('before', 'shutdown', commManager.shutdown)
    
    reactor.run()
    
    f.close()
Пример #2
0
def main(reactor, commID, port):
    f = open('/home/ros/launcher.log', 'w')
    log.startLogging(f)
    
    rospy.init_node('RCE_Launcher')
    
    manager = NodeManager(reactor)
    commManager = CommManager(reactor, commID)
    cmdSerializer = CommandSerializer()
    cmdSerializer.registerCommand([NodeCommand])
    commManager.registerContentSerializers([cmdSerializer,
                                            TagSerializer()])
    
    distributor = ControlDistributor()
    distributor.addHandler(types.NODE, manager.addNode)
    distributor.addHandler(types.RM_NODE, manager.removeNode)
    commManager.registerMessageProcessors([CommandProcessor(distributor),
                                           TagProcessor(distributor)])
    
    factory = RCEServerFactory(commManager)
    factory.addApprovedMessageTypes([msgTypes.COMMAND, msgTypes.TAG])
    reactor.listenTCP(port, factory)
    
    def terminate():
        reactor.callFromThread(manager.shutdown)
        reactor.callFromThread(commManager.shutdown)
        reactor.callFromThread(reactor.stop)

    rospy.on_shutdown(terminate)
    
    reactor.run(installSignalHandlers=False)
    
    f.close()
Пример #3
0
def main(reactor, commID, relayIP, relayPort, relayID, nodeIP, nodePort,
         nodeID):
    f = open('/opt/rce/data/env.log', 'w')
    log.startLogging(f)
    
    rospy.init_node('RCE_Master')
    
    manager = Manager(reactor)
    commManager = CommManager(reactor, commID)
    manager.registerCommManager(commManager)
    messenger = Messenger(manager, commManager)
    manager.registerMessenger(messenger)
    
    cmdSerializer = CommandSerializer()
    cmdSerializer.registerCommand([NodeForwarderCommand, ConnectionCommand])
    cmdSerializer.registerCommand(map(lambda x: x[1], _PARAMETER))
    cmdSerializer.registerCommand(map(lambda x: x[1], _INTERFACE))
    
    commManager.registerContentSerializers([cmdSerializer,
                                            TagSerializer(),
                                            ROSMsgSerializer()])
    
    distributor = ControlDistributor()
    distributor.addHandler(types.NODE, manager.addNode)
    distributor.addHandler(types.RM_NODE, manager.removeNode)
    distributor.addHandler(types.RM_PARAMETER, manager.removeParameter)
    distributor.addHandler(types.RM_INTERFACE, manager.removeInterface)
    distributor.addHandler(types.CONNECTION, manager.modifyConnection)
    
    for conv in _PARAMETER:
        distributor.addHandler(conv[0], manager.addParameter)
    
    for conv in _INTERFACE:
        distributor.addHandler(conv[0], manager.addInterface)
    
    commManager.registerMessageProcessors([CommandProcessor(distributor),
                                           TagProcessor(distributor),
                                           messenger])
    
    factory = RCEClientFactory(commManager, relayID)
    factory.addApprovedMessageTypes([msgTypes.COMMAND, msgTypes.TAG,
                                     msgTypes.ROS_MSG])
    reactor.connectTCP(relayIP, relayPort, factory)
    
    factory = RCEClientFactory(commManager, nodeID)
    reactor.connectTCP(nodeIP, nodePort, factory)
    
    def terminate():
        reactor.callFromThread(manager.shutdown)
        reactor.callFromThread(commManager.shutdown)
        reactor.callFromThread(reactor.stop)

    rospy.on_shutdown(terminate)
    
    reactor.run(installSignalHandlers=False)
    
    f.close()
Пример #4
0
def main(reactor, commID, uidPort, containerPort, relayPort):
    f = open('/home/rce-user/master.log', 'w')
    log.startLogging(f)
    #log.startLogging(sys.stdout)
    
    manager = MasterManager(reactor)
    commManager = CommManager(reactor, commID)
    loadBalancer = LoadBalancer(commManager)
    uidServer = UIDServer(loadBalancer, 30)
    manager.registerLoadBalancer(loadBalancer)
    
    manager.registerControlFactory(_createControlFactory(commManager))
    
    cmdSerializer = CommandSerializer()
    cmdSerializer.registerCommand(
        [ContainerCommand, RobotCommand, NodeCommand,
         ParameterCommand, ArrayCommand, FileCommand, ConnectionCommand,
         ServiceInterfaceCommand, ServiceProviderInterfaceCommand,
         PublisherInterfaceCommand, SubscriberInterfaceCommand,
         ServiceConverterCommand, ServiceProviderConverterCommand,
         PublisherConverterCommand, SubscriberConverterCommand,
         ServiceForwarderCommand, ServiceProviderForwarderCommand,
         PublisherForwarderCommand, SubscriberForwarderCommand])
    commManager.registerContentSerializers([ConnectDirectiveSerializer(),
                                            CommInfoSerializer(),
                                            cmdSerializer,
                                            TagSerializer(),
                                            RequestSerializer()])
    
    commManager.registerMessageProcessors([RequestProcessor(manager)])
    
    reactor.listenTCP(uidPort, uidServer)
    
    cb = MasterCallbackFromContainer(uidServer)
    factory = RCEServerFactory(commManager, [cb], [cb])
    reactor.listenTCP(containerPort, factory)
    
    cb = MasterCallbackFromRelay(uidServer)
    factory = RCEServerFactory(commManager, [cb], [cb])
    factory.addApprovedMessageTypes([types.REQUEST])
    reactor.listenTCP(relayPort, factory)
    
#    factory = CloudEngineWebSocketFactory(MasterWebSocketProtocol, manager,
#                                          'ws://localhost:9000')
#    listenWS(factory)
    
    handler = AuthenticationHandler(manager)
    reactor.listenTCP(9000, Site(MasterRobotAuthentication(handler)))
    
    reactor.addSystemEventTrigger('before', 'shutdown', uidServer.shutdown)
    reactor.addSystemEventTrigger('before', 'shutdown', manager.shutdown)
    reactor.addSystemEventTrigger('before', 'shutdown', commManager.shutdown)
    
    reactor.run()
    
    f.close()
Пример #5
0
def main(reactor, commID, masterIP, masterPort, masterID, rosPort, relayPort):
    f = open('/home/rce-user/relay.log', 'w')
    log.startLogging(f)
    #log.startLogging(sys.stdout)
    
    manager = Manager(reactor)
    manager.registerMasterIP(masterIP)
    commManager = CommManager(reactor, commID)
    manager.registerCommManager(commManager)
    sender = RemoteRequestSender(commManager)
    manager.registerRequestSender(sender)
    messenger = Messenger(manager, commManager)
    manager.registerMessenger(messenger)
    
    cmdSerializer = CommandSerializer()
    cmdSerializer.registerCommand([RobotCommand, ConnectionCommand])
    cmdSerializer.registerCommand(map(lambda x: x[1], _CONVERTER))
        
    commManager.registerContentSerializers([ConnectDirectiveSerializer(),
                                            cmdSerializer,
                                            TagSerializer(),
                                            RequestSerializer(),
                                            ROSMsgSerializer()])
    
    distributor = ControlDistributor()
    distributor.addHandler(types.ROBOT, manager.addRobot)
    distributor.addHandler(types.RM_ROBOT, manager.removeRobot)
    distributor.addHandler(types.RM_INTERFACE, manager.removeInterface)
    distributor.addHandler(types.CONNECTION, manager.modifyConnection)
    
    for conv in _CONVERTER:
        distributor.addHandler(conv[0], manager.addInterface)
    
    commManager.registerMessageProcessors([ConnectDirectiveProcessor(manager),
                                           CommandProcessor(distributor),
                                           TagProcessor(distributor),
                                           messenger])
    
    factory = MasterFactory(commManager, masterID)
    factory.addApprovedMessageTypes([msgTypes.COMMAND, msgTypes.TAG,
                                     msgTypes.CONNECT])
    reactor.connectTCP(masterIP, masterPort, factory)
    
    cb = RelayCallbackFromRelay(manager, commManager)
    factory = RCEServerFactory(commManager, [cb], [cb])
    factory.addApprovedMessageTypes([msgTypes.ROS_MSG])
    reactor.listenTCP(relayPort, factory)
    
    cb = RelayCallbackFromEndpoint(manager, commManager)
    factory = RCEServerFactory(commManager, [cb], [cb])
    factory.addApprovedMessageTypes([msgTypes.ROS_MSG])
    reactor.listenTCP(rosPort, factory)
    
    factory = CloudEngineWebSocketFactory(RobotWebSocketProtocol, manager,
                                          'ws://localhost:9010')
    listenWS(factory)
    
    reactor.addSystemEventTrigger('before', 'shutdown', manager.shutdown)
    reactor.addSystemEventTrigger('before', 'shutdown', commManager.shutdown)
    
    reactor.run()
    
    f.close()