Creating and registering a new SimulationExecutionListener
A com.nomagic.magicdraw.simulation.execution.SimulationExecutionListener is a listener for various events that can occur during execution of a model.
public class SimulationExecutionListener {
void configLoaded(Element config, SimulationExecution execution);
void executionStarted(SimulationExecution execution);
void beforeContextInitialized(SimulationExecution execution);
void contextInitialized(SimulationExecution execution);
void executionTerminated(SimulationExecution execution);
void elementActivated(Element element, Collection<?> values, ActivationContext context);
void elementDeactivated(Element element, Collection<?> values, ActivationContext context);
void eventTriggered(SignalInstance signal);
void operationCalled(Operation operation, List<ParameterValue> parameterValues, Object_ caller, Object_ target, boolean isSynchronous);
void behaviorCalled(Behavior behavior, List<ParameterValue> parameterValues, Object_ caller, Object_ target, boolean isSynchronous);
void objectCreated(Object_ sender, Object_ object);
void beforeObjectDestroyed(Object_ object)
void valueChange(StructuredValue context, FeatureValue feature, Object oldValue, Object newValue)
void objectStateActivated(StructuredValue context, State newState)
void busyStatusChange(StructuredValue context, Object oldValue, Object newValue);
}
To register a created execution listener to a global list, that ensures this listener to be added to each created SimulationExecution, use the following code:
SimulationManager.registerSimulationExecutionListener(listener); //listener is an instance of SimulationExecutionListener.
If the SimulationExecution is already created, listener can be registered directly to that specific execution by calling the following:
| Open API | Function |
|---|---|
SimulationManager.registerSimulationExecutionListener(SimulationExecutionListener listener, SimulationExecution execution) | Registers SimulationExecutionListener dynamically during the execution. |
SimulationManager.unregisterSimulationExecutionListener(SimulationExecutionListener listener, SimulationExecution execution) | Unregisters SimulationExecutionListener. |