LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Clone specific FGV?

Solved!
Go to solution

Hi,

 

I have a "main" VI and a subVI having an FGV to store data. My main VI calls the subVI at a certain point to write the FGV and reads it somewhere else. It turned out that I need to make my main VI reentrant as we need to run multiple instances in parallel. The problem is that the FGVs should hold different values (based on the instance). If I keep the FGV non reentrant then each instance reads and writes the same FGV, so that wont work.

 

I'm wondering if it possible to somehow create an "instance specific" FGV or if must drop the FGV completely.

 

Thanks!

0 Kudos
Message 1 of 5
(1,293 Views)
Solution
Accepted by 1984

Hi 1984,

 


@1984 wrote:

I'm wondering if it possible to somehow create an "instance specific" FGV or if must drop the FGV completely.


You could "improve" your FGV to expect one more input value, which would indicate the calling instance. Internally the FGV would keep an array of data…

 

General suggestion: to handle several "objects" of the same data structure using several objects (of the same class) might come handy…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(1,276 Views)

Yeah, a key-value pair (eg: map) could be a solution to this this problem.

 

Thx!

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

The most conservative approach is to write a vi that will manage an indexed set of reentrant FGVs. This set could be static or even dynamic if you create instances on the fly and call them by reference. Each portion of your code would call the manager vi specifying the desired instance by index or other suitable identifier.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 4 of 5
(1,264 Views)

@1984 wrote:

Hi,

 

I have a "main" VI and a subVI having an FGV to store data. My main VI calls the subVI at a certain point to write the FGV and reads it somewhere else. It turned out that I need to make my main VI reentrant as we need to run multiple instances in parallel. The problem is that the FGVs should hold different values (based on the instance). If I keep the FGV non reentrant then each instance reads and writes the same FGV, so that wont work.

 

I'm wondering if it possible to somehow create an "instance specific" FGV or if must drop the FGV completely.Thanks!


Sure.  A number of years ago, I wrote a "monitoring" VI that had up to 24 "stations" with 24 video cameras connected to 24 sensors that would tell the camera when to take a video.  In my Project, I had a section for a Station, which was organized as a reentrant VI so that I could run up to 24 of them in parallel.  The "Station" section of the Project had a "Sensor", a "Camera", and a "Video" sub-section with the main VI (I called them names like "Loop Sensor", to remind myself that as far as the Station clone was concerned, these were parallel Loops specific to that Station that "ran forever" until the Station told them to stop, which it did when the caller told the Station to exit).  And the "trick" was that "Loop Sensor" was coded as a Pre-Allocated Clone, Reentrant Execution.  Worked like a charm (to my vast amazement, the first time I tested it ...).

 

Bob Schor

Message 5 of 5
(1,225 Views)