NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Step.SwitchExecEnabled does not work as expected

I would like to dynamically set the "Enable Switching" checkbox in the Switching properties of a step.  I thought that setting the Step.SwitchExecEnabled variable to False in a pre-expression would disable switching, but it doesn't.  I did find that if I uncheck "Enable Switching" and set Step.SwitchExecEnabled to True, the second time I execute the step, switching will be enabled.  So it seems that the issue may be in the execution order between the pre-expression and the switching. 

 

The reason I want to dynamically change the setting is that the same software must run on systems that may or may not have switching hardware.  I cannot use a precondition because I still want the step to execute.  I just want to skip the switching in some cases.  One workaround is to put the switching in a separate step, but there are many steps so I would like to avoid that if possible.

 

 

I'm using TS 2010.

0 Kudos
Message 1 of 2
(2,919 Views)

The only thing that executes before the switching is the precondition. You could change the switching setting in the precondition as follows:

 

Step.SwitchExecEnabled = StationGlobals.SwitchingEnabled, True

 

The ", True" at the end of the expression ensures that the preconditions still evaluates to True so that the step still executes. In a compound expression like this, the result of the combined expression is the result of the last expression.

 

Hope this helps,

-Doug

Message 2 of 2
(2,903 Views)