AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agxPython Namespace Reference

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
 

Typedefs

typedef agx::observer_ptr
< const
ScriptIDEAutocompleteCollection > 
ScriptIDEAutocompleteCollectionConstObserver
 
typedef agx::ref_ptr< const
ScriptIDEAutocompleteCollection > 
ScriptIDEAutocompleteCollectionConstRef
 
typedef agx::observer_ptr
< ScriptIDEAutocompleteCollection > 
ScriptIDEAutocompleteCollectionObserver
 
typedef agx::ref_ptr
< ScriptIDEAutocompleteCollection > 
ScriptIDEAutocompleteCollectionRef
 
typedef agx::observer_ptr
< const ScriptIDEAutocomplete > 
ScriptIDEAutocompleteConstObserver
 
typedef agx::ref_ptr< const
ScriptIDEAutocomplete > 
ScriptIDEAutocompleteConstRef
 
typedef agx::observer_ptr
< ScriptIDEAutocomplete > 
ScriptIDEAutocompleteObserver
 
typedef agx::ref_ptr
< ScriptIDEAutocomplete > 
ScriptIDEAutocompleteRef
 
typedef agx::observer_ptr
< const ScriptIDE > 
ScriptIDEConstObserver
 
typedef agx::ref_ptr< const
ScriptIDE > 
ScriptIDEConstRef
 
typedef agx::observer_ptr
< const
ScriptIDEDataCollection > 
ScriptIDEDataCollectionConstObserver
 
typedef agx::ref_ptr< const
ScriptIDEDataCollection > 
ScriptIDEDataCollectionConstRef
 
typedef agx::observer_ptr
< ScriptIDEDataCollection > 
ScriptIDEDataCollectionObserver
 
typedef agx::ref_ptr
< ScriptIDEDataCollection > 
ScriptIDEDataCollectionRef
 
typedef agx::observer_ptr
< const ScriptIDEData > 
ScriptIDEDataConstObserver
 
typedef agx::ref_ptr< const
ScriptIDEData > 
ScriptIDEDataConstRef
 
typedef agx::observer_ptr
< ScriptIDEData > 
ScriptIDEDataObserver
 
typedef agx::ref_ptr
< ScriptIDEData > 
ScriptIDEDataRef
 
typedef agx::observer_ptr
< ScriptIDE > 
ScriptIDEObserver
 
typedef agx::ref_ptr< ScriptIDE > ScriptIDERef
 
typedef agx::observer_ptr
< const
ScriptSimulationParameter > 
ScriptSimulationParameterConstObserver
 
typedef agx::ref_ptr< const
ScriptSimulationParameter > 
ScriptSimulationParameterConstRef
 
typedef agx::observer_ptr
< ScriptSimulationParameter > 
ScriptSimulationParameterObserver
 
typedef agx::ref_ptr
< ScriptSimulationParameter > 
ScriptSimulationParameterRef
 
typedef agx::observer_ptr
< const
StartPlaybackSignalCallback > 
StartPlaybackSignalCallbackConstObserver
 
typedef agx::ref_ptr< const
StartPlaybackSignalCallback > 
StartPlaybackSignalCallbackConstRef
 
typedef agx::observer_ptr
< StartPlaybackSignalCallback > 
StartPlaybackSignalCallbackObserver
 
typedef agx::ref_ptr
< StartPlaybackSignalCallback > 
StartPlaybackSignalCallbackRef
 
typedef agx::observer_ptr
< const
StartRecordingSignalCallback > 
StartRecordingSignalCallbackConstObserver
 
typedef agx::ref_ptr< const
StartRecordingSignalCallback > 
StartRecordingSignalCallbackConstRef
 
typedef agx::observer_ptr
< StartRecordingSignalCallback > 
StartRecordingSignalCallbackObserver
 
typedef agx::ref_ptr
< StartRecordingSignalCallback > 
StartRecordingSignalCallbackRef
 
typedef agx::observer_ptr
< const
StopPlaybackSignalCallback > 
StopPlaybackSignalCallbackConstObserver
 
typedef agx::ref_ptr< const
StopPlaybackSignalCallback > 
StopPlaybackSignalCallbackConstRef
 
typedef agx::observer_ptr
< StopPlaybackSignalCallback > 
StopPlaybackSignalCallbackObserver
 
typedef agx::ref_ptr
< StopPlaybackSignalCallback > 
StopPlaybackSignalCallbackRef
 
typedef agx::observer_ptr
< const
StopRecordingSignalCallback > 
StopRecordingSignalCallbackConstObserver
 
typedef agx::ref_ptr< const
StopRecordingSignalCallback > 
StopRecordingSignalCallbackConstRef
 
typedef agx::observer_ptr
< StopRecordingSignalCallback > 
StopRecordingSignalCallbackObserver
 
typedef agx::ref_ptr
< StopRecordingSignalCallback > 
StopRecordingSignalCallbackRef
 

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 ()
 

Detailed Description

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 Documentation

Definition at line 36 of file ScriptIDE.h.

Definition at line 36 of file ScriptIDE.h.

Definition at line 39 of file ScriptIDEData.h.

Definition at line 36 of file ScriptIDE.h.

Definition at line 36 of file ScriptIDE.h.

Enumeration Type Documentation

Enumerator
SCRIPTCONTEXT_INVALID 
SCRIPTCONTEXT_PYTHON 
SCRIPTCONTEXT_AGXVIEWER 
SCRIPTCONTEXT_FMI 
SCRIPTCONTEXT_QTVIEWER 

Definition at line 66 of file agxPython/ScriptManager.h.

Function Documentation

AGXPYTHON_EXPORT bool agxPython::doFile ( const std::string &  path)
AGXPYTHON_EXPORT ScriptContext* agxPython::getContext ( )
AGXPYTHON_EXPORT bool agxPython::scriptIsAttached ( )