NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

RunState.CallingStep.datasource

When I insert a Test step, in the the default data source field is Step.Result.[Numeric, String, Pass/Fail, etc.].  I am accessing this expression by calling "RunState.CallingStep.datasource" which gives me whatever has been entered into this field.  If the datasource field contains the variable "Step.Result.Numeric" for example, then when i access the datasource expression, the string "Step.Result.Numeric" is outputted instead of the value located at this location. 

 

I would like to access the value of variable located in the Data Source expression.

[DL]
0 Kudos
Message 1 of 13
(4,751 Views)

Since DataSource is actually an Expression, you need to call Evaluate on it, e.g. Locals.foo = Evaluate(Step.Result.DataSource)

0 Kudos
Message 2 of 13
(4,749 Views)

I tried to use Evaluate(RunState.CallingStep.DataSource) but i get an error.  Error is -17308; Specified value does not have the expected type.  Because Evaluate is expecting a string type.

[DL]
0 Kudos
Message 3 of 13
(4,745 Views)

Oops, you have to wrap Expression datatypes in the Str() function. Your final call would be Evaluate(Str(RunState.CallingStep.DataSource)).

0 Kudos
Message 4 of 13
(4,744 Views)

i tried that and it didnt work

[DL]
0 Kudos
Message 5 of 13
(4,741 Views)

Keep in mind that if the DataSource is something like "Step.Result.PassFail" that the expression will be evaluated with the current step being the Step object, not your calling step. You're changing the context of the expression without changing the expression to account for it.

 

A quick fix would be to replace "Step." with "RunState.CallingStep" but that may break other expressions unexpectedly.

0 Kudos
Message 6 of 13
(4,738 Views)

Hi DL,

 

Why are you doing this and where are you doing this. Maybe a simple example may help to understand your problem better.

 

 

Regards
Ray Farmer
0 Kudos
Message 7 of 13
(4,714 Views)

Locals.mystring = Str(Evaluate(Step.DataSource))

 

But not sure why you want to do this. There might be a better way to accomplish what you are trying to do. If you post more details perhaps someone can suggest something.

 

Hope this helps,

-Doug

0 Kudos
Message 8 of 13
(4,704 Views)

I'm making an Engine Callback for SequenceFilePostStepFailure.  In this callback, i'm creating a custom popup error message box.  In this error message box, i want to display the calling step's name, the calling step's measured value (which caused the error to occur), and the calling step's minimum and maximum limit values.

 

In the test step, there is an expression field for DataSource.  However, in order to make this error pop up box applicable to all scripts, and not rewrite how the DataSource expression is stated, i want to capture the Datasource expression and evaluate it.

 

For example,

 

If the DataSource expression is: Step.Result.Numeric

I want to be able to query the Step.Result.Numeric expression and pull that value to display in the error pop up box.  The reason for this is that if there is a different statement in the DataSource expression such as: Step.Result.Number*10, I want the error pop up box to pull the value of that expression.

 

If i call RunState.CallingStep.DataSource, then the correct expression is displayed in the error pop up box.  However, i would like the value of that expression displayed and not the string expression itself.

[DL]
0 Kudos
Message 9 of 13
(4,688 Views)

Here is my message expression for a numeric limit test.

 

"Step Failed: " + RunState.CallingStep.Name + "\n" +
"Minimum Value: " + RunState.CallingStep.Limits.LowExpr + "\n" +
"Maximum Value: " + RunState.CallingStep.Limits.HighExpr + "\n" +
"Measured Value: " + RunState.CallingStep.DataSource + "\n\n" +
"Failure Date: " + Str(Date()) + "\n" +
"Failure Time: " + Str(Time())

 

I would like to evaluate the expressions contained in the red highlighted text.

[DL]
0 Kudos
Message 10 of 13
(4,685 Views)