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 AtomicBoolean
if this flag is true, it tells that the engine is already closed.protected AtomicBoolean
if this flag is true, it tells that the engine is interrupted and it is closing.protected SimulationSession
a reference to the running session of this engine. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
activateElement
(Element element, com.nomagic.magicdraw.simulation.execution.data.ActivationInfo info) Activate the element, it delegates to all storing engine listener.void
activateElement
(Element element, Collection<?> c) Activate the element, it delegates to all storing engine listener.void
addEngineListener
(EngineListener listener) Add the specified engine listener to the storing engine listener list.void
addEngineListener
(EngineListener listener, int index) Add the specified engine listener to the storing engine listener list with specified position.void
addInternalEngineListener
(com.nomagic.magicdraw.simulation.engine.InternalEngineListener listener) Add the specified internal engine listener to the storing engine listener list.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.void
deactivateElement
(Element element, com.nomagic.magicdraw.simulation.execution.data.ActivationInfo info) Deactivate the element, it delegates to all storing engine listener.void
deactivateElement
(Element element, Collection<?> c) Deactivate the element, it delegates to all storing engine listener.void
Destroys object.abstract void
Engine execution.Gets active elements.com.nomagic.magicdraw.simulation.engine.EngineAnimationController
Returns 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.Session
getter.com.nomagic.magicdraw.simulation.engine.ExecutionStatus
Get the execution status.getValuesAsString
(Collection<?> values) Get the string of the given collection.abstract void
Engine initialization.final void
internalExecute
(Element element) Engine internal execution.final void
internalInit
(Element element) Engine internal initialization.final void
Engine internal onClose.void
Interrupt this engine.boolean
isClosed()
boolean
boolean
Get executionFinished.boolean
return boolean value of isInterrupted.abstract void
onClose()
Engine onClose.void
removeEngineListener
(EngineListener listener) Remove the specified engine listener from the storing engine listener list.void
removeInternalEngineListener
(com.nomagic.magicdraw.simulation.engine.InternalEngineListener listener) Remove the specified internal engine listener from the storing internal engine listener list.void
runWhenExecutionFinished
(Runnable runnable) Thread safe way to ensure that runnable will be called exactly once when engine has finished executionvoid
setSession
(SimulationSession session) Session
setter.void
setStatus
(com.nomagic.magicdraw.simulation.engine.ExecutionStatus status) Set status.void
triggerEvent
(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
Session
setter.- Parameters:
session
- the specified session
-
getSession
Session
getter.- 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
-