01-20-2023 03:54 AM
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!
Solved! Go to Solution.
01-20-2023 04:33 AM
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…
01-20-2023 04:39 AM
Yeah, a key-value pair (eg: map) could be a solution to this this problem.
Thx!
01-20-2023 04:40 AM
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.
01-20-2023 07:52 AM
@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