horatius Posted November 5, 2008 Report Share Posted November 5, 2008 I have loops with long waiting periods. If I press a button the VI should stop the current waiting cycle and continue without passing of whole waiting time. I think it's possible with Event Structure but there must be an easier way to do this. Quote Link to comment
Karissap Posted November 6, 2008 Report Share Posted November 6, 2008 Instead of using the wait function or event structure you could use "Wait for front panel activity.vi" This will wait for a specified number of milliseconds or until the user interacts with the front panel (like pressing a button). Quote Link to comment
jdunham Posted November 6, 2008 Report Share Posted November 6, 2008 QUOTE (horatius @ Nov 4 2008, 05:19 PM) I have loops with long waiting periods. If I press a button the VI should stop the current waiting cycle and continue without passing of whole waiting time. I think it's possible with Event Structure but there must be an easier way to do this. We use queues and notifiers for this (they act the same way). You can have the notifier wait as long as you want (or forever), and then you can close or destroy it from another loop and it will stop waiting. We call this "scuttling" and we use it everywhere. You will want to filter error 1 and error 1122. Quote Link to comment
PaulL Posted November 6, 2008 Report Share Posted November 6, 2008 Why would you not want to use the event structure? Quote Link to comment
horatius Posted November 6, 2008 Author Report Share Posted November 6, 2008 QUOTE (Paul_at_Lowell @ Nov 5 2008, 04:43 PM) Why would you not want to use the event structure? then I have one frame more around my loop and the arrangement is becoming bigger and bigger and less clear but maybe someone has an easy solution Quote Link to comment
PaulL Posted November 6, 2008 Report Share Posted November 6, 2008 Hmm.... Well, I think in most cases the event structure is the way to go. I think it's worth learning to use it well before pursuing other approaches. Maybe it would be more beneficial for us to help you with your implementation of the event structure. I'm sure there are other opinions, though. Quote Link to comment
crossrulz Posted November 6, 2008 Report Share Posted November 6, 2008 OpenG has a good wait function that uses an Occurance if you'd rather not code it up yourself. I'd say the event structure would be the next easiest way to go. Quote Link to comment
Neville D Posted November 6, 2008 Report Share Posted November 6, 2008 QUOTE (horatius @ Nov 5 2008, 08:05 AM) then I have one frame more around my loop and the arrangement is becoming bigger and bigger and less clearbut maybe someone has an easy solution Maybe you should break up your code inside the loops into sub-VI's? You can't dump everything into the top-level VI. N. Quote Link to comment
horatius Posted November 6, 2008 Author Report Share Posted November 6, 2008 Ok, I surrender Has anyone an example with an Event Structure? Quote Link to comment
ooth Posted November 6, 2008 Report Share Posted November 6, 2008 I'm not sure if this will help but take a look at it. Quote Link to comment
B Chavez Posted November 6, 2008 Report Share Posted November 6, 2008 Would something like this work? It basically divides your long wait into many small waits, checking a control each time. Quote Link to comment
horatius Posted November 6, 2008 Author Report Share Posted November 6, 2008 Following the post of "ooth" I found the simplest solution. just an Event Structure with 2 cases time out case Event case Download File:post-11132-1225920945.vi Quote Link to comment
ooth Posted November 6, 2008 Report Share Posted November 6, 2008 horatius, I tried it that way first and had some problems. But now I went back and re-did your way and it works fine. I'm glad you found an easier way. Oh I remember what my problem was.... make sure you are not doing anything in the Timeout case because it only will get done every 10,000msec (or whatever you set the event time to). The way I made my example, you can see the time string update every sec but if you changed the timeout from 1000 to 10,000 then you would only see the string update once every 10sec! It's not a big deal if you are not doing anything in the timeout event but waiting, though. Quote Link to comment
Mark Smith Posted November 6, 2008 Report Share Posted November 6, 2008 How about this? Just one event case handles the user interaction and the timeout Mark Quote Link to comment
horatius Posted November 7, 2008 Author Report Share Posted November 7, 2008 yes this is easier how can I arrange both cases in one window, send me your vi! Quote Link to comment
ooth Posted November 7, 2008 Report Share Posted November 7, 2008 To add events to the same case:1. Right click on the event bar (where it says "Timeout")2. Select "edit events handled by this case"3. In the pop-up window press the blue + button4. then select the Stop control and pick "Value Change" (just like before)Now both event are in the same case Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.