Example #1
0
def run_client(application_class):
    """Run autobahn application"""

    session_factory = wamp.ApplicationSessionFactory()
    session_factory.session = application_class
    transport_factory = websocket.WampWebSocketClientFactory(session_factory,
                                                             debug=False,
                                                             debug_wamp=False)

    loop = asyncio.get_event_loop()
    return loop.run_until_complete(
        loop.create_connection(transport_factory, '0.0.0.0', 8080))
Example #2
0
def magic_box(sproto, extra):
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    component_config = types.ComponentConfig(realm="realm1", extra=extra)
    session_factory = wamp.ApplicationSessionFactory(config=component_config)
    session_factory.session = sproto
    transport_factory = websocket.WampWebSocketClientFactory(session_factory)
    coro = loop.create_connection(transport_factory, '127.0.0.1', 9002)
    loop.run_until_complete(coro)
    loop.run_forever()
    loop.close()
    return
Example #3
0
    def __init__(self):
        #__init__ VARIABLES FROM HARNESS
        print(datetime.datetime.now(),' - DriverClient.__init__:')
        print('\n\targs: ',locals(),'\n')
        self.driver_dict = {}
        self.meta_dict = {
            'drivers' : lambda from_,session_id,name,param: self.drivers(from_,session_id,name,param),
            'add_driver' : lambda from_,session_id,name,param: self.add_driver(from_,session_id,name,param),
            'remove_driver' : lambda from_,session_id,name,param: self.remove_driver(from_,session_id,name,param),
            'callbacks' : lambda from_,session_id,name,param: self.callbacks(from_,session_id,name,param),
            'meta_callbacks' : lambda from_,session_id,name, param: self.meta_callbacks(from_,session_id,name,param),
            'set_meta_callback' : lambda from_,session_id,name,param: self.set_meta_callback(from_,session_id,name,param),
            'add_callback' : lambda from_,session_id,name,param: self.add_callback(from_,session_id,name,param),
            'remove_callback' : lambda from_,session_id,name,param: self.remove_callback(from_,session_id,name,param),
            'flow' : lambda from_,session_id,name,param: self.flow(from_,session_id,name,param),
            'clear_queue' : lambda from_,session_id,name,param: self.clear_queue(from_,session_id,name,param),
            'connect' : lambda from_,session_id,name,param: self.driver_connect(from_,session_id,name,param),
            'disconnect' : lambda from_,session_id,name,param: self.driver_disconnect(from_,session_id,name,param),
            'commands' : lambda from_,session_id,name,param: self.commands(from_,session_id,name,param),
            'configs' : lambda from_,session_id,name,param: self.configs(from_,session_id,name,param),
            'set_config' : lambda from_,session_id,name,param: self.set_config(from_,session_id,name,param),
            'meta_commands' : lambda from_,session_id,name,param: self.meta_commands(from_,session_id,name,param)
        }

        self.in_dispatcher = {
            'command': lambda from_,session_id,data: self.send_command(from_,session_id,data),
            'meta': lambda from_,session_id,data: self.meta_command(from_,session_id,data)
        }

        self.topic = {
            'frontend' : 'com.opentrons.frontend',
            'driver' : 'com.opentrons.driver',
            'labware' : 'com.opentrons.labware',
            'bootstrapper' : 'com.opentrons.bootstrapper'
        }

        self.clients = {
            # uuid : 'com.opentrons.[uuid]'
        }
        self.max_clients = 4

        self.id = str(uuid.uuid4())

        self.session_factory = wamp.ApplicationSessionFactory()
        self.session_factory.session = WampComponent
        self.session_factory._myAppSession = None
        self.session_factory._crossbar_connected = False
        self.transport_factory = None

        self.transport = None
        self.protocol = None

        self.loop = asyncio.get_event_loop()
Example #4
0
        'ingredients']  #extract the ingredient section from prot_dict
    ingr = Ingredients({})

    ingr.configure_ingredients(
        ingr_data)  #configure the ingredienets from prot_dict data

    publisher.set_head(head)
    publisher.set_runner(runner)
    subscriber.set_deck(deck)
    subscriber.set_head(head)
    subscriber.set_runner(runner)


loop = asyncio.get_event_loop()
try:
    session_factory = wamp.ApplicationSessionFactory()
    session_factory.session = WampComponent

    session_factory._myAppSession = None

    # TODO: should not be hardcoded but rather moved to setting file...
    url = "ws://127.0.0.1:31947/ws"

    serializers = []

    serializers.append(JsonSerializer())
    serializers.append(MsgPackSerializer())

    transport_factory = websocket.WampWebSocketClientFactory(
        session_factory, url=url, serializers=serializers)