NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

TestStand response to DLL Return Value

I've inherited a TestStand sequence that calls a DLL in several of the steps. The DLL's 'Return Value' is set as follows: 'Type' = U8. 'Result Action' = No Action, and the 'Set Error.Code' box is checked. I want to know what these settings do, what triggers a Step Failure, and what triggers a Step Error.
0 Kudos
Message 1 of 9
(4,555 Views)

Nothing will trigger a failure or error just from these settings.  The only thing that is happening is the Step.Result.Error.Code variable will be set to the return value.  Setting the code will never change the status of the step.  However, the status expression may be using this value to determine the result, depending on how it is set.

 

Allen P.

NI

0 Kudos
Message 2 of 9
(4,549 Views)

That helps. Thanks.

 

The Status Expression used in the DLL calls looks like this:

Step.DataSource != "Step.Result.PassFail" ? Step.Result.PassFail = Evaluate(Step.DataSource) : False,

Step.Result.PassFail ? "Passed" : "Failed"

 

What's the Step.DataSource variable? 

0 Kudos
Message 3 of 9
(4,547 Views)
It sounds like you are using a PassFail step.  If you look at the "Data Source" tab of the step, you will see what is being used to evaluate the pass/fail status of the step.  This is an expression, meaning it could be just a single variable, or something more elaborate that uses expression functions and many variables to return a Boolean value.  Typically, this is a variable called Step.Result.PassFail.  In most cases, you will assign this variable as one of the output parameters of your DLL.  The Data Source describes what piece of data is evaluated to determine if it passes or fails.
0 Kudos
Message 4 of 9
(4,543 Views)

On the step's Properties screen, under the General tab, there's a button named 'Edit Pass/Fail Source...' This button pops up a window that shows the Data Source Expression:

 

Step.Result.PassFail = (Step.Result.Error.Code == 1)? 1:0).

 

0 Kudos
Message 5 of 9
(4,541 Views)

Correction to above:

 

Step.Result.PassFail = (Step.Result.Error.Code == 1)? 1:0

0 Kudos
Message 6 of 9
(4,539 Views)

This means the step will pass when the return code is 1 and fail when it is not 1.  It also assigns the pass/fail status to the Step.Result.PassFail variable (which is not neccesary since it is already being copied in the Result Expression).  The code could be simplified to the following:

 

Step.Result.Error.Code == 1

 

The ? 1:0  part is unneccesary (and partially unclear, since it would be more readable with true and false instead of 1 and 0).

Assigning to the Step.Result.PassFail variable is also not needed since the Status Expression does the same thing.

 

Allen P.

NI

0 Kudos
Message 7 of 9
(4,534 Views)

I have another question about the Status Expression used in the DLL call (copied below):

 

Step.DataSource != "Step.Result.PassFail" ? Step.Result.PassFail = Evaluate(Step.DataSource) : False,

Step.Result.PassFail ? "Passed" : "Failed"

 

I'm having trouble parsing the Status Expression in my mind so I understand what's going on.  Is there a document indicating the order in which operators and functions are evaluated....the 'order of precedence'?

0 Kudos
Message 8 of 9
(4,504 Views)

I am not aware of a specific document that describes the order of operations, but it should be nearly identical to C syntax.

 

The basics of that expression are as follows:

 

If the data source is not Step.Result.PassFail (not the default case), Evaluate the Step.DataSource property and store the result in Step.Result.PassFail.  Otherwise do nothing.  The comma means there is new statement, and the last statement is what assigns the result status to the step (this must be a string).   It the PassFail variable is true, it sets the step to "Passed", otherwise it sets it to "Failed".

 

Allen P.

NI

0 Kudos
Message 9 of 9
(4,497 Views)