Using Timers
Using Timer
The Timer class allows you to specify a function that is called at regular intervals
This is used when you need to wait for a process to complete before moving to the next steps. In some screen scripts, you may need to wait for the data source to be fully loaded before you add your customisation.
Timers are a UI script only thing - view scripts can't use them.
ui.setTimeout or ui.addTimer are the preferred functions.
Please refer to the timer.html document in the vi69A/Doc folder in timer.html
Timer example
def btnTest_Click(self):
timer = UI.addTimer(self,"mytimer") #returns a Timers object
timer.setTimeout(5000) #setTimeout returns nothing.
timer.setOnTimer(onTimer)
return
def onTimer(self):
showMessageBox("timer fired")
For an example on how to use Timer , you can look at the VI1011.py in the VIxxA folder.
The VI Modules screen does that to delay loading the bottom grid. Each the row in the top grid changes, it calls setTimeout again with the same timer ID (eg "timer1"). Since it is the same id it cancels the previous timer and starts a new one.
Most of the time, you'd use something like this:
Example from VI1011 Extender Module
self.setTimeout(300, self.onTimerCallback, "timer1")
def onModuleChangedTimer(self):
# do something