Skip to content

Commit d9ca6e4

Browse files
Add blocking flag and skeleton callback processing
1 parent 06d6b96 commit d9ca6e4

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

softioc/builder.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
LoadDbdFile(os.path.join(os.path.dirname(__file__), 'device.dbd'))
99

1010
from . import device, pythonSoftIoc # noqa
11+
# Re-export this so users only have to import the builder
12+
from .device import set_blocking # noqa
1113

1214
PythonDevice = pythonSoftIoc.PythonDevice()
1315

@@ -301,5 +303,7 @@ def UnsetDevice():
301303
'Action',
302304
# Other builder support functions
303305
'LoadDatabase',
304-
'SetDeviceName', 'UnsetDevice'
306+
'SetDeviceName', 'UnsetDevice',
307+
# Device support functions
308+
'set_blocking'
305309
]

softioc/device.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414
# dispatcher(func, *args) will queue a callback to happen
1515
dispatcher = None
1616

17+
# Global blocking flag, used to mark asynchronous (False) or synchronous (True)
18+
# processing modes for Out records.
19+
# Default False to maintain behaviour from previous versions.
20+
blocking = False
21+
22+
def set_blocking(val):
23+
global blocking
24+
blocking = val
25+
1726

1827
# EPICS processing return codes
1928
EPICS_OK = 0
@@ -142,6 +151,8 @@ def __init__(self, name, **kargs):
142151
else:
143152
self._value = None
144153

154+
self._blocking = kargs.pop('blocking', blocking)
155+
145156
self.__super.__init__(name, **kargs)
146157

147158
def init_record(self, record):
@@ -162,6 +173,13 @@ def init_record(self, record):
162173
recGblResetAlarms(record)
163174
return self._epics_rc_
164175

176+
def __completion(self):
177+
pass
178+
179+
def __wrap_completion(self, value):
180+
self.__on_update(value)
181+
self.__completion()
182+
165183
def _process(self, record):
166184
'''Processing suitable for output records. Performs immediate value
167185
validation and asynchronous update notification.'''
@@ -183,7 +201,7 @@ def _process(self, record):
183201
self._value = value
184202
record.UDF = 0
185203
if self.__on_update and self.__enable_write:
186-
dispatcher(self.__on_update, python_value)
204+
dispatcher(self.__wrap_completion, python_value)
187205
return EPICS_OK
188206

189207

0 commit comments

Comments
 (0)