AmiDet API¶
- class pcdsdaq.ami.AmiDet(prefix, *, name, filter_string=None, min_duration=0, normalize=True)¶
Detector that gets data from pyami scalars.
The data will be in the form of an accumulated mean, rms, and number of entries used in the calculations. The raw data is not avaiable via pyami.
This only supports scalars. The array features are known to crash both the python session and active ami clients, so don’t use them.
- Parameters:
prefix (
str
) – The ami name to use to retrieve the data.name (
str
, required keyword) – The shorter name to use to label the data.filter_str (
str
, optional) – If provided, we’ll filter the incoming data using this filter string. If omitted or None, we’ll use the last set_l3t string. If False, but not None, we’ll do no filtering at all. This includes the empty string.min_duration (
float
, optional) – If provided, we’ll wait this many seconds before declaring the acquisition as complete. Otherwise, we’ll stop acquring on read.normalize (
bool
orAmiDet
, optional) – Determines the normalization behavior of this detector. The default isTrue
, which means normalize to the currentmonitor_det
. Seeset_monitor_det
.False
means do not normalize. You can also pass in any other detector to normalize against something that is not themonitor_det
.
- get(*args, **kwargs)¶
Get the value of all components in the device
Keyword arguments are passed onto each signal.get(). Components beginning with an underscore will not be included.
- put(*args, **kwargs)¶
Put a value to all components of the device
Keyword arguments are passed onto each signal.put()
- Parameters:
dev_t (DeviceTuple or tuple) – The device tuple with the value(s) to put (see get_device_tuple)
- read(*args, **kwargs)¶
Read data from the device.
This method is expected to be as instantaneous as possible, with any substantial acquisition time taken care of in
trigger()
.The
OrderedDict
returned by this method must have identical keys (in the same order) as theOrderedDict
returned bydescribe()
.By convention, the first key in the return is the ‘primary’ key and maybe used by heuristics in
bluesky
.The values in the ordered dictionary must be dict (-likes) with the keys
{'value', 'timestamp'}
. The'value'
may have any type, the timestamp must be a float UNIX epoch timestamp in UTC.- Returns:
data – The keys must be strings and the values must be dict-like with the keys
{'value', 'timestamp'}
- Return type:
OrderedDict
- set_det_filter(*args, event_codes=None, operator='&')¶
Set the filter on this detector only.
This lets you override the l3t filter for a single AmiDet. Call with no arguments to revert to the last l3t filter. Call with a simple
False
to disable filtering on this detector. Call as you would to set the l3t filter to setup a normal filtering override.- Parameters:
*args ((
AmiDet
,float
,float
) n times) – A sequence of (detector, low, high), which create filters that make sure the detector is between low and high. If instead, the first argument isFalse
, we’ll disable filtering on this detector.event_codes (
list
, optional) – A list of event codes to include in the filter. l3pass will be when the event code is present.operator (
str
, optional) – The operator for combining the detector ranges and event codes. This can either be|
toor
the conditions together, so l3pass will happen if any filter passes, or it can be left at the default&
toand
the conditions together, so l3pass will only happen if all filters pass.
- stage()¶
Called early in a bluesky scan to initialize the pyami.Entry object.
Note that pyami.Entry objects begin accumulating data immediately.
This will be when the filter_string is used to determine how to filter the pyami data. Setting the filter_string after stage is called will have no effect.
Internally this creates a new pyami.Entry object. These objects start accumulating data immediately.
- trigger()¶
Called during a bluesky scan to clear the accumulated pyami data.
This must be done because the pyami.Entry objects continually accumulate data forever. You can stop it by deleting the objects as in
unstage
, and you can clear it here to at least start from a clean slate.If min_duration is zero, this will return a status already marked done and successful. Otherwise, this will return a status that will be marked done after min_duration seconds.
If there is a normalization detector in use and it has not been staged, it will be staged during the first trigger in a scan.
- unstage()¶
Called late in a bluesky scan to remove the pyami.Entry object and the monitor.
Does a best-guess at the ami configuration, if it has not yet been setup. |
|
Pick the hostname or group to use for the pyami connection. |
|
Pick the file to write out for the l3t trigger |
|
Designate one |
|
Set up the l3t filters. |
|
Return valid l3t/pyami filter strings in a useful format. |
|
Helper function for creating an ami filter string. |
|
Helper function that creates a filter for a certain event code. |
|
Helper function to combine ami filter strings |