def initialize_input(self): self.interface = self.input_dev.interface try: self.atlas_device = setup_atlas_device(self.input_dev) except Exception: self.logger.exception("Exception while initializing sensor")
def initialize(self): self.interface = self.input_dev.interface try: self.atlas_device = setup_atlas_device(self.input_dev) except Exception: self.logger.exception("Exception while initializing sensor") # Throw out first measurement of Atlas Scientific sensor, as it may be prone to error self.get_measurement()
def initialize_input(self): self.interface = self.input_dev.interface try: self.atlas_device = setup_atlas_device(self.input_dev) if self.led == 'on': self.atlas_device.query('L,1') elif self.led == 'off': self.atlas_device.query('L,0') except Exception: self.logger.exception("Exception while initializing sensor")
def initialize_input(self): self.interface = self.input_dev.interface try: self.atlas_device = setup_atlas_device(self.input_dev) if self.temperature_comp_meas_measurement_id: self.atlas_command = AtlasScientificCommand(self.input_dev, sensor=self.atlas_device) except Exception: self.logger.exception("Exception while initializing sensor") # Throw out first measurement of Atlas Scientific sensor, as it may be prone to error self.get_measurement()
def setup_atlas_ec_measure(input_id): """ Acquire a measurement from the Atlas Scientific EC input and return it Used during calibration to display the current EC to the user """ if not utils_general.user_has_permission('edit_controllers'): return redirect(url_for('routes_page.page_atlas_ec_calibrate')) selected_input = Input.query.filter_by(unique_id=input_id).first() ec = None error = None atlas_command = setup_atlas_device(selected_input) if selected_input.interface in ['FTDI', 'UART']: ec_status, ec_list = atlas_command.query('R') if ec_list: logger.debug("Returned list: {lines}".format(lines=ec_list)) # Find float value in list float_value = None for each_split in ec_list: if str_is_float(each_split): float_value = each_split break # 'check probe' indicates an error reading the sensor if 'check probe' in ec_list: error = '"check probe" returned from input' # if a string resembling a float value is returned, this # is our measurement value elif str_is_float(float_value): ec = float(float_value) logger.debug('Found float value: {val}'.format(val=ec)) else: logger.error('Value or "check probe" not found in list: ' '{val}'.format(val=ec_list)) elif selected_input.interface == 'I2C': ec_status, ec_str = atlas_command.query('R') if ec_status == 'error': error = "Input read unsuccessful: {err}".format(err=ec_str) elif ec_status == 'success': ec = ec_str if error: logger.error(error) return error, 204 else: return ec
def initialize_input(self): self.interface = self.input_dev.interface self.calibrate_sensor_measure = self.input_dev.calibrate_sensor_measure try: self.atlas_device = setup_atlas_device(self.input_dev) # Enabling DO, disabling % saturation self.atlas_device.write("O,mg,1") self.atlas_device.write("O,%,0") ret_val = self.atlas_device.write("O,?") self.logger.info("Parameters enabled: {}".format(ret_val)) except Exception: self.logger.exception("Exception while initializing sensor") # Throw out first measurement of Atlas Scientific sensor, as it may be prone to error self.get_measurement()
def initialize(self): self.interface = self.input_dev.interface try: self.atlas_device = setup_atlas_device(self.input_dev) # Enabling DO, disabling % saturation self.atlas_device.query("O,mg,1") self.atlas_device.query("O,%,0") ret_status, ret_val = self.atlas_device.query("O,?") self.logger.info("Parameters enabled: {}".format(ret_val)) if self.temperature_comp_meas_measurement_id: self.atlas_command = AtlasScientificCommand( self.input_dev, sensor=self.atlas_device) except Exception: self.logger.exception("Exception while initializing sensor") # Throw out first measurement of Atlas Scientific sensor, as it may be prone to error self.get_measurement()
def initialize_input(self): self.interface = self.input_dev.interface try: self.atlas_device = setup_atlas_device(self.input_dev) if self.led == 'on': self.atlas_device.query('L,1') elif self.led == 'off': self.atlas_device.query('L,0') if self.is_enabled(0): self.atlas_device.query('O,T,1') else: self.atlas_device.query('O,T,0') if self.is_enabled(1): self.atlas_device.query('O,HUM,1') else: self.atlas_device.query('O,HUM,0') if self.is_enabled(2): self.atlas_device.query('O,Dew,1') else: self.atlas_device.query('O,Dew,0') except Exception: self.logger.exception("Exception while initializing sensor")
def setup_atlas_ezo_pump(): """ Step-by-step tool for calibrating the Atlas Scientific peristaltic pump """ if not utils_general.user_has_permission('edit_controllers'): return redirect(url_for('routes_general.home')) form_ezo_pump_calibrate = forms_calibration.CalibrationAtlasEZOPump() output = Output.query.filter(Output.output_type == 'atlas_ezo_pmp').all() ui_stage = 'start' backend_stage = None selected_output = None output_device_name = None complete_with_error = None if form_ezo_pump_calibrate.hidden_current_stage.data: backend_stage = form_ezo_pump_calibrate.hidden_current_stage.data if form_ezo_pump_calibrate.go_to_last_stage.data: selected_output = Output.query.filter( Output.unique_id == form_ezo_pump_calibrate.hidden_output_id.data).first() output_device_name = selected_output.name # Clear Calibration memory if form_ezo_pump_calibrate.clear_calibration.data: selected_output = Output.query.filter( Output.unique_id == form_ezo_pump_calibrate.selected_output_id.data).first() if not selected_output: flash( 'Output not found: {}'.format( form_ezo_pump_calibrate.selected_output_id.data), 'error') else: atlas_command = setup_atlas_device(selected_output) if atlas_command: write_cmd = 'Cal,clear' logger.error("EZO-PMP command: {}".format(write_cmd)) status, msg = atlas_command.query(write_cmd) info_str = "{act}: {lvl}: {resp}".format( act=TRANSLATIONS['calibration']['title'], lvl=write_cmd, resp=msg) if status == 'success': flash(info_str, 'success') else: flash(info_str, 'error') else: flash("Error initializing pump class", 'error') elif form_ezo_pump_calibrate.start_calibration.data: ui_stage = 'question_ml_dispensed' selected_output = Output.query.filter( Output.unique_id == form_ezo_pump_calibrate.selected_output_id.data).first() if not selected_output: flash( 'Output not found: {}'.format( form_ezo_pump_calibrate.selected_output_id.data), 'error') else: output_device_name = selected_output.name atlas_command = setup_atlas_device(selected_output) if atlas_command: if (form_ezo_pump_calibrate.ml_to_dispense.data and form_ezo_pump_calibrate.ml_to_dispense.data > 0): write_cmd = 'D,{}'.format( form_ezo_pump_calibrate.ml_to_dispense.data) logger.error("EZO-PMP command: {}".format(write_cmd)) status, msg = atlas_command.query(write_cmd) info_str = "{act}: {lvl}: {resp}".format( act=TRANSLATIONS['calibration']['title'], lvl=write_cmd, resp=msg) if status == 'success': flash(info_str, 'success') else: flash(info_str, 'error') else: flash( "Invalid amount to dispense: '{}'".format( form_ezo_pump_calibrate.ml_to_dispense.data), 'error') else: flash("Error initializing pump class", 'error') elif backend_stage == 'question_ml_dispensed': ui_stage = 'complete' output_device_name = selected_output.name atlas_command = setup_atlas_device(selected_output) if atlas_command: if (form_ezo_pump_calibrate.ml_dispensed.data and form_ezo_pump_calibrate.ml_dispensed.data > 0): write_cmd = 'Cal,{}'.format( form_ezo_pump_calibrate.ml_dispensed.data) logger.error("EZO-PMP command: {}".format(write_cmd)) status, msg = atlas_command.query(write_cmd) info_str = "{act}: {lvl}: {resp}".format( act=TRANSLATIONS['calibration']['title'], lvl=write_cmd, resp=msg) if status == 'success': flash(info_str, 'success') else: flash(info_str, 'error') else: flash( "Invalid amount dispensed: '{}'".format( form_ezo_pump_calibrate.ml_dispensed.data), 'error') else: flash("Error initializing pump class", 'error') return render_template('tools/calibration_options/atlas_ezo_pump.html', complete_with_error=complete_with_error, form_ezo_pump_calibrate=form_ezo_pump_calibrate, output=output, output_device_name=output_device_name, selected_output=selected_output, ui_stage=ui_stage)
def setup_output(self): self.setup_output_variables(OUTPUT_INFORMATION) self.interface = self.output.interface self.atlas_device = setup_atlas_device(self.output) self.output_setup = True