NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Post Action depending on variable

Solved!
Go to solution

Hi,

 

my sequence has several subsequences with pass/fail decisions for different substeps. To save testing time my sequence does not perform the following substeps if one substep returned a FAIL as result and hence I set the Post Action On Fail: Goto cleanup.

However there are situations when I want to run all substeps also if one substep before returned a FAIL. I think a good solution would to set the Post Action differently depending on a Variable (Local, Parameter, FileGlobal, StationGlobal). For example: If the Variable is TRUE I would go to Cleanup on fail, if it is FALSE I would go to the next step on fail. I could put this into all my substeps and to change the behaviour only the variable value must be changed.

 

Is this possible or is there another solution for my problem?

 

Thanks

  TT

 

0 Kudos
Message 1 of 10
(7,127 Views)

Tobias,

 

you can configure a custom condition for post actions. If the condition is true, one post action takes place, if it evaluates to false, another takes place....

 

From reading your post i think this is what you are looking for.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 10
(7,125 Views)

Thanks Norbert,

 

Yes this is what I was looking for, however I could not find out how to write On Fail: Goto Cleanup or On Fail: Goto next step in an expression and I would be grateful for some help on that.

0 Kudos
Message 3 of 10
(7,120 Views)

Ok, this is more tricky....

The problem you are facing is that the setting for the post action is defined in the step instance. You can modify that during runtime using *any* expression, but if you fail to follow the correct format there, you will produce a run-time error.

Use the Step.TS.FailActTarget to jump as you like. The Step.TS.FailAct has to be "Goto" in order for this to work.

 

The next keypoint is to find the correct place for that expression. Never tested that, but it should be possible to induce it into the custom condition itself.....

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 10
(7,115 Views)
Solution
Accepted by topic author TobiasT

@TobiasT wrote:

Thanks Norbert,

 

Yes this is what I was looking for, however I could not find out how to write On Fail: Goto Cleanup or On Fail: Goto next step in an expression and I would be grateful for some help on that.


How about this expression:

 

Step.Result.Status == "Failed" && !Locals.disableGotoCleanupOnFailure

 

With the true condition set to go to cleanup and the false condition set to go to next step.

 

-Doug

Message 5 of 10
(7,099 Views)

I tried it a bit, but could not solve it so far. I'll answer again after some more trying next week.

0 Kudos
Message 6 of 10
(7,096 Views)

@dug9000 wrote:
How about this expression:

 

Step.Result.Status == "Failed" && !Locals.disableGotoCleanupOnFailure

 

With the true condition set to go to cleanup and the false condition set to go to next step.

 

-Doug


This worked perfect.

I prefer to have the TRUE condition set to go to next step and the FALSE condition set to goto cleanup and I also inverted the meaning of the Local. To get this I changed my Custom Condition of my Post Action to:

 

Step.Result.Status != "Failed" && !Locals.enableGotoCleanupOnFailure

 

The result is exactly equal to your expression (as given in the de Morgan's law, but I also verified it on an easy example).

 

Thanks very much.

  TT

0 Kudos
Message 7 of 10
(7,079 Views)

ups there is a type in my expression above the AND must of course be an OR. So the correct expresion is:

Step.Result.Status != "Failed" || !Locals.enableGotoCleanupOnFailure

0 Kudos
Message 8 of 10
(7,072 Views)

Just want to point out that there is also a built-in feature for going to cleanup on failure (look near the bottom of the first tab in the station options dialog, "Immediately Goto Cleanup on Sequence Failure"). That might be a better choice if your use case is a simple, do it or don't do it setting rather than something more complicated.

 

-Doug

0 Kudos
Message 9 of 10
(7,050 Views)

I did not know that, so thanks for the info.

Most of the time I'll use my solution above, since then I can choose the subsequences and the change can be made w/o the use of the Station Options. I am using Control Variables for other purposes so this new Control Variable fits nice to them.

0 Kudos
Message 10 of 10
(7,042 Views)