use of org.osate.aadl2.ComponentCategory.PROCESSOR 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.ComponentCategory.PROCESSOR in project osate2 by osate.
the class PriorityInversion method checkPriorityInversion.
/**
* check for priority inversion of threads bound to the given processor
* @param curProcessor Component Instance of processor
*/
public void checkPriorityInversion(ComponentInstance curProcessor) {
SystemInstance root = curProcessor.getSystemInstance();
final ComponentInstance currentProcessor = curProcessor;
EList<Element> boundThreads = new ForAllElement() {
@Override
protected boolean suchThat(Element obj) {
if (!InstanceModelUtil.isPeriodicThread((ComponentInstance) obj)) {
return false;
}
List<ComponentInstance> boundProcessor;
try {
boundProcessor = GetProperties.getActualProcessorBinding((ComponentInstance) obj);
} catch (PropertyNotPresentException e) {
return false;
}
return boundProcessor.contains(currentProcessor);
}
}.processPreOrderComponentInstance(root, ComponentCategory.THREAD);
// we will sort the thread list by period and
// check to make sure the assigned priority is monotonically decreasing
ECollections.sort(boundThreads, (obj1, obj2) -> {
final double a = PropertyUtils.getScaled(TimingProperties::getPeriod, (ComponentInstance) obj1, TimeUnits.MS).orElse(0.0);
final double b = PropertyUtils.getScaled(TimingProperties::getPeriod, (ComponentInstance) obj2, TimeUnits.MS).orElse(0.0);
if (a > b) {
return 1;
}
if (a == b) {
return 0;
}
return -1;
});
checkDecreasingPriority(boundThreads);
}
use of org.osate.aadl2.ComponentCategory.PROCESSOR in project osate2 by osate.
the class ProcessorCheck method perform.
@Override
public void perform(SystemInstance si) {
/**
* processor needs to define their schedule
*/
if (vxworks() || deos()) {
final List<ComponentInstance> badProcessors = si.getAllComponentInstances().stream().filter(comp -> comp.getCategory() == ComponentCategory.PROCESSOR).filter(cpu -> GetProperties.getModuleSchedule(cpu).size() == 0).collect(Collectors.toList());
for (ComponentInstance cpu : badProcessors) {
addError(new ErrorReport(cpu, "Processor must define the property ARINC653::Module_Schedule"));
}
}
/**
* For vxworks, we need to check that the Source_Name property is
* defined on each virtual processor.
*/
if (vxworks()) {
final List<ComponentInstance> virtualProcessorsWithoutSourceName = si.getAllComponentInstances(ComponentCategory.VIRTUAL_PROCESSOR).stream().filter(comp -> ((comp.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) && (GetProperties.getSourceName(comp) == null))).collect(Collectors.toList());
for (ComponentInstance vp : virtualProcessorsWithoutSourceName) {
addError(new ErrorReport(vp, "Virtual Processor must define the property Programming_Properties::Source_Name"));
}
}
/**
* For vxworks, we need to check that the Source_Name property is
* defined on each virtual processor.
*/
if (deos()) {
final List<ComponentInstance> virtualProcessorsWithoutExecutionTime = si.getAllComponentInstances(ComponentCategory.VIRTUAL_PROCESSOR).stream().filter(comp -> ((comp.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) && (GetProperties.getExecutionTimeInMS(comp) == 0))).collect(Collectors.toList());
for (ComponentInstance vp : virtualProcessorsWithoutExecutionTime) {
addError(new ErrorReport(vp, "Virtual processor must define the property Timing_Properties::Execution_Time"));
}
final List<ComponentInstance> virtualProcessorsWithoutPeriod = si.getAllComponentInstances(ComponentCategory.VIRTUAL_PROCESSOR).stream().filter(comp -> ((comp.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) && (PropertyUtils.getScaled(TimingProperties::getPeriod, comp, TimeUnits.MS).orElse(0.0) == 0))).collect(Collectors.toList());
for (ComponentInstance vp : virtualProcessorsWithoutPeriod) {
addError(new ErrorReport(vp, "Virtual processor must define the property Timing_Properties::Period"));
}
}
if (pok()) {
OsateDebug.osateDebug("pok case");
/**
* For each CPU, we check that every virtual processor contained in
* the cpu is correctly referenced in the schedule slots
*/
for (ComponentInstance cpu : si.getComponentInstances().stream().filter(comp -> comp.getCategory() == ComponentCategory.PROCESSOR).collect(Collectors.toList())) {
final List<ComponentInstance> unreferencedVirtualProcessors = cpu.getComponentInstances().stream().filter(comp -> ((comp.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) && (PokProperties.getSlotsAllocation(cpu).contains(comp) == false))).collect(Collectors.toList());
for (ComponentInstance vp : unreferencedVirtualProcessors) {
addError(new ErrorReport(vp, "Virtual processor must be declared in the containing processor's POK::Slots_Allocation property"));
}
int slotsAllocationSize = PokProperties.getSlotsAllocation(cpu).size();
int slotsSize = PokProperties.getTimeSlotInMs(cpu).size();
if (slotsAllocationSize != slotsSize) {
addError(new ErrorReport(cpu, "Property POK::Slots_Allocation has " + slotsAllocationSize + " elements, but property POK::Slots has " + slotsSize + "elements"));
}
}
// List<ComponentInstance> badProcessors = (List<ComponentInstance>)
// si.getAllComponentInstances().stream()
// .filter( comp -> comp.getCategory() ==
// ComponentCategory.PROCESSOR).filter( cpu ->
// GetProperties.getModuleSchedule(cpu).size() ==
// 0).collect(Collectors.toList());
//
// for (ComponentInstance cpu : badProcessors)
// {
// addError (new ErrorReport (cpu, "Need to define the processor
// schedule"));
// }
}
}
use of org.osate.aadl2.ComponentCategory.PROCESSOR in project osate2 by osate.
the class CreateConnectionsSwitch method doModeTransitionConnections.
/**
* As we are following connection declarations we need to check whether the
* destination of the connection is named in one of the mode transitions of
* the component instance that is the destination of the connection being
* added
*
* @param parentci
* The component that is the context in which the connections are
* declared
* @param pci
* PortConnectionInstance that is being created
* @param conn
* connection being added to the ConnectionInstance
* @return true if we created a ModetransitionInstance
*/
private boolean doModeTransitionConnections(final ComponentInstance parentci, ConnectionInfo connInfo, Connection conn) {
boolean didTransition = false;
if (!(conn instanceof PortConnection || conn instanceof FeatureGroupConnection)) {
return false;
}
ComponentInstance parent = null;
Context fc = conn.getAllDestinationContext();
Element connContext = null;
if (fc instanceof ComponentImplementation || fc instanceof FeatureGroup) {
// we
// have
// an
// outgoing
// connection
parent = (ComponentInstance) parentci.eContainer();
connContext = parentci.getSubcomponent();
} else if (fc instanceof Subcomponent) {
parent = parentci.findSubcomponentInstance((Subcomponent) fc);
connContext = ((Subcomponent) fc).getAllClassifier();
}
if (parent == null) {
return false;
}
EList<ModeTransitionInstance> mtl = parent.getModeTransitionInstances();
Feature f = (Feature) conn.getAllDestination();
for (ModeTransitionInstance mti : mtl) {
ModeTransition mt = mti.getModeTransition();
Context co = null;
for (ModeTransitionTrigger trigger : mt.getOwnedTriggers()) {
TriggerPort tp = trigger.getTriggerPort();
if (tp instanceof Port) {
Port o = (Port) tp;
co = trigger.getContext();
NamedElement context = co;
if (context instanceof FeatureGroup) {
context = parent.getSubcomponent().getAllClassifier();
}
if (f == o && context == connContext) {
final ConnectionInstance mtci = addConnectionInstance(parentci.getSystemInstance(), connInfo.convertToModeTransition(), mti);
fillInModes(mtci);
fillInModeTransitions(mtci);
didTransition = true;
}
} else {
// TODO-LW: what if it's a processor port or internal event?
}
}
}
return didTransition;
}
use of org.osate.aadl2.ComponentCategory.PROCESSOR in project osate2 by osate.
the class CreateConnectionsSwitch method doModeTransitionConnections.
// ------------------------------------------------------------------------
// Methods related to mode transition connections
// ------------------------------------------------------------------------
/**
* handles the situation that a mode transition may name an event port in a
* thread (or other leaf component instance) and that port is not the
* destination of a connection instance - it is the start of a connection
* instance
*
* @param ci
* ComponentInstance
* @param fi
* FeatureInstance
* @return true if we created a ModetransitionInstance
*/
private boolean doModeTransitionConnections(ComponentInstance ci, FeatureInstance fi) {
boolean didTransition = false;
if (fi.getCategory() == FeatureCategory.EVENT_PORT) {
Subcomponent sub = ci.getSubcomponent();
Feature f = fi.getFeature();
for (ModeTransitionInstance mti : ci.getContainingComponentInstance().getModeTransitionInstances()) {
for (ModeTransitionTrigger trigger : mti.getModeTransition().getOwnedTriggers()) {
TriggerPort tp = trigger.getTriggerPort();
if (tp instanceof Port) {
Port p = (Port) tp;
Context c = trigger.getContext();
if (f == p && c == sub) {
addConnectionInstance(ci.getSystemInstance(), ConnectionInfo.newModeTransition(fi), mti);
didTransition = true;
}
} else {
// TODO-LW: what if it's a processor port or internal
// event?
}
}
}
}
return didTransition;
}
Aggregations