class EventCallback

An instance of this class is passed to any event function, which is registered with .reg_event(…, as_thread=True) or .reg_timerevent(…, as_thread=True) for IOs.

revpimodio2.helper.EventCallback()

If event functions are created for event monitoring, they must accept a transfer parameter! In this example, it is called eventcallback, but it can also have ecb or other short names.

def my_function(eventcallback):
    # Name of the IO, which triggered this event
    eventcallback.ioname
    # Value of the IO, at the Trigger point
    eventcallback.iovalue
    # Simple 3 second wait time, without program blocking
    eventcallback.exit.wait(3)
Classattributes

  • .ioname
    Returns the Name of the IO, that triggered the event.

  • .iovalue
    Returns the value of the IO at the trigger time.

Classfunctions

.exit.wait(seconds)

Waits the specified time in seconds before the function continues.
NOTE: Unlike time.sleep(seconds), using .exit.wait(seconds) can abort wait by calling .stop(). You get a return value False (full time waited) or True (aborted), to control next steps in your code!


.exit.is_set()

Returns True if the .stop() function has been called for EventCallback. This is for the global termination of the execution.


.stop()

Sets the return value of .exit.is_set() to True, and aborts all .exit.wait(seconds) operations that will return True as the return value. With this method you can exit a loop, for example.

Example: Bennis Run – Threads in the mainloop()