You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attempting to create a WaveformOut record with a String value has multiple issues regarding how PythonSoftIOC attempts to convert it into a numpy array. The failure modes are different depending on how you try and set the value.
Using initial_value="Some string" and FTVL="CHAR" you get this exception:
len() of unsized object
File "/scratch/eyh46967/pipenv/PandABlocks-client-bVxlyL_p/lib/python3.7/site-packages/softioc/builder.py", line 167, in _waveform
length = len(value)
File "/scratch/eyh46967/pipenv/PandABlocks-client-bVxlyL_p/lib/python3.7/site-packages/softioc/builder.py", line 192, in WaveformOut
_waveform(value, fields)
File "/home/eyh46967/dev/PandABlocks-client/pandablocks/ioc.py", line 618, in _waveform_rec
**kwargs,
File "/home/eyh46967/dev/PandABlocks-client/pandablocks/ioc.py", line 580, in __init__
DESC="Format string used for file naming",
File "/home/eyh46967/dev/PandABlocks-client/pandablocks/ioc.py", line 1723, in create_block_records
_HDF5RecordController(self._client)
Creating the record and immediately doing .set("some string") on the record seems to be ignored entirely with no exception but also no change to the record's value.
Creating the record and immediately doing .set("%abc") gives the following exception:
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 232, in 'calling callback function'
File "/scratch/eyh46967/pipenv/PandABlocks-client-bVxlyL_p/lib/python3.7/site-packages/softioc/device_core.py", line 191, in _init_record
return self.init_record(record)
File "/scratch/eyh46967/pipenv/PandABlocks-client-bVxlyL_p/lib/python3.7/site-packages/softioc/device.py", line 310, in init_record
return self.__super.init_record(record)
File "/scratch/eyh46967/pipenv/PandABlocks-client-bVxlyL_p/lib/python3.7/site-packages/softioc/device.py", line 125, in init_record
self._write_value(record, self._value)
File "/scratch/eyh46967/pipenv/PandABlocks-client-bVxlyL_p/lib/python3.7/site-packages/softioc/device.py", line 321, in _write_value
value = numpy.require(value, dtype=self.dtype)
File "/scratch/eyh46967/pipenv/PandABlocks-client-bVxlyL_p/lib/python3.7/site-packages/numpy/core/_asarray.py", line 380, in require
return asanyarray(a, dtype=dtype)
File "/scratch/eyh46967/pipenv/PandABlocks-client-bVxlyL_p/lib/python3.7/site-packages/numpy/core/_asarray.py", line 171, in asanyarray
return array(a, dtype, copy=False, order=order, subok=True)
ValueError: invalid literal for int() with base 10: '%abc'
From observation it also appears that doing a delayed .set() after IOC initialisation will result in similar errors, but again in a different place.
It should be noted that WaveformIn records have some attempts at handling this issue - device.py L353 has value = numpy.fromstring(value + "\0", dtype="uint8") which will work, but emits this warning: _main__:1: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
The workaround is to create the record and do .set(np.frombuffer("%s/%s_%d.h5".encode() + b"\0", dtype=np.uint8)) or similar.
Note that I cannot provide the value during record creation using either value or initial_value, as I need to set a maximum length of the record which is bigger than the length of the initial value. This is covered in issue #37
The text was updated successfully, but these errors were encountered:
This issue is mostly fixed by PR #60 , however the .set("%abc") does still have an issue - the returned array is of dtype=float32, which is incorrect. So that's the last (known) problem to cover in this issue.
Attempting to create a
WaveformOut
record with a String value has multiple issues regarding how PythonSoftIOC attempts to convert it into a numpy array. The failure modes are different depending on how you try and set the value.Using
initial_value="Some string"
andFTVL="CHAR"
you get this exception:Creating the record and immediately doing
.set("some string")
on the record seems to be ignored entirely with no exception but also no change to the record's value.Creating the record and immediately doing
.set("%abc")
gives the following exception:From observation it also appears that doing a delayed
.set()
after IOC initialisation will result in similar errors, but again in a different place.It should be noted that
WaveformIn
records have some attempts at handling this issue -device.py
L353 hasvalue = numpy.fromstring(value + "\0", dtype="uint8")
which will work, but emits this warning:_main__:1: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
The workaround is to create the record and do
.set(np.frombuffer("%s/%s_%d.h5".encode() + b"\0", dtype=np.uint8))
or similar.Note that I cannot provide the value during record creation using either
value
orinitial_value
, as I need to set a maximum length of the record which is bigger than the length of the initial value. This is covered in issue #37The text was updated successfully, but these errors were encountered: