use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class NewBusLoadAnalysis method analyzeBody.
private AnalysisResult analyzeBody(final IProgressMonitor monitor, final Element obj) {
if (obj instanceof InstanceObject) {
final SystemInstance root = ((InstanceObject) obj).getSystemInstance();
final AnalysisResult analysisResult = ResultUtil.createAnalysisResult("Bus Load", root);
analysisResult.setResultType(ResultType.SUCCESS);
analysisResult.setMessage("Bus load analysis of " + root.getFullName());
final SOMIterator soms = new SOMIterator(root);
while (soms.hasNext()) {
final SystemOperationMode som = soms.nextSOM();
final Result somResult = ResultUtil.createResult(Aadl2Util.isPrintableSOMName(som) ? Aadl2Util.getPrintableSOMMembers(som) : "", som, ResultType.SUCCESS);
analysisResult.getResults().add(somResult);
final BusLoadModel busLoadModel = BusLoadModelBuilder.buildModel(root, som);
analyzeBusLoadModel(busLoadModel, somResult, monitor);
}
monitor.done();
return analysisResult;
} else {
Dialog.showError("Bound Bus Bandwidth Analysis Error", "Can only check system instances");
return null;
}
}
use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class AbstractResourceAnalysis method sumBudgets.
/**
* calculate the budget of components with budgets, i.e., application
* components and devices For application components they are required,
* while for devices they are optional
*
* @param ci component instance whose subtree is to be added up
* @param rk Property Definition of property to be added
* @param unit Unit in which the property value should be retrieved
* @param somName String name of SOM (used in reporting)
* @return double total, zero, if no budget, -1 if hardware only in
* substructure
*/
protected double sumBudgets(ComponentInstance ci, ResourceKind rk, final SystemOperationMode som, String prefix) {
if (!ci.isActive(som)) {
return 0.0;
}
double subtotal = 0.0;
EList<ComponentInstance> subcis = ci.getComponentInstances();
boolean HWOnly = false;
boolean isSystemInstance = ci instanceof SystemInstance;
int subbudgetcount = 0;
int subcount = 0;
if (subcis.size() == 0) {
if (isHardware(ci)) {
return -1;
}
} else {
// track HWonly if subcomponents
HWOnly = true;
}
for (Iterator<ComponentInstance> it = subcis.iterator(); it.hasNext(); ) {
ComponentInstance subci = it.next();
double subresult = sumBudgets(subci, rk, som, isSystemInstance ? "" : prefix + prefixSymbol);
if (subresult >= 0) {
HWOnly = false;
subtotal += subresult;
if (subci.getCategory() == ComponentCategory.DEVICE) {
if (subresult > 0) {
// only count device if it has a budget
subcount++;
subbudgetcount++;
}
} else {
// track how many non-devices and whether they have a budget
subcount++;
if (subresult > 0) {
subbudgetcount++;
}
}
}
}
if (HWOnly) {
return -1;
}
final Enum<?> budgetUnit = rk == ResourceKind.MIPS ? ProcessorSpeedUnits.MIPS : SizeUnits.KBYTE;
double budget = getBudget(ci, rk);
if (rk.equals(ResourceKind.RAM) || rk.equals(ResourceKind.ROM) || rk.equals(ResourceKind.Memory)) {
double actualsize = getMemoryUseActual(ci, rk.name(), SizeUnits.KBYTE);
subtotal += actualsize;
}
String resourceName = ci.getCategory().getName();
String notes = "";
if (rk == ResourceKind.MIPS && ci.getCategory() == ComponentCategory.THREAD) {
subtotal = getThreadExecutioninMIPS(ci);
}
components = components + subcount;
budgetedComponents = budgetedComponents + subbudgetcount;
if (budget > 0 && subtotal > budget) {
notes = String.format("Error: subtotal/actual exceeds budget %.3f by %.3f " + budgetUnit.name(), budget, (subtotal - budget));
} else if (budget > 0 && subtotal < budget) {
notes = String.format(resourceName + " " + ci.getInstanceObjectPath() + " total %.3f " + budgetUnit.name() + " below budget %.3f " + budgetUnit.name() + " (%.1f %% slack)", subtotal, budget, (budget - subtotal) / budget * 100);
}
if (!isSystemInstance) {
detailedLog(prefix, ci, budget, subtotal, resourceName, budgetUnit, notes);
}
return subtotal == 0 ? budget : subtotal;
}
use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class BoundResourceAnalysis method checkMemoryLoads.
private void checkMemoryLoads(SystemInstance si, final SystemOperationMode som) {
count = 0;
ForAllElement countme = new ForAllElement() {
@Override
protected void process(Element obj) {
if (canHaveMemory(obj)) {
if (getROMCapacityInKB(obj) > 0.0 || getRAMCapacityInKB(obj) > 0.0 || getMemorySize(obj) > 0.0) {
count = count + 1;
}
}
}
};
countme.processPreOrderComponentInstance(si);
if (count > 0) {
errManager.infoSummaryReportOnly(si, null, "\nMemory Summary Report: " + Aadl2Util.getPrintableSOMName(som));
} else {
errManager.infoSummaryReportOnly(si, null, "\nMemory Summary Report: " + Aadl2Util.getPrintableSOMName(som) + "\n No Memory with Memory_Size or RAMCapacity or ROMCapacity");
}
ForAllElement mal = new ForAllElement() {
@Override
protected void process(Element obj) {
if (canHaveMemory(obj)) {
checkMemoryLoad((ComponentInstance) obj, som);
}
}
};
mal.processPreOrderComponentInstance(si);
}
use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class BusLoadModelBuilder method build.
// ==== Methods to build the model ====
public BusLoadModel build() {
final BusLoadModel model = BusloadFactory.eINSTANCE.createBusLoadModel();
final ForAllElement mal = new ForAllElement() {
@Override
protected void process(final Element obj) {
final ComponentInstance ci = (ComponentInstance) obj;
final ComponentCategory cat = ci.getCategory();
if (cat == ComponentCategory.BUS) {
addBus(model, ci, som);
} else if (cat == ComponentCategory.VIRTUAL_BUS) {
addVirtualBus(model, ci, som);
}
}
};
mal.processPreOrderComponentInstance(systemInstance);
return model;
}
use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class CheckPriorityInversion method analyzeInstanceModel.
@Override
protected void analyzeInstanceModel(final IProgressMonitor monitor, final AnalysisErrorReporterManager errManager, final SystemInstance root, final SystemOperationMode som) {
monitor.beginTask(getActionName(), IProgressMonitor.UNKNOWN);
try {
final PriorityInversion pi = new PriorityInversion(errManager);
pi.checkSystemPriorityInversion(root);
} catch (InvalidModelException e) {
error(e.getElement(), e.getMessage());
}
monitor.done();
}
Aggregations