LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Causing an event in one VI when called from another

Hi All

 

I wonder if anyone could give me some advice on this. I have a VI, which displays the value of a text control, as a ‘value change’ event using an indicator. If I run this, having checked the ‘update will typing’ parameter for the control, the VI runs as expected and the indicator displays what I type. If I call the VI by reference from another and pass a string to the text control using the Set Control Value [Variant] method, the indicator remains blank, even though I can see the text control is being updated. I’m guessing this is because the event structure is expecting a user generated event which is no longer occurring. Is there any way to re-configure the code so that a value passed in this way, would be seen as an event? I've tried to get some idea from the Labview examples but not being too familiar with the way events work, I'm struggling to make sense of it. (I’m using Labview 7.1)

 

Thanks

Bruce

 

0 Kudos
Message 1 of 7
(3,239 Views)

Yes the event structure is waiting for the user to change the value.  However, there is a property node called Value(signaling), which will signal the event structure that the value has changed, just as if a user had done it himself.  You would have to pass a reference of the control/indicator to the subvi, and use the Value(signaling) property node in the subvi.  If you pass the reference, then you don't need the SetControlValue method.  The property node will take care of changing the value and signaling the event.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 7
(3,233 Views)

Hi Bruce,

 

This is absolutely correct,  LabVIEW does not generate events if you use the VI Server or variables to pragmatically update the front panel VI or objects. The only exception to this rule is the Value (Signaling) property.

 

I hope this helps.

 

Best Regards,

 

Christian Hartshorne

0 Kudos
Message 3 of 7
(3,210 Views)

Thanks tbob & Christian.

 

Can I just check this? I need to create a new control or indicator in the main VI and create a reference to it. This would then be passed to the subvi and I’m assuming, wired to the Value (signaling) property? If not, where should it go? I'm not too clear on this bit.

 

That said, I currently call the subvi from main, by reference. This was because I needed the subvi front panel to be visible before sending text to it. As I’m not passing any values via the connector pane, can the control/indicator reference still be passed?

 

Thanks

Bruce

0 Kudos
Message 4 of 7
(3,194 Views)

@knight2 wrote:

Thanks tbob & Christian.

 

Can I just check this? I need to create a new control or indicator in the main VI and create a reference to it. This would then be passed to the subvi and I’m assuming, wired to the Value (signaling) property? If not, where should it go? I'm not too clear on this bit.

 

That said, I currently call the subvi from main, by reference. This was because I needed the subvi front panel to be visible before sending text to it. As I’m not passing any values via the connector pane, can the control/indicator reference still be passed?

 

Thanks

Bruce


Yes, your first paragraph is correct.  Pass the ref to the subvi and use Value(Sgnl) property node in the subvi.  This causes an event for the control, and since it is a reference, the event gets carried to the source of the reference, which is in Main.

To pass control references (or any object) to a subvi that is called by reference, you can use the Call by Reference method as shown in the attached Main vi.  This allows you to pass items into and out of the subvi called by reference.  If you use the standard way and use GetControlValue and SetControlValue, I don't think you can cause an event in Main by changing a value in the subvi.  If you use the method in my vi, you can use the Value(Sgnl) property in the subvi to cause an event in the Main vi.  This is the only way I know how to send events from a subvi to the main.

 

Download the subvi first and put it in some directory.  Then download the main and put it in the same directory as the subvi.  Then when you open Main, it should find the subvi.

 

- tbob

Inventor of the WORM Global
Download All
0 Kudos
Message 5 of 7
(3,184 Views)

Thanks tbob. Could you possibly send your code again in LV7.1? (I’ve yet to upgrade). Reading your last post, I’d actually like to pass a string from the main VI and generate the event in the sub vi, to display it, rather than the other way round. The subvi I’d like to have running asynchronously and only close when I send a ‘close’ message or something to it. Is this possible?

 

Thanks

Bruce

0 Kudos
Message 6 of 7
(3,146 Views)

I don't have the ability to downconvert to 7.1.  Sorry,  You could save and post the vi's to the Downconvert VI Request thread.

 

What you are proposing can be done.  Put the event structure in the subvi.  To close the subvi, you can pass a reference to the main stop button.  In the subvi, you will have to continuously poll the reference and use a property node to get its value.  When you see a stop condition, stop the subvi.

- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 7
(3,135 Views)