use of org.osate.aadl2.instance.SystemInstance in project osate-plugin by sireum.
the class LaunchSireumHandler method runJob.
@Override
public IStatus runJob(Element elem, IProgressMonitor monitor) {
MessageConsole console = displayConsole();
console.clearConsole();
if (!Util.emitSireumVersion(console)) {
displayPopup("AIR generation was unsuccessful");
return Status.CANCEL_STATUS;
}
SystemInstance si = getSystemInstance(elem);
if (si == null) {
Dialog.showError(getToolName(), "Please select a system implementation or a system instance");
return Status.CANCEL_STATUS;
}
writeToConsole("Generating AIR ...");
Aadl model = Util.getAir(si, true, console);
if (model != null) {
SerializerType ser = PreferenceValues.getSERIALIZATION_METHOD_OPT();
writeToConsole("Serializing AIR to " + ser.name() + " ...");
String s = Util.serialize(model, ser);
Display.getDefault().syncExec(() -> {
FileDialog fd = new FileDialog(getShell(), SWT.SAVE);
fd.setFileName("aadl." + (ser == SerializerType.MSG_PACK ? "msgpack" : "json"));
fd.setText("Specify filename");
fd.setFilterPath(getProjectPath(si).toString());
String fname = fd.open();
if (fname != null) {
File fout = new File(fname);
writeFile(fout, s, false);
writeToConsole("Wrote: " + fout.getAbsolutePath());
}
});
refreshWorkspace();
return Status.OK_STATUS;
} else {
Dialog.showError(getToolName(), "Could not generate AIR");
return Status.CANCEL_STATUS;
}
}
use of org.osate.aadl2.instance.SystemInstance in project AMASE by loonwerks.
the class FaultsVerifyAllHandler method runJob.
@Override
protected IStatus runJob(Element root, IProgressMonitor monitor) {
EphemeralImplementationUtil implUtil = new EphemeralImplementationUtil(monitor);
// this flag is set by the rerun handler to prevent clearing the advice map
if (!calledFromRerun) {
rerunAdviceMap.clear();
}
calledFromRerun = false;
disableRerunHandler();
handlerService = getWindow().getService(IHandlerService.class);
try {
// Make sure the user selected a component implementation
ComponentImplementation ci = getComponentImplementation(root, implUtil);
SystemInstance si = getSysInstance(ci, implUtil);
AnalysisResult result;
CompositeAnalysisResult wrapper = new CompositeAnalysisResult("");
if (isRecursive()) {
if (AgreeUtils.usingKind2()) {
throw new AgreeException("Kind2 only supports monolithic verification");
}
result = buildAnalysisResult(ci.getName(), si);
wrapper.addChild(result);
result = wrapper;
} else if (isRealizability()) {
AgreeProgram agreeProgram = new AgreeASTBuilder().getAgreeProgram(si, false);
Program program = LustreAstBuilder.getRealizabilityLustreProgram(agreeProgram);
wrapper.addChild(createVerification("Realizability Check", si, program, agreeProgram, AnalysisType.Realizability));
result = wrapper;
} else {
CompositeAnalysisResult wrapperTop = new CompositeAnalysisResult("Verification for " + ci.getName());
wrapVerificationResult(si, wrapperTop);
wrapper.addChild(wrapperTop);
result = wrapper;
}
showView(result, linker);
return doAnalysis(ci, monitor);
} catch (Throwable e) {
String messages = getNestedMessages(e);
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, messages, e);
} finally {
implUtil.cleanup();
}
}
use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class FlowLatencyAnalysisSwitch method invoke.
/**
* Invoke the analysis on all ETEF owned by the given component instance and return Result collection
*
* @param etef The end to end flow instance
* @param som The mode to run the analysis in. If null then run all SOMs
* @param asynchronousSystem Whether the system is treated as asynchronous
* @param majorFrameDelay Whether partition output is performed at a major frame (as opposed to the partition end)
* @param worstCaseDeadline Use deadline based processing (as opposed to max compute execution time)
* @param bestCaseEmptyQueue Assume empty queue (instead of full)
* @param disableQueuingLatency <code>true</code> if queuing latency should always be reported as zero
* @return A populated report in AnalysisResult format.
* @since org.osate.analysis.flows 3.0
*/
public AnalysisResult invoke(EndToEndFlowInstance etef, SystemOperationMode som, boolean asynchronousSystem, boolean majorFrameDelay, boolean worstCaseDeadline, boolean bestCaseEmptyQueue, boolean disableQueuingLatency) {
SystemInstance root = etef.getSystemInstance();
if (som == null) {
// we need to run it for every SOM
for (SystemOperationMode eachsom : root.getSystemOperationModes()) {
root.setCurrentSystemOperationMode(eachsom);
invokeOnSOM(etef, eachsom, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
root.clearCurrentSystemOperationMode();
}
} else {
invokeOnSOM(etef, som, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
}
// Issue 1148
fillInQueuingTimes(etef.getSystemInstance());
final List<Result> finalizedResults = finalizeResults();
return FlowLatencyUtil.recordAsAnalysisResult(finalizedResults, etef, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
}
use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class FlowLatencyAnalysisSwitch method invoke.
/**
* Invoke the analysis on all ETEF in system instance and return Result collection
*
* @param root The root system instance
* @param som The mode to run the analysis in. If null then run all SOMs
* @param asynchronousSystem Whether the system is treated as synchronous by default
* @param majorFrameDelay Whether partition output is performed at a major frame (as opposed to the partition end)
* @param worstCaseDeadline Use deadline based processing (as opposed to max compute execution time)
* @param bestCaseEmptyQueue Assume empty queue (instead of full)
* @param disableQueuingLatency <code>true</code> if queuing latency should always be reported as zero
* @return A populated report in AnalysisResult format.
* @since org.osate.analysis.flows 3.0
*/
// NB. This method is used to invoke the analysis from unit tests
public AnalysisResult invoke(SystemInstance root, SystemOperationMode som, boolean asynchronousSystem, boolean majorFrameDelay, boolean worstCaseDeadline, boolean bestCaseEmptyQueue, boolean disableQueuingLatency) {
if (som == null) {
if (root.getSystemOperationModes().isEmpty() || root.getSystemOperationModes().get(0).getCurrentModes().isEmpty()) {
// no SOM
invokeOnSOM(root, root.getSystemOperationModes().get(0), asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
} else {
// we need to run it for every SOM
for (SystemOperationMode eachsom : root.getSystemOperationModes()) {
root.setCurrentSystemOperationMode(eachsom);
invokeOnSOM(root, eachsom, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
root.clearCurrentSystemOperationMode();
}
}
} else {
invokeOnSOM(root, som, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
}
// Issue 1148
final List<Result> finalizedResults = finalizeResults();
return FlowLatencyUtil.recordAsAnalysisResult(finalizedResults, root, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency);
}
use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class BoundResourceAnalysis method getMemoryBindings.
/*
* Issue 2169: This is copied from InstanceModelUtil.getBoundSWComponents, but we had
* to specialize it because now processor/virtual processors are treated as things
* that have memory and the original method gets the wrong things from the processors.
*
* associatedObject is of category memory, system, processor, virtual processor, abstract
*/
private static EList<ComponentInstance> getMemoryBindings(final ComponentInstance associatedObject) {
EList<Element> boundComponents = null;
final SystemInstance root = associatedObject.getSystemInstance();
final ComponentCategory cc = associatedObject.getCategory();
if (cc == ComponentCategory.MEMORY || cc == ComponentCategory.SYSTEM || cc == ComponentCategory.PROCESSOR || cc == ComponentCategory.VIRTUAL_PROCESSOR || cc == ComponentCategory.ABSTRACT) {
boundComponents = new ForAllElement() {
@Override
protected boolean suchThat(Element obj) {
final List<InstanceObject> boundMemoryList = DeploymentProperties.getActualMemoryBinding((ComponentInstance) obj).orElse(Collections.emptyList());
if (boundMemoryList.isEmpty()) {
return false;
}
return boundMemoryList.contains(associatedObject);
}
}.processPostOrderComponentInstance(root);
} else {
return new BasicEList<ComponentInstance>();
}
EList<ComponentInstance> topobjects = new BasicEList<ComponentInstance>();
for (Object componentInstance : boundComponents) {
InstanceModelUtil.addAsRoot(topobjects, (ComponentInstance) componentInstance);
}
return topobjects;
}
Aggregations