Exemple #1
0
    def on_message(self, message):
        dc_sw = self.server_app_websockets.get("DATA_COLLECTION")
        if dc_sw:
            msg_dict = ujson.loads(message)

            msg_type = msg_dict.get('msg_type', 'UNKNOWN')
            if msg_type is 'UNKNOWN':
                msg_type = msg_dict.get('type', 'UNKNOWN')

            if msg_type == 'EXPERIMENT_SELECTED':
                dc_sw.data_collection_state[
                    'active_experiment'] = msg_dict.get('name')
            elif msg_type == 'OPEN_USER_MANUAL':
                from webserver import ControlFeedbackServer
                ControlFeedbackServer.openUserManual()
                msg_type = 'UNKNOWN'
            if msg_type is not 'UNKNOWN':
                dc_sw.write_message(message)

        else:
            print("")
            print(
                "WARNING: Data Collection Web Socket is not Running. Msg not sent. Is the Data Collection application running?"
            )
            print("")
    def on_message(self, message):
        dc_sw = self.server_app_websockets.get("DATA_COLLECTION")
        if dc_sw:
            msg_dict = ujson.loads(message)

            msg_type = msg_dict.get('msg_type', 'UNKNOWN')
            if msg_type is 'UNKNOWN':
                msg_type = msg_dict.get('type', 'UNKNOWN')

            if msg_type == 'EXPERIMENT_SELECTED':
                dc_sw.data_collection_state['active_experiment'] = msg_dict.get('name')
            elif msg_type == 'OPEN_USER_MANUAL':
                from webserver import ControlFeedbackServer
                ControlFeedbackServer.openUserManual()
                msg_type = 'UNKNOWN'
            if msg_type is not 'UNKNOWN':
                dc_sw.write_message(message)

        else:
            print("")
            print("WARNING: Data Collection Web Socket is not Running. Msg not sent. Is the Data Collection application running?")
            print("")