LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Opening Re-entrant sub VI front panel from main Vi front panel.

Hi all,

 

I'm relatively new to Labview (have been using it a while but not done anything particularly challenging yet!) so my approach may not be correct. I have created a VI that reads input from a data channel on a cRIO and then logs it to an excel sheet and I'm pleased that it is working as intended. This VI only logs a single channel however and for the final version of this program I will need to log 150 channels simultaneously and display the data on a front panel (data includes channel no., a plot, and a couple of Boolean indicators and is also where you input channel name and formulate the log file path). The other key requirement is that you must be able to stop, start, rename, and restart logging on each channel, essentially allowing you to hot-swap the input source to a new log file without affecting other channels. 

 

Essentially I want to copy and paste my code 150 times with the front panel to create the program but obviously that isn't ideal as if I need to change the logging code then all channels will need changing manually. I have created the logging VI as a re-entrant subVI and copy pasted that and the program works as intended. The issue is that I have no way of opening the re-entrant VI front panels where the graphs and certain parameters are located during run time. I can open them by double clicking from the block diagram but that obviously wont be available / suitable during program run time. Using the invoke node I can make the subVI show /  hide the front panel however this affects all clones of that subVI at once and not the specific clone I want to target.

 

First question: How can I display / hide the reentrant subVI front panel for a specific clone at will? 

Second question: Is this an XY problem - is there a better way of doing this and am I making this more difficult for myself?

0 Kudos
Message 1 of 6
(2,092 Views)

@EChamberlain wrote:

First question: How can I display / hide the reentrant subVI front panel for a specific clone at will? 


Either make the reentrant subVIs communicate their reference to the main VI (queue, DVR, channel wire, …) OR start those VIs dynamically, and keep the reference.

 

I'd prefer the first option, as dynamically starting VIs makes some things harder. It's not easy getting clone references when you lost then for instance, so stopping all clones when the main stopped can be a pain.

 

However, putting 150 reentrant subVIs on the main seems a bit excessive... If you have to add one input to it (for instance a queue reference (yes, you can do that by name (but you shouldn't))), you'd be wiring 150 inputs. Not ideal.

 


@EChamberlain wrote:

Second question: Is this an XY problem - is there a better way of doing this and am I making this more difficult for myself?


I'd make a class, and initialize 150 objects from it. Then call the 'run' method in a parallel for loop.

 

Others will probably recommend actor framework. Each 'logging VI' ('acquire VI' afaic) would be an actor.

 

There are thousand ways to do this. Noting wrong with your way.

0 Kudos
Message 2 of 6
(2,070 Views)

wiebe@CARYA wrote:
make the reentrant subVIs communicate their reference to the main VI

How would I go about doing this? I assume I would create a reference output from the SubVI back to the main and use that to open and close the front panel but how do I get that reference from the clone? 

0 Kudos
Message 3 of 6
(2,056 Views)

@EChamberlain wrote:

wiebe@CARYA wrote:
make the reentrant subVIs communicate their reference to the main VI

How would I go about doing this? I assume I would create a reference output from the SubVI back to the main and use that to open and close the front panel but how do I get that reference from the clone? 


Queue, DVR, channel wire, …

0 Kudos
Message 4 of 6
(2,049 Views)

wiebe@CARYA wrote:

@EChamberlain wrote:

First question: How can I display / hide the reentrant subVI front panel for a specific clone at will? 


Either make the reentrant subVIs communicate their reference to the main VI (queue, DVR, channel wire, …) OR start those VIs dynamically, and keep the reference.


I have had a lot of success with option 2.  Just use a simple FOR loop to launch all of the clones and auto-index their reference.  Of course, I would probably use a Map to hold the references now that 2019 is out.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(2,026 Views)

@crossrulz wrote:

wiebe@CARYA wrote:

@EChamberlain wrote:

First question: How can I display / hide the reentrant subVI front panel for a specific clone at will? 


Either make the reentrant subVIs communicate their reference to the main VI (queue, DVR, channel wire, …) OR start those VIs dynamically, and keep the reference.


I have had a lot of success with option 2.  Just use a simple FOR loop to launch all of the clones and auto-index their reference.  Of course, I would probably use a Map to hold the references now that 2019 is out.


Or an array if you just want the (ordered) references.

 

Biggest problem I have with dynamically started VIs is that once you lose the references (stop the main), the VIs keep dangling in memory. Stopping them isn't easy, as there is no way to get the clone references of those VIs.

 

This can on the other hand be very convenient. For instance, I start my program, load and initialize some things, etc. That takes time. But I don't have to do this every time, as I can edit other dialogs because they are started dynamically.

 

Just saying: choose carefully. There are ups and downs to each method.

0 Kudos
Message 6 of 6
(2,000 Views)