From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Force a step to fail from VI

Solved!
Go to solution

Hi folks,

I have a lot of sequences testing values on a serial bus. The adapter for data acquisition is LabVIEW. To detect a test with old data on the bus, I want to check if the bus is active at each test step. For this I don't want to change the sequence, because there are so manny steps for bus tests. 

 

Inside the adapter VI I know the bus status (active/inactive) and I have a SequenceContext there. If the bus is not active, the step shall fail. Throwing an error or manipulating the value is not an option.

 

How can I force a step to fail from inside the adapter VI? 

 

Kind regards

Rainer Langlitz

 

 

0 Kudos
Message 1 of 8
(3,041 Views)

You did not provide enough details to get a full answer.

 

Is the step to fail the step that calls the LabVIEW module or the step has already been executed?

 

Do you need to execute that step again before the sequence is being reloaded?

 

A very easy way is to simply set the status expression of the step calling the module to "Failed". If you simply set the Status of the step to "Failed", the Status expression will change the status after the code module terminates its execution. However, the status expression of that step is then changed until the sequence is being re-loaded from the file. You can check what is the step test type and then populate the Status expression with the appropriate expression if you do not want to fail the step.

 

Example of the VI code below and in attachment (LabVIEW 2018).

 

Fail numeric limit test_BD.png

Marc Dubois
Message 2 of 8
(3,000 Views)

For a passfail LabVIEW step, you could pass out a boolean from the VI and assign it to Step.Result.PassFail.

0 Kudos
Message 3 of 8
(2,989 Views)

Hi MarcDub,

the step to fail is the step calling the LV module. The test type can be Numeric Limit, Boolean or String. And some steps are called again.

 

Because of the Boolean step type, Value manipulation does not work. A manipulation of the Status expression must be reversible for all test types.

 

I was thinking about an array of "step executions to fail" and let them fail in a callback. This is not an option, because I need to add the callback in each sequence file.

 

Another idea is to create an additional entry in the ResultList. I can see the ResultList in the debugger. I can change the size of the array in the LV module using the SequenceContext. But I could not figure out how to add a simple Pass/Fail test to the array.

0 Kudos
Message 4 of 8
(2,986 Views)

@railang wrote:

Because of the Boolean step type, Value manipulation does not work.


I don't understand what is the problem with a Boolean test (Pass/Fail) step type. What do you mean by "Value manipulation does not work"?


@railang wrote:

Hi MarcDub,

the step to fail is the step calling the LV module. The test type can be Numeric Limit, Boolean or String. And some steps are called again.

 

... A manipulation of the Status expression must be reversible for all test types.


If you add a case for each of the test step type to the case structure in the LabVIEW code I provided, the approach I proposed would work. If the module does not need to be failed, the appropriate expression is written to the Status Expression field.

Marc Dubois
0 Kudos
Message 5 of 8
(2,957 Views)

There are a lot of test steps in the sequences for testing data on a serial bus (e.g. ARINC429). The adapter VI reads the data and outputs a value to be tested in the step. This value is a numeric, string or even boolean. I could manipulate the value which is passed from the VI connector pane to the test step, by setting it to a value that must fail, like "NaN", "-4711" or "INVALID". But this does not work for the boolean value, because I don't know whether the value it is tested to be true or false. There are steps that test a boolean flag on the bus to be false, and in this case the Data Source is something like "!Step.Result.PassFail" or "Step.Result.PassFail == False".

 

I am looking for a piece of code I can put into the adapter VI to force the step to fail. Or to add an additional failing step to the result list programatically. I want to avoid the effort to touch each step for this.

 

There is one problem with the status expression approach: If the status expression is changed do "Failed" and the sequence file is saved afterwards (e.g. when debugging the sequence), the modified status expression is saved on disk. This is not a functional issue, because the expression will be reverted on the next execution of the step. But on a code audit I need to explain this to the auditor.

 

I would like to go for the solution with the addition ResultList entry. Could anybody tell me, how to do this in LabVIEW?

0 Kudos
Message 6 of 8
(2,950 Views)
Solution
Accepted by topic author railang

I understand that you cannot modify the test sequences, even temporarily, but can you modify the process model?

If you cannot modify the process model, one approach I can see is to make the calling sequence fail and report which steps made it fail in ReportText. The benefit of this approach is that you only modify the calling modules. It can be done as shown below (attached as Fail NumericLimitTest3.vi):

Fail numeric limit test3_BD.png

If you absolutely want to fail the step and that you can modify the process model, you can create an entry in the result container of the step, like a boolean called ForcedToFail and set it to true if you want to fail the step. Then, you can override a ProcessModel engine callback named ProcessModelPostResultListEntry. In that callback, you check if the item ForcedToFail is present, and if it is and it is true, you set Result.Status to "Failed". You also need to set the Variable RunState.Caller.SequenceFailed to True if you want the sequence to fail as well. Module code would look like below (attached as Fail NumericLimitTest2.vi). I also set the the "IncludeInReport" flag so that the ForcedToFailed property would show up in the report to indicate if a step was forced to fail only if that step was forced to fail.

Fail numeric limit test2_BD.png

This latter approach might significantly slow down your test if there are a lot of steps. Instead of overriding the Process Model Engine callback, you can also loop through all the test results in a callback that you would modify directly in the Process model, like PostMainSequence, or you might prefer to create a new sequence (callback or not) and insert it right after the call to MainSequence. You need to loop through the array Parameters.MainSequenceResult.TS.SequenceCall.ResultList, checks if the ForcedToFail property exists, and if it does, you set the Status to "Failed". The sequence has already been failed by the module. If the step result is a SequenceCall, you need to start a new loop. I attached the sequence file SequentialModel_ForcedToFail.seq that contains PostMainSequence, a subsequence, and the engine callback ProcessModelPostResultListEntry. Notice that this latter callback has the step disabled so that the approach using PostMainSequence can run.

 

Marc Dubois
Message 7 of 8
(2,931 Views)

Hi Marc,

thank you for helping me with that. I have implemented the callback solution, because all my sequence files already including the SequenceFilePostResultListEntry callback. From there I can modify the 

Parameters.Result.Status if the property ForcedToFail is True.

 

#NoValidation(Parameters.Result.Status = Parameters.Step.Result.ForcedToFail ? "Failed" : Parameters.Result.Status),
#NoValidation(Parameters.Step.Result.DeleteSubProperty("ForcedToFail", PropOption_DeleteIfExists))

 

Let Step Fail.png

 

Kind regards

Rainer

0 Kudos
Message 8 of 8
(2,892 Views)