示例#1
0
    def __init__(self, configs):
        mgr = ugm_config_manager.UgmConfigManager(
            configs.get_param('ugm_config'))
        start_id = int(configs.get_param('blink_ugm_id_start'))
        count = int(configs.get_param('blink_ugm_id_count'))
        dec_count = int(configs.get_param('blink_id_count'))
        active_field_ids = [
            int(field)
            for field in configs.get_param('active_field_ids').split(';')
        ]

        assert (start_id >= 0)
        assert (count >= 0)
        assert (count == dec_count)

        self.blink_ugm = []
        self.unblink_ugm = []
        for dec in active_field_ids:  #range(count):
            cfg = mgr.get_config_for(start_id + dec)
            new_blink_cfg = {
                'id':
                cfg['id'],
                configs.get_param('blink_ugm_key'):
                configs.get_param('blink_ugm_value')
            }
            new_unblink_cfg = {
                'id':
                cfg['id'],
                configs.get_param('blink_ugm_key'):
                cfg[configs.get_param('blink_ugm_key')]
            }
            self.blink_ugm.append([new_blink_cfg])
            self.unblink_ugm.append([new_unblink_cfg])
示例#2
0
def run(maze_parent_id=102,
        output_path='configs/brain2013_config_8_fields_tablet',
        template='brain2013_config_8_fields_tablet_no_maze'):
    mgr = m.UgmConfigManager(template)
    parent = mgr.get_config_for(maze_parent_id)
    parent['stimuluses'].append(MAZE)
    mgr.set_config(parent)
    mgr.update_to_file(output_path)
示例#3
0
 def __init__(self, addresses, type=peers.LOGIC_P300_CALIBRATION):
     super(LogicFinish, self).__init__(addresses=addresses, type=type)
     self.ugm = ugm_config_manager.UgmConfigManager(
         'config_8_no_stimulus_fields_tablet').config_to_message()
     self.text_id = 54321
     self.text = u'Dziękujemy za udział w eksperymencie!'
     time.sleep(3)
     self.ready()
    def __init__(self, addresses):
        super(LogicP300Calibration,
              self).__init__(addresses=addresses,
                             type=peers.LOGIC_P300_CALIBRATION)
        self.blinking_ugm = ugm_config_manager.UgmConfigManager(
            self.config.get_param("ugm_config")).config_to_message()
        self.status_ugm = ugm_config_manager.UgmConfigManager(
            self.config.get_param("status_config")).config_to_message()
        self.hi_text = self.config.get_param("hi_text")
        self.hi_text_2 = self.config.get_param("hi_text_2")
        self.hi_text_3 = self.config.get_param("hi_text_3")
        self.bye_text = self.config.get_param("bye_text")
        self.break_text = self.config.get_param("break_text")
        self.break_duration = float(self.config.get_param("break_duration"))
        self.trials_count = int(self.config.get_param("trials_count"))
        self.current_target = int(self.config.get_param("target"))
        self.blink_duration = float(self.config.get_param("blink_duration"))

        self._trials_counter = self.trials_count
        self.ready()
        self.begin()
示例#5
0
    def __init__(self, ugm_config, speller_area_count, start_area_id, fix_id):
        self.speller_area_count = int(speller_area_count)
        self.start_area_id = int(start_area_id)
        self.fix_id = int(fix_id)
        assert (self.speller_area_count > 0)
        mgr = ugm_config_manager.UgmConfigManager(ugm_config)
        self.area_configs = []
        count = self.start_area_id
        for i in range(self.speller_area_count):
            print("GOOOO: " + str(count + i))
            self.area_configs.append(AreaConfig(mgr.get_config_for(count + i)))

        self.fix_config = FixConfig(mgr.get_config_for(self.fix_id))
    def __init__(self, addresses):
        super(LogicRobotFeedback, self).__init__(addresses=addresses,
                                          type=peers.LOGIC_SSVEP_CALIBRATION)
        self.ugm = ugm_config_manager.UgmConfigManager(self.config.get_param("ugm_config")).config_to_message()

        self.robot_image_id = int(self.config.get_param("robot_image_id"))

        self._robot = rovio.Rovio('', self.config.get_param('robot_ip'))

        self.tmp1_path = os.path.join(DEFAULT_SANDBOX_DIR, self.config.get_param('tmp_file1'))
        self.tmp2_path = os.path.join(DEFAULT_SANDBOX_DIR, self.config.get_param('tmp_file2'))
        self.paths = [self.tmp1_path, self.tmp2_path]
        self.ready()
示例#7
0
    def __init__(self, addresses):
        super(LogicGiveID, self).__init__(addresses=addresses,
                                          type=peers.LOGIC_SSVEP_CALIBRATION)

        self.ugm = ugm_config_manager.UgmConfigManager(
            self.config.get_param("ugm_config")).config_to_message()
        self.file_id_path = self.config.get_param("file_id_path")
        self.file_id_name = self.config.get_param("file_id_name")
        self.text_id = int(self.config.get_param("ugm_text_id"))
        self.s_id = self.config.get_param("scenarios_id")
        self._init_id()
        self._init_id_file()
        time.sleep(3)
        self.ready()
示例#8
0
    def __init__(self, addresses):
        super(LogicSSVEPCalibration, self).__init__(addresses=addresses,
                                          type=peers.LOGIC_SSVEP_CALIBRATION)
        self.ugm = ugm_config_manager.UgmConfigManager(self.config.get_param("ugm_config")).config_to_message()
        self.raw_ugm = ugm_config_manager.UgmConfigManager(self.config.get_param("ugm_config"))
        self.text_ids = [int(i) for i in self.config.get_param("ugm_text_ids").split(';')]
        self.text_id = int(self.config.get_param('ugm_text_id'))
        self.hi_text = self.config.get_param("hi_text")
        self.bye_text = self.config.get_param("bye_text")
        self.trial_text = self.config.get_param("trial_text")
        self.ready_text = self.config.get_param("ready_text")
        self.break_texts = self.config.get_param("break_texts").split(';')
        self.break_times = [float(i) for i in self.config.get_param("break_times").split(';')]
        assert(len(self.break_texts)==len(self.break_times))
        self.target_time = float(self.config.get_param("target_time"))
        self.target_fancy = int(self.config.get_param("target_fancy"))
        self.feed_time = float(self.config.get_param("feed_time"))
        self.feed_text = self.config.get_param("feed_text")
        self._init_sequence()

        self._curr_fancy_x = 0.4
        self._curr_fancy_y = 0.4

        self.ready()
示例#9
0
 def __init__(self, ugm_config, ids, color='g'):
     assert (color in ['r', 'g', 'b'])
     self.color = color
     self.mutable_configs = []
     self.initial_configs = []
     mgr = ugm_config_manager.UgmConfigManager(ugm_config)
     for id in ids:
         self.initial_configs.append({
             'id':
             id,
             'color':
             mgr.get_config_for(id)['color']
         })
         self.mutable_configs.append({
             'id':
             id,
             'color':
             mgr.get_config_for(id)['color']
         })
    def __init__(self, addresses):
        #Create a helper object to get configuration from the system
        super(LogicRobotFeedback2, self).__init__(addresses=addresses,
                                                  type=peers.ROBOT_FEEDBACK)

        self.ugm = ugm_config_manager.UgmConfigManager(
            self.config.get_param("ugm_config")).config_to_message()
        self.robot_image_id = int(self.config.get_param("robot_image_id"))
        self._robot = rovio.Rovio('', self.config.get_param('robot_ip'))
        self.tmp1_path = os.path.join(DEFAULT_SANDBOX_DIR,
                                      self.config.get_param('tmp_file1'))
        self.tmp2_path = os.path.join(DEFAULT_SANDBOX_DIR,
                                      self.config.get_param('tmp_file1'))
        self.paths = [self.tmp1_path, self.tmp2_path]
        self.index = 0
        self.imgpath = self.paths[self.index]
        self._last_time = time.time()
        self.is_on = int(self.config.get_param("is_on"))
        if DEBUG:
            self.debug = streaming_debug.Debug(128, self.logger, 4)
        self.ready()
 def __init__(self, addresses):
     super(UgmBlinkingEnginePeer, self).__init__(addresses=addresses, type=peers.UGM_ENGINE_PEER)
     context = ctx.get_new_context()
     context['logger'] = self.logger
     connection = ugm_blinking_connection.UgmBlinkingConnection(settings.MULTIPLEXER_ADDRESSES,
                                                                context)
     ENG = ugm_blinking_engine.UgmBlinkingEngine(
         ugm_config_manager.UgmConfigManager(self.config.get_param('ugm_config')),
         connection,
         context)
     ENG.set_configs(DummyClient(self.config.param_values()))
     srv = ugm_internal_server.UdpServer(
         ENG, 
         self.config.get_param('internal_ip'),
         int(self.config.get_param('use_tagger')),
         context
         )
     self.set_param('internal_port', str(srv.socket.getsockname()[1]))
     thread.start_new_thread(
             srv.run, 
             ()
             )
     self.ready()
     ENG.run()
示例#12
0
    def __init__(self, configs):
        mgr = ugm_config_manager.UgmConfigManager(
            configs.get_param('ugm_config'))
        start_id = int(configs.get_param("blink_ugm_id_start"))
        count = int(configs.get_param('blink_ugm_id_count'))
        dec_count = int(configs.get_param('blink_id_count'))
        rows = int(configs.get_param('blink_ugm_row_count'))
        cols = int(configs.get_param('blink_ugm_col_count'))
        assert (start_id >= 0)
        assert (count >= 0)
        assert (rows >= 0)
        assert (cols >= 0)
        assert (count == rows * cols)
        assert (dec_count >= 0)
        assert (dec_count == rows + cols)

        self.blink_ugm = []
        self.unblink_ugm = []

        for dec in range(dec_count):
            if dec < cols:
                blink_cfgs = []
                unblink_cfgs = []
                for row in range(rows):
                    cfg = mgr.get_config_for(start_id + row * cols + dec)
                    new_blink_cfg = {
                        'id':
                        cfg['id'],
                        configs.get_param('blink_ugm_key'):
                        configs.get_param('blink_ugm_value')
                    }
                    blink_cfgs.append(new_blink_cfg)
                    new_unblink_cfg = {
                        'id':
                        cfg['id'],
                        configs.get_param('blink_ugm_key'):
                        cfg[configs.get_param('blink_ugm_key')]
                    }
                    unblink_cfgs.append(new_unblink_cfg)
                self.blink_ugm.append(blink_cfgs)
                self.unblink_ugm.append(unblink_cfgs)
            else:
                dc = dec - cols
                blink_cfgs = []
                unblink_cfgs = []
                for col in range(cols):
                    cfg = mgr.get_config_for(start_id + cols * dc + col)
                    new_blink_cfg = {
                        'id':
                        cfg['id'],
                        configs.get_param('blink_ugm_key'):
                        configs.get_param('blink_ugm_value')
                    }
                    blink_cfgs.append(new_blink_cfg)
                    new_unblink_cfg = {
                        'id':
                        cfg['id'],
                        configs.get_param('blink_ugm_key'):
                        cfg[configs.get_param('blink_ugm_key')]
                    }
                    blink_cfgs.append(new_blink_cfg)
                    unblink_cfgs.append(new_unblink_cfg)

                self.blink_ugm.append(blink_cfgs)
                self.unblink_ugm.append(unblink_cfgs)
示例#13
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Author:
#     Mateusz Kruszyński <*****@*****.**>

from obci.configs import variables_pb2
from multiplexer.multiplexer_constants import peers, types
from obci.gui.ugm import ugm_config_manager

TEXT_SCREEN_MGR = ugm_config_manager.UgmConfigManager('text_neg')
TEXT_ID = 101
STATUS_ID = 54321
LOGO_ID = 55555


def send_text(conn, text):
    cfg = TEXT_SCREEN_MGR.get_config_for(TEXT_ID)
    cfg['message'] = text
    TEXT_SCREEN_MGR.set_config(cfg)
    send_config(conn, TEXT_SCREEN_MGR.config_to_message())


def send_status(conn, text):
    send_config_for(conn, STATUS_ID, 'message', text)


def send_logo(conn, img):
    send_config_for(conn, LOGO_ID, 'image_path', img)


def send_config_for(conn, id, key, value):