WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-02-2010, 08:52 PM
GiudiceLab GiudiceLab is offline
Member
 
Join Date: May 2009
Location: Orono, ME
Posts: 49
Unhappy Timer event in viztask

I am trying to detect when a timer has expired in order to capture the time it takes a person to respond to a change. Using viztask, my code looks something like
Code:
# Start a timer
viz.starttimer(0, 1, viz.PERPETUAL)

# define our changing function
def changeThing():
        # change the thing
        thing = thing + change

# Register the timer callback
viz.callback(viz.TIMER_EVENT, changeThing)

# Define the experimental loop
def experiment():
	# Initialize trial number
	trial = 1
	# Wait for spacebar to begin experiment
	yield viztask.waitKeyDown(' ')
	while trial <= numTrials:
		# Update the instructions
		msgbox.message('Trial ' + str(trial))
		# Wait for the timer
                yield viztask.waitEvent( viz.TIMER_EVENT )
		# Wait for response
		yield viztask.waitKeyDown(' ')
		# Increment the trial number
		trial = trial + 1

# Schedule the experiment
viztask.schedule( experiment() )
which I thought would work, but never gets past the waitEvent. I have tried using a timer callback and vizact.ontimer, but neither works to move the script forward (although the function that is called with the timer works fine). Am I doing something wrong, or is this not possible to do? Or do I need a different approach? This was supposed to be a simple example for class, and I don't want to cover custom events yet. Any help is appreciated.
Thanks!
__________________
Virtual Environments and Multimodal Interaction (VEMI) Lab

This time, it should work...
Reply With Quote
  #2  
Old 10-07-2010, 01:14 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Timer events behave differently than all other events. They are only sent to the event handler that started the timer. Also, waiting for any timer event doesn't seem very useful, since a lot of other vizard modules use timer events internally.

I would suggest using viztask.Signal objects. The documentation contains sample code for using task signals. The following code shows how to create a task signal:
Code:
timer_signal = viztask.Signal()
In your timer callback you can trigger the signal:
Code:
timer_signal.send()
And in your task you can wait for the signal to be triggered using this code:
Code:
yield timer_signal.wait()
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
timer question again Elittdogg Vizard 3 10-18-2007 11:29 AM
Timer speed Jerry Vizard 1 12-08-2006 12:01 PM
sending event markers to a monitoring computer mikestatic Vizard 3 01-26-2006 10:23 AM
Elapse timer astull Vizard 1 12-14-2005 12:34 PM
Timer event documentation pkhoosh Vizard 1 10-21-2005 11:12 AM


All times are GMT -7. The time now is 08:50 AM.


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