Difference between revisions of "IC Python API:RLPy RPyTimer"

From Reallusion Wiki!
Jump to: navigation, search
(Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Modules|Modules}} == Detailed Description == This class provides repetitive and single-shot timers. <syntaxhighlight lang="Python"> cl...")
 
m
Line 26: Line 26:
  
 
</syntaxhighlight>
 
</syntaxhighlight>
==Member Functions==
+
== Member Functions ==
===GetInterval===
+
=== GetInterval ===
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
 
RLPy.RPyTimer.GetInterval ( self )
 
RLPy.RPyTimer.GetInterval ( self )
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Get timer interval value.
 
Get timer interval value.
====Returns====
+
==== Returns ====
<div style="margin-left: 2em;">Timer interval in milliseconds - int
+
<div style="margin-left: 2em;">
 +
Timer interval in milliseconds - int
 
</div>
 
</div>
 
-----
 
-----
===IsRunning===
+
=== IsRunning ===
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
 
RLPy.RPyTimer.IsRunning ( self )
 
RLPy.RPyTimer.IsRunning ( self )
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Check if the timer is running.
 
Check if the timer is running.
====Returns====
+
==== Returns ====
<div style="margin-left: 2em;">True if the timer is running; otherwise returns false - bool
+
<div style="margin-left: 2em;">
 +
True if the timer is running; otherwise returns false - bool
 
</div>
 
</div>
 
-----
 
-----
===IsSingleShot===
+
=== IsSingleShot ===
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
 
RLPy.RPyTimer.IsSingleShot ( self )
 
RLPy.RPyTimer.IsSingleShot ( self )
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Get timer single shot status.
 
Get timer single shot status.
====Returns====
+
==== Returns ====
<div style="margin-left: 2em;">Is timer single shot or not - bool
+
<div style="margin-left: 2em;">
 +
Is timer single shot or not - bool
 
</div>
 
</div>
 
-----
 
-----
===RegisterPyTimerCallback===
+
=== RegisterPyTimerCallback ===
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
 
RLPy.RPyTimer.RegisterPyTimerCallback ( self, pCallback )
 
RLPy.RPyTimer.RegisterPyTimerCallback ( self, pCallback )
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Register timer event callback.
 
Register timer event callback.
====Parameters====
+
==== Parameters ====
 
<div style="margin-left: 2em;">
 
<div style="margin-left: 2em;">
 
 
'''pCallback''' [IN] pointer of timer callback object - RLPy.RPyTimerCallback
 
'''pCallback''' [IN] pointer of timer callback object - RLPy.RPyTimerCallback
 
</div>
 
</div>
 
-----
 
-----
===SetInterval===
+
=== SetInterval ===
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
 
RLPy.RPyTimer.SetInterval ( self, nMSec )
 
RLPy.RPyTimer.SetInterval ( self, nMSec )
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Set timer interval value.
 
Set timer interval value.
====Parameters====
+
==== Parameters ====
 
<div style="margin-left: 2em;">
 
<div style="margin-left: 2em;">
 
 
'''nMSec''' [IN] timer interval in milliseconds - int
 
'''nMSec''' [IN] timer interval in milliseconds - int
 
</div>
 
</div>
 
-----
 
-----
===SetSingleShot===
+
=== SetSingleShot ===
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
 
RLPy.RPyTimer.SetSingleShot ( self, bSingleShot )
 
RLPy.RPyTimer.SetSingleShot ( self, bSingleShot )
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Set timer single shot status.
 
Set timer single shot status.
====Parameters====
+
==== Parameters ====
 
<div style="margin-left: 2em;">
 
<div style="margin-left: 2em;">
 
 
'''bSingleShot''' [IN] timer single shot status - bool
 
'''bSingleShot''' [IN] timer single shot status - bool
 
</div>
 
</div>
 
-----
 
-----
===Start===
+
=== Start ===
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
 
RLPy.RPyTimer.Start ( self )
 
RLPy.RPyTimer.Start ( self )
Line 93: Line 93:
 
Start the timer.
 
Start the timer.
 
Starts or restarts the timer. If the timer is already running, it will be stopped and restarted.
 
Starts or restarts the timer. If the timer is already running, it will be stopped and restarted.
 +
-----
 +
=== Stop ===
 +
<syntaxhighlight lang="Python">
 +
RLPy.RPyTimer.Stop ( self )
 +
</syntaxhighlight>
 +
Stop the timer.
 +
-----
 +
=== UnregisterPyTimerCallback ===
 +
<syntaxhighlight lang="Python">
 +
RLPy.RPyTimer.UnregisterPyTimerCallback ( self )
 +
</syntaxhighlight>
 +
Unregister timer event callback.

Revision as of 21:29, 4 July 2019

Main article: Modules.

Detailed Description

This class provides repetitive and single-shot timers.

class MyPyTimerCallback(RLPy.RPyTimerCallback):
 def __init__(self):
   RLPy.RPyTimerCallback.__init__(self)

 def Timeout(self):
   print ("timeout")

# set timer
timer = RLPy.RPyTimer()
timer.SetInterval(100)
timer.SetSingleShot(True)
print(timer.GetInterval()) # 100
# register callback
timer_callback = MyPyTimerCallback()
timer.RegisterPyTimerCallback(timer_callback)
# start timer
timer.Start()
...
# unregister callback
timer.UnregisterPyTimerCallback()

Member Functions

GetInterval

RLPy.RPyTimer.GetInterval ( self )

Get timer interval value.

Returns

Timer interval in milliseconds - int


IsRunning

RLPy.RPyTimer.IsRunning ( self )

Check if the timer is running.

Returns

True if the timer is running; otherwise returns false - bool


IsSingleShot

RLPy.RPyTimer.IsSingleShot ( self )

Get timer single shot status.

Returns

Is timer single shot or not - bool


RegisterPyTimerCallback

RLPy.RPyTimer.RegisterPyTimerCallback ( self, pCallback )

Register timer event callback.

Parameters

pCallback [IN] pointer of timer callback object - RLPy.RPyTimerCallback


SetInterval

RLPy.RPyTimer.SetInterval ( self, nMSec )

Set timer interval value.

Parameters

nMSec [IN] timer interval in milliseconds - int


SetSingleShot

RLPy.RPyTimer.SetSingleShot ( self, bSingleShot )

Set timer single shot status.

Parameters

bSingleShot [IN] timer single shot status - bool


Start

RLPy.RPyTimer.Start ( self )

Start the timer. Starts or restarts the timer. If the timer is already running, it will be stopped and restarted.


Stop

RLPy.RPyTimer.Stop ( self )

Stop the timer.


UnregisterPyTimerCallback

RLPy.RPyTimer.UnregisterPyTimerCallback ( self )

Unregister timer event callback.