LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

call event from other event or other vi

I have LabVIEW 6.1.

1. Can I call an event or a serious of events from another event? How can I do that? It doesn't matter if the events are executed after the event that called them is completed.

2. Can I call an event from another vi? Let's say I have an event structure in a subvi. Can I trigger an event in the subvi calling it from the main vi? How would I do that?

Thanks for your help.

Jerome.
0 Kudos
Message 1 of 7
(3,229 Views)
Salutations,

In reality, a program should only have 1 event structure. Or so someone much more knowledgable with labview has told me in the past.

It's an important note to make that when running events or SubVi's, they will run until they are accomplished and then allow the next event or subvi to take place. So if you have multiple event structures, you must wait until one finished before the next one is run (This might...no guarantees, be avoided by multiple while loops and not locking the front panel on the execution of an event). Now, since you don't care, you can handle such a case. Just make multiple events in your one main event structure. I'm not sure what exactly you want to do, just make sure you "unfreeze" the front panel when you're messing with what handles what events.

Hence, you could have a "run" button that's pressed and it goes about it's business. Then you could have a mouse down response, that you hit while your "run" process is still going, this will be, in a sense, logged and accomplished once the "run" task is done. Now, if you're looking for data to trigger another event, maybe I'd switch over to a case structure that's inside your event structure. For case structures, every case must have an output.

Can you trigger an event in the subvi calling it from the main vi.... Excellent question... I'm not exactly sure when this would come up, but i'm not super experienced like some of the people around here. It may be possible, but i'd imagine a case structure would be more efficient. Like the ones in error handling. Pass the case to the subvi, it'll operate depending on what you want, and then continue along. Events seem most useful when dealing with events that occur on the front panel.

Hope this helps,
ElSmitho
0 Kudos
Message 2 of 7
(3,222 Views)
ElSmitho,

Thanks a lot for your response. I would like to explain more what I want to do:

I have a vi that contains an event structure. This vi allows me to do signal processing on a data set. I implemented the event structure because the signal processing comprises many different operation. Having the event structure in place allows me to have better control on each processing step.

Now, after I know how to set the processing parameters for a given type of data set I would like to automate the processing. But instead of writing a new vi that does all the processing at once, I would like to build a vi or another event that calls the events that do the processing in a specific way.

Thanks for all your feedback and inputs,

Jerome.
0 Kudos
Message 3 of 7
(3,217 Views)
If I remember correctly, dynamic events are not available in 6.1.
This means that you can't fire events programatically.
However, if you create a task handler (basically just a queue with it's own loop), which is fed by an event structure, you can also feed it from another source. Since, like ElSmitho said, having the code in your UI loop isn't the best strategy, this is a good idea regardless of whether or not you want to fire events. If you pass it to the subVI, there is no reason why you can't add a task to the queue from within the subVI.
Search this site for "queued task handler" for more data on this. You may even find examples in LV for how to do this.

___________________
Try to take over the world!
0 Kudos
Message 4 of 7
(3,211 Views)
Thanks for your reply. If I understand you correctly, you are suggesting to fill the queue of the event with elements, which would then in turn make the events execute one after the other.

I have never worked with queues and browsing through some sites I couldn't figure out how to set this up. Would you mind giving some guidelines how to implement a queue that is connected to the event structure and how to control the queue?

Thanks,

Jerome.
0 Kudos
Message 5 of 7
(3,201 Views)
My point was that you can't access or manipulate the event queue. You would have to do this without an event structure.
The Dequeue VI has a timeout setting which can be set to -1, or wait forever. This means that if you if you have a loop with it (that's the task handler), the loop will "pause" whenever the queue is empty, thus working like an event structure. You can feed "tasks" into the queue either from your event structure loop or from subVIs with no problems. Look at the queue examples shipped with LV to see how it works.

___________________
Try to take over the world!
0 Kudos
Message 6 of 7
(3,196 Views)
Thank you very much for your help.

Regards,

Jerome.
0 Kudos
Message 7 of 7
(3,173 Views)