NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

how to get runstate loop index of interactive execution?

I want to get runstate loop index(loop count) of interactive execution. I used TS_PropertyGetValNumber  with arguement as "RunState.LoopIndex", but zero value is returning. Anybody could suggest a way to get loop index in interactive execution? Thanks in advance........
0 Kudos
Message 1 of 9
(5,724 Views)
Hi,
 
I believe you have to get a reference to the Interactive Context by using SequenceContext.InteractiveContext which returns an InteractiveContext reference. Then get a reference as a property object using InteractiveContext.AsPropertyObject. Then you can Use the TS_PropertyGetValNumber  to get the RunState.LoopIndex.
Remember to release the references when you have finished with them.
 
Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 2 of 9
(5,707 Views)

Hi Ray,

Using TS only, where is the value of the loop index of a sequence step?  How do I read it?

 

Thanks

Rafi

0 Kudos
Message 3 of 9
(5,503 Views)
Hi Rafi2003,

If you look at the properties tab for that looping step and look at the looping section you can find the loop index variable.  Unless you have set the loop type to be custom the loop index variable will be RunState.LoopIndex.  If you've set it to custom then the loop index variable can be something else, but you should be able to see what it is from those expressions.

Let me know if you have any questions.
Kristen
National Instruments
0 Kudos
Message 4 of 9
(5,476 Views)

I use loopindex in runstate for my array but analyze gives me error for out of range because I use (loopindex -1) even in the loop define I init this loopindex starts at 1 in custom mode. How can I Re_init loopIndex value in variable section???????? Thanks.

0 Kudos
Message 5 of 9
(4,999 Views)

You should be able to use a statement similar to "RunState.LoopIndex = 1" assuming 1 is what you wanted to re-init that index too.  You should be able to put that statement in an expression box of a step where you what it to be re-initialized.

Jensen
National Instruments
Applications Engineer
0 Kudos
Message 6 of 9
(4,985 Views)

I did but analyzer still give me warning even I run debug this block. Result is "test fail" for this block.

0 Kudos
Message 7 of 9
(4,981 Views)

I am not sure what you are testing in this step, or if the re-initialization of the index is part of the test logic.  Also if you are talking about the sequence analyzer that is giving the warning, it is trying to ensure that you are using best practices, and the rules it usees to analyze your sequence can even be created by the user.  That means it may not be a problem that will affect the performance of the sequence file or the logic, but it may be hard to understand and less readable code than desired.  If this is the case, you can try to restructure the logic so that it does the same thing but follows the rules of your anaylzer.  Having the test fail I think must be the logic of the step, and not have much to do with the warning of the sequence analyzer, but I would need more information to be sure.

Jensen
National Instruments
Applications Engineer
0 Kudos
Message 8 of 9
(4,963 Views)

That mean RunState structure can not be initialize and it always be started at 0. I try to check if the signal I measured has PULSE which data will store in local array. Maybe I will use Locals.Index so I can initialize at 1.

0 Kudos
Message 9 of 9
(4,952 Views)