Jump to content

event handling


sydney

Recommended Posts

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?

Link to comment

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.

Link to comment

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.

post-16630-125691014297_thumb.png

Uh, little bit to slow for that forum. Daklu posted a similar solution in his post :)

Regards,

Frank

  • Like 1
Link to comment

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.

post-16630-125691014297_thumb.png

Uh, little bit to slow for that forum. Daklu posted a similar solution in his post smile.gif

Regards,

Frank

Both solutions are quite good, but yours is exactly what I needed. Thanks, and enjoy your futbol...

Link to comment
  • 1 month later...

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.

post-16813-126026883592_thumb.png

After that, I can run test.vi without any warnings or errors. During vi execution, no events are detected.

post-16813-126026889573_thumb.png

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!

Link to comment

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 :worshippy: This was only an example, I'll not use my subVI as it is :rolleyes:

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.