This class accommodates all devices connected to the RevPi core (including itself). These are depicted as RevPiDevice objects or derived from them.
class RevPiDevicelist(procimg, list_devices, **kwargs)
procimg
Path to process imagelist_devices
Device list from piCtory configurationsyncoutputs
If True, the outputs from the process image are synchronizedkwargs
The following optional keyword parameters can be passed:auto_refresh
If true, add all devices to auto_refreshmonitoring
Inputs and outputs are read, never writtensimulator
Load the module as a simulator and exchange IOssyncoutputs
If true, output is loaded at instantiation
All values are passed to the RevPiModIO-class.
The following attributes are provided:
core
- Provides the RevPiCore() device for direct access.
length
- Contains the byte length of all devices
The following functions are provided:
auto_refresh(device, [remove=False])
device
RevPiDevice-object to be added for automatic process image updating. NOTE: Here, the name can also be passed as str () or the position as int (), the function then itself finds the appropriate RevPiDevice objectremove
If True, the specified device is removed from the automatic process image update. This parameter is set to False and must not be specified when adding.
exit([full=True])
Terminates the mainloop () and thus the event Monitoring.
full
If true, all devices from the auto_refresh () are also removed. This means that after the exit () call, read / write / updateprocimg (dev) functions can be executed and the main program can be terminated.
get_devbyname(name)
Returns the RevPiDevice-Object with the specified name.
get_devbyposition(position)
Returns the RevPiDevice-Object at a specified piCtory position.
get_refreshtime()
Returns the update rate of the automatic process image update in milliseconds.
mainloop([freeze=False, blocking=True])
Goes to the mainloop () with the program thread and waits for triggering events registered via RevPiDevice.reg_event.
freeze
If True, the process image update is paused until all event functions have been traversed. If outputs are set in these functions, they are written to the process image only after processing.blocking
If the parameter “blocking” is specified with False, this activates the event monitoring and does NOT block the program at the position of the call. Good for GUI programming, if events are required by the RevPi, but the program should be continued.
readprocimg([force=False, device=None])
For all devices, the current data of the ** INPUTS ** are read from the process image in its local buffer. This only applies to devices where RevPiDevice.autoupdate is set to True (this is the default value when instantiating)
force
If this value is true the buffer is also updated for devices where the autoupdate is set to False.device
Here, you can optionally specify a single device or a devicelist for which the process image should be read.
device="dio01" / device=32
device=["dio01", "dio02"] / device=[32, 33]
Applies only to devices that are NOT registered in auto_refresh ()!
set_refreshtime(millisecond)
millisecond
Sets the update rate of the process image to specified milliseconds.
A value between 10 and 2000 must be entered here. The default value is 50 milliseconds
setdefaultvalues([force=False, device=None])
Sets the default values for all devices from the value editor of piCtory. This only applies to devices where RevPiDevice.autoupdate is set to True (this is the default value when instantiating)
force
If this value is true the buffer is also updated for devices where the autoupdate is set to False.device
Here, you can optionally specify a single device or a devicelist for which the default values should be set.
device="dio01" / device=32
device=["dio01", "dio02"] / device=[32, 33]
Applies only to devices that are NOT registered in auto_refresh ()!
syncoutputs([force=False, device=None])
Reads for all devices the current data of the OUTPUTS from the process image in their local buffer. This only applies to devices where RevPiDevice.autoupdate is set to True (this is the default value when instantiating)
force
If this value is true the buffer is also updated for devices where the autoupdate is set to False.device
Here, you can optionally specify a single device or a devicelist for which the outputs should be synced.
device="dio01" / device=32
device=["dio01", "dio02"] / device=[32, 33]
This function can be useful after a program crash to find out the currently set Outputs.
Applies only to devices that are NOT registered in auto_refresh ()!
updateprocimg([force=False, device=None])
This is called first RevPiDevicelist.readprocimg (force, device) followed by RevPiDevicelist.writeprocimg (force, device)
Applies only to devices that are NOT registered in auto_refresh ()!
wait(device, io, **kwargs)
Waiting for an IO to change.
The value change is always checked if new data has been read for devices in RevPiDevicelist.auto_refresh().
RETURN VALUE: The return type is an integer value
- Waited successfully: <= 0
- 0: IO changed value
- -1: okvalue matched IO value
- Waited faulty: > 0
- 1: exitevent was set
- 2: reached timeout
- 100: RevPiModIO.devices.exit() was set
If the value is changed, the wait with the true return value is terminated. NOTE: If RevPiProcimgWriter () does not provide any new data, it will wait for eternity (not if “timeout” is specified).
If edge is specified with RISING or FALLING, this edge must be triggered. If the value should be 1 at the entry with edge RISING, the wait is only terminated with True if it is changed from 0 to 1. As exitevent, a threading.Event () object can be passed, which immediately terminates the wait at is_set () with a false return value. If the value okvalue is present at the input for the wait, the wait is immediately terminated with True return value. The time-out value immediately aborts the wait with a false return value. (The timeout is calculated over the cycle time of the auto_refresh function, so it does not exactly correspond to the specified milliseconds, it is always rounded upwards!)
device
Name, position, or RevPiDevice object on which the input is locatedio
Name or IO object to whose value change is to be maintainedkwargs
The following optional keyword parameters can be passed:edge
Edge RISING, FALLING or BOTH, where it’s ended by Trueexitevent
Thrading.Event () for premature termination with Falseokvalue
IO value at which the wait is immediately terminated with Truetimeout
Time in ms after it is aborted by False
writedefaultinputs(virtual_device)
Writes to a virtual device piCtory default input values.
virtual_device
Specify a single device or a devicelist for which the default values should be written.
If default values for inputs of a virtual device are specified in piCtory, they are only set during system startup or a piControl reset. If the process image is then overwritten with NULL, these values are lost. Use this function to restore them.
writeprocimg([force=False, device=None])
For all devices, write the current data of the OUTPUTS from the local buffer into the process image. This only applies to devices where RevPiDevice.autoupdate is set to True (this is the default value when instantiating)
force
If this value is true the buffer is also updated for devices where the autoupdate is set to False.device
Here, you can optionally specify a single device or a devicelist for which the process image should be written.
device="dio01" / device=32
device=["dio01", "dio02"] / device=[32, 33]
Applies only to devices that are NOT registered in auto_refresh ()!