NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

displaying looping steps in an operator interface

In the operator interface, you can find out if a step is looping through the "Context->GetLoopindex" method.
If this function returns a number greater then 0, then you can get to the result of that first loop, by getting the Next-Step and then calling "GetCurrentLoopResult" on that Next Step dispatch. BUT this does not work when your step has done its last iteration. The function "GetLastStepResult" returns the complete looping step, but calling GetCurrentLoopresult, returns with a null pointer.
So I don't see any way of getting the results of the last iteration of the loop.

Can anybody help me here ?
How can I get the result property for that last iteration of a looping step ?

Gli
0 Kudos
Message 1 of 4
(3,330 Views)
I don't really understand your logic for using the NextStep property of the SequenceContext object to obtain the results for all step iterations that make up a loop. I'm not sure where you are actually doing this evaluation process at, whether it be in a step code module or in the sequence itself via ActiveX Automation Adapter action steps that access the TS objects, but this may be why you chose to do it this specific way. I don't know.

What I can tell you though is that the SequenceContext.Step property actually contains a reference to the currently executing step and if you used the Step.CurrentLoopResult PropertyObject reference at the time that the specific step is still active you could use this on any loop iteration and obtain its result container. This
will work on ALL iterations. Other than that if you have enabled result recording for all iterations of the loop (there is a checkbox for this in the looping operations tab of the properties dialog for a step) you can also simply use the ThisContext.Locals.ResultList[i] variable expression to obtain the result container of a specific loop iteration step in an expression statement (remember that this may contain results from other steps that are not part of the loop and you must be able to determine which index of ResultList actually contains the loop iteration you want to look at).

In the end though you are right, your current logic of using the SequenceContext.NextStep property will not allow you to access the last loop iteration's result reference. One other thing to think about though when using the NextStep reference is when has the result container been updated with the results of the step it references? If you try to get the "NextStep" while still in the previous step re
lative to the NextStep, NextStep still has not executed yet and will not have any results recorded for the context of the current execution.

Jason F.
Applications Engineer
National Instruments
www.ni.com/ask
0 Kudos
Message 2 of 4
(3,330 Views)
I assume your looping step is a numeric limit so one suggestion would be to create a Local variable called “LastResult”. Then in your step’s Post Expression statement, add the following, (Locals.LastResult = Step.Result.Numeric). Now when your looping step is finished, the last result will be in the local variable, LastResult which you can then easily gain access to.
0 Kudos
Message 3 of 4
(3,330 Views)
Jason,
I'm writing an operator interface, and every step I get a trace message which I can handle in my own operator interface.
Now, when a step is looping, the PrevStep method does not return the last loop iteration result, it always returns the last step executed (so the step before the loop-step)...that is why I have to use the Next step method, to gain access to the looping step, when I get the dispatch pointer from this next step method, i can call the GetCurrentLoopResult to get the last iteration.
Now here's the special tricky part, when the last iteration is done, the PrevStep will contain the complete result of the loop and the next step method points to the step after the loopstep...I tried to get access to the Prev Step dispath (which succeeds) a
nd then call the GetCurrentLoopresult on this prev step, but that returns a NULL pointer, so it seems that I ca never get access to that last loop iteration result.
I hope I explained things a bit clearer now, ....please help !?
0 Kudos
Message 4 of 4
(3,329 Views)