Exemplo n.º 1
0
def createWebsocketInterface(appcfg):
    address = keyChainValue(appcfg, 'view_server', 'address')
    port = keyChainValue(appcfg, 'view_server', 'port')
    sockopt = ((socket.IPPROTO_TCP, socket.TCP_NODELAY, 1),)
    ws_url = "ws://{0}:{1}/data_websocket".format(address, port)
    ui_server_websocket = create_connection(ws_url, None, sockopt=sockopt)
    ui_server_websocket.settimeout(0)
    # Inform feedback webserver of experiment directory list
    avail_exp_list = DataCollectionRuntime.getActiveExperimentNames(
                                        appcfg.get("experiment_inactive_token"))
    msg_type = 'EXP_FOLDER_LIST'
    ui_server_websocket.send(ujson.encode([{'msg_type': msg_type,
                                            'data': avail_exp_list}, ]))

    msg_type = 'DATA_COLLECT_CONFIG'
    ui_server_websocket.send(ujson.encode([{'msg_type': msg_type,
                                            'data': appcfg}, ]))

    return ui_server_websocket
Exemplo n.º 2
0
            #
            dsfilename = iohub_conf.get('data_store', {}).get('filename')
            if dsfilename is None:
                dsfilename = 'events'
            dsfilepath = pjoin(DataCollectionRuntime.results_root_folder,
                                    DataCollectionRuntime.active_exp_name,
                                    dsfilename)
            iohub_conf.get('data_store', {})['filename'] = dsfilepath
            # save modified iohub_config for loading by upcoming session
            #
            dump(iohub_conf, file(pjoin(configurationDirectory,
                                new_iohubconfig_rpath), 'w'), Dumper = Dumper)
            iohub_conf = None
            # Create the experiment Session Runtime
            #
            runtime = DataCollectionRuntime(configurationDirectory,
                                            "..\\settings\\last_app_config.yaml")

            # Set the app web socket and send a msg indicating data collection
            # is ready
            #
            runtime.ui_server_websocket = proxy(ws)
            cmtype = "success"
            msg = {'msg_type': 'EXP_SESSION_STARTED', 'type': cmtype}
            runtime.sendToWebServer(msg)

            app_conf = None

            # Start the exp runtime
            #
            cmd, _ = runtime.start(app_config_file_name,pjoin(configurationDirectory,
                                                        new_iohubconfig_rpath))