def scaler_counts_table(self, scaler, seconds, format_='%d', **kwargs): """ Run the scaler `scaler` for `seconds`, and report the results in a table :param scaler: Scaler device or record name :param seconds: Time in seconds Additional kwarg parameters are passed onto scaler_counts_list. """ names = self.scaler_channel_names(scaler) values = self.scaler_counts_list(scaler, seconds, **kwargs) values_str = [format_ % v for v in values] header = ['Name', 'Counts'] table = SimpleTable(header) for name, value in zip(names, values_str): table.add_row([name, value]) return table
def fields(self, pv, string, max_interest=4, values=True): ''' Search the field information database for 'text'. If the first argument is a PV it will detect its record type, otherwise use a record type (.RTYP) to start with. ''' try: rf = util.get_record_fields(pv) except IOError: # not a record type, or not one we have information on # try it as a PV instead: rtype = util.get_record_type(pv) rf = util.get_record_fields(rtype) else: rtype = pv if isinstance(string, (list, tuple)): text = ' '.join(string) else: text = string headers = ['Field'] + [col.capitalize() for col in rf.columns] table = SimpleTable(headers) rows = list([name] + info for name, info in rf.find(text)) for row in rows: table.add_row(row) remove_rows = [] if rtype != pv and values: # this means a PV was passed in and the RTYP was determined table.add_column('Value', index=1, fill='') for i, row in enumerate(table.rows): if i == 0: continue field = row[0] try: interest = int(table['Interest', i]) except: interest = 0 else: if interest > max_interest: remove_rows.append(i) continue if interest > 3: timeout = self.fields_timeout / 2 else: timeout = self.fields_timeout value = epics.caget('%s.%s' % (pv, field), connection_timeout=timeout, verbose=True) if value is None: value = '' table[1, i] = '%s' % value removed = 0 for row in remove_rows: table.remove_row(row - removed) removed += 1 return rtype, table