-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
InstrumentParameter -> StandardParameter, instrument is optional
- Loading branch information
1 parent
e396059
commit c73f8c5
Showing
4 changed files
with
23 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,12 +174,13 @@ def __getitem__(self, keys): | |
return SweepFixedValues(self, keys) | ||
|
||
|
||
class InstrumentParameter(Parameter): | ||
class StandardParameter(Parameter): | ||
''' | ||
defines one measurement parameter | ||
instrument: an instrument that handles this parameter | ||
name: the local name of this parameter | ||
instrument: an instrument that handles this parameter | ||
default None | ||
get_cmd: a string or function to get this parameter | ||
async_get_cmd: a function to use for async get, or for both sync | ||
|
@@ -221,7 +222,7 @@ class InstrumentParameter(Parameter): | |
max_val_age: max time (in seconds) to trust a saved value from | ||
this parameter as the starting point of a sweep | ||
''' | ||
def __init__(self, instrument, name, | ||
def __init__(self, name, instrument=None, | ||
get_cmd=None, async_get_cmd=None, get_parser=None, | ||
parse_function=None, val_mapping=None, | ||
set_cmd=None, async_set_cmd=None, set_parser=None, | ||
|
@@ -295,8 +296,8 @@ def get_async(self): | |
def _set_get(self, get_cmd, async_get_cmd, get_parser): | ||
self._get, self._get_async = syncable_command( | ||
param_count=0, cmd=get_cmd, acmd=async_get_cmd, | ||
exec_str=self._instrument.ask, | ||
aexec_str=self._instrument.ask_async, | ||
exec_str=self._instrument.ask if self._instrument else None, | ||
aexec_str=self._instrument.ask_async if self._instrument else None, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
AdriaanRol
Contributor
|
||
output_parser=get_parser, no_cmd_function=no_func) | ||
|
||
if self._get is not no_func: | ||
|
@@ -307,8 +308,9 @@ def _set_set(self, set_cmd, async_set_cmd, set_parser): | |
# in self.set_sweep, when we choose a swept or non-swept setter. | ||
self._set, self._set_async = syncable_command( | ||
param_count=1, cmd=set_cmd, acmd=async_set_cmd, | ||
exec_str=self._instrument.write, | ||
aexec_str=self._instrument.write_async, | ||
exec_str=self._instrument.write if self._instrument else None, | ||
aexec_str=(self._instrument.write_async if self._instrument | ||
else None), | ||
input_parser=set_parser, no_cmd_function=no_func) | ||
|
||
if self._set is not no_func: | ||
|
@@ -424,17 +426,17 @@ class ManualParameter(Parameter): | |
''' | ||
defines one parameter that reflects a manual setting / configuration | ||
name: the local name of this parameter | ||
instrument: the instrument this applies to. Not actually used for | ||
anything, just required so this class can be used with | ||
Instrument.add_parameter(name, parameter_class=ManualParameter) | ||
name: the local name of this parameter | ||
initial_value: optional starting value. Default is None, which is the | ||
only invalid value allowed (and None is only allowed as an initial | ||
value, it cannot be set later) | ||
''' | ||
def __init__(self, instrument, name, initial_value=None, **kwargs): | ||
def __init__(self, name, instrument=None, initial_value=None, **kwargs): | ||
super().__init__(name=name, **kwargs) | ||
if initial_value is not None: | ||
self.validate(initial_value) | ||
|
@damazter this (and the same below) is all we need to make
instrument
optional. I should add a usage note though that without an instrument you can't use the string forms ofget_cmd
andset_cmd
...