Class ExecutionEngine
java.lang.Object
com.nomagic.magicdraw.simulation.engine.ExecutionEngine
Allows executing
Behavior in a customized
way during simulation execution. Currently, supports overriding execution behavior of :
- StateMachine
- Interaction
- Activity, unless the Activity is the target of the simulation execution itself
Note: Simulation execution target is always executed with the default fUML ExecutionEngine to initialize the fUML runtime values-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<com.nomagic.magicdraw.simulation.engine.InternalEngineListener>protected AtomicBooleanif this flag is true, it tells that the engine is already closed.protected AtomicBooleanif this flag is true, it tells that the engine is interrupted and it is closing.protected SimulationSessiona reference to the running session of this engine. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivateElement(Element element, com.nomagic.magicdraw.simulation.execution.data.ActivationInfo info) Activate the element, it delegates to all storing engine listener.voidactivateElement(Element element, Collection<?> c) Activate the element, it delegates to all storing engine listener.voidaddEngineListener(EngineListener listener) Add the specified engine listener to the storing engine listener list.voidaddEngineListener(EngineListener listener, int index) Add the specified engine listener to the storing engine listener list with specified position.voidaddInternalEngineListener(com.nomagic.magicdraw.simulation.engine.InternalEngineListener listener) Add the specified internal engine listener to the storing engine listener list.voidaddInternalEngineListener(com.nomagic.magicdraw.simulation.engine.InternalEngineListener listener, int index) Add the specified internal engine listener to the storing internal engine listener list with specified position.voiddeactivateElement(Element element, com.nomagic.magicdraw.simulation.execution.data.ActivationInfo info) Deactivate the element, it delegates to all storing engine listener.voiddeactivateElement(Element element, Collection<?> c) Deactivate the element, it delegates to all storing engine listener.voidDestroys object.abstract voidEngine execution.Gets active elements.com.nomagic.magicdraw.simulation.engine.EngineAnimationControllerReturns all available signals at current state.ExecutionEngineDescriptor getter.Get the engine listener list.List<com.nomagic.magicdraw.simulation.engine.InternalEngineListener>Get the engine listener list.Gets last visited element - element that was activated last and is already deactivatedgetNormativeValues(Collection<?> values) Get the normative values collection from the specified value collection.Sessiongetter.com.nomagic.magicdraw.simulation.engine.ExecutionStatusGet the execution status.getValuesAsString(Collection<?> values) Get the string of the given collection.abstract voidEngine initialization.final voidinternalExecute(Element element) Engine internal execution.final voidinternalInit(Element element) Engine internal initialization.final voidEngine internal onClose.voidInterrupt this engine.booleanisClosed()booleanbooleanGet executionFinished.booleanreturn boolean value of isInterrupted.abstract voidonClose()Engine onClose.voidremoveEngineListener(EngineListener listener) Remove the specified engine listener from the storing engine listener list.voidremoveInternalEngineListener(com.nomagic.magicdraw.simulation.engine.InternalEngineListener listener) Remove the specified internal engine listener from the storing internal engine listener list.voidrunWhenExecutionFinished(Runnable runnable) Thread safe way to ensure that runnable will be called exactly once when engine has finished executionvoidsetSession(SimulationSession session) Sessionsetter.voidsetStatus(com.nomagic.magicdraw.simulation.engine.ExecutionStatus status) Set status.voidtriggerEvent(String event) Trigger the specified event, it delegates to all storing engine listener.
-
Field Details
-
session
a reference to the running session of this engine. -
isInterrupted
if this flag is true, it tells that the engine is interrupted and it is closing. this flag is used to checked in internalOnClose(). -
isClosed
if this flag is true, it tells that the engine is already closed. all onClose tasks have been done. -
internalListeners
protected final List<com.nomagic.magicdraw.simulation.engine.InternalEngineListener> internalListeners
-
-
Constructor Details
-
ExecutionEngine
Constructor.- Parameters:
engineDescriptor- the given engine's descriptor.
-
-
Method Details
-
getEngineDescriptor
ExecutionEngineDescriptor getter.- Returns:
- ExecutionEngineDescriptor
-
getAnimationController
public com.nomagic.magicdraw.simulation.engine.EngineAnimationController getAnimationController() -
init
Engine initialization.- Parameters:
element- the given element
-
execute
Engine execution.- Parameters:
element- the given element
-
onClose
@OpenApi public abstract void onClose()Engine onClose. -
internalInit
Engine internal initialization.- Parameters:
element- the specified element
-
internalExecute
Engine internal execution.- Parameters:
element- the specified element
-
internalOnClose
public final void internalOnClose()Engine internal onClose. -
isClosing
public boolean isClosing() -
isClosed
public boolean isClosed() -
destroyObject
public void destroyObject()Destroys object. -
addEngineListener
Add the specified engine listener to the storing engine listener list.- Parameters:
listener- the specified engine listener
-
addEngineListener
Add the specified engine listener to the storing engine listener list with specified position.- Parameters:
listener- the specified engine listenerindex- the index to add
-
removeEngineListener
Remove the specified engine listener from the storing engine listener list.- Parameters:
listener- the specified engine listener
-
addInternalEngineListener
public void addInternalEngineListener(com.nomagic.magicdraw.simulation.engine.InternalEngineListener listener) Add the specified internal engine listener to the storing engine listener list.- Parameters:
listener- the specified internal engine listener
-
addInternalEngineListener
public void addInternalEngineListener(com.nomagic.magicdraw.simulation.engine.InternalEngineListener listener, int index) Add the specified internal engine listener to the storing internal engine listener list with specified position.- Parameters:
listener- the specified internal engine listenerindex- the index to add
-
removeInternalEngineListener
public void removeInternalEngineListener(com.nomagic.magicdraw.simulation.engine.InternalEngineListener listener) Remove the specified internal engine listener from the storing internal engine listener list.- Parameters:
listener- the specified internal engine listener
-
getEngineListeners
Get the engine listener list.- Returns:
- the engine listener list.
-
getInternalEngineListeners
public List<com.nomagic.magicdraw.simulation.engine.InternalEngineListener> getInternalEngineListeners()Get the engine listener list.- Returns:
- the engine listener list.
-
activateElement
Activate the element, it delegates to all storing engine listener.- Parameters:
element- the specified elementc- the passing values
-
activateElement
public void activateElement(Element element, com.nomagic.magicdraw.simulation.execution.data.ActivationInfo info) Activate the element, it delegates to all storing engine listener.- Parameters:
element- the specified elementinfo- ActivationInfo
-
deactivateElement
Deactivate the element, it delegates to all storing engine listener.- Parameters:
element- the specified elementc- the passing values
-
deactivateElement
public void deactivateElement(Element element, com.nomagic.magicdraw.simulation.execution.data.ActivationInfo info) Deactivate the element, it delegates to all storing engine listener.- Parameters:
element- the specified elementinfo- ActivationInfo
-
triggerEvent
Trigger the specified event, it delegates to all storing engine listener.- Parameters:
event- the specified event
-
getAvailableSignals
Returns all available signals at current state. For the state machine, available signals can change current state to another state.
Default implementation returns an empty Set.- Returns:
- the available signals at current state.
-
getValuesAsString
Get the string of the given collection.- Parameters:
values- the specified collection- Returns:
- the string value
-
getNormativeValues
Get the normative values collection from the specified value collection.- Parameters:
values- the specified value collection.- Returns:
- the normative values collection
-
getStatus
public com.nomagic.magicdraw.simulation.engine.ExecutionStatus getStatus()Get the execution status.- Returns:
- the execution status
-
setSession
Sessionsetter.- Parameters:
session- the specified session
-
getSession
Sessiongetter.- Returns:
Session
-
setStatus
public void setStatus(com.nomagic.magicdraw.simulation.engine.ExecutionStatus status) Set status.- Parameters:
status- the specified status
-
getActiveElements
Gets active elements.- Returns:
- Active elements
-
getLastVisitedElement
Gets last visited element - element that was activated last and is already deactivated- Returns:
- Last visited element
-
interrupt
public void interrupt()Interrupt this engine. -
isInterrupted
public boolean isInterrupted()return boolean value of isInterrupted.- Returns:
- boolean value of isInterrupted.
-
isExecutionFinished
public boolean isExecutionFinished()Get executionFinished.- Returns:
- executionFinished
-
runWhenExecutionFinished
Thread safe way to ensure that runnable will be called exactly once when engine has finished execution
-