Is there a remotely way to stop a Plecs simulation? Is there a way to extract Outport data during simulation?

Greetings,

wrote a script to control soome simulation form Python and this is the code to start the simulation:

data = server.plecs.simulate(modelName, opts)

How does the API works? Does it get data at every Plecs step and then it displays the last values registered at the last step? I tried using a new thread to initialize an empty data list and then try to catch the data from it at every couple of seconds but it appears that only the last data is displayed.

Output



{‘Time’: , ‘Values’: }

Is there a workaround. Is it there a possibility to catch data from Outport while python is executing server.plecs.simulate(modelName, opts) command?

Also is there a command in Python that can remotely stop a Plecs simulation from running. Maybe a manual with all the XML-RPC commands for Plecs standalone?

Thank you.

The plecs.simulate() call is a blocking, which means that you are not able pass any other command until the current plecs.simulate() has finished executing. There is not a command to halt the simulation or access the data before the simulation is complete.

One workaround is to use a “To File” block which will update continuously as the simulation proceeds. You can then read the text file in another thread.