def on_step_options_changed(self, plugin, step_number): logger.debug('[OpenDropPlugin] on_step_options_changed(): %s ' 'step #%d' % (plugin, step_number)) app = get_app() app_values = self.get_app_values() options = self.get_step_options(step_number) if (app.protocol and not app.running and not app.realtime_mode and (plugin == 'microdrop.gui.dmf_device_controller' or plugin == self.name) and app.protocol.current_step_number == step_number): self.on_step_run()
def on_protocol_pause(self): """ Handler called when a protocol is paused. """ app = get_app() self._kill_running_step() if self.control_board.connected() and not app.realtime_mode: # Turn off all electrodes logger.debug('Turning off all electrodes.') self.control_board.set_state_of_all_channels( np.zeros(self.control_board.number_of_channels()))
def on_step_run(self): """ Handler called whenever a step is executed. Plugins that handle this signal must emit the on_step_complete signal once they have completed the step. The protocol controller will wait until all plugins have completed the current step before proceeding. """ logger.debug('[TestPlugin] on_step_run()') app = get_app() if (self.proxy and app.realtime_mode or app.running): options = self.get_step_options() self.proxy.digital_write(pin=13, value=options['led_on']) emit_signal('on_step_complete', [self.name, None])
def on_step_run(self): """ Handler called whenever a step is executed. Plugins that handle this signal must emit the on_step_complete signal once they have completed the step. The protocol controller will wait until all plugins have completed the current step before proceeding. """ logger.debug('[OpenDropPlugin] on_step_run()') self._kill_running_step() app = get_app() options = self.get_step_options() dmf_options = app.dmf_device_controller.get_step_options() logger.debug('[OpenDropPlugin] options=%s dmf_options=%s' % (options, dmf_options)) app_values = self.get_app_values() if (self.control_board.connected() and (app.realtime_mode or app.running)): state = dmf_options.state_of_channels max_channels = self.control_board.number_of_channels() if len(state) > max_channels: state = state[0:max_channels] elif len(state) < max_channels: state = np.concatenate([state, np.zeros(max_channels - len(state), int)]) assert(len(state) == max_channels) emit_signal("set_frequency", options['frequency'], interface=IWaveformGenerator) emit_signal("set_voltage", options['voltage'], interface=IWaveformGenerator) self.control_board.set_state_of_all_channels(state) # if a protocol is running, wait for the specified minimum duration if app.running: logger.debug('[OpenDropPlugin] on_step_run: ' 'timeout_add(%d, _callback_step_completed)' % options['duration']) self.timeout_id = gobject.timeout_add( options['duration'], self._callback_step_completed) return else: self.step_complete()
def on_step_swapped(self, original_step_number, new_step_number): logger.debug('[OpenDropPlugin] on_step_swapped():' 'original_step_number=%d, new_step_number=%d' % (original_step_number, new_step_number)) self.on_step_options_changed(self.name, get_app().protocol.current_step_number)
def _callback_step_completed(self): logger.debug('[OpenDropPlugin] _callback_step_completed') self.step_complete() return False # stop the timeout from refiring
def _kill_running_step(self): if self.timeout_id: logger.debug('[OpenDropPlugin] _kill_running_step: removing' 'timeout_id=%d' % self.timeout_id) gobject.source_remove(self.timeout_id)