Search in sources :

Example 1 with ConnectionReference

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

the class ValidateConnectionsSwitch method endsWithReverse.

private boolean endsWithReverse(ConnectionInstance test, ConnectionInstance conni) {
    List<ConnectionReference> testRefs = test.getConnectionReferences();
    List<ConnectionReference> connRefs = conni.getConnectionReferences();
    if (connRefs.size() >= testRefs.size()) {
        return false;
    }
    ListIterator<ConnectionReference> testing = test.getConnectionReferences().listIterator(test.getConnectionReferences().size());
    Iterator<ConnectionReference> prefix = connRefs.iterator();
    while (prefix.hasNext()) {
        ConnectionReference t = testing.previous();
        ConnectionReference p = prefix.next();
        if (t.getConnection() != p.getConnection()) {
            return false;
        }
        if (!prefix.hasNext()) {
            return t.getSource() == p.getDestination();
        }
    }
    return false;
}
Also used : ConnectionReference(org.osate.aadl2.instance.ConnectionReference)

Example 2 with ConnectionReference

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

the class ValidateConnectionsSwitch method startsWith.

private boolean startsWith(ConnectionInstance test, ConnectionInstance conni) {
    List<ConnectionReference> testRefs = test.getConnectionReferences();
    List<ConnectionReference> connRefs = conni.getConnectionReferences();
    if (connRefs.size() >= testRefs.size()) {
        return false;
    }
    Iterator<ConnectionReference> testing = testRefs.iterator();
    Iterator<ConnectionReference> prefix = connRefs.iterator();
    while (prefix.hasNext()) {
        ConnectionReference t = testing.next();
        ConnectionReference p = prefix.next();
        if (t.getConnection() != p.getConnection()) {
            return false;
        }
        if (!prefix.hasNext()) {
            return t.getDestination() == p.getDestination();
        }
    }
    return false;
}
Also used : ConnectionReference(org.osate.aadl2.instance.ConnectionReference)

Example 3 with ConnectionReference

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

the class ValidateConnectionsSwitch method startsWithReverse.

private boolean startsWithReverse(ConnectionInstance test, ConnectionInstance conni) {
    List<ConnectionReference> testRefs = test.getConnectionReferences();
    List<ConnectionReference> connRefs = conni.getConnectionReferences();
    if (connRefs.size() >= testRefs.size()) {
        return false;
    }
    Iterator<ConnectionReference> testing = testRefs.iterator();
    ListIterator<ConnectionReference> prefix = connRefs.listIterator(connRefs.size());
    while (prefix.hasPrevious()) {
        ConnectionReference t = testing.next();
        ConnectionReference p = prefix.previous();
        if (t.getConnection() != p.getConnection()) {
            return false;
        }
        if (!prefix.hasPrevious()) {
            return t.getDestination() == p.getSource();
        }
    }
    return false;
}
Also used : ConnectionReference(org.osate.aadl2.instance.ConnectionReference)

Example 4 with ConnectionReference

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

the class CreateConnectionsSwitch method addConnectionInstance.

protected ConnectionInstance addConnectionInstance(final SystemInstance systemInstance, final ConnectionInfo connInfo, final ConnectionInstanceEnd dstI) {
    // with aggregate data ports will be sources/destinations missing
    int numConns = connInfo.connections.size();
    if (connInfo.sources.size() != numConns || connInfo.destinations.size() != numConns) {
        // happens if conn leaves system to aggregate data port
        warning(connInfo.container, "Connection from " + connInfo.sources.get(0).getInstanceObjectPath() + " to " + dstI.getInstanceObjectPath() + " could not be instantiated.");
        return null;
    }
    // check for duplicate connection instance
    // with arrays we can get duplicates that we don't need
    ComponentInstance container = connInfo.container;
    List<Connection> conns = connInfo.connections;
    if (container == null) {
        container = systemInstance;
    }
    for (ConnectionInstance test : container.getConnectionInstances()) {
        // check for duplicates and do not create
        if (connInfo.src == test.getSource() && dstI == test.getDestination() && conns.size() == test.getConnectionReferences().size()) {
            ListIterator<Connection> i = conns.listIterator();
            boolean isDuplicate = true;
            for (ConnectionReference ref : test.getConnectionReferences()) {
                if (ref.getConnection() != i.next()) {
                    isDuplicate = false;
                    break;
                }
            }
            if (!isDuplicate) {
                // also test reverse direction
                isDuplicate = true;
                i = conns.listIterator(conns.size());
                for (ConnectionReference ref : test.getConnectionReferences()) {
                    if (ref.getConnection() != i.previous()) {
                        isDuplicate = false;
                        break;
                    }
                }
            }
            if (isDuplicate) {
                return null;
            }
        }
    }
    boolean duplicate = false;
    // Generate a name for the connection
    String containerPath = (connInfo.container != null) ? container.getInstanceObjectPath() : systemInstance.getName();
    int len = containerPath.length() + 1;
    String srcPath = connInfo.src.getInstanceObjectPath();
    StringBuffer sb = new StringBuffer();
    String dstPath = "xxx";
    int i = (srcPath.startsWith(containerPath)) ? len : 0;
    srcPath = srcPath.substring(i);
    sb.append(srcPath);
    sb.append(" -> ");
    if (dstI != null) {
        dstPath = dstI.getInstanceObjectPath();
        i = (dstPath.startsWith(containerPath)) ? len : 0;
        dstPath = dstPath.substring(i);
        sb.append(dstPath);
    }
    ConnectionInstance conni = null;
    if (!duplicate) {
        conni = connInfo.createConnectionInstance(sb.toString(), dstI);
        if (conni == null) {
            warning(container, "Connection sequence from " + srcPath + " to " + dstPath + " is only outgoing. No connection instance created.");
            return null;
        } else {
            container.getConnectionInstances().add(conni);
        }
        fillInModes(conni);
        fillInModeTransitions(conni);
    }
    return conni;
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ParameterConnection(org.osate.aadl2.ParameterConnection) AccessConnection(org.osate.aadl2.AccessConnection) FeatureGroupConnection(org.osate.aadl2.FeatureGroupConnection) Connection(org.osate.aadl2.Connection) PortConnection(org.osate.aadl2.PortConnection)

Example 5 with ConnectionReference

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

the class CreateEndToEndFlowsSwitch method isValidContinuation.

boolean isValidContinuation(EndToEndFlowInstance etei, ConnectionInstance conni, FlowSpecification fspec) {
    /*
		 * Issue 2009: Check if the connection instance connects to the flow spec. Here we have a weird
		 * situation. If the subcomponent the flow spec is qualified by is only described by a component type, then
		 * connection end is going to match up with the beginning of the flow. That's fine. If the component
		 * has a classifier implementation AND the flow spec has a flow implementation, then everything will also
		 * fine: either the connection instance is correct and reaches the start of the flow implementation, or it
		 * is incorrect and doesn't. But we can also have the case that the subcomponent is described by a
		 * component implementation but the flow spec does not have a flow implementation. In this case we
		 * still may have the case the connection instance continues into the subcomponent and terminates at a
		 * subsubcomponent. But the flow spec that we have here will be at the edge of the original subcomponent.
		 * so the end connection instance will not match up with the start of the flow spec.
		 *
		 * So what we really need to do is walk backwards along the connections that make up the connection instance
		 * until we find one that connects to the flow because as wee the connection instance may "punch through" the
		 * subcomponent.
		 */
    final FlowEnd inEnd = fspec.getAllInEnd();
    final Context flowCxt = inEnd.getContext();
    final Feature flowIn = inEnd.getFeature();
    final List<Feature> flowInRefined = flowIn.getAllFeatureRefinements();
    final EList<ConnectionReference> connRefs = conni.getConnectionReferences();
    int idx = connRefs.size() - 1;
    boolean result = false;
    while (!result && idx >= 0) {
        final Connection conn = connRefs.get(idx).getConnection();
        result = isValidContinuationConnectionEnd(flowCxt, flowIn, flowInRefined, conn.getDestination());
        if (!result && conn.isBidirectional()) {
            result = isValidContinuationConnectionEnd(flowCxt, flowIn, flowInRefined, conn.getSource());
        }
        idx -= 1;
    }
    return result;
}
Also used : Context(org.osate.aadl2.Context) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) Connection(org.osate.aadl2.Connection) Feature(org.osate.aadl2.Feature) FlowEnd(org.osate.aadl2.FlowEnd)

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