-
Notifications
You must be signed in to change notification settings - Fork 3
Problem: RE stalls when writing FileName PV in area detector
This call to RE(bps.mv(file_name_signal, "text"))
stalls with this message reported to the console:
In [6]: RE(bps.mv(ad_filename, filename))
/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/ophyd/utils/epics_pvs.py:289: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
ret = (a == b)
The user must type ^C^C
to stop the RE
and get a command prompt. Then, usually RE.abort()
to place the RunEngine into the idle state.
Every command after this event will see the same message reported to the console.
CONTENTS
Use the string=True
kwarg when creating an EpicsSignalBase
(subclass) that connects with a waveform string PV.
EPICS area detector uses many waveform string PVs to allow text with len() > 40 characters. One example is the HDF File Writing Plugin FileName
PV which is a waveform of 256 characters. Here is a local instance with an empty string value:
(base) prjemian@zap:~$ caget ad:HDF1:FileName
ad:HDF1:FileName 256 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The caget
command has a -S
option to render this PV value as a string:
(base) prjemian@zap:~$ caget -S ad:HDF1:FileName
ad:HDF1:FileName
In ophyd, we see the same:
In [1]: from ophyd import EpicsSignalWithRBV
In [2]: ad_filename = EpicsSignalWithRBV("ad:HDF1:FileName", name="ad_filename", string=False)
In [3]: ad_filename.get()
Out[3]: array([0], dtype=uint8)
In [4]: ad_filename.get(as_string=True)
Out[4]: ''
or, simpler
In [5]: ad_filename = EpicsSignalWithRBV("ad:HDF1:FileName", name="ad_filename", string=True)
In [6]: ad_filename.get()
Out[6]: ''
String comparison works without comment:
In [7]: ad_filename.get()
Out[7]: ''
In [8]: ad_filename.get() == ""
Out[8]: True
The .put()
also completes without comment:
In [9]: filename = "/home/8ididata/2021-3/ZDT{:02d}_{:06d}.bin".format(1,2)
In [10]: filename
Out[10]: '/home/8ididata/2021-3/ZDT01_000002.bin'
In [11]: ad_filename.put(filename)
and the camonitor-S
trace shows this worked properly:
(base) prjemian@zap:~$ camonitor -S ad:HDF1:FileName{,_RBV}
ad:HDF1:FileName 2021-12-02 11:06:04.239834 0
ad:HDF1:FileName_RBV 2021-12-02 11:06:04.239829 0
ad:HDF1:FileName_RBV 2021-12-02 11:13:01.404614 /home/8ididata/2021-3/ZDT01_000002.bin
ad:HDF1:FileName 2021-12-02 11:13:01.404634 /home/8ididata/2021-3/ZDT01_000002.bin
So, no problem from the ophyd layer, yet the error report comes from this layer:
/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/ophyd/utils/epics_pvs.py:289: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
ret = (a == b)
Pivot now to that same .put()
operation using the bluesky.RunEngine, using bps.mv()
:
In [1]: from ophyd import EpicsSignalWithRBV
In [2]: ad_filename = EpicsSignalWithRBV("ad:HDF1:FileName", name="ad_filename", string=True)
In [3]: filename = "/home/8ididata/2021-3/ZDT{:02d}_{:06d}.bin".format(1,2)
In [4]: from bluesky import RunEngine, plan_stubs as bps
In [5]: RE = RunEngine({})
In [6]: RE(bps.mv(ad_filename, filename))
Out[6]: ()
No problem observed. When the string=True
kwarg is not given, that produces the problem.
In [1]: from ophyd import EpicsSignalWithRBV
In [2]: ad_filename = EpicsSignalWithRBV("ad:HDF1:FileName", name="ad_filename")
In [3]: filename = "/home/8ididata/2021-3/ZDT{:02d}_{:06d}.bin".format(1,2)
In [4]: from bluesky import RunEngine, plan_stubs as bps
In [5]: RE = RunEngine({})
In [6]: RE(bps.mv(ad_filename, filename))
/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/ophyd/utils/epics_pvs.py:289: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
ret = (a == b)
At this point, RE
has not returned and is stuck with a failed comparison.
This article was developed using these package versions:
package | version |
---|---|
bluesky | 1.8.1 |
epics | 3.5.0 |
ophyd | 1.6.3 |
python | 3.9.7 |