use of org.osate.aadl2.ComponentImplementation in project AGREE by loonwerks.
the class SimulationLaunchShortcut method getComponentImplementation.
private ComponentImplementation getComponentImplementation(final ISelection selection) {
ComponentImplementation componentImplementation = null;
// Determine a component implementation based on the current selection
if (selection instanceof IStructuredSelection) {
final Object selectedObject = ((IStructuredSelection) selection).getFirstElement();
if (selectedObject instanceof IFile) {
final IFile iFile = (IFile) selectedObject;
final ResourceSet resourceSet = new ResourceSetImpl();
final Resource resource = resourceSet.getResource(URI.createPlatformResourceURI(iFile.getFullPath().toString(), true), true);
if (resource != null) {
if (resource.getContents().size() > 0) {
final SystemInstance systemInstance = (SystemInstance) resource.getContents().get(0);
componentImplementation = systemInstance.getComponentImplementation();
}
}
} else if (selectedObject instanceof EObjectNode) {
final EObject selectedEObject = selectionHelper.getEObject((EObjectNode) selectedObject);
if (selectedEObject instanceof ComponentImplementation) {
componentImplementation = (ComponentImplementation) selectedEObject;
}
} else {
componentImplementation = graphicalEditorSelectionHelper.getComponentImplementationByApplicableObject(selectedObject);
}
}
return componentImplementation;
}
use of org.osate.aadl2.ComponentImplementation in project AGREE by loonwerks.
the class TestCaseGeneratorMenuListener method addViewTestCaseMenu.
private void addViewTestCaseMenu(IMenuManager manager, AnalysisResult result) {
final Counterexample cex = getCounterexample(result);
TcgExtractorRegistry tcgReg = (TcgExtractorRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.TCG_EXTRACTOR_EXT_ID);
List<TcgExtractor> extractors = tcgReg.getTcgExtractors();
if (cex != null) {
final String cexType = getCounterexampleType(result);
final Layout layout = linker.getLayout(result.getParent());
final Renaming renaming = linker.getRenaming(result.getParent());
final Map<String, EObject> refMap = ((TcgRenaming) renaming).getTcgRefMap();
final Counterexample translatedCex = AgreeMenuListener.translateCounterexampleArrayIndices(cex);
MenuManager sub = new MenuManager("View " + cexType + "Test Case in");
manager.add(sub);
sub.add(new Action("Console") {
@Override
public void run() {
viewCexConsole(translatedCex, layout, refMap, (TcgRenaming) renaming);
}
});
sub.add(new Action("Eclipse") {
@Override
public void run() {
viewCexEclipse(translatedCex, layout, refMap);
}
});
sub.add(new Action("Spreadsheet") {
@Override
public void run() {
viewCexSpreadsheet(translatedCex, layout);
}
});
// send counterexamples to external plugins
PropertyResult pr = (PropertyResult) result;
EObject property = refMap.get(pr.getName());
ComponentImplementation compImpl = linker.getComponent(result.getParent());
for (TcgExtractor ex : extractors) {
sub.add(new Action(ex.getDisplayText()) {
@Override
public void run() {
ex.receiveCex(compImpl, property, translatedCex, refMap);
}
});
}
}
}
use of org.osate.aadl2.ComponentImplementation in project AGREE by loonwerks.
the class TestSuiteMenuListener method addViewTestCaseMenu.
private void addViewTestCaseMenu(IMenuManager manager, TestCase testCase) {
final Counterexample cex = testCase.getCex();
TcgExtractorRegistry tcgReg = (TcgExtractorRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.TCG_EXTRACTOR_EXT_ID);
List<TcgExtractor> extractors = tcgReg.getTcgExtractors();
if (cex != null) {
/*
* TODO: getCounterexampleType?
*/
// final String cexType = getCounterexampleType(result);
final String cexType = "";
final Layout layout = linker.getLayout(result);
final Renaming renaming = linker.getRenaming(result);
final Map<String, EObject> refMap = ((TcgRenaming) linker.getRenaming(result)).getTcgRefMap();
final Counterexample translatedCex = AgreeMenuListener.translateCounterexampleArrayIndices(cex);
MenuManager sub = new MenuManager("View " + cexType + "Test Case in");
manager.add(sub);
sub.add(new Action("Console") {
@Override
public void run() {
viewCexConsole(translatedCex, layout, refMap, (TcgRenaming) renaming);
}
});
sub.add(new Action("Eclipse") {
@Override
public void run() {
viewCexEclipse(translatedCex, layout, refMap);
}
});
sub.add(new Action("Spreadsheet") {
@Override
public void run() {
viewCexSpreadsheet(translatedCex, layout);
}
});
// send counterexamples to external plugins
EObject property = refMap.get(testCase.getName());
ComponentImplementation compImpl = linker.getComponent(result);
for (TcgExtractor ex : extractors) {
sub.add(new Action(ex.getDisplayText()) {
@Override
public void run() {
ex.receiveCex(compImpl, property, translatedCex, refMap);
}
});
}
}
}
use of org.osate.aadl2.ComponentImplementation 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 org.osate.aadl2.ComponentImplementation in project AGREE by loonwerks.
the class TcgLinkerFactory method createVerification.
protected AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram) {
AgreeRenaming agreeRenaming = new AgreeRenaming();
AgreeLayout layout = new AgreeLayout();
RenamingVisitor.addRenamings(lustreProgram, agreeRenaming, compInst, layout);
TcgRenaming renaming = new TcgRenaming(agreeRenaming, agreeRenaming.getRefMap());
Node mainNode = lustreProgram.getMainNode();
if (mainNode == null) {
throw new AgreeException("Could not find main lustre node after translation");
}
List<String> properties = new ArrayList<>();
JKindResult result;
result = new JKindResult(resultName, properties, renaming);
queue.add(result);
ComponentImplementation compImpl = AgreeUtils.getInstanceImplementation(compInst);
linker.setAgreeProgram(result, agreeProgram);
linker.setProgram(result, lustreProgram);
linker.setComponent(result, compImpl);
linker.setContract(result, getContract(compImpl));
linker.setLayout(result, layout);
// linker.setReferenceMap(result, renaming.getRefMap());
linker.setLog(result, AgreeLogger.getLog());
linker.setRenaming(result, renaming);
// System.out.println(program);
return result;
}
Aggregations