Search in sources :

Example 26 with ConnectionInstanceEnd

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

the class ConnectionInfo method resolveFeatureInstance.

protected ConnectionInstanceEnd resolveFeatureInstance(ConnectionInstanceEnd origCIE, ConnectionInstanceEnd rootCIE) {
    if (origCIE instanceof ComponentInstance || rootCIE instanceof ComponentInstance) {
        return rootCIE;
    }
    FeatureInstance rootFI = (FeatureInstance) rootCIE;
    if (rootFI.getFeatureInstances().isEmpty()) {
        return rootCIE;
    }
    ConnectionInstanceEnd parentFI = rootFI;
    FeatureInstance origFI = (FeatureInstance) origCIE;
    Element origParent = origFI.getOwner();
    if (origParent instanceof FeatureInstance) {
        FeatureInstance origParentFI = (FeatureInstance) origParent;
        if (origParentFI.getOwner() instanceof FeatureInstance) {
            ConnectionInstanceEnd resFI = resolveFeatureInstance(origParentFI, rootFI);
            if (resFI != null) {
                parentFI = resFI;
            }
        }
        EList<FeatureInstance> filist = ((FeatureInstance) parentFI).getFeatureInstances();
        for (FeatureInstance featureInstance : filist) {
            if (Aadl2InstanceUtil.isSame(origFI, featureInstance)) {
                return featureInstance;
            }
        }
    }
    return rootFI;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) Element(org.osate.aadl2.Element) ConnectedElement(org.osate.aadl2.ConnectedElement) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 27 with ConnectionInstanceEnd

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

the class CreateConnectionsSwitch method findDestinationFeatureInstance.

/**
 * Find the feature instance under FGI, whose name matches the the Feature at the other end
 * We do this by finding the connection declaration that goes down at the other end
 * It is found by matching the FGT name and then retrieving the feature instance matching the name
 * @param connInfo
 * @param fgi
 * @return FeatureInstance
 */
FeatureInstance findDestinationFeatureInstance(ConnectionInfo connInfo, FeatureInstance fgi) {
    List<ConnectionInstanceEnd> srclist = connInfo.sources;
    List<ConnectionInstanceEnd> dstlist = connInfo.destinations;
    ConnectionInstanceEnd target = null;
    for (int i = 0; i < srclist.size(); i++) {
        ConnectionInstanceEnd src = srclist.get(i);
        ConnectionInstanceEnd dst = dstlist.get(i);
        if (target != null && target != src) {
            if (src == target.eContainer()) {
                // we have a feature in a FG
                FeatureInstance targetFI = findFeatureInstance(fgi, target.getName());
                if (targetFI == null) {
                    // name does not match. We may have an inverse of feature group type with its own set of feature names
                    // In this case it is an index based match
                    int idx = dst.eContents().indexOf(target);
                    if (idx >= 0) {
                        targetFI = fgi.getFeatureInstances().get(idx);
                    }
                }
                return targetFI;
            } else {
                target = dst;
            }
        } else {
            target = dst;
        }
    }
    return null;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd)

Example 28 with ConnectionInstanceEnd

use of org.osate.aadl2.instance.ConnectionInstanceEnd in project osate-plugin by sireum.

the class Visitor method buildEndPoint.

private org.sireum.hamr.ir.EndPoint buildEndPoint(ConnectionInstanceEnd cie) {
    final List<String> component = Arrays.asList(cie.getComponentInstance().getInstanceObjectPath().split("\\."));
    final Position componentPos = VisitorUtil.buildPosInfo(cie.getComponentInstance().getInstantiatedObjects().get(0));
    if (cie instanceof FeatureInstance) {
        final List<String> feature = Arrays.asList(cie.getInstanceObjectPath().split("\\."));
        final Position featurePos = VisitorUtil.buildPosInfo(cie.getInstantiatedObjects().get(0));
        final AadlASTJavaFactory.Direction direction = handleDirection(((FeatureInstance) cie).getDirection());
        return factory.endPoint(factory.name(component, componentPos), factory.name(feature, featurePos), direction);
    } else if (cie instanceof ComponentInstance) {
        return factory.endPoint(factory.name(component, componentPos), null, null);
    } else if (cie instanceof ModeTransitionInstance) {
        throw new RuntimeException("Need to handle ModeTransitionInstanceImpl: " + cie);
    } else {
        throw new RuntimeException("Unexpected: " + cie);
    }
}
Also used : Position(org.sireum.message.Position) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) AadlASTJavaFactory(org.sireum.hamr.ir.AadlASTJavaFactory) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ModeTransitionInstance(org.osate.aadl2.instance.ModeTransitionInstance)

Example 29 with ConnectionInstanceEnd

use of org.osate.aadl2.instance.ConnectionInstanceEnd in project osate-plugin by sireum.

the class Visitor method buildEndPoint.

private List<org.sireum.hamr.ir.EndPoint> buildEndPoint(ConnectionInstanceEnd connInstEnd, List<String> path) {
    List<org.sireum.hamr.ir.EndPoint> result = VisitorUtil.iList();
    final List<String> component = Arrays.asList(connInstEnd.getComponentInstance().getInstanceObjectPath().split("\\."));
    final Position componentPos = VisitorUtil.buildPosInfo(connInstEnd.getComponentInstance().getInstantiatedObjects().get(0));
    if (connInstEnd instanceof FeatureInstance) {
        FeatureInstance connElem = (FeatureInstance) connInstEnd;
        String featurePre = connElem.getFeature().getName();
        FeatureInstance temp = connElem;
        while (temp.eContainer() instanceof FeatureInstance) {
            featurePre = ((FeatureInstance) temp.eContainer()).getName() + "_" + featurePre;
            temp = (FeatureInstance) temp.eContainer();
        }
        if (connElem.getCategory() == FeatureCategory.FEATURE_GROUP && !connElem.getFeatureInstances().isEmpty()) {
            // Feature ff = connElem.getFeature().getRefined();
            final String fp = featurePre;
            result = VisitorUtil.addAll(result, connElem.getFeatureInstances().stream().flatMap(fii -> flattenFeatureGroupInstance(fii, fp, component, componentPos, false).stream()).collect(Collectors.toList()));
        } else if (connElem.getCategory() == FeatureCategory.BUS_ACCESS) {
            final List<String> feature = VisitorUtil.add(component, featurePre);
            final Position featurePos = VisitorUtil.buildPosInfo(connElem.getInstantiatedObjects().get(0));
            final AadlASTJavaFactory.Direction direction = AadlASTJavaFactory.Direction.InOut;
            result = VisitorUtil.add(result, factory.endPoint(factory.name(component, componentPos), factory.name(feature, featurePos), direction));
        } else {
            final List<String> feature = VisitorUtil.add(component, featurePre);
            final Position featurePos = VisitorUtil.buildPosInfo(connElem.getInstantiatedObjects().get(0));
            final AadlASTJavaFactory.Direction direction = handleDirection(connElem.getDirection());
            result = VisitorUtil.add(result, factory.endPoint(factory.name(component, componentPos), factory.name(feature, featurePos), direction));
        }
    // org.sireum.hamr.ir.Feature f = buildFeature(connElem, component);
    // if(connElem.getCategory() == FeatureCategory.FEATURE_GROUP) {
    // connElem.getFeatureInstances().forEach(fi -> {
    // 
    // });
    // }
    // final List<String> component = (connElem.getgetContext() != null) && (connElem
    // .getContext() instanceof Subcomponent)
    // ? VisitorUtil.add(path, connElem.getContext().getName())
    // : path;
    } else if (connInstEnd instanceof ComponentInstance) {
        result = VisitorUtil.toIList(factory.endPoint(factory.name(component, componentPos), null, null));
    } else if (connInstEnd instanceof ModeTransitionInstance) {
        throw new RuntimeException("Need to handle ModeTransitionInstanceImpl: " + connInstEnd);
    } else {
        throw new RuntimeException("Unexpected: " + connInstEnd);
    }
    if (result.size() > 1) {
    // System.out.println("");
    }
    return result;
}
Also used : Arrays(java.util.Arrays) DataImplementation(org.osate.aadl2.DataImplementation) ListValue(org.osate.aadl2.ListValue) Element(org.osate.aadl2.Element) NamedValue(org.osate.aadl2.NamedValue) RangeValue(org.osate.aadl2.RangeValue) PropertyUtils(org.osate.xtext.aadl2.properties.util.PropertyUtils) PropertyExpression(org.osate.aadl2.PropertyExpression) AnnexLib(org.sireum.hamr.ir.AnnexLib) Classifier(org.osate.aadl2.Classifier) RecordValue(org.osate.aadl2.RecordValue) FeatureConnection(org.osate.aadl2.FeatureConnection) AccessImpl(org.osate.aadl2.impl.AccessImpl) Map(java.util.Map) ParameterConnection(org.osate.aadl2.ParameterConnection) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) Bundle(org.osgi.framework.Bundle) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) Annex(org.sireum.hamr.ir.Annex) AccessConnection(org.osate.aadl2.AccessConnection) ConnectionEnd(org.osate.aadl2.ConnectionEnd) DirectedFeatureImpl(org.osate.aadl2.impl.DirectedFeatureImpl) FeatureCategory(org.osate.aadl2.instance.FeatureCategory) InstancePackage(org.osate.aadl2.instance.InstancePackage) FeatureGroupConnection(org.osate.aadl2.FeatureGroupConnection) BusAccessImpl(org.osate.aadl2.impl.BusAccessImpl) Set(java.util.Set) EObject(org.eclipse.emf.ecore.EObject) Connection(org.osate.aadl2.Connection) AadlASTJavaFactory(org.sireum.hamr.ir.AadlASTJavaFactory) Collectors(java.util.stream.Collectors) UnitLiteral(org.osate.aadl2.UnitLiteral) List(java.util.List) Property(org.osate.aadl2.Property) AccessType(org.osate.aadl2.AccessType) ReferenceValue(org.osate.aadl2.ReferenceValue) BusSubcomponentImpl(org.osate.aadl2.impl.BusSubcomponentImpl) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) StringLiteral(org.osate.aadl2.StringLiteral) Option(org.sireum.Option) Feature(org.osate.aadl2.Feature) HashMap(java.util.HashMap) Constructor(java.lang.reflect.Constructor) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) DataSubcomponent(org.osate.aadl2.DataSubcomponent) PropertyAssociation(org.osate.aadl2.PropertyAssociation) PreferenceValues(org.sireum.aadl.osate.PreferenceValues) DirectionType(org.osate.aadl2.DirectionType) Subcomponent(org.osate.aadl2.Subcomponent) Position(org.sireum.message.Position) FeatureGroup(org.osate.aadl2.FeatureGroup) NumberValue(org.osate.aadl2.NumberValue) FeatureGroupImpl(org.osate.aadl2.impl.FeatureGroupImpl) ClassifierValue(org.osate.aadl2.ClassifierValue) AadlUtil(org.osate.aadl2.modelsupport.util.AadlUtil) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) Some(org.sireum.Some) PropertyConstant(org.osate.aadl2.PropertyConstant) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ModeTransitionInstance(org.osate.aadl2.instance.ModeTransitionInstance) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) FeatureGroupType(org.osate.aadl2.FeatureGroupType) PortConnection(org.osate.aadl2.PortConnection) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) DataTypeImpl(org.osate.aadl2.impl.DataTypeImpl) DataClassifier(org.osate.aadl2.DataClassifier) BooleanLiteral(org.osate.aadl2.BooleanLiteral) Platform(org.eclipse.core.runtime.Platform) NamedElement(org.osate.aadl2.NamedElement) FlowSpecificationInstance(org.osate.aadl2.instance.FlowSpecificationInstance) ConnectedElement(org.osate.aadl2.ConnectedElement) Position(org.sireum.message.Position) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ModeTransitionInstance(org.osate.aadl2.instance.ModeTransitionInstance) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) List(java.util.List) ArrayList(java.util.ArrayList)

Example 30 with ConnectionInstanceEnd

use of org.osate.aadl2.instance.ConnectionInstanceEnd in project AMASE by loonwerks.

the class AsymFaultASTBuilder method processFaults.

/**
 * Process all faults in the list of fault statements and return a list of
 * those faults. It is assumed that all faults in faultGroup are part of multiple
 * faults on a single output.
 *
 * @param faultGroup List of asymmetric FaultStatements.
 * @return List of processed faults.
 */
public List<Fault> processFaults(List<FaultStatement> faultGroup) {
    if (faultGroup.isEmpty()) {
        new SafetyException("Problem with multiple faults on the same output.");
    }
    List<Fault> faultList = new ArrayList<Fault>();
    List<ConnectionInstanceEnd> senderConnections = new ArrayList<>();
    DataPortImpl senderOutput = null;
    // 1. Create fault nodes using parent method
    for (FaultStatement fs : faultGroup) {
        faultList.add(super.createSenderFault(fs));
    }
    // 2. Gather connections and add to parent map - can use any fstmt to do this.
    senderOutput = super.findSenderOutput(faultGroup.get(0));
    senderConnections = super.populateMapSenderToReceiver(senderOutput);
    // 3. Create communication nodes
    createCommNodes(senderConnections, senderOutput, faultList);
    setPathForFaults(faultList, agreeNode);
    return faultList;
}
Also used : ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) DataPortImpl(org.osate.aadl2.impl.DataPortImpl) ArrayList(java.util.ArrayList) FaultStatement(edu.umn.cs.crisys.safety.safety.FaultStatement) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException)

Aggregations

ConnectionInstanceEnd (org.osate.aadl2.instance.ConnectionInstanceEnd)47 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)35 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)33 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)23 ConnectionReference (org.osate.aadl2.instance.ConnectionReference)18 ArrayList (java.util.ArrayList)13 Connection (org.osate.aadl2.Connection)10 Feature (org.osate.aadl2.Feature)9 Subcomponent (org.osate.aadl2.Subcomponent)9 ConnectionEnd (org.osate.aadl2.ConnectionEnd)8 BasicEList (org.eclipse.emf.common.util.BasicEList)7 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)7 Element (org.osate.aadl2.Element)7 InstanceObject (org.osate.aadl2.instance.InstanceObject)7 HashMap (java.util.HashMap)6 List (java.util.List)6 FeatureGroup (org.osate.aadl2.FeatureGroup)6 FeatureGroupConnection (org.osate.aadl2.FeatureGroupConnection)6 ModeTransitionInstance (org.osate.aadl2.instance.ModeTransitionInstance)6 Map (java.util.Map)5