use of org.osate.analysis.flows.model.LatencyContributorConnection in project osate2 by osate.
the class FlowLatencyAnalysisSwitch method mapConnectionInstance.
private void mapConnectionInstance(final EndToEndFlowInstance etef, final FlowElementInstance flowElementInstance, LatencyReportEntry entry) {
ConnectionInstance connectionInstance = (ConnectionInstance) flowElementInstance;
final RealRange expected = PropertyUtils.getScaledRange(org.osate.aadl2.contrib.communication.CommunicationProperties::getLatency, flowElementInstance, TimeUnits.MS).orElse(RealRange.ZEROED);
ComponentInstance componentInstanceSource = InstanceModelUtil.getRelatedComponentSource(connectionInstance);
ComponentInstance componentInstanceDestination = InstanceModelUtil.getRelatedComponentDestination(connectionInstance);
ComponentInstance srcHW = InstanceModelUtil.getHardwareComponent(componentInstanceSource);
ComponentInstance dstHW = InstanceModelUtil.getHardwareComponent(componentInstanceDestination);
ComponentInstance srcPartition = FlowLatencyUtil.getPartition(componentInstanceSource);
ComponentInstance dstPartition = FlowLatencyUtil.getPartition(componentInstanceDestination);
// if we exit a partition then we may have I/O Delay until the end of the partition window or the end of the major frame
if (srcPartition != null && srcPartition != dstPartition) {
double partitionLatency = FlowLatencyUtil.getPartitionPeriod(srcPartition);
List<ScheduleWindow> schedule = FlowLatencyUtil.getModuleSchedule(srcPartition);
double partitionDuration = FlowLatencyUtil.getPartitionDuration(srcPartition, schedule);
if (partitionDuration > 0) {
LatencyContributor ioLatencyContributor = new LatencyContributorComponent(srcPartition, flowElementInstance, report.isMajorFrameDelay());
if (!FlowLatencyUtil.isInSchedule(srcPartition, schedule)) {
ioLatencyContributor.reportWarning("Partition not found in ARINC653 schedule of processor " + FlowLatencyUtil.getModule(srcPartition).getName());
}
ioLatencyContributor.setWorstCaseMethod(LatencyContributorMethod.PARTITION_OUTPUT);
ioLatencyContributor.setBestCaseMethod(LatencyContributorMethod.PARTITION_OUTPUT);
if (partitionLatency == 0) {
ioLatencyContributor.setSamplingPeriod(partitionDuration);
ioLatencyContributor.reportInfo("No partition period/rate. Using partition duration");
} else {
ioLatencyContributor.setSamplingPeriod(partitionLatency);
}
double frameOffset = FlowLatencyUtil.getPartitionFrameOffset(srcPartition, schedule);
ioLatencyContributor.setPartitionOffset(frameOffset);
ioLatencyContributor.setPartitionDuration(partitionDuration);
entry.addContributor(ioLatencyContributor);
}
}
// now we deal with communication latency
LatencyContributor latencyContributor = new LatencyContributorConnection(connectionInstance, report.isMajorFrameDelay());
processActualConnectionBindingsSampling(connectionInstance, latencyContributor);
ComponentClassifier relatedConnectionData = (ComponentClassifier) FlowLatencyUtil.getConnectionData(connectionInstance);
processActualConnectionBindingsTransmission(connectionInstance, relatedConnectionData == null ? 0.0 : AadlContribUtils.getDataSize(relatedConnectionData, SizeUnits.BYTES), latencyContributor);
if (expected.getMaximum() > 0) {
latencyContributor.setWorstCaseMethod(LatencyContributorMethod.SPECIFIED);
latencyContributor.setExpectedMaximum(expected.getMaximum());
}
if (expected.getMinimum() > 0) {
latencyContributor.setBestCaseMethod(LatencyContributorMethod.SPECIFIED);
latencyContributor.setExpectedMinimum(expected.getMinimum());
}
if (latencyContributor.getSubContributors().isEmpty()) {
if (expected.getMaximum() > 0) {
latencyContributor.setMaximum(expected.getMaximum());
}
if (expected.getMinimum() > 0) {
latencyContributor.setMinimum(expected.getMinimum());
}
} else {
latencyContributor.reportInfo("Adding latency subtotal from protocols and hardware - shown with ()");
}
// set synchronous if on same processor
if (srcHW != null && dstHW != null) {
// we have two hardware components. One or both could be a device
ComponentInstance srcTime = (ComponentInstance) TimingProperties.getReferenceTime(srcHW).orElse(null);
ComponentInstance dstTime = (ComponentInstance) TimingProperties.getReferenceTime(dstHW).orElse(null);
if (srcHW == dstHW) {
latencyContributor.setSynchronous();
} else if (srcTime != null && dstTime != null) {
if (srcTime == dstTime) {
latencyContributor.setSynchronous();
} else {
latencyContributor.setAsynchronous();
}
} else {
latencyContributor.setSyncUnknown();
}
} else {
// set synchronous if in same partition. This may be the case if the partitions are not bound yet to a processor
if (dstPartition != null && srcPartition != null) {
if (srcPartition == dstPartition) {
latencyContributor.setSynchronous();
} else {
// no else part: partitions are unbound so we want to have both a sync and async analysis
latencyContributor.setSyncUnknown();
}
}
}
entry.addContributor(latencyContributor);
if (dstPartition != null && srcPartition != dstPartition) {
// add partition latency if the destination is a partition and it is different from the source partition (or null)
double partitionLatency = FlowLatencyUtil.getPartitionPeriod(dstPartition);
List<ScheduleWindow> schedule = FlowLatencyUtil.getModuleSchedule(dstPartition);
double partitionDuration = FlowLatencyUtil.getPartitionDuration(dstPartition, schedule);
LatencyContributorComponent platencyContributor = new LatencyContributorComponent(dstPartition, flowElementInstance, report.isMajorFrameDelay());
if (!FlowLatencyUtil.isInSchedule(dstPartition, schedule)) {
platencyContributor.reportWarning("Partition not found in ARINC653 schedule of processor " + FlowLatencyUtil.getModule(dstPartition).getName());
}
if (partitionDuration > 0) {
double frameOffset = FlowLatencyUtil.getPartitionFrameOffset(dstPartition, schedule);
platencyContributor.setPartitionOffset(frameOffset);
if (partitionLatency == 0) {
platencyContributor.setSamplingPeriod(partitionDuration);
platencyContributor.reportInfo("No partition period. Using partition duration");
} else {
platencyContributor.setSamplingPeriod(partitionLatency);
}
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);
}
}
}
Aggregations