def processGuiSignal(self, flag, name): '''Receive flags from the Front End as user input TODO: Not all needed ''' name = name.split('_')[0] logger.info('Received signal from GUI: ' + flag[0]) if flag[0]: if flag[0] == Spike.run(): logger.info('Begin run!') #self.flags['run'] = True self.run() elif flag[0] == Spike.setup(): logger.info('Running setup') self.setup() elif flag[0] == Spike.ready(): logger.info('GUI ready') self.actorStates[name] = flag[0] elif flag[0] == Spike.quit(): logger.warning('Quitting the program!') self.flags['quit'] = True self.quit() elif flag[0] == Spike.load(): logger.info('Loading Tweak config from file ' + flag[1]) self.loadTweak(flag[1]) elif flag[0] == Spike.pause(): logger.info('Pausing processes') # TODO. Alsoresume, reset else: logger.error( 'Signal received from Nexus but cannot identify {}'.format( flag))
def quit(self): # with open('timing/noticiations.txt', 'w') as output: # output.write(str(self.listing)) logger.warning('Killing child processes') for q in self.sig_queues.values(): try: q.put_nowait(Spike.quit()) except Full as f: logger.warning('Signal queue ' + q.name + ' full, cannot tell it to quit: {}'.format(f)) self.processes.append(self.p_GUI) #self.processes.append(self.p_watch) for p in self.processes: # if p.is_alive(): # p.terminate() p.join() logger.warning('Done with available frames') print('total time ', time.time() - self.t) self.destroyNexus()
def run(self): while True: if self.flag: try: self.checkStore2() except Exception as e: logger.error('Watcher exception during run: {}'.format(e)) #break try: signal = self.q_sig.get(timeout=0.005) if signal == Spike.run(): self.flag = True logger.warning('Received run signal, begin running') elif signal == Spike.quit(): logger.warning('Received quit signal, aborting') break elif signal == Spike.pause(): logger.warning('Received pause signal, pending...') self.flag = False elif signal == Spike.resume(): #currently treat as same as run logger.warning('Received resume signal, resuming') self.flag = True except Empty as e: pass #no signal from Nexus