packstove Posted September 13, 2006 Report Share Posted September 13, 2006 Is there a way to stop a VI within an event structure once the Event structure is activated, or are you forced to wait untill the script within the event structure terminates itself. I have been trying to use event structures to initiate code, but I also need to be able to terminate the code based on user interface. But everytime I try to code the program the script will intiate and run correctly but I cannot interupt/stop it once the code begins. The buttons on the front panel will not respond. Is there a way to interrupt the code in an event structure? Quote Link to comment
Jacemdom Posted September 14, 2006 Report Share Posted September 14, 2006 Is there a way to stop a VI within an event structure once the Event structure is activated, or are you forced to wait untill the script within the event structure terminates itself. I have been trying to use event structures to initiate code, but I also need to be able to terminate the code based on user interface. But everytime I try to code the program the script will intiate and run correctly but I cannot interupt/stop it once the code begins. The buttons on the front panel will not respond. Is there a way to interrupt the code in an event structure? You will need 2 seperate loops in order to achieve your goal. I suggest you look at the different templates/framework available in LabVIEW via the starting dialog "VI From Template". Depending on your needs, select one of the design patterns. Producer/Consumer or Master/Slave Is there a way to interrupt the code in an event structure? I don't believe so... Quote Link to comment
mross Posted September 14, 2006 Report Share Posted September 14, 2006 Is there a way to stop a VI within an event structure once the Event structure is activated, or are you forced to wait untill the script within the event structure terminates itself. I have been trying to use event structures to initiate code, but I also need to be able to terminate the code based on user interface. But everytime I try to code the program the script will intiate and run correctly but I cannot interupt/stop it once the code begins. The buttons on the front panel will not respond. Is there a way to interrupt the code in an event structure? As a general rule you may not want to put much inside an event structure, or you may get the behavior you have noticed. At least avoid putting while loops inside or vi's that have while loops. The event won't stop and the loop won't iterate until all the event border outputs are filled. That's dataflow. Investigate the use of queues. Use the event structure to enqueue integer numbers (or enums) that correspond to cases in an separate loop. For example: A user event occurs and within the event an enqueue function puts a 1 in the queue, in the other loop is a dequeue function, when the number 1 appears in the queue it is dequeued to run the case called 1. Within that case you could queue up further numbers, 2, 3, 4 that correspond to other cases. Every time the dequeue and case loop interates another number is dequeued and its case runs. The queue functions as a FIFO in this basic manner. If at some point another user event occurs it then enqueues another number which waits its turn unitl all the prior queued numbers are dequeued used. You can queue up most anything that can be in a wire. Whatever you wire to enqueue pops out at the dequeue. A typical use is to have an Enum instead of just an integer to fire a case structure. All the Enum really does us give an verbal map to the numbers that are really the otuput of an enum. There are other details to using the queue like obtain queue, destroy queue, etc. The most common use for this would probably be the event driven producer consumer design pattern. You will love this once you get the hang of it. Mike Quote Link to comment
packstove Posted September 14, 2006 Author Report Share Posted September 14, 2006 Thanks Mike, Jacemdom, I'll look into both of your suggestions. Looks like I still have a lot to learn. Quote Link to comment
mross Posted September 15, 2006 Report Share Posted September 15, 2006 Thanks Mike, Jacemdom, I'll look into both of your suggestions. Looks like I still have a lot to learn. I needed a little utility to run a servo so I wrote it up using the forms I described earlier, and annotated it for your reading pleasure. Download File:post-48-1158345079.llb 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.