WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Timer for experiment (https://forum.worldviz.com/showthread.php?t=5778)

Eugene 07-02-2016 01:18 PM

Timer for experiment
 
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 command. The frame time will not increase when viz.pause is called:

Code:

'''
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)



All times are GMT -7. The time now is 11:39 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC