IC8 Python API:RLPy RPyTimer
Contents
- 1 Description
- 2 Constructor & Destructor
- 3 Member Functions
- 4 Properties
Description
This class is used to setup a timed event. Use SetInterval and GetInterval to access and set the time interval. Use SetSingleShot and IsSingleShot to access and set the trigger state (single shot or repeatly trigger). Use Start, Stop, and IsRunning to control the execution of the Timer. In order to receive trigger events, first create a new class and inherit from RPyTimerCallback and register with RegisterPyTimerCallback. When not in use, you can unregister the timer event with UnRegisterPyTimerCallback. See Also: RPyTimerCallback.
Constructor & Destructor
__init__ (self)
Initializes a new py timer instance.
Member Functions
GetInterval (self)
Get the time interval for the event triggered by the timer in milliseconds. The default interval value is 0, which will cause the timer to start triggering immediately after Start. See Also: SetInterval
Sample code
Demonstrates calls to `RLPy.RPyTimer.GetInterval` and `RLPy.RPyTimer.SetInterval` using the example's inputs.
def run_script():
import RLPy
timer = RLPy.RPyTimer()
timer.SetInterval(1000)
print (timer.GetInterval()) # 1000
IsRunning (self)
Check if the Timer is currently running. See Also: Start, Stop
Sample code
Calls `RLPy.RPyTimer.IsRunning` with the inputs shown in the example.
def run_script():
import RLPy
timer = RLPy.RPyTimer()
timer.Start()
print (timer.IsRunning()) # True
IsSingleShot (self)
Get the Timer trigger settings. Return True if the trigger is single-shot and False for repeat trigger. See Also: SetSingleShot
Sample code
Demonstrates calls to `RLPy.RPyTimer.IsSingleShot` and `RLPy.RPyTimer.SetSingleShot` using the example's inputs.
def run_script():
import RLPy
timer = RLPy.RPyTimer()
timer.SetSingleShot(True)
print (timer.IsSingleShot()) # True
RegisterPyTimerCallback (self, pCallback)
Register a Callback object with the Timer. See Also: UnregisterPyTimerCallback
Parameters
- pCallback
SetInterval (self, nMSec)
Set the Timer trigger interval in milliseconds. The default interval value is 0, which will cause the timer to start triggering immediately after Start(). See Also: GetInterval
Parameters
- nMSec
Sample code
Calls `RLPy.RPyTimer.Stop` with the inputs shown in the example.
def run_script():
import RLPy
timer = RLPy.RPyTimer()
timer.SetInterval(100)
timer.Start()
# do something
timer.Stop()
Sample code
Demonstrates calls to `RLPy.RPyTimer.GetInterval` and `RLPy.RPyTimer.SetInterval` using the example's inputs.
def run_script():
import RLPy
timer = RLPy.RPyTimer()
timer.SetInterval(1000)
print (timer.GetInterval()) # 1000
Sample code
Calls `RLPy.RPyTimer.Start` with the inputs shown in the example.
def run_script():
import RLPy
timer = RLPy.RPyTimer()
timer.SetInterval(100)
timer.Start()
SetSingleShot (self, bSingleShot)
Set the Timer trigger state. Single-shot will only fire off the trigger event once, otherwise the event will fire off according to the Timer interval. The default setting is False. See Also: IsSingleShot
Parameters
- bSingleShot
Sample code
Demonstrates calls to `RLPy.RPyTimer.IsSingleShot` and `RLPy.RPyTimer.SetSingleShot` using the example's inputs.
def run_script():
import RLPy
timer = RLPy.RPyTimer()
timer.SetSingleShot(True)
print (timer.IsSingleShot()) # True
Start (self)
Start or restart the Timer. If the Timer is already running, then this operation will stop the Timer first then start it again. If the trigger is set to single-shot then the Timer event will activate one more time.
Sample code
Calls `RLPy.RPyTimer.Stop` with the inputs shown in the example.
def run_script():
import RLPy
timer = RLPy.RPyTimer()
timer.SetInterval(100)
timer.Start()
# do something
timer.Stop()
Sample code
Calls `RLPy.RPyTimer.Start` with the inputs shown in the example.
def run_script():
import RLPy
timer = RLPy.RPyTimer()
timer.SetInterval(100)
timer.Start()
Sample code
Calls `RLPy.RPyTimer.IsRunning` with the inputs shown in the example.
def run_script():
import RLPy
timer = RLPy.RPyTimer()
timer.Start()
print (timer.IsRunning()) # True
Stop (self)
Stop the Timer.
Sample code
Calls `RLPy.RPyTimer.Stop` with the inputs shown in the example.
def run_script():
import RLPy
timer = RLPy.RPyTimer()
timer.SetInterval(100)
timer.Start()
# do something
timer.Stop()
UnregisterPyTimerCallback (self)
Unregister the Callback object for the Timer. See Also: RegisterPyTimerCallback
Properties
thisown
Indicates whether this SWIG proxy owns the underlying C++ object.