Search in sources :

Example 51 with ConnectionInstanceEnd

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

the class ConnectionInstanceImpl method basicSetSource.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetSource(ConnectionInstanceEnd newSource, NotificationChain msgs) {
    ConnectionInstanceEnd oldSource = source;
    source = newSource;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, InstancePackage.CONNECTION_INSTANCE__SOURCE, oldSource, newSource);
        if (msgs == null) {
            msgs = notification;
        } else {
            msgs.add(notification);
        }
    }
    return msgs;
}
Also used : ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 52 with ConnectionInstanceEnd

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

the class ConnectionReferenceImpl method setSource.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setSource(ConnectionInstanceEnd newSource) {
    ConnectionInstanceEnd oldSource = source;
    source = newSource;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, InstancePackage.CONNECTION_REFERENCE__SOURCE, oldSource, source));
    }
}
Also used : ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 53 with ConnectionInstanceEnd

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

the class ConnectionReferenceImpl method setDestination.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setDestination(ConnectionInstanceEnd newDestination) {
    ConnectionInstanceEnd oldDestination = destination;
    destination = newDestination;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, InstancePackage.CONNECTION_REFERENCE__DESTINATION, oldDestination, destination));
    }
}
Also used : ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 54 with ConnectionInstanceEnd

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

the class InstanceModelUtil method doConnectedByBus.

/**
 * returns list of buses connecting to HW components. Can be empty list (if
 * same component), or null (no connection).
 *
 * @param source HW component
 * @param destination HW component
 * @return list of buses involved in the physical connection
 */
protected static List<ComponentInstance> doConnectedByBus(ComponentInstance srcHW, ComponentInstance dstHW, List<ComponentInstance> visitedBuses) {
    if (srcHW == null || dstHW == null || srcHW == dstHW) {
        return visitedBuses;
    }
    for (FeatureInstance fi : srcHW.getFeatureInstances()) {
        if (fi.getCategory() == FeatureCategory.BUS_ACCESS) {
            for (ConnectionInstance aci : fi.getDstConnectionInstances()) {
                ConnectionInstanceEnd src = aci.getSource();
                ComponentInstance curBus = src instanceof ComponentInstance ? (ComponentInstance) src : ((FeatureInstance) src).getComponentInstance();
                if (!visitedBuses.contains(curBus)) {
                    if (connectedToBus(dstHW, curBus)) {
                        List<ComponentInstance> res = new ArrayList<ComponentInstance>();
                        res.add(curBus);
                        return res;
                    } else {
                        // first check if there is a bus this bus is connected to
                        visitedBuses.add(curBus);
                        List<ComponentInstance> res = doConnectedByBus(curBus, dstHW, visitedBuses);
                        if (res != null) {
                            res.add(0, curBus);
                            return res;
                        } else {
                            // check for buses that are connected to this bus
                            for (ConnectionInstance srcaci : curBus.getSrcConnectionInstances()) {
                                ComponentInstance bi = srcaci.getDestination().getContainingComponentInstance();
                                if (bi.getCategory() == ComponentCategory.BUS) {
                                    if (connectedToBus(dstHW, bi)) {
                                        res = new BasicEList<ComponentInstance>();
                                        res.add(bi);
                                        return res;
                                    } else {
                                        visitedBuses.add(bi);
                                        res = doConnectedByBus(bi, dstHW, visitedBuses);
                                        if (res != null) {
                                            res.add(0, curBus);
                                            return res;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return visitedBuses;
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ArrayList(java.util.ArrayList)

Example 55 with ConnectionInstanceEnd

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

the class InstanceModelUtil method getRelatedComponentDestination.

/**
 * Get the component that is connected at the destination side of the connection.
 * @param connectionInstance - the connection to be processed
 * @return - the component that is the connection destination (and not its feature)
 */
public static ComponentInstance getRelatedComponentDestination(ConnectionInstance connectionInstance) {
    ConnectionInstanceEnd destinationEnd;
    ComponentInstance destination = null;
    destinationEnd = connectionInstance.getDestination();
    if (!(destinationEnd instanceof ComponentInstance)) {
        destination = destinationEnd.getContainingComponentInstance();
    } else {
        destination = (ComponentInstance) destinationEnd;
    }
    return destination;
}
Also used : ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Aggregations

ConnectionInstanceEnd (org.osate.aadl2.instance.ConnectionInstanceEnd)45 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)32 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)30 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)21 ConnectionReference (org.osate.aadl2.instance.ConnectionReference)16 ArrayList (java.util.ArrayList)11 Connection (org.osate.aadl2.Connection)8 BasicEList (org.eclipse.emf.common.util.BasicEList)7 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)7 Feature (org.osate.aadl2.Feature)7 InstanceObject (org.osate.aadl2.instance.InstanceObject)7 ConnectionEnd (org.osate.aadl2.ConnectionEnd)6 Subcomponent (org.osate.aadl2.Subcomponent)6 Element (org.osate.aadl2.Element)5 HashMap (java.util.HashMap)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4 SystemInstance (org.osate.aadl2.instance.SystemInstance)4 InstantiatedClassifier (org.osate.aadl2.instance.util.InstanceUtil.InstantiatedClassifier)4 Collections (java.util.Collections)3