Skip to content

Commit 944e072

Browse files
committed
Improve value conversion when writing to waveform value
Use numpy.require to ensure value is of the correct format. Also improve validation of written value. This addresses Jira CGP-182
1 parent 2484e89 commit 944e072

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

python/softioc/device.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,12 @@ def set(self, value,
326326
# Note that the trailing null is needed to work around problems with
327327
# some clients.
328328
value = numpy.fromstring(value + '\0', dtype = 'uint8')
329+
330+
value = numpy.require(value, dtype = self.dtype)
329331
self._value = (+value, severity, alarm, timestamp)
332+
if value.shape == (): value.shape = (1,)
333+
assert value.ndim == 1, 'Can\'t write multidimensional arrays'
334+
330335
self.trigger()
331336

332337

0 commit comments

Comments
 (0)