NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

how to get result list parameters to an array variable

I want to generate a text report that can be imported to excel. I want to show each test step name, status and numeric result. I found out that TS records this data to an array called ResultList in Main Sequence locals. Each step is recoded as an array element but they also collapse into a tree view, i think each array element becomes a container. How can i get a step's status, name and numeric parameters

0 Kudos
Message 1 of 10
(7,285 Views)

Hi CK,

 

I hope you are doing well today!  You can access the step name, status, and result during run-time in RunState.Root.  For instance, I have attached an example below, titled resultlisttest.seq, that was created in TestStand 2010.  This example has a Numeric Limit Test and a Message Popup that displays that test's name, status, and numeric result (which I have set with a pre-expression to the number 10).  Being the first step in the test, I accessed these parameters through RunState.Root.Locals.ResultList[0].  The image below shows the message displayed at the end of the test:

 

resultlistmessage.png

 

You can see these run-time values during a test by setting breakpoints in your sequence.  When you run your test and it hits a breakpoint and pauses, you can go to the Variables tab and expand the locations to view what values are available to you (shown in the above image).  I hope this helps, CK.  Have a great day!

 

 

Taylor G.
Product Support Engineer
National Instruments
www.ni.com/support
0 Kudos
Message 2 of 10
(7,263 Views)

thank you very much. That's a step but not exctly my requirement. As far as i can see container arrays are being created for sequences but i want to do s'thing like TS already does. I want to copy all step names and results whose statuses are "Passed" and " Failed" to array variables. Then i will call a dll that will use these arrays as input parameters and write these records to a .txt or excel file.

Because TS report types are not effective to make result analyses we want to generate our own report generator. To avioid too much coding labour i don't want add steps to copy each step result to array variables. (Actually we did it for another application but it is very tiring and prone to mistakes)

0 Kudos
Message 3 of 10
(7,239 Views)

CK,

 

It seems you are re-inventing the wheel.  XML reports are very usable for result analysis.  In fact I would say more usable than any txt or excel document you could produce.  Not to mention TestStand has the capability to log to databases (which is already built in).  And it seems that databases are the ultimate in mineable data.

 

However, that being said..... to answer your question:

 

What you are asking is not trivial because there are multiple contributors when creating a report.  If you look through the process model you will see all of the steps that relate to report generation.  Each one does something different based on the report options, execution status (terminated, aborted, etc..) and report type.  If you truly want to do it right then you should follow how the process model does it and add code for your new generation type.

 

If you want a quick and dirty solution then you can just put some logic in the cleanup step group to parse through the ResultList and generate the file you want.  In order to do this I would create a while loop (or for loop) or a statement step that loops.  I would have it loop for each item in the array.  A for loop may be better because then you could have a different step for each step type and precondition it.  Then just grab what you want out of that result list and assign it to your array. 

 

I created a simple rough example.  It doesn't account for calling subsequences or anything like that.  You would have to build logic for all of that.

 

Hope this helps,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 4 of 10
(7,231 Views)

So, how do you get TestStand to stop reporting that references to Locals.CurrentResult are unknown variables? In your example, you set Locals.CurrentResult to an element in Locals.ResultList. Then you use Locals.CurrentResult.TS.StepName and Locals.CurrentResult.Status in a message. The sequence analyzer complains about that as follows:

Message     : Unknown variable or property name 'Locals.CurrentResult.TS'.
File        : C:\DOCUME~1\MARISE~1.EDW\LOCALS~1\Temp\ParseResultList.seq
Location    : Seq["MainSequence"].Cleanup["Display Step Info"].MessageExpr
Rule        : Expressions must evaluate to a value of the expected type
Description : Each expression property must not include syntax errors and must evaluate to a value of the type
 the property expects. Syntax errors and incorrect value types can cause errors at run time.
Ignore this message if the expressions will evaluate correctly at run time.  This might happen if
variables are created dynamically at run time or are propogated.

I'm trying to clean up exactly such analyzer complaints (see here) without luck. Do you have any ideas?

 

Thanks,

- Gizmogal

 

0 Kudos
Message 5 of 10
(7,108 Views)

I think what you are asking is virtually impossible without a human verifying each of the variables/properties.  The problem is that the one in my example is created dynamically by me copying over the current result to an empty container.  The container doesn't know what it will contain until runtime.  If you were to make a rule for that it would have to know what is going to be created at runtime and what is a true bad variable/property.  You could look for specific things that you might know might be created such as RunState properties but outside of that it's too hard to predict.

 

Sorry I couldn't be more helpful but it seems like in this instance it is going to be tough.

 

One thing you could do is turn this rule off.  The problem with that is it won't catch the actual errors.

 

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 6 of 10
(7,104 Views)

Thanks for your answer. Someone did actually point me to a solution that allowed me to keep the rule turned on:

solution

 

Cheers!

Gizmogal

0 Kudos
Message 7 of 10
(7,068 Views)

Why did i get an error when I ran your example?

untitled.JPG

0 Kudos
Message 8 of 10
(6,986 Views)

My guess is you are seeing that error because of an Unknown variabe or property name.  🙂

 

I don't know what the author of that sequence file was thinking.  The process model Locals.ResultList won't be populated until MainSequence returns.

 

 

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 9 of 10
(6,977 Views)

Hi Jane.Yu and jiggawax,

 

If you run the example I posted a while back without a Process Model (i.e. just Run MainSequence from the Execute menu), the property will exist.  However, a better place to get this information from would be simply Locals.ResultList[i], where i is the index of the result you are looking for.  In other words, you can simply remove the RunState.Root. from the MessagePopup step's expression.  This property will exist unless you have both On-The-Fly Reporting enabled in the Report Options and Discard Results or Disable Results When Not Required by Model option selected in the Model Options.

 

Sorry for the confusion in the example.  I hope this helps!  Have a great day!

Taylor G.
Product Support Engineer
National Instruments
www.ni.com/support
0 Kudos
Message 10 of 10
(6,971 Views)