Search in sources :

Example 1 with AGREESimulationEngine

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);
    }
}
Also used : AGREESimulationEngine(edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationEngine) SimulationEngine(edu.uah.rsesc.aadlsimulator.SimulationEngine) SimulationUIService(edu.uah.rsesc.aadlsimulator.ui.services.SimulationUIService) UnknownProperty(jkind.results.UnknownProperty) AGREESimulationEngine(edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationEngine) ILaunch(org.eclipse.debug.core.ILaunch) EObject(org.eclipse.emf.ecore.EObject) SimulationLaunchShortcut(edu.uah.rsesc.aadlsimulator.ui.launch.SimulationLaunchShortcut) SimulationService(edu.uah.rsesc.aadlsimulator.services.SimulationService) PartInitException(org.eclipse.ui.PartInitException)

Example 2 with AGREESimulationEngine

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;
        }
    };
}
Also used : SimulationUIService(edu.uah.rsesc.aadlsimulator.ui.services.SimulationUIService) ComponentImplementation(org.osate.aadl2.ComponentImplementation) AGREESimulationState(edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationState) ExportArguments(edu.uah.rsesc.aadlsimulator.agree.ext.AGREESimulationExporter.ExportArguments) AGREESimulationEngine(edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationEngine) SimulatorState(edu.uah.rsesc.aadlsimulator.ui.services.SimulatorState) Counterexample(jkind.results.Counterexample) Renaming(jkind.api.results.Renaming)

Example 3 with AGREESimulationEngine

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();
                }
            });
        }
    }
}
Also used : SimulationUIService(edu.uah.rsesc.aadlsimulator.ui.services.SimulationUIService) IAction(org.eclipse.jface.action.IAction) AGREESimulationEngine(edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationEngine) ExporterProxy(edu.uah.rsesc.aadlsimulator.agree.services.AGREESimulatorExtensionService.ExporterProxy) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SimulatorState(edu.uah.rsesc.aadlsimulator.ui.services.SimulatorState) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AGREESimulatorExtensionService(edu.uah.rsesc.aadlsimulator.agree.services.AGREESimulatorExtensionService) MenuItem(org.eclipse.swt.widgets.MenuItem)

Example 4 with AGREESimulationEngine

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);
}
Also used : AGREESimulationEngine(edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationEngine)

Aggregations

AGREESimulationEngine (edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationEngine)4 SimulationUIService (edu.uah.rsesc.aadlsimulator.ui.services.SimulationUIService)3 SimulatorState (edu.uah.rsesc.aadlsimulator.ui.services.SimulatorState)2 SimulationEngine (edu.uah.rsesc.aadlsimulator.SimulationEngine)1 AGREESimulationState (edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationState)1 ExportArguments (edu.uah.rsesc.aadlsimulator.agree.ext.AGREESimulationExporter.ExportArguments)1 AGREESimulatorExtensionService (edu.uah.rsesc.aadlsimulator.agree.services.AGREESimulatorExtensionService)1 ExporterProxy (edu.uah.rsesc.aadlsimulator.agree.services.AGREESimulatorExtensionService.ExporterProxy)1 SimulationService (edu.uah.rsesc.aadlsimulator.services.SimulationService)1 SimulationLaunchShortcut (edu.uah.rsesc.aadlsimulator.ui.launch.SimulationLaunchShortcut)1 Renaming (jkind.api.results.Renaming)1 Counterexample (jkind.results.Counterexample)1 UnknownProperty (jkind.results.UnknownProperty)1 ILaunch (org.eclipse.debug.core.ILaunch)1 EObject (org.eclipse.emf.ecore.EObject)1 IAction (org.eclipse.jface.action.IAction)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1 PartInitException (org.eclipse.ui.PartInitException)1