use of org.osate.aadl2.Abstract in project osate2 by osate.
the class AadlClassifierUtil method getComponentImplementationEClass.
public static EClass getComponentImplementationEClass(final ComponentCategory cc) {
Objects.requireNonNull(cc, "cc must not be null");
final Aadl2Package p = Aadl2Package.eINSTANCE;
switch(cc) {
case ABSTRACT:
return p.getAbstractImplementation();
case BUS:
return p.getBusImplementation();
case DATA:
return p.getDataImplementation();
case DEVICE:
return p.getDeviceImplementation();
case MEMORY:
return p.getMemoryImplementation();
case PROCESS:
return p.getProcessImplementation();
case PROCESSOR:
return p.getProcessorImplementation();
case SUBPROGRAM:
return p.getSubprogramImplementation();
case SUBPROGRAM_GROUP:
return p.getSubprogramGroupImplementation();
case SYSTEM:
return p.getSystemImplementation();
case THREAD:
return p.getThreadImplementation();
case THREAD_GROUP:
return p.getThreadGroupImplementation();
case VIRTUAL_BUS:
return p.getVirtualBusImplementation();
case VIRTUAL_PROCESSOR:
return p.getVirtualProcessorImplementation();
default:
throw new RuntimeException("Unexpected category: " + cc);
}
}
use of org.osate.aadl2.Abstract in project osate2 by osate.
the class AadlClassifierUtil method getComponentTypeEClass.
public static EClass getComponentTypeEClass(final ComponentCategory cc) {
Objects.requireNonNull(cc, "cc must not be null");
final Aadl2Package p = Aadl2Package.eINSTANCE;
switch(cc) {
case ABSTRACT:
return p.getAbstractType();
case BUS:
return p.getBusType();
case DATA:
return p.getDataType();
case DEVICE:
return p.getDeviceType();
case MEMORY:
return p.getMemoryType();
case PROCESS:
return p.getProcessType();
case PROCESSOR:
return p.getProcessorType();
case SUBPROGRAM:
return p.getSubprogramType();
case SUBPROGRAM_GROUP:
return p.getSubprogramGroupType();
case SYSTEM:
return p.getSystemType();
case THREAD:
return p.getThreadType();
case THREAD_GROUP:
return p.getThreadGroupType();
case VIRTUAL_BUS:
return p.getVirtualBusType();
case VIRTUAL_PROCESSOR:
return p.getVirtualProcessorType();
default:
throw new RuntimeException("Unexpected category: " + cc);
}
}
use of org.osate.aadl2.Abstract in project osate2 by osate.
the class SetExtendedClassifierPropertySection method getExtensibleClassifierDescriptions.
/**
* Return a list of EObjectDescriptions for classifiers that could be extended.
* The result will includes null since extending no classifier is a valid option.
* @return
*/
private List<IEObjectDescription> getExtensibleClassifierDescriptions(final Classifier classifier) {
final List<IEObjectDescription> objectDescriptions = new ArrayList<IEObjectDescription>();
objectDescriptions.add(null);
final String name = classifier.getQualifiedName();
// Populate the list with valid classifier descriptions
if (name != null) {
for (final IEObjectDescription desc : AadlModelAccessUtil.getAllEObjectsByType(classifier.eResource(), classifier.eClass())) {
if (!name.equalsIgnoreCase(desc.getName().toString("::"))) {
objectDescriptions.add(desc);
}
}
// Ensure that abstract classifiers are in the list
if (classifier instanceof ComponentType) {
if (classifier.eClass() != Aadl2Package.eINSTANCE.getAbstractType()) {
for (final IEObjectDescription desc : AadlModelAccessUtil.getAllEObjectsByType(classifier.eResource(), Aadl2Package.eINSTANCE.getAbstractType())) {
if (!name.equalsIgnoreCase(desc.getName().toString("::"))) {
objectDescriptions.add(desc);
}
}
}
} else if (classifier instanceof ComponentImplementation) {
if (classifier.eClass() != Aadl2Package.eINSTANCE.getAbstractImplementation()) {
for (final IEObjectDescription desc : AadlModelAccessUtil.getAllEObjectsByType(classifier.eResource(), Aadl2Package.eINSTANCE.getAbstractImplementation())) {
if (!name.equalsIgnoreCase(desc.getName().toString("::"))) {
objectDescriptions.add(desc);
}
}
}
}
}
return objectDescriptions;
}
use of org.osate.aadl2.Abstract in project osate2 by osate.
the class FlowLatencyAnalysisSwitch method mapComponentInstance.
private void mapComponentInstance(final EndToEndFlowInstance etef, final FlowElementInstance flowElementInstance, LatencyReportEntry entry) {
ComponentInstance componentInstance;
final boolean hasLatency = flowElementInstance instanceof FlowSpecificationInstance || flowElementInstance instanceof ConnectionInstance || flowElementInstance instanceof EndToEndFlowInstance || latencyCats.contains(((ComponentInstance) flowElementInstance).getCategory());
final RealRange expected = hasLatency ? PropertyUtils.getScaledRange(org.osate.aadl2.contrib.communication.CommunicationProperties::getLatency, flowElementInstance, TimeUnits.MS).orElse(RealRange.ZEROED) : RealRange.ZEROED;
if (flowElementInstance instanceof FlowSpecificationInstance) {
componentInstance = flowElementInstance.getComponentInstance();
} else {
componentInstance = (ComponentInstance) flowElementInstance;
}
FeatureInstance incomingConnectionFI = FlowLatencyUtil.getIncomingConnectionFeatureInstance(etef, flowElementInstance);
/**
* Get all the relevant properties.
*/
double period = periodCats.contains(componentInstance.getCategory()) ? PropertyUtils.getScaled(TimingProperties::getPeriod, componentInstance, TimeUnits.MS).orElse(0.0) : 0.0;
double deadline = deadlineCats.contains(componentInstance.getCategory()) ? PropertyUtils.getScaled(TimingProperties::getDeadline, componentInstance, TimeUnits.MS).orElse(0.0) : 0.0;
boolean isAssignedDeadline = isAssignedDeadline(componentInstance);
final boolean isThreadOrDevice = InstanceModelUtil.isThread(componentInstance) || InstanceModelUtil.isDevice(componentInstance) || InstanceModelUtil.isAbstract(componentInstance);
final boolean isPeriodic = period > 0 && (isThreadOrDevice ? (!InstanceModelUtil.isSporadicComponent(componentInstance) && !InstanceModelUtil.isTimedComponent(componentInstance) && !InstanceModelUtil.isAperiodicComponent(componentInstance)) : true);
final RealRange responseTime = getResponseTimeInMilliSec(flowElementInstance, componentInstance, isPeriodic);
final RealRange executionTime = getExecutionTimeInMilliSec(flowElementInstance, componentInstance, isPeriodic);
/**
* The component is periodic. Therefore it will sample its input unless we have an immediate connection or delayed connection
*/
boolean checkLastImmediate = false;
if (isPeriodic) {
// we have a periodic component that samples
if (incomingConnectionFI != null) {
// it is not the first component in the ETEF. We need to add sampling latency
if (incomingConnectionFI.getCategory() == FeatureCategory.DATA_PORT || incomingConnectionFI.getCategory() == FeatureCategory.ABSTRACT_FEATURE) {
// sampling incoming data
// period is set, and if thread, abstract, or device needs to be dispatched as periodic
// We sample only data ports. Event and event data ports have queuing latency
LatencyContributorComponent samplingLatencyContributor = new LatencyContributorComponent(componentInstance, flowElementInstance, report.isMajorFrameDelay());
samplingLatencyContributor.setSamplingPeriod(period);
if ((InstanceModelUtil.isThread(componentInstance) || InstanceModelUtil.isDevice(componentInstance)) && !hasAssignedPropertyValue(componentInstance, "Dispatch_Protocol")) {
samplingLatencyContributor.reportInfo("Assume Periodic dispatch because period is set");
}
if (FlowLatencyUtil.isPreviousConnectionDelayed(etef, flowElementInstance)) {
samplingLatencyContributor.setBestCaseMethod(LatencyContributorMethod.DELAYED);
samplingLatencyContributor.setWorstCaseMethod(LatencyContributorMethod.DELAYED);
} else if (FlowLatencyUtil.isPreviousConnectionImmediate(etef, flowElementInstance)) {
// the cumulative does not exceed the deadline of the last.
if (!FlowLatencyUtil.isNextConnectionImmediate(etef, flowElementInstance)) {
checkLastImmediate = true;
}
} else {
// sampled. We may under sample
ComponentInstance prevComp = FlowLatencyUtil.getPreviousComponent(etef, flowElementInstance);
double prevPeriod = prevComp != null ? PropertyUtils.getScaled(TimingProperties::getPeriod, prevComp, TimeUnits.MS).orElse(0.0) : 0;
if (period > 0 && prevPeriod > 0 && period % prevPeriod == 0.0) {
samplingLatencyContributor.setSamplingPeriod(prevPeriod);
} else {
samplingLatencyContributor.setSamplingPeriod(period);
}
samplingLatencyContributor.setBestCaseMethod(LatencyContributorMethod.SAMPLED);
samplingLatencyContributor.setWorstCaseMethod(LatencyContributorMethod.SAMPLED);
}
entry.addContributor(samplingLatencyContributor);
} else {
// queuing latency handled later
// do nothing here
}
} else {
// The periodic component is the first component in the ETEF
// record fact that first element is periodic so we can process synchronous behavior correctly
LatencyContributorComponent samplingLatencyContributor = new LatencyContributorComponent(componentInstance, flowElementInstance, report.isMajorFrameDelay());
samplingLatencyContributor.setBestCaseMethod(LatencyContributorMethod.FIRST_PERIODIC);
samplingLatencyContributor.setWorstCaseMethod(LatencyContributorMethod.FIRST_PERIODIC);
entry.addContributor(samplingLatencyContributor);
}
} else {
// the component is not executing periodically
if (entry.getContributors().isEmpty()) {
// insert first partition sampling for the aperiodic case. For other partitions it is inserted by connection processing
ComponentInstance firstPartition = FlowLatencyUtil.getPartition(componentInstance);
if (firstPartition != null) {
double partitionLatency = FlowLatencyUtil.getPartitionPeriod(firstPartition);
List<ScheduleWindow> schedule = FlowLatencyUtil.getModuleSchedule(firstPartition);
double partitionDuration = FlowLatencyUtil.getPartitionDuration(firstPartition, schedule);
LatencyContributorComponent platencyContributor = new LatencyContributorComponent(firstPartition, flowElementInstance, report.isMajorFrameDelay());
if (!FlowLatencyUtil.isInSchedule(firstPartition, schedule)) {
platencyContributor.reportWarning("Partition not found in ARINC653 schedule of processor " + FlowLatencyUtil.getModule(firstPartition).getName());
}
if (partitionDuration > 0) {
platencyContributor.setSamplingPeriod(partitionLatency);
double frameOffset = FlowLatencyUtil.getPartitionFrameOffset(firstPartition, schedule);
platencyContributor.setPartitionOffset(frameOffset);
platencyContributor.setPartitionDuration(partitionDuration);
platencyContributor.setWorstCaseMethod(LatencyContributorMethod.PARTITION_SCHEDULE);
platencyContributor.setBestCaseMethod(LatencyContributorMethod.PARTITION_SCHEDULE);
entry.addContributor(platencyContributor);
} else {
platencyContributor.setSamplingPeriod(partitionLatency);
platencyContributor.setWorstCaseMethod(LatencyContributorMethod.PARTITION_FRAME);
platencyContributor.setBestCaseMethod(LatencyContributorMethod.PARTITION_FRAME);
entry.addContributor(platencyContributor);
}
}
}
}
/**
* Selection of the worst case value, generic case.
*/
LatencyContributorMethod bestmethod;
LatencyContributorMethod worstmethod;
double worstCaseValue = 0.0;
double bestCaseValue = 0.0;
worstmethod = LatencyContributorMethod.UNKNOWN;
LatencyContributorComponent processingLatencyContributor = new LatencyContributorComponent(componentInstance, flowElementInstance, report.isMajorFrameDelay());
if (responseTime.getMaximum() != 0.0) {
worstCaseValue = responseTime.getMaximum();
worstmethod = LatencyContributorMethod.RESPONSE_TIME;
} else if (executionTime.getMaximum() != 0.0) {
if (!report.isWorstCaseDeadline()) {
// Use execution time for worst-case if preferences specify not deadline or no deadline is specified
worstCaseValue = executionTime.getMaximum();
worstmethod = LatencyContributorMethod.PROCESSING_TIME;
} else if (!isAssignedDeadline) {
worstCaseValue = executionTime.getMaximum();
worstmethod = LatencyContributorMethod.PROCESSING_TIME;
processingLatencyContributor.reportInfo("Using execution time as deadline was not set");
}
}
if ((worstCaseValue == 0.0) && isAssignedDeadline && report.isWorstCaseDeadline()) {
// use deadline if no execution time and deadline was explicitly assigned
worstCaseValue = deadline;
worstmethod = LatencyContributorMethod.DEADLINE;
}
if ((worstCaseValue == 0.0) && (expected.getMaximum() != 0.0)) {
// use flow latency if neither deadline nor execution time
worstCaseValue = expected.getMaximum();
worstmethod = LatencyContributorMethod.SPECIFIED;
} else if (worstCaseValue == 0.0 && deadline != 0.0) {
// if no flow spec value then use default deadline == period
worstCaseValue = deadline;
worstmethod = LatencyContributorMethod.DEADLINE;
processingLatencyContributor.reportInfo("Using deadline as execution time was not set");
}
/**
* Selection of the best case value, generic cases.
*/
bestmethod = LatencyContributorMethod.UNKNOWN;
if (responseTime.getMinimum() != 0.0) {
bestCaseValue = responseTime.getMinimum();
bestmethod = LatencyContributorMethod.RESPONSE_TIME;
} else if (executionTime.getMinimum() != 0.0) {
bestCaseValue = executionTime.getMinimum();
bestmethod = LatencyContributorMethod.PROCESSING_TIME;
}
if ((bestCaseValue == 0.0) && (expected.getMinimum() != 0.0)) {
bestCaseValue = expected.getMinimum();
bestmethod = LatencyContributorMethod.SPECIFIED;
}
// take into account queuing delay
if (incomingConnectionFI != null) {
double qs = 0;
LatencyContributorComponent ql = new LatencyContributorComponent(componentInstance, flowElementInstance, report.isMajorFrameDelay());
if (hasAssignedPropertyValue(incomingConnectionFI, org.osate.xtext.aadl2.properties.util.CommunicationProperties.QUEUE_SIZE)) {
qs = CommunicationProperties.getQueueSize(incomingConnectionFI).orElse(0);
} else if (incomingConnectionFI.getCategory() == FeatureCategory.DATA_PORT && isThreadOrDevice && (InstanceModelUtil.isSporadicComponent(componentInstance) || InstanceModelUtil.isTimedComponent(componentInstance) || InstanceModelUtil.isAperiodicComponent(componentInstance))) {
// treat data port as a port of queue size 1 when not a sampling thread
qs = 1;
ql.reportInfo("Data port as queue size 1 for sporadic, aperiodic, timed dispatch");
}
if (qs != 0) {
// take into account queuing delay on event and event data ports.
double dl = 0.0;
if (InstanceModelUtil.isSporadicComponent(componentInstance) || InstanceModelUtil.isPeriodicComponent(componentInstance)) {
dl = period;
ql.reportInfo("Sporadic or periodic has period delay per queue element");
} else {
dl = worstCaseValue;
}
double queuingDelay = qs * dl;
ql.setMaximum(queuingDelay);
if (report.isBestcaseEmptyQueue()) {
ql.setMinimum(0.0);
ql.reportInfo("Assume best case empty queue");
} else {
double mindl = (InstanceModelUtil.isSporadicComponent(componentInstance) || InstanceModelUtil.isPeriodicComponent(componentInstance) ? period : bestCaseValue);
ql.setMinimum(qs * mindl);
ql.reportInfo("Assume best case full queue");
}
ql.setWorstCaseMethod(LatencyContributorMethod.QUEUED);
ql.setBestCaseMethod(LatencyContributorMethod.QUEUED);
entry.addContributor(ql);
}
}
processingLatencyContributor.setWorstCaseMethod(worstmethod);
processingLatencyContributor.setBestCaseMethod(bestmethod);
processingLatencyContributor.setMaximum(worstCaseValue);
processingLatencyContributor.setMinimum(bestCaseValue);
processingLatencyContributor.setExpectedMaximum(expected.getMaximum());
processingLatencyContributor.setExpectedMinimum(expected.getMinimum());
if (checkLastImmediate && deadline > 0.0) {
processingLatencyContributor.setImmediateDeadline(deadline);
}
processingLatencyContributor.checkConsistency();
entry.addContributor(processingLatencyContributor);
}
use of org.osate.aadl2.Abstract 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);
}
Aggregations