NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Logging Additional Results using Pre-step Callback

Solved!
Go to solution

In my sequence, the SequenceFilePreStep callback checks if a step is a test step (ex. NumericLimitTest). If it is, a temperature value from a global array has to be stored to the step's Additional Results. Let's say the temperature array index is just zero here. I use the following statement then.

 

RunState.CallingStep.AdditionalResults.CustomResults.Insert("FileGlobals.Temperature[0]",FileGlobals.Temperature[0],"",PropFlags_IncludeInReport,-1)

 

The problem is that the variable name is evaluated as a number, which is the same as the temperature value. (Please refer to the attached image) But it doesn't even allow me to use some arbitrary name such as "Temp". It forces me to use "FileGlobals.Temperature[0]" as the variable name. Otherwise, I get an error. How can I assign a variable name in the Additional Results as I want?

 

Another question is, is it possible to check whether a variable with a cerain name in the Additional Results exists, using expressions? Basically, I want to replace an old temperature value in the Additional Results with a new value whenever a loop iterates.

 

Any input will be appreciated.

0 Kudos
Message 1 of 5
(3,951 Views)

Hi pomirobotics,

 

The first parameter for the Insert method needs be a string and also evaluate to a string. You are correctly giving a string to this first parameter, but it evaluates to a number (50).  And if you use "Temp", it tries to evaluate it as a variable, which doesn't exist. Try this expression:

 

RunState.CallingStep.AdditionalResults.CustomResults.Insert("\"FileGlobals.Temperature[0]\"",Str(FileGlobals.Temperature[0]),"",PropFlags_IncludeInReport,-1)

Jason H
Automated Test Software R&D
Message 2 of 5
(3,922 Views)
Solution
Accepted by topic author Chickentree

pomirobotics,

 

Actually, the result name is an expression rather than just a string (you can see this by going to the Additional Results section of the Step Settings and looking at the visual editor for Additional Results entries). Therefore, you need to include another set of double quotes in your name expression. Here is an example:

 

RunState.Step.AdditionalResults.CustomResults.Insert("\"ResultName\"","Locals.MyNumber","",PropFlags_IncludeInReport,-1)

 

The backslashes escape the inner set of quotes so that they are interpreted properly when the expression is run. 

 

Hope it helps!

Message 3 of 5
(3,918 Views)

The double quote trick certainly worked!

 

The remaining problem is that I have to replace old additional result values with new ones for every loop iteration.

 

Is it possible at all to use some method like Exists to check whether an additional result with a certain name already exists and get its array index?

 

I need to record the most recent temperature value for every test step and some test steps have their own unique additional results, too.

 

Tracking additional results by name would be a sure-fire way if possible.

0 Kudos
Message 4 of 5
(3,905 Views)

I suppose I should go with this way.

 

FileGlobals.AdditionalResultsCount = RunState.CallingStep.AdditionalResults.CustomResults.Count

 

For Locals.LoopIndex = FileGlobals.AdditionalResultsCount -1; Locals.LoopIndex >=0; Locals.LoopIndex -= 1

   If RunState.CallingStep.AdditionalResults.CustomResults.Item(Locals.LoopIndex).Name == "\"Temperature\""

      RunState.CallingStep.AdditionalResults.CustomResults.Remove(Locals.LoopIndex)

   End

End

 

RunState.CallingStep.AdditionalResults.CustomResults.Insert("\"Temperature\"","FileGlobals.Temperature[0]","",PropFlags_IncludeInReport,-1)

Message 5 of 5
(3,889 Views)