Home AMX Forum NetLinx Studio
Options

Multiple WAIT_UNTIL on same variable

Spire_JeffSpire_Jeff Formerly Caffeinated Programmer
Anyone know how WAIT_UNTILs are evaluated? Take this example:
function1(){
  wait_until(bConnected){
    bConnected = 0;
    do something;
  }
}
function2(){
  wait_until(bConnected){
    bConnected = 0;
    do something;
  }
}
function3(){
  wait_until(bConnected){
    bConnected = 0;
    do something;
  }
}
button_event[dvTP,1]{
  push:{
    function1();
    function2();
    function3();
  }
}
timeline_event[tlComm]{// fires once every 10 seconds
  fnConnect(); //sets bConnect = 1 on successful connection
}

Will all three events fire at when the connection is made? If only one event fires, is the WAIT_UNTIL queue FIFO, LIFO, ....???? Any ideas?

Jeff

Comments

  • CT-DallasCT-Dallas Junior Member
    Can you do a quick test with send_string 0's in each of your waits?
  • Spire_JeffSpire_Jeff Formerly Caffeinated Programmer
    I could, but I wanted to be a lazy American and have someone give me the answer :)

    I will see if I can run a quick test and post the results.

    Jeff
  • Spire_JeffSpire_Jeff Formerly Caffeinated Programmer
    Ok, it seems that only 1 wait will fire each time the condition becomes true. (As I had hoped :) ). It also looks like the queue is FIFO. I pushed the button to queue all 3 and and fn1 executed first. I then pushed the button again and only fn1 was requeued because the other waits still existed. the next time connect went true, fn2 executed, then fn3, then fn1.

    Jeff
  • a_riot42a_riot42 AMX Wizard
    Spire_Jeff wrote: »
    Ok, it seems that only 1 wait will fire each time the condition becomes true. (As I had hoped :) ). It also looks like the queue is FIFO. I pushed the button to queue all 3 and and fn1 executed first. I then pushed the button again and only fn1 was requeued because the other waits still existed. the next time connect went true, fn2 executed, then fn3, then fn1.

    Jeff

    wait_untils are evil. A puppy dies every time you use one.
    Paul
  • Jimweir192Jimweir192 Junior Member
    Save the puppy!

    and who said programmers don't have a soft side!
  • ericmedleyericmedley Senior Member - 3709 Posts
    Jimweir192 wrote: »
    and who said programmers don't have a soft side!
    All sides of me are soft. I don't get away from my desk much nowadays.
  • DHawthorneDHawthorne Junior Member
    Guess I'm responsible for a lot of dead puppies.

    I use wait_until regularly for warm up times on equipment. I have a few simple rules to make sure they never cause me any trouble:

    1) Make absolutely sure what you are waiting for is really going to happen.
    2) Take another look at rule #1.
    3) Name your waits so they can be canceled and so they stack properly.
    4) Stick to very, very simple and SHORT timing situations. Anything even remotely complex should be in a timeline.

    I think that #3 is the issue for the OP. Name those waits and it should work as expected.
  • Spire_JeffSpire_Jeff Formerly Caffeinated Programmer
    DHawthorne wrote: »
    Guess I'm responsible for a lot of dead puppies.

    I use wait_until regularly for warm up times on equipment. I have a few simple rules to make sure they never cause me any trouble:

    1) Make absolutely sure what you are waiting for is really going to happen.
    2) Take another look at rule #1.
    3) Name your waits so they can be canceled and so they stack properly.
    4) Stick to very, very simple and SHORT timing situations. Anything even remotely complex should be in a timeline.

    I think that #3 is the issue for the OP. Name those waits and it should work as expected.

    I agree with 1, 2 & 4. 3 is situation dependent. In my case, I don't need to cancel the waits at any time so naming them is not necessary. Because I am calling them from functions, the wait is only created at one place in code so NetLinx will prevent multiple instances based on the default identifier.

    The way my actual code is written, the execution of the code inside the waits is conditional and if they do get executed out of order, it doesn't matter. Basically, I only send one command each time the web connection is opened. Step C is the important step, but step C requires that step A and step B have been done based on a specific part of Step C. The program tries to execute C as long as there are queued commands. They way it is written, it doesn't matter which order the functions are called because only the appropriate step will actually be executed. Upon execution, it kills the connected variable and ensures that only the one command is sent during the connection. I am sure that in a week or two I would be horrified with the complexity I have created and I might be able to rewrite it to be more human friendly, but at this point, it works reliably and does not seem to overload the processor, so I am temporarily happy with it :) It is actually a lot simpler than I am describing it, but there is some sensitive information involved and I have to be a little veiled at the moment ;)

    Jeff
Sign In or Register to comment.