wait on a condition

PennController for IBEX Forums Support wait on a condition

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #7095
    samsanto
    Participant

    Hi Jeremy,

    I am having difficulty figuring out how to wait() on a specific condition. Basically I have a long audio file playing in my study. At random times, it pauses and the participant has to answer a question in the form of choosing from 3 images in a selector. Then the audio immediately resumes. If they take more than 30 seconds, the audio will resume and no response is recorded. I am having difficulty figuring out the logic to this “wait,” as I want to wait on the selector OR 30 seconds. This is what I have so far, which I feel like is close, but is not working for the 30 seconds part (only the selection):

    
    newTimer("waitSelector", 30000) 
    .start()
    ,
    newSelector("images").add( getImage("on"), getImage("mid"), getImage("off"))
    .log()
    .wait(getTimer("waitSelector").test.running() && !getSelector("images").test.selected())
    ,
    

    Here’s my demo link if that will help: https://farm.pcibex.net/r/PRLnQL/

    Thanks,
    Sam

    #7097
    Jeremy
    Keymaster

    Hi Sam,

    PennController’s top-down write-and-execute style makes this kind of disjunctive logic a little tricky. In your case, I suggest you just wait for the Timer element, and have the Selector element halt the timer upon selection:

    newSelector("images")
      .add( getImage("on"), getImage("mid"), getImage("off"))
      .log()
      .callback( getTimer("waitSelector").stop() )
    ,
    newTimer("waitSelector", 30000) 
      .start()
      .wait()
    

    Also, you cannot use javascript’s ! operator on PennController commands (see this guide). If you want to negate a test, just replace test with testNot

    Jeremy

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.