def load_resolution(): try: m = get_monitors() return round_down_to(m[0].height, 500) except Exception as err: log_warning(err) return 1000
def read_device_name(self, channel=0): if self.HasChannels: return self.ChannelConfig.get('Names', 'CH{}'.format(channel)) if self.Config.has_option('Names', self.SectionName): return self.Config.get('Names', self.SectionName) log_warning('Setting device name to "UNKNOWN"') return 'UNKNOWN'
def open_serial_port(self): try: self.Serial = Serial(port=self.SerialPortName, baudrate=9600, parity=PARITY_NONE, stopbits=STOPBITS_ONE, bytesize=EIGHTBITS, timeout=.5, ) self.bOpen = True log_info('Open serial port: {}'.format(self.SerialPortName)) except SerialException: log_warning('Could not open serial port: {}'.format(self.SerialPortName)) self.bOpen = False
def get_selected_runs(self): """ :return: list of selected run numbers. """ runs = [ run for run, selected in self.Selection.iteritems() if selected ] if not runs: log_warning('No runs selected!') return runs
def is_tripped(self, statusword): bit = 0x08 if int(statusword) & bit == bit: log_warning('keithley is tripped') self.clear_error_queue() self.clear_buffer() sleep(1) return True return False
def select_runs_from_runplan(self, plan_nr): self.reset_selection() plan = make_runplan_string(plan_nr) try: runs = self.RunPlan[plan]['runs'] self.SelectedRunPlan = plan self.select_runs_in_range(runs[0], runs[-1]) except KeyError: log_warning('Run plan {r} does not exist!'.format(r=plan))
def set_sense_resistance_offset_compensated(self, state): if not isint(state): if state in ['True', 'TRUE', '1', 'ON', 'On']: state = True elif state in ['False', 'FALSE', '0', 'OFF', 'Off']: state = False else: log_warning('Four Wire Measurement not valid state: {}'.format(state)) return False return self.write(':SENSE:RESISTANCE:OCOMPENSATED {}'.format('ON' if state else 'OFF'))
def get_all_channel_status(self): now = time() if now - self.LastStatusUpdate > 1: while True: try: bitmasks = self.get_answer_for_query(':READ:CHAN:STAT?{}'.format(self.make_channel_string(ALL))).split() self.LastStatus = [self.convert_channel_status(int(bitmask)) for bitmask in bitmasks] self.LastStatusUpdate = now return self.LastStatus except Exception as err: log_warning('No valid channel status, retry: {}'.format(err)) self.clear_buffer(warning=False) return self.LastStatus
def save_plots(self, savename, sub_dir=None, canvas=None, x=1, y=1, prnt=True, save=True, show=True): """ Saves the canvas at the desired location. If no canvas is passed as argument, the active canvas will be saved. """ if canvas is None: try: canvas = gROOT.GetListOfCanvases()[-1] except Exception as inst: print log_warning( 'Error in save canvas: {err}'.format(err=inst)) return try: self.Analysis.draw_run_info(canvas=canvas, x=x, y=y) except AttributeError as err: log_warning(err) canvas.Modified() canvas.Update() if save: try: self.save_canvas(canvas, sub_dir=sub_dir, name=savename, print_names=prnt, show=show) except Exception as inst: print log_warning('Error in save_canvas:\n{0}'.format(inst))
def set_to_manual(self, status): log_warning('set_to_manual not implemented')
def select_run(self, run_number, deselect=False): if run_number not in self.RunInfo: log_warning('Run {run} not found in list of run numbers'.format( run=run_number)) self.Selection[run_number] = True if not deselect else False
def set_bias(self, voltage, channel=0): log_warning('set_bias not implemented')
def get_output_status(self, channel=0): log_warning('get_output_status not implemented') return False
def get_path(self): if self.Path is None: log_warning('Set the path first!') return self.Path
def connect(self): log_warning('"connect" not implemented')
def read_iv(self): log_warning('read_iv not implemented') return []
def validate_voltage(self, voltage, channel=0): if not self.MinBias[channel] - .1 < voltage < self.MaxBias[channel] + .1: log_warning('Invalid target voltage! {v} not in [{b}, {e}]'.format(v=voltage, b=self.MinBias[channel], e=self.MaxBias[channel])) return False return True
def set_output(self, status, channel=0): log_warning('set_output not implemented')