use of org.osate.aadl2.instance.FlowElementInstance in project osate2 by osate.
the class CreateEndToEndFlowsSwitch method testConnection.
/**
* @param conni
* @param etei
* @param result
*/
private boolean testConnection(ConnectionInstance conni, EndToEndFlowInstance etei) {
Iterator<ConnectionReference> refIter = conni.getConnectionReferences().iterator();
boolean match = false;
while (refIter.hasNext()) {
String name1 = refIter.next().getConnection().getName();
String name2 = connections.get(0).getName();
if (name1.equalsIgnoreCase(name2)) {
Iterator<Connection> connIter = connections.iterator();
connIter.next();
match = true;
while (match && refIter.hasNext() && connIter.hasNext()) {
match &= refIter.next().getConnection().getName().equalsIgnoreCase(connIter.next().getName());
}
if (!refIter.hasNext() && connIter.hasNext()) {
match = false;
}
}
}
if (match && connections.size() == 1) {
// make sure connection instance goes in the same direction as the flow
ComponentInstance connci = conni.getSource().getComponentInstance();
FlowElementInstance fei = etei;
while (fei instanceof EndToEndFlowInstance) {
fei = ((EndToEndFlowInstance) fei).getFlowElements().get(((EndToEndFlowInstance) fei).getFlowElements().size() - 1);
}
if (fei instanceof FlowSpecificationInstance) {
fei = fei.getComponentInstance();
}
ComponentInstance flowci = (ComponentInstance) fei;
match = false;
ComponentInstance ci = connci;
while (!(ci instanceof SystemInstance)) {
if (ci == flowci) {
match = true;
break;
}
ci = ci.getContainingComponentInstance();
}
}
if (match) {
// test if the connection instance is connected to the end of the ete instance
// relevant if the flow goes through a port of a feature group and the connection
// instance comes from an expanded fg connection
ConnectionInstanceEnd src = conni.getSource();
if (src instanceof FeatureInstance) {
FeatureInstance firstFeature = (FeatureInstance) src;
FeatureInstance lastFeature = getLastFeature(etei);
if (lastFeature != null) {
match = isSameorContains(lastFeature, firstFeature);
}
}
}
return match;
}
use of org.osate.aadl2.instance.FlowElementInstance 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);
}
}
}
use of org.osate.aadl2.instance.FlowElementInstance in project osate2 by osate.
the class CreateEndToEndFlowsSwitch method fillinModes.
protected void fillinModes(EndToEndFlowInstance etei) {
if (etei.getSystemInstance().getSystemOperationModes().size() <= 1) {
return;
}
// first, calculate intersection of all connection and ete instance SOMs
EList<FlowElementInstance> feis = etei.getFlowElements();
List<SystemOperationMode> soms = new ArrayList<SystemOperationMode>(etei.getSystemInstance().getSystemOperationModes());
for (FlowElementInstance fei : feis) {
List<SystemOperationMode> newSoms = new ArrayList<SystemOperationMode>();
if (fei instanceof ConnectionInstance) {
ConnectionInstance conni = (ConnectionInstance) fei;
if (conni.getInSystemOperationModes().isEmpty()) {
continue;
}
for (SystemOperationMode som : soms) {
if (conni.getInSystemOperationModes().contains(som)) {
newSoms.add(som);
}
}
} else if (fei instanceof EndToEndFlowInstance) {
EndToEndFlowInstance efi = (EndToEndFlowInstance) fei;
if (efi.getInSystemOperationModes().isEmpty()) {
continue;
}
for (SystemOperationMode som : soms) {
if (efi.getInSystemOperationModes().contains(som)) {
newSoms.add(som);
}
}
} else {
continue;
}
soms = newSoms;
}
// then, keep those SOMs where all other flow elements are active
for (FlowElementInstance fei : feis) {
List<SystemOperationMode> newSoms = new ArrayList<SystemOperationMode>();
if (fei instanceof FlowSpecificationInstance) {
FlowSpecificationInstance fsi = (FlowSpecificationInstance) fei;
for (SystemOperationMode som : soms) {
if (fsi.isActive(som)) {
newSoms.add(som);
}
}
} else if (fei instanceof ComponentInstance) {
ComponentInstance ci = (ComponentInstance) fei;
for (SystemOperationMode som : soms) {
if (ci.isActive(som)) {
newSoms.add(som);
}
}
} else {
continue;
}
soms = newSoms;
}
// finally, keep those SOMs where the ete and used flow implementations are active
for (SystemOperationMode som : soms) {
if (containsModeInstances(som, etei.getModesList())) {
etei.getInSystemOperationModes().add(som);
}
}
etei.getModesList().clear();
}
Aggregations