sydney Posted October 30, 2009 Report Share Posted October 30, 2009 Normally, I would have a 'confirmation popup dialog' send out a T/F and use the value in my code to determine whether or not to really do something; however, in this particular case I really need to have the event in the sub VI passed to the calling VI for processing. In other languages an event that was not processed at one level would then be handled at the next upper level and so forth until at the application level. I am trying to do something similar where the calling VI actually handles the value change event, but do not know if this is even possible. Any ideas? Quote Link to comment
Daklu Posted October 30, 2009 Report Share Posted October 30, 2009 You can do this using User Events. First, I'm assuming your dialog box is running in a separate thread from the calling vi. If not, there's no reason to use events. There are several ways to accomplish what you want to do. Here's one way... If your dialog box is a single vi and you don't want to expand it beyond a single vi, the calling vi needs to create a User Event. Fork the User Event wire and pass one branch into the dialog vi as a parameter and the other branch into a Register For Events prim. Then wire the Event Registration Refnum into the Dynamic Events terminal of the calling vi's event structure. In the dialog vi, you have an event structure that fires on the value changed event. Inside that event case, wire the caller's User Event (that was passed in as a parameter) into a Generate User Event prim. When the value changed event on the dialog box fires, it will in turn fire an event in the caller's event structure. Quote Link to comment
FrankB Posted October 30, 2009 Report Share Posted October 30, 2009 Hi sydney, I'm pretty sure that there is not a solution for directly catching events from subs that where not handled by the subs themself. There may be many solutions to get aware in a calling VI of something that you do in sub VIs. But if you like to do it with an event here is a little example VI (screenshot only) for something that should do what you need. Uh, little bit to slow for that forum. Daklu posted a similar solution in his post Regards, Frank 1 Quote Link to comment
Daklu Posted October 30, 2009 Report Share Posted October 30, 2009 Daklu posted a similar solution in his post A picture is worth a thousand words. Since I only typed ~100 words your solution is 10 times better than mine. Quote Link to comment
sydney Posted October 30, 2009 Author Report Share Posted October 30, 2009 Hi sydney, I'm pretty sure that there is not a solution for directly catching events from subs that where not handled by the subs themself. There may be many solutions to get aware in a calling VI of something that you do in sub VIs. But if you like to do it with an event here is a little example VI (screenshot only) for something that should do what you need. Uh, little bit to slow for that forum. Daklu posted a similar solution in his post Regards, Frank Both solutions are quite good, but yours is exactly what I needed. Thanks, and enjoy your futbol... Quote Link to comment
FrankB Posted October 31, 2009 Report Share Posted October 31, 2009 A picture is worth a thousand words. Since I only typed ~100 words your solution is 10 times better than mine. Both solutions are quite good, but yours is exactly what I needed. Thanks, and enjoy your futbol... Thanks Quote Link to comment
_thomas Posted December 8, 2009 Report Share Posted December 8, 2009 Hi everyone, I have tried given example but without any success. I hope someone could point me in the right direction. First I execute subVI. I'm trying to detect "Event" indicator value change. After that, I can run test.vi without any warnings or errors. During vi execution, no events are detected. subVI.vi test.vi Quote Link to comment
jgcode Posted December 8, 2009 Report Share Posted December 8, 2009 Hi everyone, I have tried given example but without any success. I hope someone could point me in the right direction. First I execute subVI. I'm trying to detect "Event" indicator value change. After that, I can run test.vi without any warnings or errors. During vi execution, no events are detected. Hi Thomas A Value Change event is not fired by a control when you programmatically write to it (unless you write to the Val(Sign) property). If you change your "Event" Switch to a control (from an indicator), disconnect the logic and run your VIs your code will work when you manually change the state of the Switch! Additionally you may like to put some timing in the subVI.vi's while loop - unthrottled loops hog CPU resources. Cheers! Quote Link to comment
_thomas Posted December 9, 2009 Report Share Posted December 9, 2009 Hi Thomas A Value Change event is not fired by a control when you programmatically write to it (unless you write to the Val(Sign) property). If you change your "Event" Switch to a control (from an indicator), disconnect the logic and run your VIs your code will work when you manually change the state of the Switch! Additionally you may like to put some timing in the subVI.vi's while loop - unthrottled loops hog CPU resources. Cheers! Thanks, you have solved my problem This was only an example, I'll not use my subVI as it is Quote Link to comment
jgcode Posted December 9, 2009 Report Share Posted December 9, 2009 Thanks, you have solved my problem This was only an example, I'll not use my subVI as it is Cool! 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.