PDA

View Full Version : Timer for experiment


Eugene
07-02-2016, 01:18 PM
Hi Jeff,

I'm using Vizard to run an experiment. I used viz.tick() to register a startTime for an action e.g. turn ON the power of a system. I added a delay for the simulation to complete the process. Recently, I added viz.pause and viz.play to my program so that I could pause the simulation at any time to ask questions. However, I realized that viz.tick() is still running even when I pause the simulation. As my progress bar update is based on viz.tick() it did not pause as I expected.

Is there ways to stop viz.tick() when I pause the program or would you recommends I use other methods to register my time.

Thank you.

def displayProcessTime():

global RemainingTime
global StartTime
global EstimatedTime
global Time

print 'displayProcessTime function'

if 'SHUTDOWN' not in instrList[currentStep[0]][0]:
StartTime = viz.tick()
EstimatedTime = StartTime + int(timing[instrument][1])
#RemainingTime = EstimatedTime - viz.tick()
else:
StartTime = viz.tick()
EstimatedTime = StartTime + int(timing[instrument][2])
#RemainingTime = EstimatedTime - viz.tick()

.....

while viz.tick() <= EstimatedTime:
print 'SSRMS PB'
yield viztask.waitTime(0.5)
UpdateProgressBar()
myBar.set(ProgressBarLevel)

Jeff
07-07-2016, 03:54 AM
Try using the viz.getFrameTime (http://docs.worldviz.com/vizard/#commands/viz/getFrameTime.htm) command. The frame time will not increase when viz.pause is called:

'''
Press 1 to play
Press 2 to pause
'''

import viz
import vizact
import vizinfo

viz.go()

vizinfo.InfoPanel()
viz.pause()

def printTime():
print viz.getFrameTime()

vizact.ontimer(0,printTime)
vizact.onkeydown('1',viz.play)
vizact.onkeydown('2',viz.pause)