mirror of
https://github.com/naruxde/revpimodio2.git
synced 2025-11-08 13:53:53 +01:00
docs: Add IO context manager description
Signed-off-by: Sven Sager <akira@narux.de>
This commit is contained in:
@@ -88,6 +88,17 @@ class IOList(object):
|
||||
io_del._parentdevice._update_my_io_list()
|
||||
|
||||
def __enter__(self):
|
||||
"""
|
||||
Read inputs on entering context manager and write outputs on leaving.
|
||||
|
||||
All entries are read when entering the context manager. Within the
|
||||
context manager, further .readprocimg() or .writeprocimg() calls can
|
||||
be made and the process image can be read or written. When exiting,
|
||||
all outputs are always written into the process image.
|
||||
|
||||
When 'autorefresh=True' is used, all read or write actions in the
|
||||
background are performed automatically.
|
||||
"""
|
||||
if self.__modio._looprunning:
|
||||
raise RuntimeError("can not start multiple mainloop/cycleloop/with sessions")
|
||||
self.__modio._looprunning = True
|
||||
@@ -96,6 +107,12 @@ class IOList(object):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
"""
|
||||
Write outputs to process image before leaving the context manager.
|
||||
|
||||
If 'autorefresh=True' is used, this operation is asynchronous. The
|
||||
outputs are automatically written in the background.
|
||||
"""
|
||||
self.__modio.writeprocimg()
|
||||
self.__modio._looprunning = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user