Class ExecutionEngine

java.lang.Object
com.nomagic.magicdraw.simulation.engine.ExecutionEngine

@OpenApi public abstract class ExecutionEngine extends Object
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 Details

    • session

      @OpenApi protected SimulationSession session
      a reference to the running session of this engine.
    • isInterrupted

      protected AtomicBoolean 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

      protected AtomicBoolean 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

      @OpenApi public ExecutionEngine(ExecutionEngineDescriptor engineDescriptor)
      Constructor.
      Parameters:
      engineDescriptor - the given engine's descriptor.
  • Method Details

    • getEngineDescriptor

      @OpenApi public ExecutionEngineDescriptor getEngineDescriptor()
      ExecutionEngineDescriptor getter.
      Returns:
      ExecutionEngineDescriptor
    • getAnimationController

      public com.nomagic.magicdraw.simulation.engine.EngineAnimationController getAnimationController()
    • init

      @OpenApi public abstract void init(Element element)
      Engine initialization.
      Parameters:
      element - the given element
    • execute

      @OpenApi public abstract void execute(Element element)
      Engine execution.
      Parameters:
      element - the given element
    • onClose

      @OpenApi public abstract void onClose()
      Engine onClose.
    • internalInit

      public final void internalInit(Element element)
      Engine internal initialization.
      Parameters:
      element - the specified element
    • internalExecute

      public final void internalExecute(Element element)
      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

      @OpenApi public void addEngineListener(EngineListener listener)
      Add the specified engine listener to the storing engine listener list.
      Parameters:
      listener - the specified engine listener
    • addEngineListener

      public void addEngineListener(EngineListener listener, int index)
      Add the specified engine listener to the storing engine listener list with specified position.
      Parameters:
      listener - the specified engine listener
      index - the index to add
    • removeEngineListener

      @OpenApi public void removeEngineListener(EngineListener listener)
      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 listener
      index - 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

      @OpenApi public List<EngineListener> 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

      @OpenApi public void activateElement(Element element, Collection<?> c)
      Activate the element, it delegates to all storing engine listener.
      Parameters:
      element - the specified element
      c - 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 element
      info - ActivationInfo
    • deactivateElement

      @OpenApi public void deactivateElement(Element element, Collection<?> c)
      Deactivate the element, it delegates to all storing engine listener.
      Parameters:
      element - the specified element
      c - 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 element
      info - ActivationInfo
    • triggerEvent

      @OpenApi public void triggerEvent(String event)
      Trigger the specified event, it delegates to all storing engine listener.
      Parameters:
      event - the specified event
    • getAvailableSignals

      public Set<Signal> 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

      public String getValuesAsString(@CheckForNull Collection<?> values)
      Get the string of the given collection.
      Parameters:
      values - the specified collection
      Returns:
      the string value
    • getNormativeValues

      public Collection<String> getNormativeValues(Collection<?> values)
      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

      public void setSession(SimulationSession session)
      Session setter.
      Parameters:
      session - the specified session
    • getSession

      public SimulationSession getSession()
      Session getter.
      Returns:
      Session
    • setStatus

      public void setStatus(com.nomagic.magicdraw.simulation.engine.ExecutionStatus status)
      Set status.
      Parameters:
      status - the specified status
    • getActiveElements

      @OpenApi public List<Element> getActiveElements()
      Gets active elements.
      Returns:
      Active elements
    • getLastVisitedElement

      @OpenApi @CheckForNull public Element 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

      public void runWhenExecutionFinished(Runnable runnable)
      Thread safe way to ensure that runnable will be called exactly once when engine has finished execution