def __init__(self, config_path=r'./config.js'): self.PHASES = [] self.current_phase = 'start' self.__nreload = False self.__pinterval = 0.1 threading.Thread.__init__(self) self.setDaemon(True) self._phIF = None self.CODER = DefaultCoder() with open(config_path, 'r') as f: self.configs = json.load(f)
def __init__(self): bciCore.__init__(self, config_path=r'./config.js') self.PHASES = [{ 'name': 'start', 'next': 'prompt', 'duration': 1 }, { 'name': 'prompt', 'next': 'que' }, { 'name': 'que', 'next': 'stop', 'duration': 4 }] self.CODER = DefaultCoder()
def __init__(self, config_path=r'./config.js'): with open(config_path, 'r') as f: buf = f.read() self.config = json.loads(buf) self.spconfig = self.config['signal_processing'] # 不需要接受marker则不启动marker子线程 if self.spconfig['sp_host_ip'] is None: self.__marker_thread_on = False else: self.__marker_thread_on = True addr = (self.spconfig['sp_host_ip'], self.spconfig['sp_host_port']) #启用临时进程进行时钟同步 subprocess.Popen( 'python sync_sock.py %s %i' % (self.spconfig['sp_host_ip'], self.spconfig['sp_host_port'])) time.sleep(1) self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # 建立udp socket self.sock.bind(addr) self.SAVEDATA = False if self.spconfig['save data']: self.SAVEDATA = True self.output_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # 建立udp socket self.output_addr = self.spconfig['result receiver address'] ampclass = {} exec('from %s import EEGamp' % (self.spconfig['amplifier'], ), ampclass) # python3 对exec进行了安全性升级,注意参数的使用 EEGamp = ampclass['EEGamp'] self.amp = EEGamp(self.spconfig['samplingrate'], self.spconfig['eeg channels'], 0.1, **self.spconfig['amplifier params']) threading.Thread.__init__(self) self.setDaemon(True) # 子线程用于接受trigger 并且子线程随主线程一起结束 self._lock = thread.allocate_lock() self.__marker = {} self.RESULT = "" # 发送结果的编码器 self.CODER = DefaultCoder()
def __init__(self, config_path=r'./config.js'): with open(config_path, 'r') as f: buf = f.read() self.config = json.loads(buf) self.spconfig = self.config['signal_processing'] # 不需要接受marker则不启动marker子线程 if self.spconfig['sp_host_ip'] is None: self.__marker_thread_on = False else: self.__marker_thread_on = True addr = (self.spconfig['sp_host_ip'], self.spconfig['sp_host_port']) #启用临时进程进行时钟同步 #客户端进程完成同步获得计算同步参数,以本机时钟为准。因此该进程无需关注是否完成同步 subprocess.Popen( 'python sync_sock.py %s %i' % (self.spconfig['sp_host_ip'], self.spconfig['sp_host_port'])) time.sleep(0.1) # sock用于接受marker self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # 建立udp socket self.sock.bind(addr) #用于发送结果 self.output_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # 建立udp socket self.output_addr = self.spconfig['result receiver address'] #放大器模块导入 ampclass = {} exec('from %s import EEGamp' % (self.spconfig['amplifier'], ), ampclass) # python3 对exec进行了安全性升级,注意参数的使用 EEGamp = ampclass['EEGamp'] self.amp = EEGamp(self.spconfig['samplingrate'], self.spconfig['eeg channels'], 0.1, **self.spconfig['amplifier params']) self.__marker = {} self.RESULT = "" self.start_record = False # 用于主线程和marker线程同步,解决start_clk未初始化 # 发送结果的编码器 self.CODER = DefaultCoder() # 数据保存模块初始化 self.stIF = StorageInterface() self.storage_proc = multiprocessing.Process(target=storage_pro, args=(self.stIF.args, self.spconfig)) self.storage_proc.start() self.stIF.wait() self._lock = thread.allocate_lock() self.marker_thread = threading.Thread(target=self.thread_fun, args=(), daemon=True) self.running = True
def __init__(self, configs_path='./config.js'): super(SigProApp, self).__init__(configs_path) self.CODER = DefaultCoder()