开云体育

Locked AbstractAutomaton and stop() #scripting


 

Using?jmri.jmrit.automat.AutomatSummary.instance().length() I can step through a list of the classes I have running within my JMRI session, and I can get each class name using the getName() function.

I'm wondering if it is possible to use the AbstractAutomaton stop() method within one script to stop a class from a completely different script running (as if it was killed from the Thread Monitor).? I have multiple scripts running on my layout, each one starts a class that is controlling a specific locomotive, as well as some other "Master" scripts that control the layout as a whole and direct the individual loco scripts to perform specific functions.

My usage case is a type of controlled "emergency stop" that would be triggered from a panel control.? If activated, the control would launch a new script, which would perform the following:
  • Loop through all my locomotives, and
    • Set the speed to zero (which uses acceleration in the decoders) or -1 (immediate stop) - this is to be determined later
    • Locate the class that is responsible for this loco control and stop it, regardless of what the class is currently doing
  • Other tidy up as necessary to return the layout to a defined condition
  • Exit
So after this script is executed, I want all the locos to be stopped, and the other classes that were running to be stopped and removed from the Thread Monitor.

Can it be done?

Join [email protected] to automatically receive all group messages.