LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Nugget of the week: Dynamic event registration

Hi,

 

In the beginning I want to salute everybody and give us my sincere thanks for your help. After I want to expose my problem. I have the code you can see in the image enclose, like all the codes I see, I use a local variable (stop) to throw the event structure. I use the method "value change". I need change that local varible (stop) to a global variable (Parar medida) to throw the event structure.

 

To simplify I need throw the event structure with the method "value change" of a global variable. Can I make it? If I can make it, can use another method to throw the event structure with a global variable?

 

Bye.

0 Kudos
Message 31 of 77
(6,400 Views)

Here are some options:

  1. Use a timeout event. This is probably the easiest. You just wire a timeout value into the hourglass in the top left corner and then configure the Application>>Timeout event and in that event read the global.
  2. Use the methods shown earlier in the thread to get a reference to the global VI and then to the control on its FP. You can then use that reference to register for the value change event. To be honest, I have no idea if this will work, although it might.
  3. Create a global stop event reference and call that instead of the global. You can this by creating a VI which will work like this:

___________________
Try to take over the world!
0 Kudos
Message 32 of 77
(6,359 Views)

Hi,tst,

thank you, I will try your solution.

0 Kudos
Message 33 of 77
(6,334 Views)

Hi everyone, just getting back in the Labview saddle on 'event handling': forgive me but I've spent a few hours hands-on on trying to solve this problem and I just cannot see (or find) the fix: it is related to dynamic event registration for a calling vi to a sub-vi containing an event handler.

 

Aim: I want to set-up an event (a control value change) on a front panel which is then detected in a sub-vi running an event handler.

 

Main problem: My code is working but locking out the front panel of the calling vi ...permanently during execution of the sub-vi.

 

Initial Attempt: I have followed as best I can the tips for dynamic event registration as per the Labview 2009 examples: I use the details of the calling vi's current path to open up a vi reference code and then I register the events using the 'register for events' function where the event source is an array of my front panel control references.  I then pass the information for the control references to the sub-vi which contains an event handler set to detect a dynamic 'value change' in the calling vi front panel.  I've set the event handler up in a While loop (etc) and it detects the first change (great!!) but then it locks out the calling front panel (not great!).

 

Problem: so the coding works as planned and detects the front panel control value change on the calling vi but it then locks the front panel of the controlling vi and will not let it go!  I've tried many ways to unlock the panel but no such look.

 

Debug Attempts:

 

1) Unregistering the event (either inside or outside) of the while loop of the event handler in the sub-vi has no effect.

 

2) There is no check box option in the edit event handler option to 'unlock the front panel' - it is not shown at all for the 'edit event' on the dynamic value change

 

 

Accordingly, I'm a bit stumped at the moment and feel I'm missing an 'obvious' trick to unlock the front panel of the calling vi once the event is detected (...I'd like to be able to redetect another on the front panel....)

 

If anyone can help I'd be grateful - apols if its obvious or solved elsewhere.

 

Regards

 

Neil

0 Kudos
Message 34 of 77
(5,983 Views)

Neil,

 

Either Pictures or code, otherwise we're flying blind.....

 

Shane.

0 Kudos
Message 35 of 77
(5,977 Views)

Blueside wrote:

...it detects the first change (great!!) but then it locks out the calling front panel (not great!).

 

Problem: so the coding works as planned and detects the front panel control value change on the calling vi but it then locks the front panel of the controlling vi and will not let it go!  I've tried many ways to unlock the panel but no such look.

 

...

Neil


Set the "Lock Front Panel" when the event is registered.

 

Dynamic_Event.JPG 

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 36 of 77
(5,968 Views)

Ben,

 

You can set that for dynamically registered events?  I didn't know that.  But only for Events for actual Controls, right?

 

Shane.

0 Kudos
Message 37 of 77
(5,965 Views)

Intaris wrote:

Ben,

 

You can set that for dynamically registered events?  I didn't know that.  But only for Events for actual Controls, right?

 

Shane.


I didn't know it either unitl I read the post and and went looking for the "Enabel..." in the Event Dialog box. When I did not find it there I desperately started right-clicking to find out where ....

 

That porpoerty seems to be available for "Panel Resize" and other VI related events so it is not just the controls. Is that what you are asking?

 

The above is in LV 2009 in the event that the version makes a difference.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 38 of 77
(5,964 Views)

Hi Ben, Shane,

Hi Ben, Shane,

 

Great response guys!

 

It worked!! And trust me I right clicked everything on the screen...until you showed me exactly where to right-click.

 

I think this code / technique is quite important so I've attached my finished code as a bitmap (....I need to suss how to include it here as code etc...and will do so soon as)

 

 Thank you so much

 

Neil

PS: shane sorry for stupidly posting my reply into a tag field...its been that kind of day.

0 Kudos
Message 39 of 77
(5,952 Views)

Here is my current version of the code:  (note the very important right-click on the Reg Events 'Value Change' is not shown:!

 

image of event handler v1 jpeg.JPG

Message 40 of 77
(5,940 Views)