From f911e9c6d7ed5a2d4496a6262fab27a1af1667f6 Mon Sep 17 00:00:00 2001 From: Martin Gaughran Date: Mon, 9 Aug 2021 15:52:33 +0100 Subject: [PATCH 1/2] Allow waveform.set() to be called before iocInit() With CGP-182 (944e072), waveform.set() was modified to use the dtype attribute, which is only created after softioc.iocInit() is called. This change adds a default for dtype, preventing this issue. --- softioc/device.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/softioc/device.py b/softioc/device.py index ebcf7622..7d125345 100644 --- a/softioc/device.py +++ b/softioc/device.py @@ -293,6 +293,8 @@ class WaveformBase(ProcessDeviceSupportCore): # NELM Length of allocated array in number of elements # NORD Currently reported length of array (0 <= NORD <= NELM) _fields_ = ['UDF', 'FTVL', 'BPTR', 'NELM', 'NORD'] + # Allow set() to be called before init_record: + dtype = None def init_record(self, record): self.dtype = DbfCodeToNumpy[record.FTVL] From 3dda72c2cea2f1e86c506a782415dfd6de1f78a0 Mon Sep 17 00:00:00 2001 From: Tom Cobb Date: Tue, 10 Aug 2021 09:17:27 +0100 Subject: [PATCH 2/2] Add test --- tests/sim_records.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/sim_records.py b/tests/sim_records.py index 18d86464..726eea97 100644 --- a/tests/sim_records.py +++ b/tests/sim_records.py @@ -42,6 +42,8 @@ def update_sin_wf(value): sin_wf.set(numpy.sin( numpy.linspace(0, 2*numpy.pi*sin_ph.get(), sin_len.get()))) sin_wf = Waveform('SIN', datatype = float, length = 1024) +# Check we can update its value before iocInit as per #22 +sin_wf.set([1, 2, 3]) sin_len = longOut( 'SINN', 0, 1024, initial_value=1024, on_update=update_sin_wf) sin_ph = aOut('SINP', initial_value = 0.0, on_update = update_sin_wf)