NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Variable usage in TestStand expression statements

Solved!
Go to solution
I am trying to implement the following:

Locals.tot_power= (Locals.tot_power+ 10E Locals.reading)

as an expression in TestStand, it doesnt accept the variable locals.reading for the exp power. Is it possible to do this somehow?
0 Kudos
Message 1 of 3
(4,383 Views)
Indeed in TestStand the exponent can't be a variable. Depending on the type of 'locals.result' (i.e. unsigned integer or real) two possible solution might solve your problem:
Solution 1 (always expect an unsigned integer in 'locals.result' variable):
- Define another numeric variable in locals section, for instance 'locals.temp'.
Then, in an additional 'statement' step define the expression "Locals.temp *= 10" and a custom 'Loop option' with the following 'Loop While Expression':

RunState.LoopIndex < Locals.reading

The attached sequence file "Solution1.seq" gives an example of the description above.

Solution 2 (the values in the 'locals.reading' are real numbers):
- For this problem I wrote a math library (.DLL) where I implemented the mathematical function
suitable for my needs, that aren't supported by TestStand. In the "Solution2.zip" attached file I used the exported function "TS_pow", which implements "z = x^y" and is called from an 'Action' type step using 'Flexible DLL adapter'. The result returned by this function is stored in 'locals.temp' variable and is used in the second 'Statement' step. (The expression in the 'Statement' step may be moved into the previous 'Action' step in the 'Post step' expression, so the function "Locals.tot_power= (Locals.tot_power+ 10E Locals.reading)
" result can be achieved in a single step.)
The "Solution2.zip" contains also the VC++ source code used to create "math.dll".

Hope this answer your question,
Silvius
Silvius Iancu
Download All
Message 2 of 3
(4,383 Views)
Solution
Accepted by topic author noog
I guess there is also another easy solution that is to use the Evaluate() function.
In the following example Locals.MyNumber and Locals.Exp are numeric variables.

Ex.:
Locals.MyNumber = Evaluate(Val("10E" + Str(Locals.Exp)))

Roberto Piacentini
National Instruments
Applications Engineer
www.ni.com/support
Message 3 of 3
(4,383 Views)