def __init__(self, name, **kwargs): SharedGObject.__init__(self, 'instrument_%s' % name, replace=True) self._name = name self._initialized = False self._locked = False self._changed = {} self._changed_hid = None self._options = kwargs if 'tags' not in self._options: self._options['tags'] = [] self._parameters = {} self._parameter_groups = {} self._functions = {} self._added_methods = [] self._probe_ids = [] self._default_read_var = None self._default_write_var = None self._lock_class = kwargs.get('lockclass', name) if self._lock_class in Instrument._lock_classes: self._access_lock = Instrument._lock_classes[self._lock_class] else: self._access_lock = calltimer.TimedLock(2.0) self._lock_classes[self._lock_class] = self._access_lock
def __init__(self): SharedGObject.__init__(self, 'instruments%d' % Instruments.__id) Instruments.__id += 1 self._instruments = {} self._instruments_info = {} self._tags = []
def __init__(self): SharedGObject.__init__(self, 'flow') self._status = 'starting' self._measurements_running = 0 self._abort = False self._pause = False self._exit_handlers = [] self._callbacks = {}
def __init__(self, *args, **kwargs): ''' Create a plot object. args input: data objects (Data) filenames (string) kwargs input: name (string), default will be 'plot<n>' maxpoints (int), maximum number of points to show, default 10000 maxtraces (int), maximum number of traces to show, default 5 mintime (int, seconds), default 1 autoupdate (bool), default None, which means listen to global needtempfile (bool), default False. Whether the plot needs data in a temporary file. supportbin (bool), default False. Whether the temporary file can be in binary format. refreshrate (int), minimum elapsed time in second during two updates of a graph being plotting without file. Default 1 second. ''' maxpoints = kwargs.get('maxpoints', 10000) maxtraces = kwargs.get('maxtraces', 5) mintime = kwargs.get('mintime', 1) autoupdate = kwargs.get('autoupdate', None) needtempfile = kwargs.get('needtempfile', False) supportbin = kwargs.get('supportbin', False) refreshrate = kwargs.get('refreshrate', 1) name = kwargs.get('name', '') self._name = Plot._plot_list.new_item_name(self, name) SharedGObject.__init__(self, 'plot_%s' % self._name, replace=True) self._data = [] # Plot properties, things such as maxpoints might be migrated here. self._properties = {} self._maxpoints = maxpoints self._maxtraces = maxtraces self._mintime = mintime self._autoupdate = autoupdate self._needtempfile = needtempfile self._supportbin = supportbin self._refreshrate = refreshrate self._last_update = 0 self._update_hid = None data_args = get_dict_keys(kwargs, ('coorddim', 'coorddims', 'valdim', 'title', 'offset', 'ofs', 'traceofs', 'surfofs')) data_args['update'] = False data_args['setlabels'] = False self.add(*args, **data_args) Plot._plot_list.add(self._name, self)
def __init__(self, name=None, mintime=1, autoupdate=True, template='gnuplot_2d', output_dir='.', run=True): ''' Create a plot wrapper for plotting qt.Data objects. args input: data objects (Data) kwargs input: name (string) --- default 'plot<n>' mintime (int, seconds) --- min time between autoupdates, default 1 autoupdate (bool) --- update the plot when data points added, default True template (string) --- default 'gnuplot_2d' output_dir (string) --- directory for storing the plot. default '.' run (bool) --- whether the plot script should be immediately ran (opened) (But a window may not pop up until data is added.) ''' self._name = name if name else '' self._name = Plot._plot_list.new_item_name(self, self._name) SharedGObject.__init__(self, 'plot_%s' % self._name, replace=True) self._data = [] self._mintime = mintime self._autoupdate = autoupdate self._last_update = 0 self._update_hid = None self._pltbr = plotbridge_plot(name=self._name, template=template, output_dir=output_dir, overwrite=True) Plot._plot_list.add(self._name, self) if run: self._pltbr.run(interactive=True)
def __init__(self, base_name='item', **kwargs): ''' Construct new named list object. Input: base_name (string): the base name for new items type (constant): TYPE_ACTIVE or TYPE_PASSIVE. Active lists make sure that an item always exists, so if an item is requested that does not exist a new one will be created on the fly by calling the create() function Passive lists simply return None if an item does not exist. ''' shared_name = kwargs.get('shared_name', 'namedlist_%s' % base_name) SharedGObject.__init__(self, shared_name) self._list = {} self._last_item = None self._auto_counter = 0 self._base_name = base_name type = kwargs.get('type', NamedList.TYPE_PASSIVE) self._type = type
def __init__(self, *args, **kwargs): ''' Create data object. There are three different uses: 1) create an empty data object for use in a measurement 2) create a data object and fill immediately with a numpy array 3) create a data object from an existing data file All inputs are optional. The 'name' input is used in an internal list (accessable through qt.data). If omitted, a name will be auto generated. This 'name' will also be used later to auto generate a filename when calling 'create_file()' (if that is called without options). The input 'filename' here is only used for loading an existing file. args input: filename (string), set the filename to load. data (numpy.array), array to construct data object for kwargs input: name (string), default will be 'data<n>' infile (bool), default True inmem (bool), default False if no file specified, True otherwise tempfile (bool), default False. If True create a temporary file for the data. binary (bool), default True. Whether tempfile should be binary. ''' # Init SharedGObject a bit lower name = kwargs.get('name', '') infile = kwargs.get('infile', True) inmem = kwargs.get('inmem', False) self._inmem = inmem self._tempfile = kwargs.get('tempfile', False) self._temp_binary = kwargs.get('binary', True) self._options = kwargs self._file = None self._stop_req_hid = None # Dimension info self._dimensions = [] self._block_sizes = [] self._loopdims = None self._loopshape = None self._complete = False self._reshaped_data = None # Number of coordinate dimensions self._ncoordinates = 0 # Number of value dimensions self._nvalues = 0 # Number of data points self._npoints = 0 self._npoints_last_block = 0 self._npoints_max_block = 0 self._comment = [] self._localtime = time.localtime() self._timestamp = time.asctime(self._localtime) self._timemark = time.strftime('%H%M%S', self._localtime) self._datemark = time.strftime('%Y%m%d', self._localtime) # FIXME: the name generation here is a bit nasty name = Data._data_list.new_item_name(self, name) self._name = name SharedGObject.__init__(self, 'data_%s' % name, replace=True, idle_emit=True) data = get_arg_type(args, kwargs, (numpy.ndarray, list, tuple), 'data') if data is not None: self.set_data(data) else: self._data = numpy.array([]) self._infile = infile filepath = get_arg_type(args, kwargs, types.StringType, 'filepath') if self._tempfile: self.create_tempfile(filepath) elif filepath is not None and filepath != '': if 'inmem' not in kwargs: inmem = True self.set_filepath(filepath, inmem) self._infile = True else: self._dir = '' self._filename = '' self._infile = infile # Don't hold references to temporary data files if not self._tempfile: Data._data_list.add(name, self)