VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping RT sequence with Python

Solved!
Go to solution

Hi to everyone,

I'm currently trying to learn how to use VeriStand with python with the objective to automate testing in series.

At the moment I have a script that cyclically turn on and off a screen to simulate the execution of a loop that can require a lot of time.

This script can be started from the gui by pressing the button.

 

The problem I'm facing is that, if the test.py contains an infinite while loop, I am unable to stop its execution. I've tried adding another button in the gui to launch a script where the sequence only contains niveristand.library.generate_error(42, "Termination", ErrorAction.StopSequencebut the real time sequence doesn't stop the previous one.

 

Is there a way to send a signal from python that has the same effect on VeriStand as the stop button used in Stimulus Profile Editor to end a simulation?

 

I'm open to other advices on how to create a tool that can help a user start/stop a simulation, read the result/output, without the need to interact with the sequences and the Stimulus Profile Editor.

 

Thank you!

Download All
0 Kudos
Message 1 of 4
(232 Views)

You can refer to Creating a Multitasking Real-Time Sequence

You can monitor a user channel instead. If you are too lazy to specify which task to stop. You can use Generating Errors Primitive to stop the entire sequence. 

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 2 of 4
(202 Views)

Thank you for your answer, but I don't think it's the one I was looking for.

I know how to use multitasking, in the full version of my application from the gui it's already possible to start multiple parallel tasks. It's not a laziness problem, I specifically need to stop every running task. And as I said generating an error doesn't stop other running sequences.

What do you mean with monitor a user channel?

 

At the moment my solution is to encapsulate every task in a while loop based off a dummy variable, then I created a "kill switch" in the gui that launch a sequence with the only task of changing the variable value to false, terminating all other tasks. It's not the most elegant solution, but for now it works.

0 Kudos
Message 3 of 4
(184 Views)
Solution
Accepted by seraf24

@seraf24 wrote:

At the moment my solution is to encapsulate every task in a while loop based off a dummy variable, then I created a "kill switch" in the gui that launch a sequence with the only task of changing the variable value to false, terminating all other tasks. It's not the most elegant solution, but for now it works.


This is exactly what I meant with a user channel or dummy variable. Glad to hear that it works.

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 4 of 4
(164 Views)