NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Step Time Duration

Hello all,

I'd like to get the time duration that a step in my sequence runs for.  I've read in the TestStand Reference Manual that the Module Time Duration can be accessed using TS.ModuleTime -- However, how do I access this?  I seems that any TS container I find doesn't have a ModuleTime property.  I'm hoping to use this in Post Expressions of all my modules.

BTW, I'm using TestStand 3.5.

Thanks all!  Let me know if you need more information.

~Jeff
0 Kudos
Message 1 of 6
(5,307 Views)
Hi Jeff.
TS.ModuleTime exists in the ResultList after a step has executed.
I don't know another location where to find it. If no other location exists, you cannot use it in a Post Expression.
By the way, as soon as you "Disable Result Recording .." there will be no ResultList and thus no ModuleTime.
Regards, Guenter (currently working with TS 2.0)
0 Kudos
Message 2 of 6
(5,298 Views)
You can get directly from a step to its result in the result list with the Step.LastStepResult property.
 
However, this wouldn't help for your case because:
 
a) The module time and other builtin result properties aren't recorded until after the PostExpression (as show in table 3-4 in the reference manual).
 
b) You are using 3.5 and support for accessing an API property such as Step.LastStepResult from an expression was added in 4.0
 
c) As the previous poster pointed out, the result won't be available if result recording is turned off.
 
So, the easiest solution to time the module from the post expression of the step that calls it is probably:
 
PreExpression:  startTime = Seconds()
 
PostExpresion: endTime = Seconds() - startTime
 
 
Where startTime and endTime are local variables, globals, or step properties. You could reuse one variable in both expressions, but it would need a more generic name, like "time". While this measures time points slightly further apart that those measured by TS.ModuleTime, the difference should be very small, especially if the step type does not have pre or post substeps.
Message 3 of 6
(5,270 Views)
Thanks, James.

It definitely looks like the easiest way is just to do the pre-/post-expression timing like you suggested... I'm not looking for timing to the ms, so this should be OK.

However, I'd like to understand how I could do it using TS.ModuleTime.  I understand that that property isn't available until after the step (which includes the post-expression) is executed.  Is it possible then for me to access the ModuleTime in an expression that proceeds the module which I'd like the timing for?  Are you suggesting that accessing TS.ModuleTime via an expression isn't available in TestStand 3.5?

Thanks!

~Jeff
0 Kudos
Message 4 of 6
(5,265 Views)

Actually, timing to the millisecond should be just fine. Seconds has sub-microsecond resolution.

 

You can access TS.ModuleTime in an expression in a subsequent step. You just need to figure out the correct elemebt to look at in Locals.ResultsList[]. Accessing the Step.LastStepResult API property is an easy way to get to the right result element, but it is not valid in an expression prior to 4.0 (you would have to use a separate ActiveX step to access that property).

 

One expression that will get you the result time from the immediately previous step is:

Locals.ResultList[GetNumElements(Locals.ResultList) - 2].TS.ModuleTime

The -2 is because you must subtract 1 because the array is zero-based and you must subtract another 1 because the next step adds its result placeholder to the array as soon as it begins execution.

Message 5 of 6
(5,257 Views)

Thanks James Grey,The expression help me a lot!


Flying...
www.vihome.com.cn 虚拟仪器家园
0 Kudos
Message 6 of 6
(4,625 Views)