LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

programmatically fire an event in a subvi

I have a subvi with an event structure in a while loop. The event I'm interested in is controlled by a boolean. I want to have a boolean in my top level vi fire the event in the subvi. Can this be done?

I have attached an example.
0 Kudos
Message 1 of 5
(3,204 Views)
In your sub-vi, you need to open a vi reference to the toplevel vi. Then use the GetControlValue method to get the value of the boolean. Put this in your loop to constantly get the control's value. Now for the problem. Normally you wire the value to the value(Signaling) property to fire the event. However, since you are constantly looping and reading the value, the event fires on every loop. You may have to replace the event structure with the old time poll method. Use a case structure to execute the desired code when the boolean is TRUE. Or just put a case structure inside the event. The event will fire on every loop, but the desired code would only execute on TRUE. Since you have to poll for the toplevel boolean, there is no other way that I can think of to set off the event. Why not put the event structure in the toplevel vi, and call the sub-vi from there.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 5
(3,194 Views)
Because I'm not really using a top level vi in the actual application. I'm using TestStand to call the VI and I set the value of the "Test" boolean in TestStand with a local variable. Since TestStand uses the connector pane to interface with the vi the example is essentially the same.

I'm confused about the value(signaling) property. It is a write only property. In that case how can I get the event case to read the value?
0 Kudos
Message 3 of 5
(3,186 Views)
Value(Signaling) not only allows you to write a value to a control, it also sends a Value Change signal for events. The Value property does not send the event signal. If you are calling the vi from TestStand, your vi will not be waiting for an operator to press a button before execution. It really makes no sense to use an event structure in this case. There is no event taking place (user clicking on a button, mouse moves, etc). It would be better to use a case structure and use the boolean input from TestStand to determine the case. Put your code in the True case. If you need the event structure for other matters, you can still have the event structure alongside the case structure.
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 5
(3,181 Views)
TestStand is not quite the same. If you intend to start the VI as a step and then change the Boolean in TestStand while the step is running, I think what you'll have to do is more than just set a TestStand variable. What I would try is using VI Server to open a reference to the running VI and then use the method Set Control Value (Variant). And as Tbob mentions, using an event structure in your VI doesn't make much sense.
0 Kudos
Message 5 of 5
(3,179 Views)