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;
}
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();
}
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;
}
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;
}
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());
}
Aggregations