NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to customized PostStepFailure Call Back?

I have a Teststand application in which I use PostStepFailure Call Back to manage step failure. However there is a special case it will not work as I expected. If one step enable its build-in loop function and result is always fail,then when it stop from loop, Testand engine will call PostStepFailure for two times,but I just want it call one time.

For easy understanding,I make a simple example to demostrate it as following picture shows:

  1. The result of check GPIO State is "0"
  2. Judge criteria is check it equals to "1"
  3. Only Loop for 1 time

During executing,PostStepFailure will executed for two times not for one time!!

1.png

 

0 Kudos
Message 1 of 5
(3,324 Views)

Looping a single step creates one entry in the ResultList "overhead" which represents the result of the whole loop. As your looping step fails over all iterations, all loop iterations determine as "Failed". Hence, this will call the PostStepFailure one additional time.

You can get rid of the additional call if using loop steps from the Flow Control palette.

 

Norbert

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

Hi Daniel,

 

I can see how the PostStepFailure callback is getting called on each failing iteration, as this is descibed in the TestStand Reference Manual - Step Execution action number #20.

 

If you only want to handle a failure once per step (and ignore any repeat calls to the callback for the same step), maybe one solution would be to check the step's unique ID and if it's the same as the previous call to the PostStepFailure callback you can ignore it (as it's previously been handled).

 

This could be done by:

 

1). Create a FileGlobal.PreviousStepUniqueID

2). Modify the SequenceFilePostStepFailure sequence to have the an IF..END around your usual code (or use pre-conditions) with the expression: "Parameters.Step.UniqueStepId != FileGlobals.PreviousStepUniqueID"

3). Store the current step's Unique Id at the end of your callback, using "FileGlobals.PreviousStepUniqueID = Parameters.Step.UniqueStepId"

 

PostStepFailure.PNG

 

I hope this helps,

 

Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)

Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor

Message 3 of 5
(3,298 Views)

Hi Charlie,

     Thanks for your idea,it really help me!

      I made a little change in checking each step unique ID since my application is complexed than example.

      To avoid mistakenly matching steps from duplicated sequence by step.UniqueStepID, I append the Runstate.Caller.Step.UniqueStepID to the Step.UniqueStepID before comparing it.

     So,I did it by:

  • Create fileglobals.CurrentStepUniqueID and fileglobals.PreviousStepUniqueID
  • Modify the SequenceFilePostStepFailure by add IF Condition: "FileGlobals.CurrentStepUniqueID!=FileGlobals.PreviousStepUniqueID"
  •  Store the current step's Unique Id at the end of your callback, using "FileGlobals.PreviousStepUniqueID = FileGlobals.CurrentStepUniqueID"

1.png

 

Do you think this modification is a best practice or not?

 

0 Kudos
Message 4 of 5
(3,272 Views)

Hi Norbert

    I already guess this issue in this direction, thanks for your clarification in detail!

 

BR

Daniel Du

0 Kudos
Message 5 of 5
(3,270 Views)