use of org.osate.aadl2.instance.ConnectionInstance in project osate2 by osate.
the class ResoluteInterface method initializeSets.
private void initializeSets(ComponentInstance ci, Map<String, SortedSet<NamedElement>> sets) {
if (ci == null) {
return;
}
addToSet(sets, getCategoryName(ci.getCategory()), ci);
addToSet(sets, "component", ci);
for (ComponentInstance sub : ci.getComponentInstances()) {
initializeSets(sub, sets);
}
for (ConnectionInstance conn : ci.getConnectionInstances()) {
addToSet(sets, "connection", conn);
}
}
use of org.osate.aadl2.instance.ConnectionInstance in project osate2 by osate.
the class PortConnectionConsistency method checkPortConsistency.
public void checkPortConsistency(FeatureInstance srcFI, FeatureInstance dstFI, ConnectionInstance conni) {
double srcDataSize = AadlContribUtils.getDataSize(srcFI, SizeUnits.BYTES);
double dstDataSize = AadlContribUtils.getDataSize(dstFI, SizeUnits.BYTES);
RecordValue srcRate = GetProperties.getOutPutRate(srcFI);
RecordValue dstRate = GetProperties.getInPutRate(dstFI);
EnumerationLiteral srcRU = null;
EnumerationLiteral dstRU = null;
double srcMaxRateValue = 0;
double dstMaxRateValue = 0;
double srcMinRateValue = 0;
double dstMinRateValue = 0;
if (srcRate != null && dstRate != null) {
srcRU = GetProperties.getRateUnit(srcRate);
dstRU = GetProperties.getRateUnit(dstRate);
srcMaxRateValue = GetProperties.getMaxDataRate(srcRate);
dstMaxRateValue = GetProperties.getMaxDataRate(dstRate);
srcMinRateValue = GetProperties.getMinDataRate(srcRate);
dstMinRateValue = GetProperties.getMinDataRate(dstRate);
}
// now try it as SEI::Data_Rate
double srcRateValue = GetProperties.getMessageRatePerSecond(srcFI);
double dstRateValue = GetProperties.getMessageRatePerSecond(dstFI);
Classifier srcC = GetProperties.getSingleBaseType(srcFI);
Classifier dstC = GetProperties.getSingleBaseType(dstFI);
String srcS = GetProperties.getMeasurementUnit(srcFI);
String dstS = GetProperties.getMeasurementUnit(dstFI);
if (srcDataSize > 0 && dstDataSize > 0) {
if (srcDataSize != dstDataSize) {
error(conni, "Source data size " + srcDataSize + " Bytes and destination data size " + dstDataSize + " Bytes differ");
}
} else {
if (srcDataSize == 0 && dstDataSize > 0) {
error(conni, "Source data size is missing or zero");
}
if (dstDataSize == 0 && srcDataSize > 0) {
error(conni, "Destination data size is missing or zero");
}
}
if (srcRU != null && dstRU != null && srcRU != dstRU) {
error(conni, "Source rate unit " + srcRU.getName() + " and destination rate unit " + dstRU.getName() + " differ");
}
if (srcMaxRateValue > 0 && dstMaxRateValue > 0) {
if (srcMaxRateValue > dstMaxRateValue) {
error(conni, "Maximum source data rate " + srcMaxRateValue + " is greater than maximum destination data rate " + dstMaxRateValue);
}
if (srcMinRateValue < dstMinRateValue) {
error(conni, "Minimum source data rate " + srcMinRateValue + " is less than minimum destination data rate " + dstMinRateValue);
}
} else {
if (srcRate != null || dstRate != null) {
error(conni, "Missing input rate or output rate");
}
}
if (srcRateValue > 0 && dstRateValue > 0) {
if (srcRateValue != dstRateValue) {
error(conni, "Source data rate " + srcRateValue + " and destination data rate " + dstRateValue + " differ");
}
} else {
if (srcRateValue == 0 && dstRateValue > 0) {
error(conni, "Source data rate is missing or zero");
}
if (dstRateValue == 0 && srcRateValue > 0) {
error(conni, "Destination data rate is missing or zero");
}
}
if (srcC != null && dstC != null) {
if (srcC != dstC) {
error(conni, "Source base type " + srcC.getName() + " and destination base type " + dstC.getName() + " differ");
}
} else {
if (srcC == null && dstC != null) {
error(conni, "Source base type is missing");
}
if (dstC == null && srcC != null) {
error(conni, "Destination base type is missing");
}
}
if (srcS.length() > 0 && dstS.length() > 0) {
if (!srcS.equalsIgnoreCase(dstS)) {
error(conni, "Source measurement unit " + srcS + " and destination measurement unit " + dstS + " differ");
}
} else {
if (srcS.length() == 0 && dstS.length() > 0) {
error(conni, "Source measurement unit is missing");
}
if (dstS.length() == 0 && srcS.length() > 0) {
error(conni, "Destination measurement unit is missing");
}
}
}
use of org.osate.aadl2.instance.ConnectionInstance in project osate2 by osate.
the class CheckBindingConstraints method runAnalysis.
public static List<Issue> runAnalysis(IProgressMonitor monitor, SystemInstance si) {
List<Issue> issuesList = new ArrayList<>();
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
System.out.println(si.getSystemOperationModes().size());
SubMonitor loopMonitor = subMonitor.split(100).setWorkRemaining(si.getSystemOperationModes().size());
for (SOMIterator somIter = new SOMIterator(si); somIter.hasNext(); ) {
SystemOperationMode som = somIter.next();
SubMonitor iterationMonitor = loopMonitor.split(1);
iterationMonitor.setWorkRemaining(8);
// Processor binding
SubMonitor processorChild = iterationMonitor.split(2);
subMonitor.setTaskName("Getting Processor Binding Components");
processorChild.split(1);
List<ComponentInstance> processorBindingComponents = getComponents(monitor, si, ComponentCategory.THREAD, ComponentCategory.VIRTUAL_PROCESSOR, ComponentCategory.DEVICE).collect(Collectors.toList());
processorChild.setTaskName("Checking Processor Bindings");
processorChild.split(1);
issuesList.addAll(checkBindingConstraints(processorBindingComponents.stream(), "processor", GetProperties::getActualProcessorBinding, GetProperties::getAllowedProcessorBinding, GetProperties::getAllowedProcessorBindingClass, som));
// Dispatch Protocol
subMonitor.setTaskName("Checking Dispacth Protocols");
SubMonitor dispatchChild = iterationMonitor.split(1);
issuesList.addAll(checkDispatchProtocol(processorBindingComponents.stream(), som));
// Memory binding
subMonitor.setTaskName("Getting Memory Components");
SubMonitor memrChild = iterationMonitor.split(2);
memrChild.split(1);
Stream<ComponentInstance> memoryBindingComponents = getComponents(monitor, si, ComponentCategory.THREAD, ComponentCategory.DEVICE, ComponentCategory.DATA, ComponentCategory.SUBPROGRAM, ComponentCategory.PROCESSOR, ComponentCategory.VIRTUAL_PROCESSOR);
subMonitor.setTaskName("Checking Memory Bindings");
memrChild.split(1);
Stream<FeatureInstance> memoryBindingFeatures = getFeatures(monitor, si, FeatureCategory.DATA_PORT, FeatureCategory.EVENT_DATA_PORT);
Stream<InstanceObject> memoryBindingElements = Stream.concat(memoryBindingComponents, memoryBindingFeatures);
issuesList.addAll(checkBindingConstraints(memoryBindingElements, "memory", GetProperties::getActualMemoryBinding, GetProperties::getAllowedMemoryBinding, GetProperties::getAllowedMemoryBindingClass, som));
// Connection binding (only handles connection and virtual bus)
subMonitor.setTaskName("Checking Connection Bindings");
SubMonitor conenctionChild = iterationMonitor.split(1);
Stream<ComponentInstance> connectionBindingComponents = getComponents(monitor, si, ComponentCategory.VIRTUAL_BUS);
Stream<ConnectionInstance> connectionBindingConnections = getConnections(monitor, si);
List<InstanceObject> connectionBindingElements = Stream.concat(connectionBindingComponents, connectionBindingConnections).collect(Collectors.toList());
issuesList.addAll(checkBindingConstraints(connectionBindingElements.stream(), "connection", GetProperties::getActualConnectionBinding, GetProperties::getAllowedConnectionBinding, GetProperties::getAllowedConnectionBindingClass, som));
// Connection Quality of Service
subMonitor.setTaskName("Checking Connection Quality of Services");
SubMonitor qualityChild = iterationMonitor.split(1);
issuesList.addAll(checkRequiredAndProvided(connectionBindingElements.stream(), GetProperties::getRequiredConnectionQualityOfService, "Required_Connection_Quality_Of_Service", GetProperties::getProvidedConnectionQualityOfService, qos -> qos.getName(), som));
// Virtual Bus Class
subMonitor.setTaskName("Checking Virtual Bus Bindings");
SubMonitor busChild = iterationMonitor.split(1);
Function<ComponentInstance, Collection<ComponentClassifier>> getProvidedVBClass = boundElement -> {
Stream<ComponentClassifier> providedProperty = GetProperties.getProvidedVirtualBusClass(boundElement).stream();
Stream<ComponentClassifier> providedBySubcomponent = boundElement.getComponentInstances().stream().map(subcomponent -> subcomponent.getClassifier());
return Stream.concat(providedProperty, providedBySubcomponent).collect(Collectors.toSet());
};
issuesList.addAll(checkRequiredAndProvided(connectionBindingElements.stream(), GetProperties::getRequiredVirtualBusClass, "Required_Virtual_Bus_Class", getProvidedVBClass, vbClass -> vbClass.getName(), som));
busChild.setWorkRemaining(0);
}
subMonitor.setWorkRemaining(0);
return issuesList;
}
use of org.osate.aadl2.instance.ConnectionInstance in project osate2 by osate.
the class ARINC429ConnectionConsistency method checkPortConsistency.
public void checkPortConsistency(FeatureInstance srcFI, FeatureInstance dstFI, ConnectionInstance conni) {
Property WordID = GetProperties.lookupPropertyDefinition(conni, "ARINC429", "WordID");
Property StartBit = GetProperties.lookupPropertyDefinition(conni, "ARINC429", "FirstBit");
Property NumberBits = GetProperties.lookupPropertyDefinition(conni, "ARINC429", "NumberBits");
long srcWordID = PropertyUtils.getIntegerValue(srcFI, WordID, 0);
long dstWordID = PropertyUtils.getIntegerValue(dstFI, WordID, 0);
long srcStartBit = PropertyUtils.getIntegerValue(srcFI, StartBit, -1);
long dstStartBit = PropertyUtils.getIntegerValue(dstFI, StartBit, -1);
long srcC = PropertyUtils.getIntegerValue(srcFI, NumberBits, 0);
long dstC = PropertyUtils.getIntegerValue(dstFI, NumberBits, 0);
if (srcWordID > 0 && dstWordID > 0) {
if (srcWordID != dstWordID) {
error(conni, "Source Word ID " + srcWordID + " and Word ID " + dstWordID + " differ");
}
}
if (srcStartBit > -1 && dstStartBit > -1) {
if (srcStartBit != dstStartBit) {
error(conni, "Source Start Bit " + srcStartBit + " and destination Start Bit " + dstStartBit + " differ");
}
}
if (srcC > 0 && dstC > 0) {
if (srcC != dstC) {
error(conni, "Source number bits " + srcC + " and destination number bits " + dstC + " differ");
}
}
}
use of org.osate.aadl2.instance.ConnectionInstance in project osate2 by osate.
the class ComponentCounter method countComponents.
public static ElementsCounts countComponents(SystemInstance si) {
HashMap<ComponentCategory, Integer> categoryCounter = new HashMap<ComponentCategory, Integer>();
int connectionCount = 0;
int eteCount = 0;
// places the top system in the HashMap because .eAllContents() returns all children
categoryCounter.put(si.getCategory(), 1);
for (Iterator<EObject> componentsTree = si.eAllContents(); componentsTree.hasNext(); ) {
EObject curObject = componentsTree.next();
if (curObject instanceof ComponentInstance) {
ComponentCategory curCategory = ((ComponentInstance) curObject).getCategory();
categoryCounter.put(curCategory, categoryCounter.getOrDefault(curCategory, 0) + 1);
} else if (curObject instanceof EndToEndFlowInstance) {
eteCount++;
} else if (curObject instanceof ConnectionInstance) {
connectionCount++;
}
}
return new ElementsCounts(categoryCounter, connectionCount, eteCount);
}
Aggregations