lightlab.equipment.abstract_drivers.configurable module¶
Summary¶
Exceptions:
AccessException |
Classes:
Configurable |
Instruments can be configurable to keep track of settings within the instrument |
TekConfig |
Wraps a dictionary attribute. |
Reference¶
-
class
TekConfig(initDict=None)[source]¶ Bases:
objectWraps a dictionary attribute. Uses dpath for operations.
- Commands are defined as tuples (cStr, val). For example (‘:PATH:TO:CMD’, 4).
- Use these by doing scope.write(‘ ‘.join(TekConfig.get(‘PATH:TO:CMD’))) The val is always a string.
Todo
:transferring subgroup from one instance to another. :returning a dictionary representing a subgroup (actually this might currently be happening in error) :transferring subgroup values to a different subgroup in the same instance (for example, CH1 to CH2)
-
separator= ':'¶
-
get(cStr, asCmd=True)[source]¶ Returns the value only, not a dictionary
Parameters: asCmd (bool) – if true, returns a tuple representing a command. Otherwise returns just the value
-
getList(subgroup='', asCmd=True)[source]¶ Deep crawler that goes in and generates a command for every leaf.
Parameters: Returns: list of valid commands (cstr, val) on the subgroup subdirectory
Return type:
-
transfer(source, subgroup='')[source]¶ Pulls config from the source TekConfig object. This is useful for subgrouping.
For example, you might want to load from default only the trigger configuration.
Parameters:
-
classmethod
fromSETresponse(setResponse, subgroup='')[source]¶ setResponse (str): what is returned by the scope in response to query(‘SET?’)
It will require some parsing for subgroup shorthand
-
class
Configurable(headerIsOptional=True, verboseIsOptional=False, precedingColon=True, interveningSpace=True, **kwargs)[source]¶ Bases:
lightlab.equipment.abstract_drivers.AbstractDriverInstruments can be configurable to keep track of settings within the instrument
This class is setup so that the hardware state is reflected exactly in the ‘live’ config unless somebody changes something in lab. Watch out for that and use
forceHardwareif that is a riskThis clas uses query/write methods that are not directly inherited, so the subclass or its parents must implement those functions
-
initHardware()[source]¶ Runs upon first hardware access. Tells the instrument how to format its commands
-
setConfigParam(cStr, val=None, forceHardware=False)[source]¶ Sets an individual configuration parameter. If the value has been read before, and there is no change, then it will not write to the hardware.
Parameters: Returns: Did it requre a write to hardware?
Return type: (bool)
-
getConfigParam(cStr, forceHardware=False)[source]¶ Gets a single parameter. If the value has been read before, and there is no change, then it will not query the hardware.
This is much faster than getting from hardware; however, it assumes that nobody in lab touched anything.
Parameters: Returns: command value. Detects type, so that
'2.5'will return asfloatReturn type: (any)
If the command is not recognized, attempts to get it from hardware
-
tempConfig(cStr, tempVal, forceHardware=False)[source]¶ Changes a parameter within the context of a “with” block. Args are same as in
getConfigParam().
-
getDefaultFilename()[source]¶ Combines the
lightlab.util.io.paths.defaultFileDirwith the *IDN? string of this instrument.Returns: the default filename Return type: (str)
-
saveConfig(dest='+user', subgroup='', overwrite=False)[source]¶ If you would like to setup a temporary state (i.e. taking some measurements and going back), use a file and subgroup=
Parameters: subgroup (str) – a group of commands or a single command. If ‘’, it means everything. - Side effects:
- if dest is object or dict, modifies it if dest is token, modifies the config library of self if dest is filename, writes that file
-
loadConfig(source='+user', subgroup='')[source]¶ Loads some configuration parameters from a source which is either:
- a file name string, or
- a special token [‘+default’ or ‘+init’], or
- some TekConfig object or dict you have out there
Parameters: - source (str/TekConfig) – load source
- subgroup (str) – a group of commands or a single command. If ‘’, it means everything.
-