LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I count the number of current running clones of a vi?

In all parallell programming you'll run into race conditions of sorts, AE's has the same problem as any other solution.

 

I've included an example which has both AE as counter and user events which you could use as counter (instead of only as stopping message as now). However, if you check the number of instances too fast all might not have started yet and you can get a "wrong" value. Once all have started the number is correct. That's regardless of whether you use database, AE or events.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 21 of 28
(791 Views)

Hi 

 

           What do you mean by 'not returned by the All VIs property.'

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 22 of 28
(788 Views)

 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 23 of 28
(788 Views)

If you change the delay to 2000 in the reentrant starter loop you'll see that the event loop slowly increases until all have started. If you read the value during the startup phase you'll get a value different from the end value. That's true whether you handle it with events, AE or DB. Actually, since DB is the slowest of them, it's the highest probability of being "behind" in counting.

 

If you're going the DB route you'll need to do it as a transaction.

 

If the program starts checking after a short time (1 sec?) it's not an issue regardless of solution.

 

So, how fast are you going to start checking for the processes and what's the area of usage? Checking if they've all finished? Then my example is a good solution.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 24 of 28
(779 Views)

Ranjeet, look at what Yamaeda posted. It shows exactly how to do this using an FGV. The only problem with the example is that it the VIs don't stop on their own, but that could be easily added by adding a random timeout to each VI.

 

If you want another way to do this, it could be done, for instance, with a parallel process to which you send events to increment or decrement the value. This is basically similar to your DB method, only these events are like stored procedures.

 

If you really care about this, I suggest you take Yamaeda's example and modify it so that it works with a DB and then upload it. We'll understand how it works even if we don't have the DB and we can tell you if there's a problem with it.

 

 


Jeff suggested going over all the VIs and I said that it probably won't work (and now I tested and can confirm that it doesn't work)/

___________________
Try to take over the world!
0 Kudos
Message 25 of 28
(770 Views)

@Ranjeet_Singh wrote:

Hi @tst

 

           What do you mean by 'not returned by the All VIs property.'


Jeff suggested going over all the VIs to check if they're clones and I said that it probably won't work (and now I tested and can confirm that it doesn't work).


___________________
Try to take over the world!
0 Kudos
Message 26 of 28
(768 Views)

Yes it was originally a reentrant test with user events to stop, i added the AE as counter. 🙂

To more closely simulate your situation you can e.g. add a random(+3000) value to the timeout and close the sub-vi in the timeout. That way they'll stop after a short time OR if you press the main vi's stop.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 27 of 28
(763 Views)

Hi 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 28 of 28
(741 Views)