LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Increment PtbyPt Reentrant

Solved!
Go to solution

 

Under Other functions PtbyPt, there are increment Ptby Pt and decrement PtbyPt.  Under Execution in VI properties, reentrancy is set to Preallocated clone reentrant execution.  Does that mean I can use that VI to count multiple things? If that VI can be use for multiple counters, how does LabVIEw keep track?

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 7
(2,974 Views)

Preallocated Clones - each call has its own memory space.  So you can call this VI from multiple places and each place you call it will have its own memory.  So yes, you can keep track of multiple counts.


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
Message 2 of 7
(2,967 Views)

Does does LabVIEW keep track of multiple counters if I use that VI as my counter?  For example, if I use that VI to act as 3 counters.  One counter counts up to 100, then second one counts up to 200, and the third one counts up to 300.  They are all increment at different places of the code.  How woudl LabVIEW knows which on is which?  By looking at the code, a real person may not even be able to tell.  

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 3 of 7
(2,948 Views)

There will be an instance for each call to that VI.  Each instance (called a clone) will keep its own counter.  To LabVIEW, they each act like totally different subVIs.

 

The LabVIEW Field Journal had a good series on maintaining state.  I recommend reading the 5 part blog series.  Part 1 can be found here:http://labviewjournal.com/2012/02/maintaining-state-1/


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
Message 4 of 7
(2,918 Views)

See attached example.  I dont' see how it keep track of which counter is which.

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 5 of 7
(2,893 Views)
Solution
Accepted by topic author jyang72211

Each call has its own data set.  So the VI calls in the init case are different from those in Counter 1 or Counter 2 cases.  So you really have 6 counters going in your VI.  Need proof?  Put a FOR looop around your VI and have it iterate twice.  You will notice that you will get 10 for counter 1 in the counter 1 case.  It wasn't reset like you wanted to happen in the init case because those calls in the init case are different instances than those in the Counter 1 case.


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
Message 6 of 7
(2,887 Views)

Oh, that makes sense.  Thanks!

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 7 of 7
(2,852 Views)