08-08-2024 11:46 AM
Hello,
I have developed a QUEUE based architecture which I have made it as PREALLOCATED CLONE REENTRANT EXECUTION . Name of the engine is <DEMO_ENGINE_TRIALS.vit> . I want to run 15 instances of this engine, therefore I have made it as a clone. This Clone engine has a FGV called <DEMO_LV2G.vi>. I have made another 2 vi's viz: <FIRST CLIENT.vi> and <SECOND CLIENT.vi> .
My requirement is that, when the Clone engine starts. i.e when First and Second Client opens the 2 instances of the DEMO_ENGINE_TRIALS, and when i change the state of the switch in the clone engine, the FGV inside should update the status in calling VI
Currently, when I am turning the state in the clone engine, the FGV is updating the data in both the calling vi's , which is undesirable
Attached is the code. This is not my actual code. But I have tried to express my issue through this demo.
In my actual code, I have a Main.vi which has 15 consumers and each consumer will call the clone CAN_ENGINE's i.e <15 clones will be called> and the status of the CAN should get updated in the calling consumer loop.
Open G is required to be installed to run this code
08-08-2024 12:09 PM - edited 08-08-2024 12:10 PM
@VihangPatil wrote:
Hello,
I have developed a QUEUE based architecture which I have made it as PREALLOCATED CLONE REENTRANT EXECUTION . Name of the engine is <DEMO_ENGINE_TRIALS.vit> . I want to run 15 instances of this engine, therefore I have made it as a clone. This Clone engine has a FGV called <DEMO_LV2G.vi>. I have made another 2 vi's viz: <FIRST CLIENT.vi> and <SECOND CLIENT.vi> .
My requirement is that, when the Clone engine starts. i.e when First and Second Client opens the 2 instances of the DEMO_ENGINE_TRIALS, and when i change the state of the switch in the clone engine, the FGV inside should update the status in calling VI
Currently, when I am turning the state in the clone engine, the FGV is updating the data in both the calling vi's , which is undesirable
Attached is the code. This is not my actual code. But I have tried to express my issue through this demo.
In my actual code, I have a Main.vi which has 15 consumers and each consumer will call the clone CAN_ENGINE's i.e <15 clones will be called> and the status of the CAN should get updated in the calling consumer loop.
Open G is required to be installed to run this code
If you make the FGV preallocated clone as well, each will maintain their state. But this would have some ramifications to existing code, and I confess I did not look at the code so I can't tell if they would be acceptable or not.
08-08-2024 12:11 PM - edited 08-08-2024 12:12 PM
Why would you have a VI with a vit extension?
Your FGV is not reentrant and thus shared by all clones. If you want to keep state for all clones, you could make it contain an array where each index corresponds to one of the clones.
If you make the FGV reentrant, it will no longer be an FGV!
08-08-2024 12:15 PM
Making the FGV as pre allocated clones does not work. I tried making it Shared Clones and Pre allocated Clones. Both these methods doesn't update the calling vi with the correct status
08-08-2024 12:17 PM
Could you kindly modify the code and share, so that I get a workable solution
I am kind of stuck at this point in this development
08-08-2024 12:25 PM
Your FGV could do management based on the clone name, for example.
Each clone would call it with it's ID and the FGV would manage it (e.g. keep an array of clone names, add an array element for a new clone ID and do a lookup and find the relevant index for each later call from the same clone).
@VihangPatil wrote:
Could you kindly modify the code and share, so that I get a workable solution
Sorry, that is not part of my job. See how far you get. Good luck!
08-08-2024 12:35 PM
@altenbach wrote:
Your FGV is not reentrant and thus shared by all clones. If you want to keep state for all clones, you could make it contain an array where each index corresponds to one of the clones.
Depending on how you want to access the information, a map may be desirable (using a string "Name" as the lookup). Using the Name as a lookup helps readability as the names are self-describing. But an array using the index would be a lot simpler.
08-08-2024 12:42 PM
Yes, I actually had a Map in the back of my head when I wrote my answer. They seem to be using LabVIEW 2020 (did not check before), so a map is available and recommended, of course. 😄
08-08-2024 12:49 PM
Can you please post an example.