NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Using SequenceFilePreStep StepName to Run or Skip Step

Solved!
Go to solution

Looking for some help with a modification to my test menu.

 

I have a number of subsequences that will call specifi test files:

 

    (SubSeqCall Step) Compare_Interface_Max.seq  (where the StepName contains the name of the sequence file being called)

    (Statement Step)   Rename Test File with Error Counts  (Calls a DLL to rename the "Compare_Interface_Max.seq" file as: 0-Compare_Interface_Max.seq so that I know how many errors are in the file.)

 

This format repeats for about 180 test sequences.  Occasionally, there will be a timing problem and I need to rerun a few of the tests.

  What I'm trying to do is to before each test is run, use a DLL call to test for a filename in the report directory such as "0-Compare_Interface_Max.seq" and NOT run the test if it has already passed.

 

Two problems:

  1. How do I get the Calling StepName inside of the SequenceFilePreStep? 

        I can't seem to find it in the variables "Runstate.Caller....".  I need the name of the step that is calling to be able to test for the FileName.

          (I tried setting Locals.sStepName to the current stepname inside the PreStep expression, but it doesn't exist yet, PreStep isn't called yet when the SequenceFilePreStep is called.)

 

  2. Once I have the step name (i.e.: Contains ".seq") I can then make my call to the DLL to test to see if the file exist.

     If the file has passed OK already, I want to SKIP the SubSequence Call step and the next Statement step, and I don't know how to do that from inside the SequenceFilePreStep.

 

Any suggestions?

 

Mike

0 Kudos
Message 1 of 13
(5,968 Views)

Answers to your questions:

 

1. Parameters.Step.Name.  The step is passed as a parameter to this callback.

 

2. It's too late at this point.  If you look in the TestStand manual you will see that the EnginePreStep happens after the Precondition.  So there isn't a way to really stop the code module from executing or rather reporting the step.  I suggest you go a different route where you have an array of booleans.  Each boolean represents a flag for each step.  Set the flag if the step passes.  Use that flag as the precondition for the steps.

 

My 2 Cents,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 13
(5,963 Views)

Thanks, I see what you mean where the SequenceFilePreStep won't work.

 

I've figured out that I can use the SequenceFilePostStep and use an IF step: 

        Find(RunState.Caller.RunState.NextStep.Name, ".seq") > -1

  to determine if the next step is a SubSequence Call to one of my test files.

 

However, I can't figure out how to do a "Skip" on the next two steps. 

I've tried:

 

Locals.nThisStep = Parameters.Step.StepIndex,

RunState.Root.RunState.InitialSelection.SelectedFile.Data.Seq["MainSequence"].Setup[Locals.nThisStep+1].TS.Mode = "Skip",

RunState.Root.RunState.InitialSelection.SelectedFile.Data.Seq["MainSequence"].Setup[Locals.nThisStep+2].TS.Mode = "Skip"

  This is of course being called from the SequenceFilePostStep, But this doesn't work.  The steps still execute.

 

What am I missing?

 

Mike

 

0 Kudos
Message 3 of 13
(5,954 Views)
Solution
Accepted by topic author Mikef

RunState.Caller.Sequence.Main[runstate.Caller.RunState.NextStepIndex].Precondition = "False"

RunState.Caller.Sequence.Main[runstate.Caller.RunState.NextStepIndex+1].Precondition = "False"

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 4 of 13
(5,950 Views)

Jigg,

 

I can make that work!!

 

Thanks.

 

Mike

0 Kudos
Message 5 of 13
(5,944 Views)

Jigg,

 

FYI, the statement:

  RunState.Caller.Sequence.Main[runstate.Caller.RunState.NextStepIndex].Precondition = "False"

changed the step Precondition in the file, somewhat of a "permanent" change. (Stored in the file.)

 

I had to run another "If" statement in the SequenceFilePostStep to test to see if the PreviousStepIndex = "False" and set it back to blank. 

 

Is there another way of temporarily changing the Mode to "Skip" that would not be stored in the file, once the file execution was stopped?

 

Mike

0 Kudos
Message 6 of 13
(5,929 Views)

I have noticed that as well.  I'm not sure that there is a way around this.  I tried doing:

RunState.Caller.Sequence.Main[runstate.Caller.RunState.NextStepIndex].SetRunModeEx("Skip") and it still saves that to the file.  The odd thing is that the file can be totally read only and it still saves those settings into the disk copy.

 

You could use RunState.Caller.NextStep but that also saves the settings out to the disk copy.  And it doesn't allow you to look two steps ahead like you want.

 

Honestly, your best bet without having the disk copy change is to create an array of booleans (an element for each step).  Then set the precondition to something like FileGlobals.FlagArray[Step.Index].  Then in your callback you can just set the appropriate flag.  I would only limit it to the Main step group.  You shouldn't have any testing in setup or cleanup anyway.  I attached an example of this.  You can play with the variables obviously.

 

The other thing is to use the Post Action of a step.  You can condition it and have it GoTo any other step depending on the condition.

 

Hope this helps,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 7 of 13
(5,923 Views)

If you pass the execution reference into Step.SetRunModeEx() it will set the setting in a way that only applies to that execution. For example:

 

theStep.SetRunModeEx("Skip", RunState.Execution)

 

This setting will apply to the execution, even if you do restart, until you change the setting again. It however does not edit the file and does not apply to any other executions.

 

Hope this helps.

-Doug

Message 8 of 13
(5,919 Views)

Doug,

 

That's good to know.  I was curious about that but wasn't sure.  Is there something similar for the Precondition?

 

Thanks,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 9 of 13
(5,913 Views)

@~jiggawax~ wrote:

Doug,

 

That's good to know.  I was curious about that but wasn't sure.  Is there something similar for the Precondition?

 

Thanks,


No. SetRunModeEx with the execution specified is used by the UIs/Sequence Editor when you interactively (via the UI) change the runmode while at a breakpoint in the execution window. There is no similar use case for preconditions. Run modes are kind of like breakpoints in that people sometimes want to set them temporarily for debugging purposes.

 

-Doug

Message 10 of 13
(5,911 Views)