Search in sources :

Example 71 with ConnectionInstance

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);
    }
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 72 with ConnectionInstance

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");
        }
    }
}
Also used : RecordValue(org.osate.aadl2.RecordValue) Classifier(org.osate.aadl2.Classifier) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 73 with ConnectionInstance

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;
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) Arrays(java.util.Arrays) Element(org.osate.aadl2.Element) Spliterators(java.util.Spliterators) SubMonitor(org.eclipse.core.runtime.SubMonitor) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) DeploymentProperties(org.osate.aadl2.contrib.deployment.DeploymentProperties) StreamSupport(java.util.stream.StreamSupport) GetProperties(org.osate.xtext.aadl2.properties.util.GetProperties) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) EnumSet(java.util.EnumSet) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) FeatureCategory(org.osate.aadl2.instance.FeatureCategory) SystemInstance(org.osate.aadl2.instance.SystemInstance) SOMIterator(org.osate.aadl2.modelsupport.modeltraversal.SOMIterator) AadlUtil(org.osate.aadl2.modelsupport.util.AadlUtil) Iterator(java.util.Iterator) Aadl2Util(org.osate.aadl2.util.Aadl2Util) Collection(java.util.Collection) Set(java.util.Set) EObject(org.eclipse.emf.ecore.EObject) Collectors(java.util.stream.Collectors) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Consumer(java.util.function.Consumer) List(java.util.List) Stream(java.util.stream.Stream) ComponentCategory(org.osate.aadl2.ComponentCategory) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) Optional(java.util.Optional) AaxlReadOnlyHandlerAsJob(org.osate.ui.handlers.AaxlReadOnlyHandlerAsJob) StringExtensions(org.eclipse.xtext.xbase.lib.StringExtensions) NamedElement(org.osate.aadl2.NamedElement) Collections(java.util.Collections) Spliterator(java.util.Spliterator) Dialog(org.osate.ui.dialogs.Dialog) InstanceObject(org.osate.aadl2.instance.InstanceObject) SOMIterator(org.osate.aadl2.modelsupport.modeltraversal.SOMIterator) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ArrayList(java.util.ArrayList) SubMonitor(org.eclipse.core.runtime.SubMonitor) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) InstanceObject(org.osate.aadl2.instance.InstanceObject) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) Collection(java.util.Collection) Stream(java.util.stream.Stream)

Example 74 with ConnectionInstance

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");
        }
    }
}
Also used : Property(org.osate.aadl2.Property)

Example 75 with ConnectionInstance

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);
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) HashMap(java.util.HashMap) EObject(org.eclipse.emf.ecore.EObject) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) EndToEndFlowInstance(org.osate.aadl2.instance.EndToEndFlowInstance) ComponentCategory(org.osate.aadl2.ComponentCategory)

Aggregations

ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)71 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)64 ConnectionReference (org.osate.aadl2.instance.ConnectionReference)32 ConnectionInstanceEnd (org.osate.aadl2.instance.ConnectionInstanceEnd)28 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)25 Classifier (org.osate.aadl2.Classifier)22 InstanceObject (org.osate.aadl2.instance.InstanceObject)21 Connection (org.osate.aadl2.Connection)16 ArrayList (java.util.ArrayList)15 Element (org.osate.aadl2.Element)15 NamedElement (org.osate.aadl2.NamedElement)13 PropertyExpression (org.osate.aadl2.PropertyExpression)13 SystemInstance (org.osate.aadl2.instance.SystemInstance)13 SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)13 ComponentClassifier (org.osate.aadl2.ComponentClassifier)12 ComponentImplementation (org.osate.aadl2.ComponentImplementation)10 ListValue (org.osate.aadl2.ListValue)10 BasicEList (org.eclipse.emf.common.util.BasicEList)9 Feature (org.osate.aadl2.Feature)9 EndToEndFlowInstance (org.osate.aadl2.instance.EndToEndFlowInstance)9