09-15-2022 08:37 AM
Hi everyone,
I'm new with the TS and wanne execute a step for only 5 seconds. When the time is over the step can not be executed anymore.
I could't find any timer function like programming languages. Could you please help me. I really appreciate it.
Thank you.
Solved! Go to Solution.
09-15-2022 08:55 AM
do you mean some kind of max time limit for execution?
A step will execute as long as the code module execution completes because TestStand passes the execution to the respective language to complete the execution and TestStand will not have control to abort the code module execution mid-way as it is not under its control.
If needed, you need to implement a technique within the code module to stop execution after the timeout period.
09-15-2022 09:03 AM
Thank you for your reply.
Yes exactly. I just wanne the timer to start when the step is beeing started. after 5 seconds the step must be stoped.
09-23-2022 01:35 PM
TestStand will let you set Station Options for an execution time limit which when expired will terminate the execution or allow a prompt to be displayed for user to decide the action.
You can control the Time Limit settings dynamically using expression steps
Use these constants for the value of the StationOptions.SetTimeLimitAction and StationOptions.GetTimeLimitAction methods.
I like to label my expression steps "Watchdog On" and "Watchdog Off". Could also easily setup a Sequence call to pass a "time" parameter to make it user friendly for changing time requirements.
09-23-2022 01:40 PM
@ee-jallen wrote:
TestStand will let you set Station Options for an execution time limit which when expired will terminate the execution or allow a prompt to be displayed for user to decide the action.
You can control the Time Limit settings dynamically using expression steps
- In an expression step before your module step use the following (this will set a max time of 5 seconds):
- RunState.Engine.StationOptions.SetTimeLimitEnabled(TimeLimitType_NormalExecution, TimeLimitOperation_Executing, True),
RunState.Engine.StationOptions.SetTimeLimitAction(TimeLimitType_NormalExecution, TimeLimitOperation_Executing, TimeLimitAction_Terminate),
RunState.Engine.StationOptions.SetTimeLimit(TimeLimitType_NormalExecution,TimeLimitOperation_Executing, 5),- In an expression step after your module step use the following to "turn off" the Time Limit
- // set time back to 10 second default. This allows time enough to toggle other options when enabled later
RunState.Engine.StationOptions.SetTimeLimit(TimeLimitType_NormalExecution,TimeLimitOperation_Executing, 10),
RunState.Engine.StationOptions.SetTimeLimitEnabled(TimeLimitType_NormalExecution, TimeLimitOperation_Executing, False)Use these constants for the value of the StationOptions.SetTimeLimitAction and StationOptions.GetTimeLimitAction methods.
- TimeLimitAction_Abort–(Value: 0) Initiates an abort of a running execution.
- TimeLimitAction_KillThreads–(Value: 1) Ends the thread for a running, terminating, or aborting execution.
- TimeLimitAction_Prompt–(Value: 2) Launches a dialog box with the option to terminate, abort, or kill the execution.
- TimeLimitAction_Terminate–(Value: 3) Initiates a termination of a running execution.
I like to label my expression steps "Watchdog On" and "Watchdog Off". Could also easily setup a Sequence call to pass a "time" parameter to make it user friendly for changing time requirements.
My understanding is those settings are for the whole execution whereas the OP wanted this to be configured per-step.
09-23-2022 01:59 PM
@santo_13 wrote:
@ee-jallen wrote:
TestStand will let you set Station Options for an execution time limit which when expired will terminate the execution or allow a prompt to be displayed for user to decide the action.
You can control the Time Limit settings dynamically using expression steps
- In an expression step before your module step use the following (this will set a max time of 5 seconds):
- RunState.Engine.StationOptions.SetTimeLimitEnabled(TimeLimitType_NormalExecution, TimeLimitOperation_Executing, True),
RunState.Engine.StationOptions.SetTimeLimitAction(TimeLimitType_NormalExecution, TimeLimitOperation_Executing, TimeLimitAction_Terminate),
RunState.Engine.StationOptions.SetTimeLimit(TimeLimitType_NormalExecution,TimeLimitOperation_Executing, 5),- In an expression step after your module step use the following to "turn off" the Time Limit
- // set time back to 10 second default. This allows time enough to toggle other options when enabled later
RunState.Engine.StationOptions.SetTimeLimit(TimeLimitType_NormalExecution,TimeLimitOperation_Executing, 10),
RunState.Engine.StationOptions.SetTimeLimitEnabled(TimeLimitType_NormalExecution, TimeLimitOperation_Executing, False)Use these constants for the value of the StationOptions.SetTimeLimitAction and StationOptions.GetTimeLimitAction methods.
- TimeLimitAction_Abort–(Value: 0) Initiates an abort of a running execution.
- TimeLimitAction_KillThreads–(Value: 1) Ends the thread for a running, terminating, or aborting execution.
- TimeLimitAction_Prompt–(Value: 2) Launches a dialog box with the option to terminate, abort, or kill the execution.
- TimeLimitAction_Terminate–(Value: 3) Initiates a termination of a running execution.
I like to label my expression steps "Watchdog On" and "Watchdog Off". Could also easily setup a Sequence call to pass a "time" parameter to make it user friendly for changing time requirements.
My understanding is those settings are for the whole execution whereas the OP wanted this to be configured per-step.
Try it, create a sequence with 4 steps
Run the sequence. The Popup will show and before the count down is done the Time Limit will terminate the execution. Now run the sequence again. This time, click the OK on the first prompt, so you don't time out. Test will proceed, will turn off the Time Limit, then the 2nd Popup will display....allow it to count down and it will close successfully and the test sequence will not be terminated.
TestStand honors the new settings dynamically.
The OP could even experiment with putting the Watchdog On and Off statements in the Pre and Post properties of the step.
09-26-2022 02:50 AM
Thank you so much @ee-jallen
It worked correctly.
10-03-2022 05:18 PM - edited 10-03-2022 05:24 PM
I would also note that if you are calling code that you have control over then you should implement TestStand Termination Monitor in your code. You can find an example and topic in the TestStand help. The time limit settings will indeed signal a termination however if your code performs long actions and you need immediate response then use the Termination Monitor API in your code. The example I explained in my answer uses a native TestStand MessagePopup step which I imagine honors immediate termination signals via Termination Monitor or some other internal mechanism