use of org.osate.aadl2.ComponentCategory in project osate2 by osate.
the class FlowLatencyUtil method getModuleSchedule.
public static List<ScheduleWindow> getModuleSchedule(final ComponentInstance partition) {
if (partition == null) {
return null;
} else {
final ComponentInstance module = getModule(partition);
if (module == null) {
return null;
} else {
final ComponentCategory moduleCategory = module.getCategory();
if (moduleCategory == ComponentCategory.PROCESSOR || moduleCategory == ComponentCategory.VIRTUAL_PROCESSOR || moduleCategory == ComponentCategory.ABSTRACT) {
/* Only keep those windows that have a partition specified */
final List<ScheduleWindow> windows = Arinc653.getModuleSchedule(module).orElse(Collections.emptyList());
windows.removeIf(sw -> !sw.getPartition().isPresent());
return windows;
} else {
return Collections.emptyList();
}
}
}
}
use of org.osate.aadl2.ComponentCategory in project osate2 by osate.
the class FlowLatencyUtil method getPartitionPeriod.
/**
* get the partition period, either from the virtual processor representing the partition, or from the major frame of the ARINC653 specification of a processor
* @return partition period as latency contributor
*/
public static double getPartitionPeriod(final ComponentInstance part) {
// first look for major frame value on processor
final ComponentInstance module = getModule(part);
final ComponentCategory moduleCategory = module != null ? module.getCategory() : null;
double result = 0.0;
if (moduleCategory == ComponentCategory.PROCESSOR || moduleCategory == ComponentCategory.VIRTUAL_PROCESSOR || moduleCategory == ComponentCategory.ABSTRACT) {
result = PropertyUtils.getScaled(Arinc653::getModuleMajorFrame, module, TimeUnits.MS).orElse(0.0);
}
if (result == 0.0) {
// look for period on partition
result = PropertyUtils.getScaled(TimingProperties::getPeriod, part, TimeUnits.MS).orElse(0.0);
if (result == 0.0) {
// look for major frame value on virtual processor (partition)
result = PropertyUtils.getScaled(Arinc653::getModuleMajorFrame, part, TimeUnits.MS).orElse(0.0);
}
}
return result;
}
use of org.osate.aadl2.ComponentCategory in project osate2 by osate.
the class Binpack method getAllowedProcessorBindings.
/**
* Get the processor components that a given thread is allowed to be bound to
* based on the thread's ALLOWED_PROCESSOR_BINDING and
* ALLOWED_PROCESSOR_BINDING_CLASS property values. The processors are
* search for in the same system instance that the given thread component is
* a part of.
*
* @param thread
* The thread.
* @return An unmodifiable set of processor ComponentInstances.
* @exception IllegalArgumentException
* Thrown if the category of the component instance
* referenced by <code>thread</code> is not
* {@link ComponentCategory#THREAD_LITERAL}.
*/
public Set<ComponentInstance> getAllowedProcessorBindings(final ComponentInstance thread) {
if (thread.getCategory() != ComponentCategory.THREAD) {
throw new IllegalArgumentException("Component \"" + thread.getName() + "\" is not a thread.");
}
List<ComponentInstance> allowedBindingsVals;
try {
allowedBindingsVals = GetProperties.getAllowedProcessorBinding(thread);
} catch (PropertyNotPresentException e) {
// Ignore this situation and move on.
allowedBindingsVals = Collections.emptyList();
}
List<Classifier> allowedClassVals;
try {
allowedClassVals = GetProperties.getAllowedProcessorBindingClass(thread);
} catch (PropertyNotPresentException e) {
// Ignore this situation and move on.
allowedClassVals = Collections.emptyList();
}
final Set<ComponentInstance> searchRoots = new HashSet<>();
if (allowedBindingsVals.isEmpty()) {
searchRoots.add(thread.getSystemInstance());
} else {
for (final Iterator<ComponentInstance> i = allowedBindingsVals.iterator(); i.hasNext(); ) {
final ComponentInstance rv = i.next();
searchRoots.add(rv);
}
}
final Set<SystemClassifier> allowedSystemClassifiers = new HashSet<>();
final Set<ProcessorClassifier> allowedProcClassifiers = new HashSet<>();
for (final Iterator<Classifier> i = allowedClassVals.iterator(); i.hasNext(); ) {
final Classifier cc = i.next();
if (cc instanceof ProcessorClassifier) {
// ComponentCategory.PROCESSOR) {
allowedProcClassifiers.add((ProcessorClassifier) cc);
} else if (cc instanceof SystemClassifier) {
// cv.getValue() == ComponentCategory.SYSTEM_LITERAL) {
allowedSystemClassifiers.add((SystemClassifier) cc);
} else {
internalError("Ill-formed allowed_processor_binding_class value: got a non-system non-processor component classifier");
}
}
final Set<ComponentInstance> allowedProcs = new HashSet<>();
for (final Iterator<ComponentInstance> i = searchRoots.iterator(); i.hasNext(); ) {
final ComponentInstance ci = i.next();
getAllowedProcessorBindings(ci, allowedProcs, allowedProcClassifiers, allowedSystemClassifiers);
}
return Collections.unmodifiableSet(allowedProcs);
}
use of org.osate.aadl2.ComponentCategory 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.ComponentCategory in project osate2 by osate.
the class BusLoadAnalysis method checkBusLoads.
private void checkBusLoads(SystemInstance si, final SystemOperationMode som) {
errManager.infoSummaryReportOnly(si, null, "\nBus Summary Report: " + Aadl2Util.getPrintableSOMName(som));
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) {
checkBusBandWidthLoad(ci, som);
} else if (cat == ComponentCategory.VIRTUAL_BUS) {
checkVirtualBusBandWidthLoad(ci, som);
}
}
};
mal.processPreOrderComponentInstance(si);
}
Aggregations