Exception raised by OneDController when returning an array of one element
We have a OneDController
that was returning [1.0]
in ReadOne
.
def ReadOne(self, axis):
self.uview.StartAcquisition()
while self.uview.state() == DevState.RUNNING:
time.sleep(0.1)
return [1.0]
This value is a dummy value, as it's only used to trigger the acquisition on another machine.
During the scan the following exception is raised (TypeError: Object of type ndarray is not JSON serializable
):
ThreadPool.W001 WARNING 2022-05-09 14:35:39,801 B111A/DOOR/01: Error firing event <EventType(name=recorddata, priority=1), ('utf8_json', {'type': 'record_data', 'data': {'point_nb': 5, 'dummymovable1': 395.0, 'tango://b-v-maxpeem-csdb-0.maxiv.lu.se:10000/expchan/elmitec_ctrl/0': array([1.]), 'timestamp': 22.175090312957764}, 'macro_id': '999'})>
ThreadPool.W001 DEBUG 2022-05-09 14:35:39,804 B111A/DOOR/01: Details
Traceback (most recent call last):
File "/opt/conda/envs/sardana/lib/python3.9/site-packages/sardana/sardanabase.py", line 131, in fire_event
return EventGenerator.fire_event(self, event_type, event_value,
File "/opt/conda/envs/sardana/lib/python3.9/site-packages/sardana/sardanaevent.py", line 113, in fire_event
self._fire_event(event_type, event_value, listeners=listeners)
File "/opt/conda/envs/sardana/lib/python3.9/site-packages/sardana/sardanaevent.py", line 135, in _fire_event
real_listener(self, event_type, event_value)
File "/opt/conda/envs/sardana/lib/python3.9/site-packages/sardana/tango/macroserver/Door.py", line 277, in on_door_changed
event_value = codec.encode(('', value))
File "/opt/conda/envs/sardana/lib/python3.9/site-packages/taurus/core/util/codecs.py", line 957, in encode
data = codec.encode(data, *args, **kwargs)
File "/opt/conda/envs/sardana/lib/python3.9/site-packages/taurus/core/util/codecs.py", line 385, in encode
return format, json.dumps(data[1], *args, **kwargs)
File "/opt/conda/envs/sardana/lib/python3.9/json/__init__.py", line 234, in dumps
return cls(
File "/opt/conda/envs/sardana/lib/python3.9/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/opt/conda/envs/sardana/lib/python3.9/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/opt/conda/envs/sardana/lib/python3.9/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type ndarray is not JSON serializable
I guess that this controller should have been a ZeroDController
in the first place.
But returning an array of one element shouldn't raise an exception.