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
I seem to be unable to set the value of a StringOut record programmatically by calling .set(). This program demonstrates the issue:
# Import the basic framework components.
from softioc import softioc, builder, asyncio_dispatcher
# Create an asyncio dispatcher, the event loop is now running
dispatcher = asyncio_dispatcher.AsyncioDispatcher()
# Set the record prefix
builder.SetDeviceName("MY-DEVICE-PREFIX")
# Create some records
strout = builder.stringOut("FLIBBLE", initial_value="ABC")
# Boilerplate get the IOC started
builder.LoadDatabase()
softioc.iocInit(dispatcher)
strout.set("DEF")
# Finally leave the IOC running with an interactive shell.
softioc.interactive_ioc(globals())
The strout.set() line generates this exception:
File "/home/eyh46967/dev/pythonSoftIoc/docs/examples/trial_stringout.py", line 17, in <module>
strout.set("DEF")
File "/home/eyh46967/dev/pythonSoftIoc/softioc/device.py", line 212, in set
datatype, length, data, array = self.value_to_dbr(value)
File "/home/eyh46967/dev/pythonSoftIoc/softioc/device.py", line 186, in value_to_dbr
dbrtype = self.NumpyCharCodeToDbr[value.dtype.char]
KeyError: 'U'
The device.py code appears to be trying to convert the string value into a numpy array on line 173:
value = numpy.require(value, requirements = 'C')
Examining this array gives a value.dtype.char of U, which is unknown to the NumpyCharCodeToDbr mapping dictionary.
The text was updated successfully, but these errors were encountered:
We need to create a single function to sanitise all inputs from all possible places (initialising initial values for in & out, setting values for in&out, and waveforms) which can handle all possible Python values and convert it to a valid EPICS value.
Ensure the validation happens before iocInit(), so it'll throw an error if something goes wrong.
Whenever we pass a value we want to sanitise it to its canonical form - numpy aray for waveforms, or python string, or underlying value for numeric types, and then return the canonicalised form.
This work will involve device.py, getting and setting the values in some consistent way.
I seem to be unable to set the value of a StringOut record programmatically by calling
.set()
. This program demonstrates the issue:The
strout.set()
line generates this exception:The
device.py
code appears to be trying to convert the stringvalue
into a numpy array on line 173:Examining this array gives a
value.dtype.char
ofU
, which is unknown to theNumpyCharCodeToDbr
mapping dictionary.The text was updated successfully, but these errors were encountered: