def processActorSignal(self, sig, name): if sig is not None: logger.info('Received signal ' + str(sig[0]) + ' from ' + name) if sig[0] == Spike.ready(): self.actorStates[name.split('_')[0]] = sig[0] if all(val == Spike.ready() for val in self.actorStates.values()): self.allowStart = True #TODO: replace with q_sig to FE/Visual logger.info('Allowing start')
def run(self): logger.info('Loading FrontEnd') self.app = QtWidgets.QApplication([]) self.rasp = FrontEnd(self.visual, self.q_comm) self.rasp.show() logger.info('GUI ready') self.q_comm.put([Spike.ready()]) self.visual.q_comm.put([Spike.ready()]) self.app.exec_() logger.info('Done running GUI')
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): if self.allowStart: for q in self.sig_queues.values(): try: q.put_nowait(Spike.run()) except Full: logger.warning('Signal queue' + q.name + 'is full')
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 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
def _setup(self): self.comm.put([Spike.setup()]) self.visual.setup()
def _runProcess(self): '''Run ImageProcessor in separate thread ''' self.comm.put([Spike.run()]) logger.info('------------------------- put run in comm')
def setup(self): for q in self.sig_queues.values(): try: q.put_nowait(Spike.setup()) except Full: logger.warning('Signal queue' + q.name + 'is full')