Class ExecutionEngine


  • @OpenApi
    public abstract class ExecutionEngine
    extends java.lang.Object
    The abstract class of the execution engine that all specific execution engines must extend, and override abstract methods (init(), execute(), onClose). It maintains the list of EngineListener, and its descriptor ExecutionEngineDescriptor.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.List<com.nomagic.magicdraw.simulation.engine.InternalEngineListener> internalListeners  
      protected java.util.concurrent.atomic.AtomicBoolean isClosed
      if this flag is true, it tells that the engine is already closed.
      protected java.util.concurrent.atomic.AtomicBoolean isInterrupted
      if this flag is true, it tells that the engine is interrupted and it is closing.
      protected SimulationSession session
      a reference to the running session of this engine.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void activateElement​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element element, com.nomagic.magicdraw.simulation.execution.data.ActivationInfo info)
      Activate the element, it delegates to all storing engine listener.
      void activateElement​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element element, java.util.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​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element element, com.nomagic.magicdraw.simulation.execution.data.ActivationInfo info)
      Deactivate the element, it delegates to all storing engine listener.
      void deactivateElement​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element element, java.util.Collection<?> c)
      Deactivate the element, it delegates to all storing engine listener.
      void destroyObject()
      Destroys object.
      java.lang.String evaluateCommand​(java.lang.String commandRcvd, java.lang.String language, com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element elementContainer)
      Evaluate the specified command as string.
      abstract void execute​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element element)
      Engine execution.
      void executionFinished()
      Set executionFinished = true.
      java.util.List<com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element> getActiveElements()
      Gets active elements.
      com.nomagic.magicdraw.simulation.engine.EngineAnimationController getAnimationController()  
      java.util.Set<com.nomagic.uml2.ext.magicdraw.commonbehaviors.mdcommunications.Signal> getAvailableSignals()
      Returns all available signals at current state.
      ExecutionEngineDescriptor getEngineDescriptor()
      ExecutionEngineDescriptor getter.
      java.util.List<EngineListener> getEngineListeners()
      Get the engine listener list.
      java.util.List<com.nomagic.magicdraw.simulation.engine.InternalEngineListener> getInternalEngineListeners()
      Get the engine listener list.
      com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element getLastVisitedElement()
      Gets last visited element.
      java.util.Collection<java.lang.String> getNormativeValues​(java.util.Collection<?> values)
      Get the normative values collection from the specified value collection.
      SimulationSession getSession()
      Session getter.
      com.nomagic.magicdraw.simulation.engine.ExecutionStatus getStatus()
      Get the execution status.
      java.lang.String getValuesAsString​(java.util.Collection<?> values)
      Get the string of the given collection.
      abstract void init​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element element)
      Engine initialization.
      void internalExecute​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element element)
      Engine internal execution.
      void internalInit​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element element)
      Engine internal initialization.
      void internalOnClose()
      Engine internal onClose.
      void interupt()
      Interrupt this engine.
      boolean isExecutionFinished()
      Get executionFinished.
      boolean isInterrupted()
      return boolean value of isInterupted.
      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 setSession​(SimulationSession session)
      Session setter.
      void setStatus​(com.nomagic.magicdraw.simulation.engine.ExecutionStatus status)
      Set status.
      void triggerEvent​(java.lang.String event)
      Trigger the specified event, it delegates to all storing engine listener.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • session

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

        protected java.util.concurrent.atomic.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 java.util.concurrent.atomic.AtomicBoolean isClosed
        if this flag is true, it tells that the engine is already closed. all onClose tasks have been done.
      • internalListeners

        protected final java.util.List<com.nomagic.magicdraw.simulation.engine.InternalEngineListener> internalListeners
    • Constructor Detail

      • ExecutionEngine

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

      • getEngineDescriptor

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

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

        @OpenApi
        public abstract void init​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element element)
        Engine initialization.
        Parameters:
        element - the given element
      • execute

        @OpenApi
        public abstract void execute​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element element)
        Engine execution.
        Parameters:
        element - the given element
      • onClose

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

        public final void internalInit​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element element)
        Engine internal initialization.
        Parameters:
        element - the specified element
      • internalExecute

        public final void internalExecute​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element element)
        Engine internal execution.
        Parameters:
        element - the specified element
      • internalOnClose

        public final void internalOnClose()
        Engine internal onClose.
      • 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 java.util.List<EngineListener> getEngineListeners()
        Get the engine listener list.
        Returns:
        the engine listener list.
      • getInternalEngineListeners

        public java.util.List<com.nomagic.magicdraw.simulation.engine.InternalEngineListener> getInternalEngineListeners()
        Get the engine listener list.
        Returns:
        the engine listener list.
      • activateElement

        @OpenApi
        public void activateElement​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element element,
                                    java.util.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​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.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​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element element,
                                      java.util.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​(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.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​(java.lang.String event)
        Trigger the specified event, it delegates to all storing engine listener.
        Parameters:
        event - the specified event
      • getAvailableSignals

        public java.util.Set<com.nomagic.uml2.ext.magicdraw.commonbehaviors.mdcommunications.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 java.lang.String getValuesAsString​(@CheckForNull
                                                  java.util.Collection<?> values)
        Get the string of the given collection.
        Parameters:
        values - the specified collection
        Returns:
        the string value
      • getNormativeValues

        public java.util.Collection<java.lang.String> getNormativeValues​(java.util.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
      • evaluateCommand

        public java.lang.String evaluateCommand​(java.lang.String commandRcvd,
                                                java.lang.String language,
                                                com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element elementContainer)
        Evaluate the specified command as string.
        Parameters:
        commandRcvd - the specified command
        language - for evaluation
        elementContainer - the element container for access the tag variable
        Returns:
        string
      • 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 java.util.List<com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element> getActiveElements()
        Gets active elements.
        Returns:
        Active elements
      • getLastVisitedElement

        @OpenApi
        @CheckForNull
        public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element getLastVisitedElement()
        Gets last visited element.
        Returns:
        Last visited element
      • interupt

        public void interupt()
        Interrupt this engine.
      • isInterrupted

        public boolean isInterrupted()
        return boolean value of isInterupted.
        Returns:
        boolean value of isInterupted.
      • executionFinished

        public void executionFinished()
        Set executionFinished = true.
      • isExecutionFinished

        public boolean isExecutionFinished()
        Get executionFinished.
        Returns:
        executionFinished