def on_step_run(self): """" Handler called whenever a step is executed. Note that this signal is only emitted in realtime mode or if a protocol is running. 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. return_value can be one of: None 'Repeat' - repeat the step or 'Fail' - unrecoverable error (stop the protocol) """ app = get_app() logger.info('[SyringePumpPlugin] on_step_run(): step #%d', app.protocol.current_step_number) app_values = self.get_app_values() options = self.get_step_options() if (self.proxy != None and (app.realtime_mode or app.running)): microsteps = self.proxy.microstep_setting steps = (app_values['steps_per_microliter'] * options['microliters'] * microsteps) steps_per_second = (app_values['steps_per_microliter'] * microsteps * options['microliters_per_min'] / 60.0) self.proxy.move(steps, steps_per_second) print 'move(steps=%d, steps_per_second=%d)' % (steps, steps_per_second) while self.proxy.steps_remaining: gtk.main_iteration() return_value = None emit_signal('on_step_complete', [self.name, return_value])
def on_app_options_changed(self, plugin_name): app = get_app() if plugin_name == self.name: app_values = self.get_app_values() reconnect = False if self.control_board.connected(): for k, v in app_values.items(): if k == 'baud_rate' and self.control_board.baud_rate != v: self.control_board.baud_rate = v reconnect = True if k == 'serial_port' and self.control_board.port != v: reconnect = True if reconnect: self.connect() self._update_protocol_grid() elif plugin_name == app.name: # Turn off all electrodes if we're not in realtime mode and not # running a protocol. if (self.control_board.connected() and not app.realtime_mode and not app.running): logger.info('Turning off all electrodes.') self.control_board.set_state_of_all_channels( np.zeros(self.control_board.number_of_channels()) )
def set_voltage(self, voltage): """ Set the waveform voltage. Parameters: voltage : RMS voltage """ logger.info("[OpenDropPlugin].set_voltage(%.1f)" % voltage) self.control_board.set_waveform_voltage(voltage)
def set_frequency(self, frequency): """ Set the waveform frequency. Parameters: frequency : frequency in Hz """ logger.info("[OpenDropPlugin].set_frequency(%.1f)" % frequency) self.control_board.set_waveform_frequency(frequency) self.current_frequency = frequency
def on_plugin_enable(self): # We need to call AppDataController's on_plugin_enable() to update the # application options data. AppDataController.on_plugin_enable(self) self.on_app_init() app_values = self.get_app_values() try: self.proxy = SerialProxy(port=app_values['serial_port']) self.proxy.pin_mode(pin=13, mode=1) logger.info('Connected to %s on port %s', self.proxy.properties.display_name, app_values['serial_port']) except Exception, e: logger.error('Could not connect to base-node-rpc on port %s: %s.', app_values['serial_port'], e)
def on_flash_firmware(self, widget=None, data=None): app = get_app() try: connected = self.proxy != None if not connected: self.check_device_name_and_version() if connected: port = self.proxy.port # disconnect del self.proxy self.proxy = None from arduino_helpers.upload import upload from base_node_rpc import get_firmwares logger.info(upload('uno', lambda b: get_firmwares()[b][0], port)) app.main_window_controller.info("Firmware updated successfully.", "Firmware update") except Exception, why: logger.error("Problem flashing firmware. ""%s" % why)
def on_step_run(self): """ Handler called whenever a step is executed. Note that this signal is only emitted in realtime mode or if a protocol is running. 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. return_value can be one of: None 'Repeat' - repeat the step or 'Fail' - unrecoverable error (stop the protocol) """ app = get_app() logger.info('[AnalystRemotePlugin] on_step_run(): step #%d', app.protocol.current_step_number) # If `acquire` is `True`, start acquisition options = self.get_step_options() if options['acquire']: app_values = self.get_app_values() try: if self.timeout_id is not None: # Timer was already set, so cancel previous timer. gobject.source_remove(self.timeout_id) self.remote = AnalystRemoteControl(app_values['subscribe_uri'], app_values['request_uri']) self.remote.start_acquisition() self.timeout_id = gobject.timeout_add(100, self.remote_check_tick) except: print "Exception in user code:" print '-'*60 traceback.print_exc(file=sys.stdout) print '-'*60 # An error occurred while initializing Analyst remote control. emit_signal('on_step_complete', [self.name, 'Fail']) else: emit_signal('on_step_complete', [self.name, None])
def on_step_options_changed(self, plugin, step_number): app = get_app() if (plugin == 'wheelerlab.test_plugin'): options = self.get_step_options() logger.info('[TestPlugin] on_step_options_changed():' '%s step #%d -> %s' % (plugin, step_number, options))