use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class BoundResourceAnalysis method analysisBody.
public void analysisBody(final IProgressMonitor monitor, final Element obj) {
if (obj instanceof InstanceObject) {
SystemInstance root = ((InstanceObject) obj).getSystemInstance();
monitor.beginTask(actionName, IProgressMonitor.UNKNOWN);
final SOMIterator soms = new SOMIterator(root);
while (soms.hasNext()) {
final SystemOperationMode som = soms.nextSOM();
checkProcessorLoads(root, som);
checkVirtualProcessorLoads(root, som);
checkMemoryLoads(root, som);
}
monitor.done();
} else {
Dialog.showError("Bound Resource Analysis Error", "Can only check system instances");
}
}
use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class BusLoadAnalysis method analysisBody.
public void analysisBody(final IProgressMonitor monitor, final Element obj) {
if (obj instanceof InstanceObject) {
SystemInstance root = ((InstanceObject) obj).getSystemInstance();
monitor.beginTask(actionName, IProgressMonitor.UNKNOWN);
final SOMIterator soms = new SOMIterator(root);
while (soms.hasNext()) {
final SystemOperationMode som = soms.nextSOM();
checkBusLoads(root, som);
}
monitor.done();
} else {
Dialog.showError("Bound Bus Bandwidth Analysis Error", "Can only check system instances");
}
}
use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class Binpack method analyzeInstanceModel.
@Override
protected void analyzeInstanceModel(final IProgressMonitor monitor, final AnalysisErrorReporterManager errManager, final SystemInstance root, final SystemOperationMode som) {
try {
monitor.beginTask("Binding threads to processors in " + root.getName(), IProgressMonitor.UNKNOWN);
logInfo("Binpacker Analysis Report\n");
/*
* Verify that all the busses have a transmission time
*/
final ForAllElement addBuses = new ForAllElement(errManager) {
@Override
public void process(Element obj) {
checkBuses((ComponentInstance) obj);
}
};
addBuses.processPreOrderComponentInstance(root, ComponentCategory.BUS);
/*
* Find and report all thread and device instances that don't have a
* period specified.
*/
EList<Element> incompletethreads = new ForAllElement() {
@Override
protected boolean suchThat(Element obj) {
final ComponentCategory cat = ((ComponentInstance) obj).getCategory();
if (cat == ComponentCategory.THREAD || cat == ComponentCategory.DEVICE) {
return org.osate.pluginsupport.properties.PropertyUtils.getScaled(TimingProperties::getPeriod, (ComponentInstance) obj, TimeUnits.MS).orElse(0.0) == 0.0;
} else {
return false;
}
}
}.processPreOrderComponentInstance(root);
for (final Iterator<Element> i = incompletethreads.iterator(); i.hasNext(); ) {
final ComponentInstance o = (ComponentInstance) i.next();
logWarning((InstanceModelUtil.isThread(o) ? "Thread " : "Device ") + o.getComponentInstancePath() + " is missing period property. Using default of 1 ns");
}
/*
* Find and report all thread instances that don't have a
* compute execution time specified.
*/
incompletethreads = new ForAllElement() {
@Override
protected boolean suchThat(Element obj) {
return GetProperties.getThreadExecutioninMilliSec((ComponentInstance) obj) == 0.0;
}
}.processPreOrderComponentInstance(root, ComponentCategory.THREAD);
for (final Iterator<Element> i = incompletethreads.iterator(); i.hasNext(); ) {
final ComponentInstance o = (ComponentInstance) i.next();
logWarning("Thread " + o.getComponentInstancePath() + " is missing compute_execution_time or InstructionsPerDispatch property. Using default of 0 ns");
}
/*
* Find if all the port connections have data size
*/
final ForAllElement addThreadConnections = new ForAllElement(errManager) {
@Override
public void process(Element obj) {
if (obj instanceof ConnectionInstance) {
final ConnectionInstance connInst = (ConnectionInstance) obj;
if (connInst.getKind() == ConnectionKind.PORT_CONNECTION) {
final FeatureInstance src = (FeatureInstance) connInst.getSource();
Feature srcAP = src.getFeature();
Classifier cl = srcAP.getClassifier();
if (cl instanceof DataClassifier) {
DataClassifier srcDC = (DataClassifier) cl;
if (AadlContribUtils.getDataSize(srcDC, SizeUnits.BYTES) == 0) {
logWarning("Data size of connection source port " + src.getComponentInstancePath() + " not specified");
}
}
}
}
}
};
addThreadConnections.processPreOrderAll(root);
/* The partitionChoice is set in initializeANalysis() */
NoExpansionExpansor expansor = new NoExpansionExpansor();
LowLevelBinPacker packer = null;
if (partitionChoice == IMMEDIATE_PARTITION) {
packer = new BFCPBinPacker(expansor);
} else if (partitionChoice == DEFER_EXEC_TIME) {
packer = new DFCPBinPacker(expansor);
} else if (partitionChoice == DEFER_BANDWIDTH) {
packer = new DFBPBinPacker(expansor);
}
AssignmentResult result = binPackSystem(root, expansor, packer, errManager, som);
reportResults(som, result);
if (result.isSuccess()) {
showResults(som, root, result);
} else {
showNoResults(som);
}
} catch (InvalidModelException e) {
error(e.getElement(), e.getMessage());
}
}
use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class ProcessCheck method perform.
public void perform(SystemInstance si) {
/**
* Get processes that do not have thread
*/
final List<ComponentInstance> processWithoutThread = si.getAllComponentInstances().stream().filter(c -> c.getCategory() == ComponentCategory.PROCESS).filter(pr -> pr.getComponentInstances().stream().filter(subco -> subco.getCategory() == ComponentCategory.THREAD).collect(Collectors.toList()).size() == 0).collect(Collectors.toList());
for (ComponentInstance process : processWithoutThread) {
addError(new ErrorReport(process, "Every Process needs to have at least one thread subcomponent"));
}
/**
* Get Processes that are not bound to a virtual processor/runtime
*/
final List<ComponentInstance> processWithoutRuntime = si.getAllComponentInstances().stream().filter(comp -> comp.getCategory() == ComponentCategory.PROCESS && !(GetProperties.getBoundProcessor(comp) instanceof VirtualProcessor)).collect(Collectors.toList());
for (ComponentInstance process : processWithoutRuntime) {
addError(new ErrorReport(process, "Process must be bound to a Virtual Processor through the property Deployment_Properties::Actual_Processor_Binding"));
}
/**
* Get processes that are not bound to a memory
*/
final List<ComponentInstance> processWithoutMemory = si.getAllComponentInstances().stream().filter(comp -> (comp.getCategory() == ComponentCategory.PROCESS) && (GetProperties.getActualMemoryBinding(comp) == null)).collect(Collectors.toList());
for (ComponentInstance process : processWithoutMemory) {
addError(new ErrorReport(process, "Process must define the property Deployment_Properties::Actual_Memory_Binding"));
}
}
use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class CheckerHandler method execute.
/**
* the command has been executed, so extract extract the needed information
* from the application context.
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final IWorkbenchWindow window;
int checkerkind;
String checkKind;
EObject selectedObject;
SystemInstance selectedSystemInstance;
List<ErrorReport> errors;
checkerkind = AbstractCheck.CHECKER_KIND_UNKNOWN;
checkKind = event.getParameter("org.osate.codegen.checker.kind");
/**
* Get the type of check we will do. And then, pass it to the checker
* object.
*/
if (checkKind.equalsIgnoreCase("pok")) {
checkerkind = AbstractCheck.CHECKER_KIND_POK;
}
if (checkKind.equalsIgnoreCase("vxworks")) {
checkerkind = AbstractCheck.CHECKER_KIND_VXWORKS;
}
if (checkKind.equalsIgnoreCase("deos")) {
checkerkind = AbstractCheck.CHECKER_KIND_DEOS;
}
window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
errors = new ArrayList<ErrorReport>();
selectedSystemInstance = null;
selectedObject = SelectionHelper.getSelectedObjectinOutline();
if (selectedObject instanceof SystemInstance) {
selectedSystemInstance = (SystemInstance) selectedObject;
}
if (selectedObject instanceof SystemImplementation) {
try {
selectedSystemInstance = InstantiateModel.buildInstanceModelFile((SystemImplementation) selectedObject);
} catch (Exception e) {
MessageDialog.openError(window.getShell(), e.getMessage(), e.getStackTrace().toString());
IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
StatusManager manager = StatusManager.getManager();
manager.handle(status, StatusManager.LOG);
selectedSystemInstance = null;
}
}
if (selectedSystemInstance == null) {
MessageDialog.openError(window.getShell(), "Code Generation Checker", "Please select a system implementation in the outline view");
return null;
}
errors.addAll(executeCheck(selectedSystemInstance, MemoryCheck.class, checkerkind));
errors.addAll(executeCheck(selectedSystemInstance, ProcessorCheck.class, checkerkind));
errors.addAll(executeCheck(selectedSystemInstance, ProcessCheck.class, checkerkind));
errors.addAll(executeCheck(selectedSystemInstance, ThreadCheck.class, checkerkind));
errors.addAll(executeCheck(selectedSystemInstance, DataCheck.class, checkerkind));
/**
* For now, we print the errors.
*/
String msg = new String();
for (ErrorReport e : errors) {
try {
IMarker marker = getIResource(e.getComponent().eResource()).createMarker(MARKER_TYPE);
marker.setAttribute(IMarker.MESSAGE, e.getComponent().getName() + " - " + e.getMessage());
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
// marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
} catch (CoreException exception) {
msg += exception.getMessage() + System.lineSeparator();
IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, exception.getMessage(), exception);
StatusManager manager = StatusManager.getManager();
manager.handle(status, StatusManager.LOG);
}
}
if (!msg.isEmpty()) {
MessageDialog.openError(window.getShell(), msg, "1");
} else if (errors.isEmpty()) {
MessageDialog.openInformation(window.getShell(), "Code Generation Checker", "No problems found");
} else {
MessageDialog.openError(window.getShell(), "Code Generation Checker", errors.size() + " problem(s) found");
}
return null;
}
Aggregations