use of edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationEngine 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);
}
}
use of edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationEngine in project AGREE by loonwerks.
the class ExportAction method buildExportArguments.
private ExportArguments buildExportArguments() {
final SimulationUIService simUiService = (SimulationUIService) Objects.requireNonNull(PlatformUI.getWorkbench().getService(SimulationUIService.class), "Unable to retrieve Simulation UI Service");
final SimulatorState simulatorState = simUiService.getCurrentState();
if (!(simulatorState.getEngineState() instanceof AGREESimulationState)) {
throw new RuntimeException("Simulation engine state must be an AGREESimulationState");
}
if (!(simulatorState.getSimulationEngine() instanceof AGREESimulationEngine)) {
throw new RuntimeException("Simulation engine must be an AGREESimulationEngine");
}
final AGREESimulationState agreeSimState = (AGREESimulationState) simulatorState.getEngineState();
final AGREESimulationEngine engine = (AGREESimulationEngine) simulatorState.getSimulationEngine();
final ComponentImplementation componentImplementation = engine.getSystemInstance().getComponentImplementation();
final Counterexample cex = buildCounterexample(agreeSimState);
final Renaming renaming = engine.getSimulationProgram().getAgreeRenaming();
return new ExportArguments() {
@Override
public ComponentImplementation getComponentImplementation() {
return componentImplementation;
}
@Override
public Counterexample getCounterexample() {
return cex;
}
@Override
public Renaming getAgreeRenaming() {
return renaming;
}
};
}
use of edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationEngine in project AGREE by loonwerks.
the class ExporterMenuContributionItem method fill.
@Override
public void fill(final Menu menu, int index) {
final SimulationUIService simUiService = (SimulationUIService) Objects.requireNonNull(PlatformUI.getWorkbench().getService(SimulationUIService.class), "Unable to retrieve Simulation UI Service");
final SimulatorState simulatorState = simUiService.getCurrentState();
final boolean visible = simulatorState.getEngineState() != null && simulatorState.getSimulationEngine() instanceof AGREESimulationEngine;
if (visible) {
final AGREESimulatorExtensionService extService = Objects.requireNonNull((AGREESimulatorExtensionService) PlatformUI.getWorkbench().getService(AGREESimulatorExtensionService.class), "unable to get AGREE Simulator Extension service");
for (final ExporterProxy exporter : extService.getExporters()) {
final IAction exporterAction = new ExportAction(exporter);
final MenuItem exporterMenuItem = new MenuItem(menu, SWT.CHECK, index++);
exporterMenuItem.setEnabled(simUiService.getCurrentState().getEngineState().getNumberOfFrames() > 0);
exporterMenuItem.setText(exporter.getName());
exporterMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
exporterAction.run();
}
});
}
}
}
use of edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationEngine in project AGREE by loonwerks.
the class TogglePropertyEnablementCommand method activate.
@Override
public void activate(final CommandContext ctx) {
final AGREESimulationEngine engine = (AGREESimulationEngine) ctx.getSimulationEngine();
final boolean isPropertyEnabled = ctx.getSimulationEngineState().isPropertyEnabledForNextFrame(ctx.getBusinessObject());
engine.setPropertyEnabled((SimulationProperty) ctx.getBusinessObject(), !isPropertyEnabled);
}
Aggregations