LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass string from sub VI into main VI

I have a user event being created in a sub VI which produces a string command originating from my .NET DLL. This user event sits within a loop so that it can repeatedly act on events received - so the sub VI will never stop executing. I know that data is not passed via the output terminals until a VI stops executing, so I need another way of this event string being made available in the parent VI for processing as soon as the event occurs.

 

I have been able to update an indicator on my main VI with this string, using the method outlined here: https://decibel.ni.com/content/docs/DOC-6037

 

However, this is not suitable because I need to be able to use the string in logic (e.g. in a case structure) to decide what action needs taken. I need more than simply displaying the value in an indicator. Here is the steps I need:

 

1. Sub VI receives string via event from .NET DLL and keeps executing so that the next event is also caught (this part works)

2. Sub VI passes string directly to parent VI

3. Parent VI acts on string using case structure e.g. if the string is "Initialise", do X. If it is "Execute" do Y, and so on...

 

Thanks.

This is my 3rd post in a week - can you tell I'm new to this? Smiley Happy

0 Kudos
Message 1 of 5
(3,656 Views)

Consider a custom event:  You CREATE the event in the main loop and pass the event ID to the subVI.

The subVI does a GENERATE EVENT, using the event refnum and the string you want to pass.

The main loop has an EVENT structure.  Register to receive your custom event.

Then you get an EVENT case assigned to your custom event.

 

When the subVI generates the event, your main loop event will wake up and there's your string.

 

 

OR

 

 

Consider a NOTIFIER.

Same idea, basically:

Create a NOTIFIER in the main loop and pass the refnum to the subVI.

The subVI does a SEND NOTIFICATION, using the notifier refnum and the string.

The main loop does a WAIT ON NOTIFIER (use a zero timeout if you want), using the notifier refnum.

When the WAIT ON NOTIFIER comes back without a timeout, there's your string.

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 5
(3,645 Views)

Hi Chris,

 

instead of using references to update indicator in other VIs you should think about using notifiers or queues!

 

LabVIEW comes with example VIs and an Example Finder…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 5
(3,637 Views)

I am trying to implement Steve's first option with the event refnum. Can you please list what nodes I need? Thanks

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

Attached is an example.

Run the MAIN vi.

 

The subVI generates new events every few seconds (random) and the main vi catches the new data.

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 5 of 5
(3,598 Views)