Class SimulationManager


  • @OpenApiAll
    public final class SimulationManager
    extends java.lang.Object
    API for running and stopping simulations and registering simulation listeners
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static SimulationResult execute​(Element element, boolean start)
      Non-blocking method for executing the specific element.
      static SimulationResult executeWithConfig​(Element target, Element simulationConfig, boolean start)
      Executes the target element with a specific simulation config.
      static fUML.Semantics.Classes.Kernel.Object_ getContext​(SimulationSession session)
      Get the context of the running session.
      static SimulationSession getRefSession​(fUML.Semantics.Classes.Kernel.Object_ object)
      Get the referenced session of the specified object.
      static fUML.Semantics.Classes.Kernel.Object_ getRootContext​(SimulationSession session)
      Get the root context of the running session.
      static SimulationSession getSession​(SimulationResult result)
      Retrieves simulation session from simulation result.
      static boolean isSilentSimulation​(SimulationSession session)
      Check the simulation runt in silent mode or not.
      static void logConsoleDebug​(BaseElement element, java.lang.String message)
      Log the specified message to the simulation console with "DEBUG" log level.
      static void logConsoleError​(BaseElement element, java.lang.String message)
      Log the specified message to the simulation console with "ERROR" log level.
      static void logConsoleInfo​(BaseElement element, java.lang.String message)
      Log the specified message to the simulation console with "INFO" log level.
      static void logConsoleWarn​(BaseElement element, java.lang.String message)
      Log the specified message to the simulation console with "WARN" log level.
      static void registerEngine​(ExecutionEngineDescriptor engineDescriptor)
      Registers an engine descriptor to the simulation framework.
      static void registerSimulationExecutionListener​(SimulationExecutionListener listener)
      Register the simulation execution listener.
      static void registerSimulationExecutionListener​(SimulationExecutionListener listener, SimulationExecution execution)
      Register the simulation execution listener dynamically to the specified SimulationExecution.
      static void registerSimulationOptionsProvider​(SimulationOptionsProvider optionsProvider)
      Register the simulation options provider.
      static java.util.Map<java.lang.String,​java.lang.Object> simulate​(BaseElement context, java.lang.String simulationConfigKeyword, java.lang.Object... inputs)
      Executes the simulation config with custom initial values.
      static java.util.Map<java.lang.String,​java.lang.Object> simulate​(BaseElement context, java.lang.String simulationConfigKeyword, java.lang.String[] outputs, java.lang.Object... inputs)
      Executes the simulation config with custom initial values.
      static java.util.Map<java.lang.String,​java.lang.Object> simulate​(BaseElement context, java.lang.String configKeyword, java.lang.String targetKeyword, java.lang.String[] outputs, java.lang.Object... inputs)
      Executes the target element with a specific simulation config with custom initial values.
      static java.util.Map<java.lang.String,​java.lang.Object> simulate​(Element simulationConfig, Element target, java.lang.Object... inputs)
      Executes the target element with a specific simulation config with initial custom values.
      static java.util.Map<java.lang.String,​java.lang.Object> simulate​(Element simulationConfig, Element target, java.lang.String[] outputs, java.lang.Object... inputs)
      Executes the target element with a specific simulation config with custom initial values.
      static java.util.Map<java.lang.String,​java.lang.Object> simulate​(Element simulationConfig, Element target, java.util.Collection<java.lang.String> outputs, java.util.Map<java.lang.String,​java.lang.Object> inputs)
      Executes the target element with a specific simulation config with custom initial values.
      static java.util.Map<java.lang.String,​java.lang.Object> simulate​(Element simulationConfig, java.lang.Object... inputs)
      Executes the simulation config with custom initial values.
      static java.util.Map<java.lang.String,​java.lang.Object> simulate​(Element element, java.lang.String[] outputs, java.lang.Object... inputs)
      Executes the simulation config with initial custom values.
      static java.util.Map<java.lang.String,​java.lang.Object> simulate​(Element element, java.util.Collection<java.lang.String> outputs, java.util.Map<java.lang.String,​java.lang.Object> inputs)
      Executes the simulation config or an element with custom initial values.
      static SimulationResult simulateAsync​(Element simulationConfig, Element target, java.lang.String[] outputs, java.lang.Object... inputs)
      Asynchronously executes the target element with a specific simulation config with custom initial parameters values.
      static SimulationResult simulateAsync​(Element simulationConfig, Element target, java.util.Collection<java.lang.String> outputs, java.util.Map<java.lang.String,​java.lang.Object> inputs)
      Asynchronously executes the target element with a specific simulation config with custom initial parameters values.
      static void terminate​(SimulationResult result)
      Terminate the running session.
      static void terminateSession​(SimulationSession session)
      Terminate the running session.
      static void unregisterSimulationExecutionListener​(SimulationExecutionListener listener)
      Unregister the simulation execution listener.
      static void unregisterSimulationExecutionListener​(SimulationExecutionListener listener, SimulationExecution execution)
      unregister the simulation execution listener dynamically from the specified SimulationExecution.
      static void unregisterSimulationOptionsProvider​(SimulationOptionsProvider optionsProvider)
      Unregister the simulation options provider.
      • Methods inherited from class java.lang.Object

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

      • SimulationManager

        public SimulationManager()
    • Method Detail

      • registerEngine

        public static void registerEngine​(ExecutionEngineDescriptor engineDescriptor)
        Registers an engine descriptor to the simulation framework.
        Parameters:
        engineDescriptor - an engine descriptor.
      • execute

        public static SimulationResult execute​(Element element,
                                               boolean start)
        Non-blocking method for executing the specific element.
        Parameters:
        element - the element that be executed
        start - if this flag is true, it will auto start the session. if the element is SimulationConfig, this flag will be ignored, it will use value inside SimulationConfig instead.
        Returns:
        the created SimulationResult. If this method is called in EDT, the returned SimulationResult will not be completed yet, it requires to release EDT for values completion.
      • executeWithConfig

        public static SimulationResult executeWithConfig​(Element target,
                                                         Element simulationConfig,
                                                         boolean start)
        Executes the target element with a specific simulation config. Non-blocking method.
        Parameters:
        target - target element to execute, for example InstanceSpecification
        simulationConfig - config that is compatible with the target element
        start - if this flag is true, it will auto start the session.
        Returns:
        the created SimulationResult.
      • isSilentSimulation

        public static boolean isSilentSimulation​(SimulationSession session)
        Check the simulation runt in silent mode or not.
        Parameters:
        session - the simulation session.
        Returns:
        true if simulation run in silent mode
      • terminateSession

        public static void terminateSession​(@CheckForNull
                                            SimulationSession session)
        Terminate the running session.
        Parameters:
        session - the session being terminated
      • terminate

        public static void terminate​(@CheckForNull
                                     SimulationResult result)
        Terminate the running session. If session is not found, interrupt all running tasks.
      • registerSimulationExecutionListener

        public static void registerSimulationExecutionListener​(SimulationExecutionListener listener)
        Register the simulation execution listener.
        Parameters:
        listener - the registered simulation execution listener
      • registerSimulationExecutionListener

        public static void registerSimulationExecutionListener​(SimulationExecutionListener listener,
                                                               SimulationExecution execution)
        Register the simulation execution listener dynamically to the specified SimulationExecution.
        Parameters:
        listener - the registered simulation execution listener
        execution - the simulation execution
      • registerSimulationOptionsProvider

        public static void registerSimulationOptionsProvider​(SimulationOptionsProvider optionsProvider)
        Register the simulation options provider.
        Parameters:
        optionsProvider - the registered simulation options provider
      • unregisterSimulationExecutionListener

        public static void unregisterSimulationExecutionListener​(SimulationExecutionListener listener)
        Unregister the simulation execution listener.
        Parameters:
        listener - the unregistered simulation execution listener
      • unregisterSimulationExecutionListener

        public static void unregisterSimulationExecutionListener​(SimulationExecutionListener listener,
                                                                 SimulationExecution execution)
        unregister the simulation execution listener dynamically from the specified SimulationExecution.
        Parameters:
        listener - the unregistered simulation execution listener
        execution - the simulation execution
      • unregisterSimulationOptionsProvider

        public static void unregisterSimulationOptionsProvider​(SimulationOptionsProvider optionsProvider)
        Unregister the simulation options provider.
        Parameters:
        optionsProvider - the registered simulation options provider
      • logConsoleDebug

        public static void logConsoleDebug​(BaseElement element,
                                           java.lang.String message)
        Log the specified message to the simulation console with "DEBUG" log level.
        Parameters:
        element - an element of the running simulation
        message - the specified message
      • logConsoleInfo

        public static void logConsoleInfo​(BaseElement element,
                                          java.lang.String message)
        Log the specified message to the simulation console with "INFO" log level.
        Parameters:
        element - an element of the running simulation
        message - the specified message
      • logConsoleWarn

        public static void logConsoleWarn​(BaseElement element,
                                          java.lang.String message)
        Log the specified message to the simulation console with "WARN" log level.
        Parameters:
        element - an element of the running simulation
        message - the specified message
      • logConsoleError

        public static void logConsoleError​(BaseElement element,
                                           java.lang.String message)
        Log the specified message to the simulation console with "ERROR" log level.
        Parameters:
        element - an element of the running simulation
        message - the specified message
      • getRefSession

        @CheckForNull
        public static SimulationSession getRefSession​(fUML.Semantics.Classes.Kernel.Object_ object)
        Get the referenced session of the specified object. If object is typed by Object_, the referenced session is a session that object was created.
        Parameters:
        object - a specified Object_
        Returns:
        the referenced SimulationSession
      • getSession

        @CheckForNull
        public static SimulationSession getSession​(SimulationResult result)
        Retrieves simulation session from simulation result.
        Returns:
        session retrieved from simulation result
      • getRootContext

        @CheckForNull
        public static fUML.Semantics.Classes.Kernel.Object_ getRootContext​(SimulationSession session)
        Get the root context of the running session.
        Parameters:
        session - the running session
        Returns:
        the root context
      • getContext

        @CheckForNull
        public static fUML.Semantics.Classes.Kernel.Object_ getContext​(SimulationSession session)
        Get the context of the running session.
        Parameters:
        session - the running session
        Returns:
        the context of the running session
      • simulate

        public static java.util.Map<java.lang.String,​java.lang.Object> simulate​(BaseElement context,
                                                                                      java.lang.String configKeyword,
                                                                                      @CheckForNull
                                                                                      java.lang.String targetKeyword,
                                                                                      @CheckForNull
                                                                                      java.lang.String[] outputs,
                                                                                      java.lang.Object... inputs)
                                                                               throws com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException
        Executes the target element with a specific simulation config with custom initial values. Returns specified simulation parameters values, or all simulation values if it isn't specified.
        Parameters:
        context - search context where to look simulationConfigKeyword and targetKeyword
        configKeyword - config name or id that is compatible with the target element
        targetKeyword - the target element name or id to execute, for example InstanceSpecification
        outputs - array of parameters names which will be returned
        inputs - key value pair of parameters values which will be used in simulation
        Returns:
        the simulation parameters values
        Throws:
        com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException - if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
      • simulate

        public static java.util.Map<java.lang.String,​java.lang.Object> simulate​(BaseElement context,
                                                                                      java.lang.String simulationConfigKeyword,
                                                                                      java.lang.Object... inputs)
                                                                               throws com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException
        Executes the simulation config with custom initial values. Returns specified simulation parameters values, or all simulation values if it isn't specified.
        Parameters:
        context - search context where to look simulationConfigKeyword
        simulationConfigKeyword - simulation config name or id
        inputs - key value pair of parameters values which will be used in simulation
        Returns:
        the simulation parameters values
        Throws:
        com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException - if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
      • simulate

        public static java.util.Map<java.lang.String,​java.lang.Object> simulate​(BaseElement context,
                                                                                      java.lang.String simulationConfigKeyword,
                                                                                      @CheckForNull
                                                                                      java.lang.String[] outputs,
                                                                                      java.lang.Object... inputs)
                                                                               throws com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException
        Executes the simulation config with custom initial values. Returns specified simulation parameters values, or all simulation values if it isn't specified.
        Parameters:
        context - search context where to look simulation config
        simulationConfigKeyword - simulation configuration name or id
        outputs - array of parameters names which will be returned
        inputs - key value pair of parameters values which will be used in simulation
        Returns:
        the simulation parameters values
        Throws:
        com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException - if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
      • simulate

        public static java.util.Map<java.lang.String,​java.lang.Object> simulate​(Element simulationConfig,
                                                                                      Element target,
                                                                                      java.lang.Object... inputs)
                                                                               throws com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException
        Executes the target element with a specific simulation config with initial custom values. Returns specified simulation parameters values, or all simulation values if it isn't specified.
        Parameters:
        simulationConfig - that is compatible with the target element
        target - the element to execute, for example InstanceSpecification
        inputs - key value pair of parameters values which will be used in simulation
        Returns:
        the simulation parameters values
        Throws:
        com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException - if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
      • simulate

        public static java.util.Map<java.lang.String,​java.lang.Object> simulate​(Element simulationConfig,
                                                                                      java.lang.Object... inputs)
                                                                               throws com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException
        Executes the simulation config with custom initial values. Returns specified simulation parameters values, or all simulation values if it isn't specified.
        Parameters:
        simulationConfig - the element to execute
        inputs - key value pair of parameters values which will be used in simulation
        Returns:
        the simulation parameters values
        Throws:
        com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException - if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
      • simulate

        public static java.util.Map<java.lang.String,​java.lang.Object> simulate​(Element element,
                                                                                      java.lang.String[] outputs,
                                                                                      java.lang.Object... inputs)
                                                                               throws com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException
        Executes the simulation config with initial custom values. This is a blocking method. Returns specified simulation parameters values, or all simulation values if it isn't specified.
        Parameters:
        element - the element to execute - either a SimulationConfig, or a Classifier/Behavior directly.
        outputs - names of parameter runtime values to be returned when simulation completes. When null is provided, all values will be returned.
        inputs - key-value map of values which will be used as initial values for the execution. When null is provided, execution will be initialized with values as described in the model.
        Returns:
        the simulation parameters values
        Throws:
        com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException - if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
      • simulate

        public static java.util.Map<java.lang.String,​java.lang.Object> simulate​(Element element,
                                                                                      @CheckForNull
                                                                                      java.util.Collection<java.lang.String> outputs,
                                                                                      @CheckForNull
                                                                                      java.util.Map<java.lang.String,​java.lang.Object> inputs)
                                                                               throws com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException
        Executes the simulation config or an element with custom initial values. This is a blocking method. Returns specified simulation parameters values, or all simulation values if it isn't specified.
        Parameters:
        element - the element to execute - either a SimulationConfig, or a Classifier/Behavior directly.
        outputs - names of parameter runtime values to be returned when simulation completes. When null is provided, all values will be returned.
        inputs - key-value map of values which will be used as initial values for the execution. When null is provided, execution will be initialized with values as described in the model.
        Returns:
        the simulation parameters values
        Throws:
        com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException - if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
      • simulate

        public static java.util.Map<java.lang.String,​java.lang.Object> simulate​(Element simulationConfig,
                                                                                      @CheckForNull
                                                                                      Element target,
                                                                                      @CheckForNull
                                                                                      java.lang.String[] outputs,
                                                                                      java.lang.Object... inputs)
                                                                               throws com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException
        Executes the target element with a specific simulation config with custom initial values. This is a blocking method. Returns specified simulation parameters values, or all simulation values if it isn't specified.
        Parameters:
        simulationConfig - that is compatible with the target element
        target - the target element to execute, for example InstanceSpecification
        outputs - names of parameter runtime values to be returned when simulation completes. When null is provided, all values will be returned.
        inputs - key-value map of values which will be used as initial values for the execution. When null is provided, execution will be initialized with values as described in the model.
        Returns:
        the simulation parameters values
        Throws:
        com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException - if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
      • simulate

        public static java.util.Map<java.lang.String,​java.lang.Object> simulate​(Element simulationConfig,
                                                                                      @CheckForNull
                                                                                      Element target,
                                                                                      @CheckForNull
                                                                                      java.util.Collection<java.lang.String> outputs,
                                                                                      @CheckForNull
                                                                                      java.util.Map<java.lang.String,​java.lang.Object> inputs)
                                                                               throws com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException
        Executes the target element with a specific simulation config with custom initial values. This is a blocking method. Returns specified simulation parameters values, or all simulation values if it isn't specified.
        Parameters:
        simulationConfig - that is compatible with the target element
        target - the target element to execute with the specified config, for example InstanceSpecification
        outputs - names of parameter runtime values to be returned when simulation completes. When null is provided, all values will be returned.
        inputs - key-value map of values which will be used as initial values for the execution. When null is provided, execution will be initialized with values as described in the model.
        Returns:
        the simulation parameters values
        Throws:
        com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException - if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
      • simulateAsync

        public static SimulationResult simulateAsync​(Element simulationConfig,
                                                     @CheckForNull
                                                     Element target,
                                                     @CheckForNull
                                                     java.lang.String[] outputs,
                                                     java.lang.Object... inputs)
                                              throws com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException
        Asynchronously executes the target element with a specific simulation config with custom initial parameters values. Returns specified simulation parameters values, or all simulation values if it isn't specified.
        Parameters:
        simulationConfig - config that is compatible with the target element
        target - target element to execute, for example InstanceSpecification
        outputs - names of parameter runtime values to be returned when simulation completes. When null is provided, all values will be returned.
        inputs - key-value map of values which will be used as initial values for the execution. When null is provided, execution will be initialized with values as described in the model.
        Returns:
        the created SimulationResult
        Throws:
        com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException - if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
      • simulateAsync

        public static SimulationResult simulateAsync​(Element simulationConfig,
                                                     @CheckForNull
                                                     Element target,
                                                     @CheckForNull
                                                     java.util.Collection<java.lang.String> outputs,
                                                     java.util.Map<java.lang.String,​java.lang.Object> inputs)
                                              throws com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException
        Asynchronously executes the target element with a specific simulation config with custom initial parameters values. Returns specified simulation parameters values, or all simulation values if it isn't specified.
        Parameters:
        simulationConfig - config that is compatible with the target element
        target - target element to execute, for example InstanceSpecification
        outputs - names of parameter runtime values to be returned when simulation completes. When null is provided, all values will be returned.
        inputs - key-value map of values which will be used as initial values for the execution. When null is provided, execution will be initialized with values as described in the model.
        Returns:
        the created SimulationResult
        Throws:
        com.nomagic.magicdraw.simulation.exceptions.SimulationInputValuesException - if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing