Search in sources :

Example 16 with ConnectionReference

use of org.osate.aadl2.instance.ConnectionReference 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;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) Connection(org.osate.aadl2.Connection) FlowSpecificationInstance(org.osate.aadl2.instance.FlowSpecificationInstance) SystemInstance(org.osate.aadl2.instance.SystemInstance) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) EndToEndFlowInstance(org.osate.aadl2.instance.EndToEndFlowInstance) FlowElementInstance(org.osate.aadl2.instance.FlowElementInstance)

Example 17 with ConnectionReference

use of org.osate.aadl2.instance.ConnectionReference in project osate2 by osate.

the class CheckInstanceSemanticsSwitch method getConnectionPath.

private static String getConnectionPath(ConnectionInstance conni, int idx) {
    StringBuffer sb = new StringBuffer();
    ConnectionReference connRef = conni.getConnectionReferences().get(idx);
    generateComponentPath(sb, connRef.getContext());
    sb.append(connRef.getName());
    return sb.toString();
}
Also used : ConnectionReference(org.osate.aadl2.instance.ConnectionReference)

Example 18 with ConnectionReference

use of org.osate.aadl2.instance.ConnectionReference in project osate2 by osate.

the class Aadl2InstanceUtil method getIncomingConnectionReferences.

/**
 * get incoming connection instances from the component instance or any contained component instance
 * @param ci component instance
 * @return list of connection instances
 */
public static EList<ConnectionReference> getIncomingConnectionReferences(ComponentInstance ci) {
    EList<ConnectionReference> result = new BasicEList<ConnectionReference>();
    // allEnclosingConnectionInstances();
    Iterable<ConnectionInstance> it = ci.getSystemInstance().getAllConnectionInstances();
    for (ConnectionInstance connectionInstance : it) {
        ConnectionInstanceEnd src = connectionInstance.getSource();
        ConnectionInstanceEnd dst = connectionInstance.getDestination();
        if ((!containedIn(src, ci) || src.getContainingComponentInstance() == ci) && containedIn(dst, ci)) {
            EList<ConnectionReference> connreflist = connectionInstance.getConnectionReferences();
            for (ConnectionReference connectionReference : connreflist) {
                ComponentInstance pci = connectionReference.getContext();
                if (pci == ci) {
                    result.add(connectionReference);
                }
            }
        }
    }
    return result;
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) BasicEList(org.eclipse.emf.common.util.BasicEList) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 19 with ConnectionReference

use of org.osate.aadl2.instance.ConnectionReference in project osate2 by osate.

the class Aadl2InstanceUtil method getOutgoingConnectionReferences.

/**
 * get outgoing connection instances from the component instance or any contained component instance
 * @param ci component instance
 * @return list of connection references
 */
public static EList<ConnectionReference> getOutgoingConnectionReferences(ComponentInstance ci) {
    EList<ConnectionReference> result = new BasicEList<ConnectionReference>();
    // allEnclosingConnectionInstances();
    Iterable<ConnectionInstance> it = ci.getSystemInstance().getAllConnectionInstances();
    for (ConnectionInstance connectionInstance : it) {
        ConnectionInstanceEnd src = connectionInstance.getSource();
        ConnectionInstanceEnd dst = connectionInstance.getDestination();
        if (containedIn(src, ci) && !containedIn(dst, ci)) {
            EList<ConnectionReference> connreflist = connectionInstance.getConnectionReferences();
            for (ConnectionReference connectionReference : connreflist) {
                ComponentInstance pci = connectionReference.getContext();
                if (pci == ci.getContainingComponentInstance()) {
                    result.add(connectionReference);
                }
            }
        }
    }
    return result;
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) BasicEList(org.eclipse.emf.common.util.BasicEList) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 20 with ConnectionReference

use of org.osate.aadl2.instance.ConnectionReference in project osate2 by osate.

the class Aadl2InstanceUtil method outOnly.

public static boolean outOnly(ConnectionInstance conni) {
    EList<ConnectionReference> connrefs = conni.getConnectionReferences();
    ConnectionReference last = connrefs.get(connrefs.size() - 1);
    return (last.getDestination().getComponentInstance() == last.getContext());
}
Also used : ConnectionReference(org.osate.aadl2.instance.ConnectionReference)

Aggregations

ConnectionReference (org.osate.aadl2.instance.ConnectionReference)35 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)20 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)14 Connection (org.osate.aadl2.Connection)12 ConnectionInstanceEnd (org.osate.aadl2.instance.ConnectionInstanceEnd)11 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)7 InstanceObject (org.osate.aadl2.instance.InstanceObject)7 Element (org.osate.aadl2.Element)6 ArrayList (java.util.ArrayList)5 ConnectionEnd (org.osate.aadl2.ConnectionEnd)5 SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)5 BasicEList (org.eclipse.emf.common.util.BasicEList)4 FeatureGroupConnection (org.osate.aadl2.FeatureGroupConnection)4 LinkedList (java.util.LinkedList)3 AccessConnection (org.osate.aadl2.AccessConnection)3 Context (org.osate.aadl2.Context)3 Feature (org.osate.aadl2.Feature)3 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)3 Mode (org.osate.aadl2.Mode)3 NamedElement (org.osate.aadl2.NamedElement)3