use of org.osate.aadl2.instance.SystemOperationMode in project osate2 by osate.
the class NotBoundResourceAnalysis method analyzeResourceBudget.
public void analyzeResourceBudget(final SystemInstance si, final SystemOperationMode som) {
init();
@SuppressWarnings("unchecked") EList<ComponentInstance> proclist = (EList<ComponentInstance>) (EList<?>) new ForAllElement().processPreOrderComponentInstance(si, ComponentCategory.PROCESSOR);
logHeader("\n\nDetailed Processor MIPS Capacity Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
logHeader("Component,Capacity");
capacity = sumCapacity(proclist, ResourceKind.MIPS, "processor", ProcessorSpeedUnits.MIPS);
detailedLogTotal1(null, capacity, ProcessorSpeedUnits.MIPS);
@SuppressWarnings("unchecked") EList<ComponentInstance> vproclist = (EList<ComponentInstance>) (EList<?>) new ForAllElement().processPreOrderComponentInstance(si, ComponentCategory.VIRTUAL_PROCESSOR);
if (!vproclist.isEmpty()) {
logHeader("\n\nDetailed Virtual Processor MIPS Capacity Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
logHeader("Component,Capacity");
vcapacity = sumVPMIPSBudget(vproclist);
detailedLogTotal1(null, vcapacity, ProcessorSpeedUnits.MIPS);
}
logHeader("\n\nDetailed MIPS Budget Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
logHeader("Component,Budget,Actual,Notes");
budgetTotal = sumBudgets(si, ResourceKind.MIPS, som, "");
if (budgetTotal >= 0) {
detailedLogTotal2(null, budgetTotal, ProcessorSpeedUnits.MIPS);
errManager.infoSummaryReportOnly(si, null, "Resource Summary: " + Aadl2Util.getPrintableSOMName(som));
report(si, "MIPS", ProcessorSpeedUnits.MIPS, som);
}
init();
@SuppressWarnings("unchecked") EList<ComponentInstance> memlist = (EList<ComponentInstance>) (EList<?>) new ForAllElement().processPreOrderComponentInstance(si, ComponentCategory.MEMORY);
capacity = capacityTotal(memlist, ResourceKind.Memory, "Memory");
if (capacity > 0) {
logHeader("\n\nDetailed Memory Capacity Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
logHeader("Component,Capacity");
capacity = sumCapacity(memlist, ResourceKind.Memory, "Memory", SizeUnits.KBYTE);
detailedLogTotal1(null, capacity, SizeUnits.KBYTE);
logHeader("\n\nDetailed Memory Budget Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
logHeader("Component,Budget,Actual,Notes");
budgetTotal = sumBudgets(si, ResourceKind.Memory, som, "");
if (budgetTotal >= 0) {
detailedLogTotal2(null, budgetTotal, SizeUnits.KBYTE);
report(si, "Memory", SizeUnits.KBYTE, som);
}
}
init();
capacity = capacityTotal(memlist, ResourceKind.RAM, "RAM");
if (capacity > 0) {
logHeader("\n\nDetailed RAM Capacity Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
logHeader("Component,Capacity");
capacity = sumCapacity(memlist, ResourceKind.RAM, "RAM", SizeUnits.KBYTE);
detailedLogTotal1(null, capacity, SizeUnits.KBYTE);
logHeader("\n\nDetailed RAM Budget Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
logHeader("Component,Budget,Actual,Notes");
budgetTotal = sumBudgets(si, ResourceKind.RAM, som, "");
if (budgetTotal >= 0) {
detailedLogTotal2(null, budgetTotal, SizeUnits.KBYTE);
report(si, "RAM", SizeUnits.KBYTE, som);
}
}
init();
capacity = capacityTotal(memlist, ResourceKind.ROM, "ROM");
if (capacity > 0) {
logHeader("\n\nDetailed ROM Capacity Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
logHeader("Component,Capacity");
capacity = sumCapacity(memlist, ResourceKind.ROM, "ROM", SizeUnits.KBYTE);
detailedLogTotal1(null, capacity, SizeUnits.KBYTE);
logHeader("\n\nDetailed ROM Budget Report " + Aadl2Util.getPrintableSOMName(som) + "\n");
logHeader("Component,Budget,Actual,Notes");
budgetTotal = sumBudgets(si, ResourceKind.ROM, som, "");
if (budgetTotal >= 0) {
detailedLogTotal2(null, budgetTotal, SizeUnits.KBYTE);
report(si, "ROM", SizeUnits.KBYTE, som);
}
}
}
use of org.osate.aadl2.instance.SystemOperationMode in project osate2 by osate.
the class PowerAnalysis method analyzePowerBudget.
public void analyzePowerBudget(SystemInstance si, Report powerReport, SystemOperationMode som) {
final String somName = Aadl2Util.getPrintableSOMName(som);
String systemName = si.getComponentClassifier().getName();
final Section section = new Section(systemName + somName);
powerReport.addSection(section);
ForAllElement DoCapacity = new ForAllElement() {
@Override
protected void action(Element aobj) {
capacity = 0.0;
budgetTotal = 0.0;
supplyTotal = 0.0;
ComponentInstance ci = (ComponentInstance) aobj;
capacity = GetProperties.getPowerCapacity(ci, 0.0);
if (capacity == 0) {
return;
}
// components that represent a power system with capacity
powerComponentHeader(section, "Computing Electrical Power for " + ci.getName());
String supplyLine = "";
String budgetLine = "";
for (FeatureInstance fi : ci.getFeatureInstances()) {
double supply = GetProperties.getPowerBudget(fi, 0.0);
if (supply > 0) {
// there must be a connection on this feature
if (!fi.getDstConnectionInstances().isEmpty() || !fi.getSrcConnectionInstances().isEmpty()) {
supplyLine = supplyLine + (supplyLine.isEmpty() ? "" : ", ") + PowerAnalysis.this.toString(supply) + " from " + fi.getContainingComponentInstance().getName();
supplyTotal += supply;
} else {
// warning unconnected power requirement
}
}
for (ConnectionInstance inconni : fi.getDstConnectionInstances()) {
// incoming connections: does the other end provide power?
ConnectionInstanceEnd srcfi = inconni.getSource();
supply = GetProperties.getPowerSupply(srcfi, 0.0);
if (supply > 0) {
supplyLine = supplyLine + (supplyLine.isEmpty() ? "" : ", ") + PowerAnalysis.this.toString(supply) + " from " + srcfi.getContainingComponentInstance().getName();
supplyTotal += supply;
}
}
for (ConnectionInstance outconni : fi.getSrcConnectionInstances()) {
// outgoing connection. Does the other end have a power budget?
ConnectionInstanceEnd dstfi = outconni.getDestination();
double budget = GetProperties.getPowerBudget(dstfi, 0.0);
if (budget > 0) {
budgetLine = budgetLine + (budgetLine.isEmpty() ? "" : ", ") + PowerAnalysis.this.toString(budget) + " for " + dstfi.getContainingComponentInstance().getName();
budgetTotal += budget;
}
}
}
// this could be a bus, possibly an abstract component
for (ConnectionInstance ac : ci.getSrcConnectionInstances()) {
// Outgoing from Power system as bus
FeatureInstance dstfi = (FeatureInstance) ac.getDestination();
double budget = GetProperties.getPowerBudget(dstfi, 0.0);
if (budget > 0) {
budgetLine = budgetLine + (budgetLine.isEmpty() ? "" : ", ") + PowerAnalysis.this.toString(budget) + " for " + dstfi.getContainingComponentInstance().getName();
budgetTotal += budget;
}
double supply = GetProperties.getPowerSupply(dstfi, 0.0);
if (supply > 0) {
supplyLine = supplyLine + (supplyLine.isEmpty() ? "" : ", ") + PowerAnalysis.this.toString(supply) + " from " + dstfi.getContainingComponentInstance().getName();
supplyTotal += supply;
}
}
for (ConnectionInstance ac : ci.getDstConnectionInstances()) {
// Incoming to Power system as bus
FeatureInstance srcfi = (FeatureInstance) ac.getSource();
double budget = GetProperties.getPowerBudget(srcfi, 0.0);
if (budget > 0) {
budgetLine = budgetLine + (budgetLine.isEmpty() ? "" : ", ") + PowerAnalysis.this.toString(budget) + " for " + srcfi.getContainingComponentInstance().getName();
budgetTotal += budget;
}
double supply = GetProperties.getPowerSupply(srcfi, 0.0);
if (supply > 0) {
supplyLine = supplyLine + (supplyLine.isEmpty() ? "" : ", ") + PowerAnalysis.this.toString(supply) + " from " + srcfi.getContainingComponentInstance().getName();
supplyTotal += supply;
}
}
report(section, ci, somName, ci.getName() + " power", capacity, budgetTotal, supplyTotal, budgetLine, supplyLine);
}
};
DoCapacity.processPreOrderComponentInstance(si);
}
use of org.osate.aadl2.instance.SystemOperationMode in project osate2 by osate.
the class SystemOperationModeItemProvider method getChildren.
/**
* Manually added to show the individual modes of a SystemOperationMode.
*/
public Collection<?> getChildren(Object object) {
SystemOperationMode som = (SystemOperationMode) object;
List<SubModeItemProvider> result = new ArrayList<SubModeItemProvider>();
for (ModeInstance subMode : som.getCurrentModes()) {
result.add(new SubModeItemProvider(adapterFactory, som, subMode));
}
return result;
}
use of org.osate.aadl2.instance.SystemOperationMode in project osate2 by osate.
the class InstantiateModel method createSystemOperationModes.
// --------------------------------------------------------------------------------------------
// Methods related to system operation modes
// --------------------------------------------------------------------------------------------
/*
* Create the system operation mode objects for the instance model.
*/
protected void createSystemOperationModes(final SystemInstance root, final int limit) throws InterruptedException {
class SOMBuilder {
class Node {
ComponentInstance ci;
Node parentNode;
State state;
Node(ComponentInstance ci, Node parentNode) {
this.ci = ci;
this.parentNode = parentNode;
}
}
class State {
boolean active;
// mode is ignored if !active
ModeInstance mode;
State(boolean active) {
this.active = active;
}
}
ArrayList<Node> workState = new ArrayList<>();
int modalCount;
int createSoms() throws InterruptedException {
Node rootNode = new Node(null, null);
rootNode.state = new State(true);
initWorkState(root, rootNode);
modalCount = workState.size();
if (modalCount == 0) {
/*
* We have no modal components, but we need to create a special SOM to
* represent our single normal operating state.
*/
final SystemOperationMode som = InstanceFactory.eINSTANCE.createSystemOperationMode();
som.setName(NORMAL_SOM_NAME);
root.getSystemOperationModes().add(som);
return 0;
} else {
return enumerateSoms(0, 0);
}
}
protected int enumerateSoms(int depth, int index) throws InterruptedException {
if (monitor.isCanceled()) {
throw new InterruptedException();
}
Node node = workState.get(depth);
State parentState = node.parentNode.state;
Iterator<ModeInstance> modes = parentState.active ? getActiveModes(node.ci, parentState.mode) : Collections.emptyIterator();
boolean active = parentState.active && modes.hasNext();
State state = new State(active);
node.state = state;
if (depth + 1 == modalCount) {
// here we add one or more SOMs
if (active) {
while (modes.hasNext()) {
if (monitor.isCanceled()) {
throw new InterruptedException();
}
state.mode = modes.next();
root.getSystemOperationModes().add(createSOM(index + 1));
if (index < 0 || ++index >= limit) {
return -1;
}
}
} else {
root.getSystemOperationModes().add(createSOM(index + 1));
if (index < 0 || ++index >= limit) {
return -1;
}
}
} else {
if (active) {
while (modes.hasNext()) {
state.mode = modes.next();
index = enumerateSoms(depth + 1, index);
if (index < 0) {
return -1;
}
}
} else {
index = enumerateSoms(depth + 1, index);
}
}
node.state = null;
return index;
}
protected Iterator<ModeInstance> getActiveModes(ComponentInstance ci, ModeInstance parentMode) {
List<ModeInstance> modes = ci.getModeInstances();
if (parentMode == null) {
// system instance
return modes.iterator();
} else if (!ci.getInModes().isEmpty() && !ci.getInModes().contains(parentMode)) {
// component not active in parent mode
return Collections.emptyIterator();
} else {
// limit derived modes to mapping
return modes.stream().filter(mi -> {
return !mi.isDerived() || mi.getParents().contains(parentMode);
}).iterator();
}
}
protected void initWorkState(ComponentInstance ci, Node parentNode) throws InterruptedException {
if (monitor.isCanceled()) {
throw new InterruptedException();
}
if (!ci.getModeInstances().isEmpty()) {
parentNode = new Node(ci, parentNode);
workState.add(parentNode);
}
for (ComponentInstance sub : ci.getComponentInstances()) {
initWorkState(sub, parentNode);
}
}
protected SystemOperationMode createSOM(int somNo) throws InterruptedException {
final SystemOperationMode som;
som = InstanceFactory.eINSTANCE.createSystemOperationMode();
for (Node node : workState) {
if (monitor.isCanceled()) {
throw new InterruptedException();
}
if (!node.state.active) {
continue;
}
ModeInstance mi = node.state.mode;
List<SystemOperationMode> soms = mode2som.get(mi);
if (soms == null) {
soms = new ArrayList<SystemOperationMode>();
mode2som.put(mi, soms);
}
soms.add(som);
som.getCurrentModes().add(mi);
}
som.setName("som_" + somNo);
return som;
}
}
int index = new SOMBuilder().createSoms();
if (index < 0) {
errManager.warning(root, "List of system operation modes is incomplete (see project property 'Instantiation')");
}
}
use of org.osate.aadl2.instance.SystemOperationMode in project osate2 by osate.
the class ForAllElement method processObject.
/**
* Process a single model object. Delegates to {@link #process(Element)}.
* This method exists to satisfy the {@link IProcessingMethod} interface. I
* would have preferred to have a <code>process</code> method in the
* interface, but I cannot because the <code>ForAllElement.process</code>
* method is <code>protected</code>. If I put the method in an interface, I
* would have to make the method <code>public</code>, which could break
* existing code.
*/
@Override
public final void processObject(final Element theElement) {
if (theElement instanceof InstanceObject) {
InstanceObject io = (InstanceObject) theElement;
SystemInstance root = io.getSystemInstance();
SystemOperationMode som = root.getCurrentSystemOperationMode();
if (som == null || io.isActive(som)) {
process(io);
}
} else {
process(theElement);
}
}
Aggregations