NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

In VB how do I pass my low and high limit results from a TestStand Step into the ResultList and how do I retrieve them from the same?

I am retrieving high and low limits from step results in VB code that looks something like this:

' (This occurs while processing a UIMsg_Trace event)
Set step = context.Sequence.GetStep(previousStepIndex, context.StepGroup)

'(etc.)

' Get step limits for results
Set oStepProperty = step.AsPropertyObject
If oStepProperty.Exists("limits", 0&) Then
dblLimitHigh = step.limits.high
dblLimitLow = step.limits.low

'(etc.)


So far, so good. I can see these results in
VB debug mode.

Immediately after this is where I try to put the limits into the results list:

'Add Limits to results
call mCurrentExecution.AddExtraResult("Step.Limits.High", "UpperLimit")
call mCurrentExecution.AddExtraResult("Step.Limits.Low", "LowerLimit")

(No apparent errors here while executing)


But in another section of code when I try to extract the limits, I get some of the results, but I do not get any limits results.

That section of code occurs while processing a UIMsg_EndExecution event and looks something like this:

(misc declarations)

'Get the size of the ResultList array
Call oResultList.GetDimensions("", 0, sDummy, sDummy, iElements, eType)

'Step through the ResultList array
For iItem = 0 To iElements - 1
Dim oResult As PropertyObject
Set oResult = oResultList.GetPropertyObject("[" & CStr(iItem) & "]", 0)
sMsg = "StepName = " & oResult.GetValString("TS.StepName", 0) & _
", Status = " & oResult.GetValString("Status", 0)
If oResult.Exists("limits", 0&) Then
Debug.Print "HighLimit: " & CStr(oResult.GetValNumber("Step.Limits.High", 0))
Debug.Print "LowLimit: " & CStr(oResult.GetValNumber("Step.Limits.Low", 0))
End If

'(handle the results)

Next iItem


I can get the step name, I can get the status, but I can't get the limits. The "if" statement above which checks for "limits" never becomes true, because, apparently the limit results never made it to the results array.

So, my question again is how can I pass the low and high limit results to the results list, and how can I retrieve the same from the results list?

Thanks,

Griff
0 Kudos
Message 1 of 6
(4,044 Views)
At first sight the problem is in the following lines of code:

'Add Limits to results
call mCurrentExecution.AddExtraResult("Step.Limits.High", "UpperLimit")
call mCurrentExecution.AddExtraResult("Step.Limits.Low", "LowerLimit")

The two lines of code above will create in ResultList array two properties named "UpperLimit" and "LowerLimit". So will return allways false, since no property named "limits" in the ResultList array was added.
One solution for this might be by replacing

'Add Limits to results
call mCurrentExecution.AddExtraResult("Step.Limits.High", "UpperLimit")
call mCurrentExecution.AddExtraResult("Step.Limits.Low", "LowerLimit")


with the following line of code:

call mCurrentExecution.AddExtraResult("Step.Limi
ts", "Limits")

Hope this solved your problem,
Silvius
Silvius Iancu
0 Kudos
Message 2 of 6
(4,044 Views)
Thanks for your response, Silvius...

I tried your suggested replacement, but I still don't get the results back.

I don't think the problem is in the
if oResult.Exixts....
statement.

I had to add that "if" statement because the
oResult.GetValNumber("Step.Limits.High", 0)
method throws an error if the "step.limits.high" property does not exist. And this is what happens to be the case for all the items in the result list!

Still no limits results in the results list.


Griff
0 Kudos
Message 3 of 6
(4,044 Views)
Griff,

The code:

call mCurrentExecution.AddExtraResult("Step.Limits.High",
"UpperLimit")
call mCurrentExecution.AddExtraResult("Step.Limits.Low",
"LowerLimit")

will (when subsequent steps with this step properties are executed) create
entries in each of those steps' ResultList called "ResultList[
index>].UpperLimit" and "ResultList[].LowerLimit". Therefor,
your check for "Limits" in the step's ResultList will ~never~ be true
because it doesn't exist.

I would follow Silvius' suggestion and replace the above lines with

call mCurrentExecution.AddExtraResult("Step.Limits", "Limits")

This should result in each step's entire Limits container being copied to
each step's ResultsList, so you should then see entries called
"ResultList
[].Limits.High" and "ResultList[
index>].Limits.Low" and your check would work.

Also the code

If oResult.Exists("Limits", 0&) Then
Debug.Print "HighLimit: " &
CStr(oResult.GetValNumber("Step.Limits.High", 0))
Debug.Print "LowLimit: " &
CStr(oResult.GetValNumber("Step.Limits.Low", 0))
End If

should be:

If oResult.Exists("Limits", 0&) Then
Debug.Print "HighLimit: " &
CStr(oResult.GetValNumber("Limits.High", 0))
Debug.Print "LowLimit: " &
CStr(oResult.GetValNumber("Limits.Low", 0))
End If

as there will also be no "ResultList[].Step" entry, unless you
explicitly add it using AddExtraResult.

HTH,

Bob Rafuse
Etec Inc.
0 Kudos
Message 4 of 6
(4,044 Views)
Bob,

Thanks for taking the time to answer.

I tried your suggestions, but they didn't work either.

I put a VB breakpoint in loop so I could examine the variable and property contents manually.

1) The "If oResults.Exists..." condition is never true

2) Typing and executing
oResult.GetValNumber("Limits.High",0)
results in a "Invalid property" kind of error. This is the case for whatever variation I use ("Step.Limits.High", "Limits.High", or "Limits")

I am still stuck, and cannot retrieve the limit values from the results array. I am not convinced that they made it to the results array in the first place.

Any other ideas?

Thanks,

Griff
0 Kudos
Message 5 of 6
(4,044 Views)
Griff,

Hmmmm...

I use this feature all the time and it works for me. The only real
difference between the code you posted and what I do is that I don't
retrieve a property object for each TestStand object, instead I pass the
entire sequence context (of the process model) then retrieve a property
object for the entire sequence context and use the full TestStand object
path to reference sub-properties. For example, to access a step's
ResultList property called "foo" I would use the path:

"Locals.ResultList[0].TS.SequenceCall.ResultList[].Foo"

My guess is the problem has something to do with the object from which
you're retrieving the property object and/or the path used to obtain
sub-properties from the object. You should be able to break-point in the
TestStand sequence editor immediately after the test step in question
executes, then see the extra results in the step's ResultList using the
context viewer.

For example, see the attached sequence file. The first step adds the extra
result "Step.Limits" as "Limits", the second step is a Numeric Limit (which
will have the step property of "Limits") test and the third step pops up a
dialog if the Limits property is found in the Numeric Limit test's
ResultList. In the Sequence Editor, try executing with the first step
enalbled then again with the first step skipped and breakpoint on the third
step. Use the context viewer to observe where the Limits property is added.
That might help you narrow in on how to specify the property path to
retrieve the value.

If in your code, you see the extra results in the context viewer, then the
problem lies in how you're trying to retrieve the property. If the extra
results aren't there, then something is wrong in how you're specifying them,
most likely a problem with the AddExtraResult call itself.

One other thing to check... its hard to tell from the code you posted... but
make sure you're calling AddExtraResult on the correct execution object and
that you're calling AddExtraResult ~before~ executing the step you want the
result to show up for. Another programmer here made the mistake of assuming
he could call AddExtraResult ~after~ the step executed and TestStand would
"back fill" previously executed steps. Thats not the case. Also, another
mistake he made was expecting the extra results to appear for steps that did
not contain the original step properties. For example, a string comparison
step doesn't have a "Step.Limits.High" property, so if this property is
called out explicitly in AddExtraResult, then the extra result won't appear
in the string comparison's ResultList entry. Thats why you should simply
specify "Step.Limits" to AddExtraResul so the Limits container (whose
contents vary depending on the step type) will get copied to the ResultList
regardless of the step type.

I call AddExtraResult at the beginning of my process model, not in a UI
message handler, so there may be some gotcha from calling it that way. If
all else fails, try adding the AddExtraResult near the beginning of your
process model and see if the extra results appear in each step's ResultList.

Good luck,

Bob Rafuse
Etec Inc.



[Attachment DebugExtraResults.seq, see below]
0 Kudos
Message 6 of 6
(4,044 Views)