Skip to content

Commit 7dabd5c

Browse files
author
mga83
committed
Add special support for writing strings to waveforms
When writing a string to a waveform convert the string to an array of characters. git-svn-id: svn+ssh://serv0002.cs.diamond.ac.uk/home/subversion/repos/controls/diamond/trunk/support/pythonSoftIoc@179945 e099a375-04f9-0310-9d5f-a741eaff62e1
1 parent da83d30 commit 7dabd5c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

python/softioc/device.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ def set(self, value,
320320
severity=alarm.NO_ALARM, alarm=alarm.UDF_ALARM, timestamp=None):
321321
'''Updates the stored value and triggers an update. The alarm
322322
severity and timestamp can also be specified if appropriate.'''
323+
if isinstance(value, str):
324+
# Convert a string into an array of characters. This will produce
325+
# the correct behaviour when treating a character array as a string.
326+
# Note that the trailing null is needed to work around problems with
327+
# some clients.
328+
value = numpy.fromstring(value + '\0', dtype = 'uint8')
323329
self._value = (+value, severity, alarm, timestamp)
324330
self.trigger()
325331

0 commit comments

Comments
 (0)