07-11-2024 04:39 AM
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.StopSequence) but 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!
Solved! Go to Solution.
07-11-2024 08:35 PM
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.
07-18-2024 08:22 AM
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.
07-20-2024 08:11 AM
@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.