|
AGXDynamics
2.31.1.0
|
ReactiveScripts are Python scripts for use in strong coupling with the Simulation instance it is assigned and the stepping in time it grants. More...
Classes | |
| class | ReactiveScript |
| The ReactiveScript class is derived from the agxSDK::StepEventListener class and require an agxSDK::Simulation instance to invoke any callbacks. More... | |
| class | ScriptConsole |
| class | ScriptContext |
| Class which manages a runtime bridge between a script and the Python ScriptManager. More... | |
| class | ScriptContext_environment |
| Class describing the contextual environment in which a script is run. More... | |
| class | ScriptContextInterface |
| Internal class which interfaces to a ScriptContext in an abstract and safe manner. More... | |
| class | ScriptError |
| Exception base class for all fatal runtime errors caused by Python scripts. More... | |
| class | ScriptIDE |
| class | ScriptIDEAutocomplete |
| class | ScriptIDEAutocompleteCollection |
| class | ScriptIDEData |
| class | ScriptIDEDataCollection |
| class | ScriptIDEInterpreter |
| class | ScriptManager |
| Class that manages the embedded Python interpreter and a script context. More... | |
| class | ScriptRuntimeListener |
| class | ScriptSimulationParameter |
| class | StartPlaybackSignalCallback |
| class | StartRecordingSignalCallback |
| class | StopPlaybackSignalCallback |
| class | StopRecordingSignalCallback |
Enumerations | |
| enum | ScriptContextType { SCRIPTCONTEXT_INVALID = 0, SCRIPTCONTEXT_PYTHON, SCRIPTCONTEXT_AGXVIEWER, SCRIPTCONTEXT_FMI, SCRIPTCONTEXT_QTVIEWER } |
Functions | |
| AGXPYTHON_EXPORT bool | doFile (const std::string &path) |
| AGXPYTHON_EXPORT ScriptContext * | getContext () |
| AGXPYTHON_EXPORT bool | scriptIsAttached () |
ReactiveScripts are Python scripts for use in strong coupling with the Simulation instance it is assigned and the stepping in time it grants.
Derived from the agxSDK::StepEventListener, the idea is to design the appropriate storage for generic metadata, Python runtime data and Simulation context data. Only the metadata is independent of any attachment to a Simulation and thus permanent relative the other two which only lasts as long the assignment to the SImulation does.
An EventListener is notified upon being added to a Simulation and later on its removal from the Simulation. This pair of callbacks defines the start and finish of the initialized Script. Only during this time can we access the agxSDK::Simulation pointer the Reactive API require to work.
Normally, an EventListener is managed by the Simulation it is added to. Because we want the ScriptManager to manage the ReactiveScripts and their execution context data, we also need a mechanism for each ReactiveScript to announce when and how it is invoked when triggered as a StepEventListener of its Simulation and again before returning. These restores the context state to the Python environment before Script execution resumes as well stores the updated context state from the Python runtime.
At the bare minimum, a ReactiveScript consists of initializing code such as initial values to locals, functions, ReactiveScript callbacks or even classes. All code found in the global scope counts as initialization code and is run only once per assignment to a Simulation. The objects created during initialization is stored afterwards until the script is called upon again and restored to Python. This context state is also scanned for specially named functions to use as callable objects back into the script from the overridden StepEventListener methods. If found, the appropriate method is unlocked and will be called by the Simulation object.
So what does this solve? The scriptable StepEventListener with potentially to make serializable storage aside, ReactiveScripts can also manage themselves in response to assignment to Simulation objects and later removal, they also manage all Python runtime data required to execute any Python code (assuming the ScriptManager has initiated the Python C API in embedded mode). Only one ReactiveScript can execute at a time/be active (for now) because only one context state can be current.
Algorithm: ScriptManager->registerReactiveScript(ReactiveScript* script); script->setSource(pythonScriptString); Simulation->add(script); ScriptManager->
| typedef agx::observer_ptr< const ScriptIDEAutocompleteCollection > agxPython::ScriptIDEAutocompleteCollectionConstObserver |
Definition at line 41 of file ScriptIDEAutocomplete.h.
| typedef agx::ref_ptr< const ScriptIDEAutocompleteCollection > agxPython::ScriptIDEAutocompleteCollectionConstRef |
Definition at line 41 of file ScriptIDEAutocomplete.h.
| typedef agx::observer_ptr< ScriptIDEAutocompleteCollection > agxPython::ScriptIDEAutocompleteCollectionObserver |
Definition at line 41 of file ScriptIDEAutocomplete.h.
| typedef agx::ref_ptr< ScriptIDEAutocompleteCollection > agxPython::ScriptIDEAutocompleteCollectionRef |
Definition at line 41 of file ScriptIDEAutocomplete.h.
| typedef agx::observer_ptr< const ScriptIDEAutocomplete > agxPython::ScriptIDEAutocompleteConstObserver |
Definition at line 118 of file ScriptIDEAutocomplete.h.
| typedef agx::ref_ptr< const ScriptIDEAutocomplete > agxPython::ScriptIDEAutocompleteConstRef |
Definition at line 118 of file ScriptIDEAutocomplete.h.
Definition at line 118 of file ScriptIDEAutocomplete.h.
Definition at line 118 of file ScriptIDEAutocomplete.h.
| typedef agx::observer_ptr< const ScriptIDE > agxPython::ScriptIDEConstObserver |
Definition at line 36 of file ScriptIDE.h.
| typedef agx::ref_ptr< const ScriptIDE > agxPython::ScriptIDEConstRef |
Definition at line 36 of file ScriptIDE.h.
| typedef agx::observer_ptr< const ScriptIDEDataCollection > agxPython::ScriptIDEDataCollectionConstObserver |
Definition at line 95 of file ScriptIDEData.h.
Definition at line 95 of file ScriptIDEData.h.
Definition at line 95 of file ScriptIDEData.h.
Definition at line 95 of file ScriptIDEData.h.
| typedef agx::observer_ptr< const ScriptIDEData > agxPython::ScriptIDEDataConstObserver |
Definition at line 39 of file ScriptIDEData.h.
| typedef agx::ref_ptr< const ScriptIDEData > agxPython::ScriptIDEDataConstRef |
Definition at line 39 of file ScriptIDEData.h.
Definition at line 39 of file ScriptIDEData.h.
| typedef agx::ref_ptr< ScriptIDEData > agxPython::ScriptIDEDataRef |
Definition at line 39 of file ScriptIDEData.h.
Definition at line 36 of file ScriptIDE.h.
| typedef agx::ref_ptr< ScriptIDE > agxPython::ScriptIDERef |
Definition at line 36 of file ScriptIDE.h.
| typedef agx::observer_ptr< const ScriptSimulationParameter > agxPython::ScriptSimulationParameterConstObserver |
Definition at line 77 of file ScriptContext.h.
| typedef agx::ref_ptr< const ScriptSimulationParameter > agxPython::ScriptSimulationParameterConstRef |
Definition at line 77 of file ScriptContext.h.
Definition at line 77 of file ScriptContext.h.
Definition at line 77 of file ScriptContext.h.
| typedef agx::observer_ptr< const StartPlaybackSignalCallback > agxPython::StartPlaybackSignalCallbackConstObserver |
Definition at line 106 of file agxPython/ScriptManager.h.
| typedef agx::ref_ptr< const StartPlaybackSignalCallback > agxPython::StartPlaybackSignalCallbackConstRef |
Definition at line 106 of file agxPython/ScriptManager.h.
| typedef agx::observer_ptr< StartPlaybackSignalCallback > agxPython::StartPlaybackSignalCallbackObserver |
Definition at line 106 of file agxPython/ScriptManager.h.
Definition at line 106 of file agxPython/ScriptManager.h.
| typedef agx::observer_ptr< const StartRecordingSignalCallback > agxPython::StartRecordingSignalCallbackConstObserver |
Definition at line 120 of file agxPython/ScriptManager.h.
| typedef agx::ref_ptr< const StartRecordingSignalCallback > agxPython::StartRecordingSignalCallbackConstRef |
Definition at line 120 of file agxPython/ScriptManager.h.
| typedef agx::observer_ptr< StartRecordingSignalCallback > agxPython::StartRecordingSignalCallbackObserver |
Definition at line 120 of file agxPython/ScriptManager.h.
Definition at line 120 of file agxPython/ScriptManager.h.
| typedef agx::observer_ptr< const StopPlaybackSignalCallback > agxPython::StopPlaybackSignalCallbackConstObserver |
Definition at line 134 of file agxPython/ScriptManager.h.
| typedef agx::ref_ptr< const StopPlaybackSignalCallback > agxPython::StopPlaybackSignalCallbackConstRef |
Definition at line 134 of file agxPython/ScriptManager.h.
| typedef agx::observer_ptr< StopPlaybackSignalCallback > agxPython::StopPlaybackSignalCallbackObserver |
Definition at line 134 of file agxPython/ScriptManager.h.
Definition at line 134 of file agxPython/ScriptManager.h.
| typedef agx::observer_ptr< const StopRecordingSignalCallback > agxPython::StopRecordingSignalCallbackConstObserver |
Definition at line 148 of file agxPython/ScriptManager.h.
| typedef agx::ref_ptr< const StopRecordingSignalCallback > agxPython::StopRecordingSignalCallbackConstRef |
Definition at line 148 of file agxPython/ScriptManager.h.
| typedef agx::observer_ptr< StopRecordingSignalCallback > agxPython::StopRecordingSignalCallbackObserver |
Definition at line 148 of file agxPython/ScriptManager.h.
Definition at line 148 of file agxPython/ScriptManager.h.
| Enumerator | |
|---|---|
| SCRIPTCONTEXT_INVALID | |
| SCRIPTCONTEXT_PYTHON | |
| SCRIPTCONTEXT_AGXVIEWER | |
| SCRIPTCONTEXT_FMI | |
| SCRIPTCONTEXT_QTVIEWER | |
Definition at line 66 of file agxPython/ScriptManager.h.
| AGXPYTHON_EXPORT bool agxPython::doFile | ( | const std::string & | path | ) |
| AGXPYTHON_EXPORT ScriptContext* agxPython::getContext | ( | ) |
| AGXPYTHON_EXPORT bool agxPython::scriptIsAttached | ( | ) |