NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to do a simple Boolean test?

Solved!
Go to solution

Hello All,

 

  Trying to do a simple Boolean test, but it is proving to be more complicated than I would have expected.  Hoping that I am missing something simple.

 

I have a Labview code module that provides a Boolean value for the output.  I want to evaluate this value and provide pass/fail results to the report.  Sounds simple, but here is what I am running into:

 

-The built-in NI step type "Pass/Fail Test" will evaluate the Boolean directly with True=Pass, and False=Fail.  This would be fine, except that I have situations where I need False to equal Pass.  I've read a few posts that speak of inverting or negating the Boolean result, but they all involve passing the result to a parameter or variable, and then evaluating it outside of the test step.  This adds several layers that I don't think I should need.

 

-I have read a post that suggested I convert the Boolean to a numeric inside of the code module.  This does indeed make sense, but this is not practical in my situation because of the scale and implementation of my code modules.  I use custom type definitions for controls and indicators from a Labview project, and would have to create a new control/indicator for every one if I wanted to change the data type.  

 

-Next logical step was to see if the "Numeric Limit Test" would recognize a Boolean.  Turns out it doesn't.     

 

-After this, I looked into creating a custom step type.  This would probably be the most useful, but it is beyond my current ability to do so.  I got as far as making a copy of the built in step type and putting it in the custom "MyTypes" directory, but I have made very little progress in editing it to make it a work.  Additionally, I've read a few posts that recommend avoiding custom step types.  

 

Hoping someone can point me in the right direction.  Please advise.

 

Thanks,

GSinMN    

0 Kudos
Message 1 of 6
(7,359 Views)
Solution
Accepted by topic author GSinMN

GSinMN,

 

I'd enter "Step.Result.PassFail" for the Boolean output parameter on your VI (just like a normal Pass/Fail Test step), and on the Data Source tab you can add an exclamation point to the front, for example: !Step.Result.PassFail. This will negate the output value and use the result of that for the comparison. 

 

If you want to log the actual output from the VI to the report (for example, so you can visually see that False output resulted in a Passed test), you can check the "Log" option for the parameter in the module settings.

Message 2 of 6
(7,357 Views)

Hello Daniel,

 

  Thanks for the quick response.  I've read a few posts that suggest exaclty that, but they point out that TestStand will look for (but not find) a parameter with the "!" in front of it, thus causing an error.  Is this not the case?  Thanks.

 

GSinMN 

 

 

0 Kudos
Message 3 of 6
(7,355 Views)

You could change the Data Source based on what value you want.  Since there doesn't appear to be an logical XOR, you will need to use a case statement.  For example, you could do:

Locals.Desired? Step.Result.PassFail:!Step.Result.PassFail


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 6
(7,354 Views)

Hello Again,

 

  Went back to test Daniel's suggestion.  Turns out that it works.  Looks like you can manipulate the parameter in the "Data Source" tab with no errors, but if you try to negate the value in the "Module" tab, that's where it throws the error.  

 

Thanks for the help.  

 

GSinMN

0 Kudos
Message 5 of 6
(7,349 Views)

Glad it works!


This is because on the Module tab, you are defining a variable where the output from the VI will be placed. This needs to be an expression that evaluates to a variable, so saying "not PassFail" is invalid. However, on the Data Source tab, you are simply defining an expression for the pass/fail state of the step, which needs to evaluate to a True/False boolean value. "Not PassFail" meets this criteria.

0 Kudos
Message 6 of 6
(7,333 Views)