LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fire events with run-time menu

Hi,

I developed an application based on an event structure. Almost all the events are fired when their corresponding controls are modified. I’d like now to alternatively fire an event by selecting an item in the run-time menu. 

 

In the ‘Menu Selection with Events.vi’ example the selection of any item in the run-time menu fires the event 0 (specifier menu selection (user)). Inside that event 0 according to the item a function is executed.

 

Is is possible to point out to another event instead? Or is possible to add the selection a menu item (or sub menu item) to fire an event that is usually fired when a the value of a control changes?

 

I enclose a VI and its .rtm file (LabVIEW 8.0)

Thanks,

Charly

It's always sunny in California! Certified LabVIEW Associate Developer!
0 Kudos
Message 1 of 5
(3,291 Views)
You can't automatically re-route events. You have to program it.

You can put a value (signalling) event in the menu activation event. So
you'd make a case selector inside the event case, to check which menu is
selected. In each case you read the value of the control who's event you
want to trigger. Put this value in the value (signalling) property. This
doesn't do anything, since the value you wirte is the same as the value is
had! But it will trigger the value change event. In the value change event
you can distinguage between "real" changes and programmatically generated
events by comparing the old and new value.

If you want to trigger other events then the value change event, it gets
more complicated. You have to make user events. Then, in the event in
question, generate the user event, and do the same in the menu activation.

Regards,

Wiebe.


Message 2 of 5
(3,264 Views)
This is to shine light on Wiebe response, here how you can do it:
yet, this mode of operation works with switching booleans, not with latching (you cannot set the value of a latch indefinitely). therefore you will also need to implement a prgramatic latching solution (e.g. after 200ms return value to false).
a more involved, but better solution would be to register the events.
 

Message Edited by Gabi1 on 10-08-2007 02:31 PM

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
Message 3 of 5
(3,251 Views)
>
> MenuEventStructure.png:
> http://forums.ni.com/attachments/ni/170/276682/1/MenuEventStructure.png

Gabi1,

You are right, you can set the value (signaling) with a latched boolean. And
you're workaround to use a switching boolean is the only solution (well, you
could use a dummy control, and add it's change event to the boolean's change
event, but it's less transparent).

But since you have a value change event, why not reset the switching boolean
to it's old value in the value change event? That way, you get the exact
behavior as a latched boolean.

Regards,

Wiebe.


0 Kudos
Message 4 of 5
(3,250 Views)

Hi Wiebe and Gabi1,

It's nice to read your posts.

I updated my code as you guys advised me. I defined one case (into a case selector) per menu item. Each case reads the value of the corresponding control and writes the same value as previously. You are right Wiebe it doesn't do anything but it is clever and it triggers the control.

That trick doesn't work with latch booleans so it's necessary to change the mechanical action of the control for a swichting boolean. Then it needs to reset the switching boolean value to get the behaviour of a latch boolean.  

It works great thanks!

Charly

 

It's always sunny in California! Certified LabVIEW Associate Developer!
0 Kudos
Message 5 of 5
(3,234 Views)