use of edu.uah.rsesc.aadlsimulator.ui.launch.SimulationLaunchShortcut in project AGREE by loonwerks.
the class SimulatorHandlerHelper method startSimulator.
public static Object startSimulator(final ExecutionEvent event, final String engineTypeId) {
try {
final SimulationUIService simulationUiService = Objects.requireNonNull(EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(SimulatorHandlerHelper.class).getBundleContext()).get(SimulationUIService.class), "unable to get simulation UI service");
if (simulationUiService.getCurrentState().getSimulationEngine() != null) {
final MessageBox messageBox = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setMessage("A simulation is already active. Do you want to stop the current simulation?");
messageBox.setText("Stop Current Simulation");
if (messageBox.open() == SWT.NO) {
return null;
}
}
if (event.getApplicationContext() instanceof IEvaluationContext) {
final IEvaluationContext appContext = (IEvaluationContext) event.getApplicationContext();
final ISelection selection = (ISelection) appContext.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
final SimulationLaunchShortcut launchShortcut = new SimulationLaunchShortcut();
launchShortcut.launch(selection, engineTypeId, ILaunchManager.RUN_MODE);
}
} catch (final Exception ex) {
final Status status = new Status(IStatus.ERROR, FrameworkUtil.getBundle(SimulatorHandlerHelper.class).getSymbolicName(), "Error", ex);
StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG);
}
return null;
}
use of edu.uah.rsesc.aadlsimulator.ui.launch.SimulationLaunchShortcut in project AGREE by loonwerks.
the class CounterexampleLoaderHelper method receiveCex.
public void receiveCex(final ComponentImplementation compImpl, Property property, EObject agreeProperty, final Counterexample cex, final Map<String, EObject> refMap, final Mode mode) {
// Launch the simulation
final SimulationService simulationService = Objects.requireNonNull(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(SimulationService.class), "Unable to retrieve simulation service");
final SimulationLaunchShortcut launchShortcut = new SimulationLaunchShortcut();
try {
final boolean isInductiveCex = property instanceof UnknownProperty;
final ILaunch launch = launchShortcut.launch(compImpl, (isInductiveCex ? mode.inductiveEngineTypeId : mode.engineTypeId), ILaunchManager.RUN_MODE);
// Get the simulation engine
final SimulationEngine simulationEngine = getSimulationEngine(launch);
if (simulationEngine instanceof AGREESimulationEngine) {
final AGREESimulationEngine agreeSimulationEngine = (AGREESimulationEngine) simulationEngine;
final SimulationUIService simulationUIService = Objects.requireNonNull(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(SimulationUIService.class), "Unable to retrieve simulation UI service");
final Map<String, Object> signalNameToSimStateElementMap = buildAgreeNameToSimulationStateElementMap(agreeSimulationEngine);
simulateCounterexample(cex, 0, signalNameToSimStateElementMap, agreeSimulationEngine, simulationService, simulationUIService);
}
} catch (final Exception e) {
simulationService.getExceptionHandler().handleException(e);
}
}
Aggregations