Package com.nomagic.magicdraw.simulation
Class SimulationManager
java.lang.Object
com.nomagic.magicdraw.simulation.SimulationManager
API for running and stopping simulations and registering simulation listeners
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SimulationResultNon-blocking method for executing the specific element.static SimulationResultexecuteWithConfig(Element target, Element simulationConfig, boolean start) Executes the target element with a specific simulation config.static Object_getContext(SimulationSession session) Get the context of the running session.static SimulationSessiongetRefSession(Object_ object) Deprecated.use object.getRefSession()static Object_getRootContext(SimulationSession session) Get the root context of the running session.static SimulationSessiongetSession(SimulationResult result) Retrieves simulation session from simulation result.static booleanisSilentSimulation(SimulationSession session) Deprecated.session.getExecution().getOptions().is(SimulationOptions.SILENT);static voidlogConsoleDebug(BaseElement element, String message) Log the specified message to the simulation console with "DEBUG" log level.static voidlogConsoleError(BaseElement element, String message) Log the specified message to the simulation console with "ERROR" log level.static voidlogConsoleInfo(BaseElement element, String message) Log the specified message to the simulation console with "INFO" log level.static voidlogConsoleWarn(BaseElement element, String message) Log the specified message to the simulation console with "WARN" log level.static voidregisterEngine(ExecutionEngineDescriptor engineDescriptor) Registers an engine descriptor to the simulation framework.static voidRegister the simulation execution listener.static voidregisterSimulationExecutionListener(SimulationExecutionListener listener, SimulationExecution execution) Register the simulation execution listener dynamically to the specified SimulationExecution.static voidregisterSimulationOptionsProvider(SimulationOptionsProvider optionsProvider) Register the simulation options provider.simulate(BaseElement context, String simulationConfigKeyword, Object... inputs) Executes the simulation config with custom initial values.simulate(BaseElement context, String simulationConfigKeyword, String[] outputs, Object... inputs) Executes the simulation config with custom initial values.simulate(BaseElement context, String configKeyword, String targetKeyword, String[] outputs, Object... inputs) Executes the target element with a specific simulation config with custom initial values.Executes the simulation config and waits for execution to complete.Executes the target element with a specific simulation config with initial custom values.Executes the target element with a specific simulation config with custom initial values.simulate(Element simulationConfig, Element target, Collection<String> outputs, Map<String, Object> inputs) Executes the target element with a specific simulation config with custom initial values.Executes the simulation config with custom initial values.Executes the simulation config with initial custom values.Executes the simulation config or an element with custom initial values.static SimulationResultsimulateAsync(Element simulationConfig, Element target, String[] outputs, Object... inputs) Asynchronously executes the target element with a specific simulation config with custom initial parameters values.static SimulationResultsimulateAsync(Element simulationConfig, Element target, Collection<String> outputs, Map<String, Object> inputs) Asynchronously executes the target element with a specific simulation config with custom initial parameters values.static voidterminate(SimulationResult result) Terminates the running execution, represented by the result object;static voidterminateSession(SimulationSession session) Terminate the running session.static voidunregisterEngine(ExecutionEngineDescriptor engineDescriptor) Unregisters an engine descriptor from the simulation framework.static voidUnregister the simulation execution listener.static voidunregisterSimulationExecutionListener(SimulationExecutionListener listener, SimulationExecution execution) unregister the simulation execution listener dynamically from the specified SimulationExecution.static voidunregisterSimulationOptionsProvider(SimulationOptionsProvider optionsProvider) Unregister the simulation options provider.
-
Constructor Details
-
SimulationManager
public SimulationManager()
-
-
Method Details
-
registerEngine
Registers an engine descriptor to the simulation framework.- Parameters:
engineDescriptor- an engine descriptor.
-
unregisterEngine
Unregisters an engine descriptor from the simulation framework.- Parameters:
engineDescriptor- an engine descriptor.
-
execute
Non-blocking method for executing the specific element.- Parameters:
element- the element to be executed, e.g. Class, Activity or a SimulationConfig with a target setstart- 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 InstanceSpecificationsimulationConfig- config that is compatible with the target elementstart- if this flag is true, it will auto start the session.- Returns:
- the created SimulationResult.
-
isSilentSimulation
Deprecated.session.getExecution().getOptions().is(SimulationOptions.SILENT); -
terminateSession
Terminate the running session.- Parameters:
session- the session being terminated
-
terminate
Terminates the running execution, represented by the result object; -
registerSimulationExecutionListener
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 listenerexecution- the simulation execution
-
registerSimulationOptionsProvider
Register the simulation options provider.- Parameters:
optionsProvider- the registered simulation options provider
-
unregisterSimulationExecutionListener
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 listenerexecution- the simulation execution
-
unregisterSimulationOptionsProvider
Unregister the simulation options provider.- Parameters:
optionsProvider- the registered simulation options provider
-
logConsoleDebug
Log the specified message to the simulation console with "DEBUG" log level.- Parameters:
element- an element of the running simulationmessage- the specified message
-
logConsoleInfo
Log the specified message to the simulation console with "INFO" log level.- Parameters:
element- an element of the running simulationmessage- the specified message
-
logConsoleWarn
Log the specified message to the simulation console with "WARN" log level.- Parameters:
element- an element of the running simulationmessage- the specified message
-
logConsoleError
Log the specified message to the simulation console with "ERROR" log level.- Parameters:
element- an element of the running simulationmessage- the specified message
-
getRefSession
Deprecated.use object.getRefSession() -
getSession
Retrieves simulation session from simulation result.- Returns:
- session retrieved from simulation result
-
getRootContext
Get the root context of the running session.- Parameters:
session- the running session- Returns:
- the root context
-
getContext
Get the context of the running session.- Parameters:
session- the running session- Returns:
- the context of the running session
-
simulate
public static Map<String,Object> simulate(BaseElement context, String configKeyword, @CheckForNull String targetKeyword, @CheckForNull String[] outputs, Object... inputs) throws 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 targetKeywordconfigKeyword- config name or id that is compatible with the target elementtargetKeyword- the target element name or id to execute, for example InstanceSpecificationoutputs- array of parameters names which will be returnedinputs- key-value pair of parameters values which will be used in simulation- Returns:
- the simulation parameters values
- Throws:
SimulationInputValuesException- if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
-
simulate
public static Map<String,Object> simulate(BaseElement context, String simulationConfigKeyword, Object... inputs) throws 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 simulationConfigKeywordsimulationConfigKeyword- simulation config name or idinputs- key-value pair of parameters values which will be used in simulation- Returns:
- the simulation parameters values
- Throws:
SimulationInputValuesException- if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
-
simulate
public static Map<String,Object> simulate(BaseElement context, String simulationConfigKeyword, @CheckForNull String[] outputs, Object... inputs) throws 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 configsimulationConfigKeyword- simulation configuration name or idoutputs- array of parameters names which will be returnedinputs- key-value pair of parameters values which will be used in simulation- Returns:
- the simulation parameters values
- Throws:
SimulationInputValuesException- if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
-
simulate
public static Map<String,Object> simulate(Element simulationConfig, @CheckForNull Element target, Object... inputs) throws 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 elementtarget- the element to execute, for example InstanceSpecificationinputs- key-value pair of parameters values which will be used in simulation- Returns:
- the simulation parameters values
- Throws:
SimulationInputValuesException- if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
-
simulate
Executes the simulation config and waits for execution to complete.- Parameters:
simulationConfig- the element to execute- Returns:
- all system values at end time.
-
simulate
public static Map<String,Object> simulate(Element simulationConfig, Object... inputs) throws SimulationInputValuesException Executes the simulation config with custom initial values.- Parameters:
simulationConfig- the element to executeinputs- key value pair-of parameters values which will be used in simulation- Returns:
- all system values at end time.
- Throws:
SimulationInputValuesException- if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
-
simulate
public static Map<String,Object> simulate(Element element, String[] outputs, Object... inputs) throws 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:
SimulationInputValuesException- if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
-
simulate
public static Map<String,Object> simulate(Element element, @CheckForNull Collection<String> outputs, @CheckForNull Map<String, Object> inputs) throws SimulationInputValuesExceptionExecutes 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:
SimulationInputValuesException- if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
-
simulate
public static Map<String,Object> simulate(Element simulationConfig, @CheckForNull Element target, @CheckForNull String[] outputs, @CheckForNull Object... inputs) throws 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 elementtarget- the target element to execute, for example InstanceSpecificationoutputs- 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:
SimulationInputValuesException- if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
-
simulate
public static Map<String,Object> simulate(Element simulationConfig, @CheckForNull Element target, @CheckForNull Collection<String> outputs, @CheckForNull Map<String, Object> inputs) throws SimulationInputValuesExceptionExecutes 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 elementtarget- the target element to execute with the specified config, for example InstanceSpecificationoutputs- 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:
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 String[] outputs, Object... inputs) throws 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 elementtarget- target element to execute, for example InstanceSpecificationoutputs- 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:
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 Collection<String> outputs, Map<String, Object> inputs) throws SimulationInputValuesExceptionAsynchronously 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 elementtarget- target element to execute, for example InstanceSpecificationoutputs- 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:
SimulationInputValuesException- if inputs value type mismatch, not all input values was replaced or inputs key value parameter is missing
-