Search in sources :

Example 6 with AgreeContract

use of com.rockwellcollins.atc.agree.agree.AgreeContract in project AGREE by loonwerks.

the class AgreeScopeProvider method getNamedElementsFromClassifier.

private Map<String, NamedElement> getNamedElementsFromClassifier(Classifier ctx, boolean fromCompImpl) {
    Map<String, NamedElement> components = new HashMap<>();
    components.putAll(getNamedElements(getAadlContainer(ctx)));
    for (AnnexSubclause annex : AnnexUtil.getAllAnnexSubclauses(ctx, AgreePackage.eINSTANCE.getAgreeContractSubclause())) {
        AgreeContract contract = (AgreeContract) ((AgreeContractSubclause) annex).getContract();
        components.putAll(getNamedElementsFromSpecs(contract.getSpecs()));
    }
    Classifier extended = ctx.getExtended();
    if (extended != null) {
        components.putAll(getNamedElementsFromClassifier(extended, false));
    }
    if (ctx instanceof ComponentImplementation) {
        components.putAll(getNamedElementsFromClassifier(((ComponentImplementation) ctx).getType(), true));
        ArrayList<NamedElement> nes = new ArrayList<>();
        nes.addAll(((ComponentImplementation) ctx).getAllSubcomponents());
        nes.addAll(((ComponentImplementation) ctx).getAllConnections());
        components.putAll(toNamedElementMap(nes));
    } else if (ctx instanceof ComponentType) {
        if (fromCompImpl) {
            ArrayList<NamedElement> nes = new ArrayList<>();
            nes.addAll(((ComponentType) ctx).getAllFeatures());
            components.putAll(toNamedElementMap(nes));
        } else {
            ArrayList<NamedElement> nes = new ArrayList<>();
            nes.addAll(((ComponentType) ctx).getOwnedFeatures());
            components.putAll(toNamedElementMap(nes));
        }
    }
    return components;
}
Also used : AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentType(org.osate.aadl2.ComponentType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) NamedElement(org.osate.aadl2.NamedElement) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Example 7 with AgreeContract

use of com.rockwellcollins.atc.agree.agree.AgreeContract in project AMASE by loonwerks.

the class SafetyAnnexContentAssist method getNestedDotIDCandidates.

private List<String> getNestedDotIDCandidates(AadlPackage aadlPackage) {
    AgreeContract contract = null;
    List<String> results = new ArrayList<>();
    for (AnnexLibrary annex : AnnexUtil.getAllActualAnnexLibraries(aadlPackage, AgreePackage.eINSTANCE.getAgreeContractLibrary())) {
        if (annex instanceof AgreeLibrary) {
            contract = (AgreeContract) ((AgreeContractLibrary) annex).getContract();
        }
    }
    if (contract != null) {
        for (SpecStatement spec : contract.getSpecs()) {
            if (spec instanceof ConstStatement) {
                results.add(((ConstStatement) spec).getName());
            }
        }
    }
    return results;
}
Also used : AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) ConstStatement(com.rockwellcollins.atc.agree.agree.ConstStatement) AgreeLibrary(com.rockwellcollins.atc.agree.agree.AgreeLibrary) AgreeContractLibrary(com.rockwellcollins.atc.agree.agree.AgreeContractLibrary) ArrayList(java.util.ArrayList) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) DefaultAnnexLibrary(org.osate.aadl2.DefaultAnnexLibrary) AnnexLibrary(org.osate.aadl2.AnnexLibrary)

Example 8 with AgreeContract

use of com.rockwellcollins.atc.agree.agree.AgreeContract in project AMASE by loonwerks.

the class SafetyValidator method collectAssignableElementsInTypeAndImpl.

/**
 * Gets all agree vars defined in this component type and implementation.
 * @param compImpl
 * @return List<String> of agree var names.
 */
private List<EObject> collectAssignableElementsInTypeAndImpl(ComponentImplementation compImpl) {
    List<EObject> assignableElements = new ArrayList<>();
    // Get impl contract
    List<AgreeContract> typeContracts = EcoreUtil2.getAllContentsOfType(compImpl, AgreeContract.class);
    // And now check component type contract
    typeContracts.addAll(EcoreUtil2.getAllContentsOfType(compImpl.getType(), AgreeContract.class));
    for (AgreeContract ac : typeContracts) {
        assignableElements.addAll(EcoreUtil2.getAllContentsOfType(ac, EqStatement.class).stream().map(eq -> eq.getLhs()).flatMap(List::stream).collect(Collectors.toList()));
    }
    return assignableElements;
}
Also used : AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) Element(org.osate.aadl2.Element) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) TransientConstraint(edu.umn.cs.crisys.safety.safety.TransientConstraint) FaultStatement(edu.umn.cs.crisys.safety.safety.FaultStatement) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) EqValue(edu.umn.cs.crisys.safety.safety.EqValue) Classifier(org.osate.aadl2.Classifier) InputStatement(edu.umn.cs.crisys.safety.safety.InputStatement) Map(java.util.Map) ComponentType(org.osate.aadl2.ComponentType) Check(org.eclipse.xtext.validation.Check) SetEq(edu.umn.cs.crisys.safety.safety.SetEq) FaultCountBehavior(edu.umn.cs.crisys.safety.safety.FaultCountBehavior) AnalysisStatement(edu.umn.cs.crisys.safety.safety.AnalysisStatement) AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) TemporalConstraint(edu.umn.cs.crisys.safety.safety.TemporalConstraint) SafetyContractImpl(edu.umn.cs.crisys.safety.safety.impl.SafetyContractImpl) PrimType(com.rockwellcollins.atc.agree.agree.PrimType) EObject(org.eclipse.emf.ecore.EObject) AadlPackage(org.osate.aadl2.AadlPackage) ProbabilityStatement(edu.umn.cs.crisys.safety.safety.ProbabilityStatement) Collectors(java.util.stream.Collectors) NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) List(java.util.List) ModelUnit(org.osate.aadl2.ModelUnit) PublicPackageSection(org.osate.aadl2.PublicPackageSection) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) RangeEq(edu.umn.cs.crisys.safety.safety.RangeEq) SystemType(org.osate.aadl2.SystemType) Arg(com.rockwellcollins.atc.agree.agree.Arg) SafetyPackage(edu.umn.cs.crisys.safety.safety.SafetyPackage) AadlPackageImpl(org.osate.aadl2.impl.AadlPackageImpl) ComponentImplementation(org.osate.aadl2.ComponentImplementation) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Expr(com.rockwellcollins.atc.agree.agree.Expr) ActivationStatement(edu.umn.cs.crisys.safety.safety.ActivationStatement) HWFaultStatement(edu.umn.cs.crisys.safety.safety.HWFaultStatement) SafetyContractSubclause(edu.umn.cs.crisys.safety.safety.SafetyContractSubclause) SafetyInterval(edu.umn.cs.crisys.safety.safety.SafetyInterval) IntervalEq(edu.umn.cs.crisys.safety.safety.IntervalEq) CheckType(org.eclipse.xtext.validation.CheckType) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) DurationStatement(edu.umn.cs.crisys.safety.safety.DurationStatement) SafetyContract(edu.umn.cs.crisys.safety.safety.SafetyContract) Subcomponent(org.osate.aadl2.Subcomponent) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) OutputStatement(edu.umn.cs.crisys.safety.safety.OutputStatement) SafetyUtil(edu.umn.cs.crisys.safety.util.SafetyUtil) EqStatement(com.rockwellcollins.atc.agree.agree.EqStatement) SpecStatement(edu.umn.cs.crisys.safety.safety.SpecStatement) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) EList(org.eclipse.emf.common.util.EList) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) DataImplementationImpl(org.osate.aadl2.impl.DataImplementationImpl) DataTypeImpl(org.osate.aadl2.impl.DataTypeImpl) DoubleDotRefImpl(com.rockwellcollins.atc.agree.agree.impl.DoubleDotRefImpl) PropertyImpl(org.osate.aadl2.impl.PropertyImpl) AnnexSubclause(org.osate.aadl2.AnnexSubclause) AnalysisBehavior(edu.umn.cs.crisys.safety.safety.AnalysisBehavior) DataPortImpl(org.osate.aadl2.impl.DataPortImpl) NamedElement(org.osate.aadl2.NamedElement) ProbabilityBehavior(edu.umn.cs.crisys.safety.safety.ProbabilityBehavior) TriggerStatement(edu.umn.cs.crisys.safety.safety.TriggerStatement) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) EqStatement(com.rockwellcollins.atc.agree.agree.EqStatement)

Example 9 with AgreeContract

use of com.rockwellcollins.atc.agree.agree.AgreeContract in project AMASE by loonwerks.

the class SafetyLinkingService method getElm.

private Element getElm(EObject context, EReference reference, String name) {
    String[] segments = name.split("::");
    if (segments.length >= 2) {
        String pkgName = String.join("::", Arrays.copyOf(segments, segments.length - 1));
        String statementName = segments[segments.length - 1];
        Namespace namespace = AadlUtil.getContainingTopLevelNamespace(context);
        PropertySet propSet = AadlUtil.findImportedPropertySet(pkgName, namespace);
        if (propSet != null) {
            Element elm = propSet.findNamedElement(statementName);
            return elm;
        }
        AadlPackage aadlPackage = AadlUtil.findImportedPackage(pkgName, namespace);
        if (aadlPackage == null) {
            for (PackageRename rename : EcoreUtil2.getAllContentsOfType(namespace.getElementRoot(), PackageRename.class)) {
                if (rename.getName() != null && pkgName.equals(rename.getName())) {
                    aadlPackage = rename.getRenamedPackage();
                }
            }
        }
        if (aadlPackage != null) {
            for (AnnexLibrary annex : AnnexUtil.getAllActualAnnexLibraries(aadlPackage, AgreePackage.eINSTANCE.getAgreeContractLibrary())) {
                AgreeContract contract = (AgreeContract) ((AgreeContractLibrary) annex).getContract();
                for (com.rockwellcollins.atc.agree.agree.SpecStatement spec : contract.getSpecs()) {
                    if (spec instanceof RecordDef) {
                        if (((RecordDef) spec).getName().equals(statementName)) {
                            return (spec);
                        }
                    } else if (spec instanceof FnDef) {
                        if (((FnDef) spec).getName().equals(statementName)) {
                            return (spec);
                        }
                    } else if (spec instanceof LibraryFnDef) {
                        if (((LibraryFnDef) spec).getName().equals(statementName)) {
                            return (spec);
                        }
                    } else if (spec instanceof NodeDef) {
                        if (((NodeDef) spec).getName().equals(statementName)) {
                            return (spec);
                        }
                    } else if (spec instanceof LinearizationDef) {
                        if (((LinearizationDef) spec).getName().equals(statementName)) {
                            return (spec);
                        }
                    } else if (spec instanceof ConstStatement) {
                        if (((ConstStatement) spec).getName().equals(statementName)) {
                            return (spec);
                        }
                    } else if (spec instanceof EnumStatement) {
                        if (((EnumStatement) spec).getName().equals(statementName)) {
                            return (spec);
                        }
                        EList<NamedID> enums = ((EnumStatement) spec).getEnums();
                        for (NamedID nid : enums) {
                            if (nid.getName().contentEquals(statementName)) {
                                return nid;
                            }
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) AadlPackage(org.osate.aadl2.AadlPackage) LibraryFnDef(com.rockwellcollins.atc.agree.agree.LibraryFnDef) NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) Element(org.osate.aadl2.Element) LinearizationDef(com.rockwellcollins.atc.agree.agree.LinearizationDef) Namespace(org.osate.aadl2.Namespace) NamedID(com.rockwellcollins.atc.agree.agree.NamedID) FnDef(com.rockwellcollins.atc.agree.agree.FnDef) LibraryFnDef(com.rockwellcollins.atc.agree.agree.LibraryFnDef) ConstStatement(com.rockwellcollins.atc.agree.agree.ConstStatement) PackageRename(org.osate.aadl2.PackageRename) EnumStatement(com.rockwellcollins.atc.agree.agree.EnumStatement) PropertySet(org.osate.aadl2.PropertySet) AnnexLibrary(org.osate.aadl2.AnnexLibrary) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef)

Example 10 with AgreeContract

use of com.rockwellcollins.atc.agree.agree.AgreeContract in project AMASE by loonwerks.

the class SafetyScopeProvider method getNamedElements.

private Set<NamedElement> getNamedElements(EObject ctx) {
    Set<NamedElement> components = new HashSet<>();
    if (ctx instanceof AadlPackage) {
        PublicPackageSection pubSec = ((AadlPackage) ctx).getPublicSection();
        for (Element el : pubSec.getOwnedElements()) {
            if (el instanceof DataImplementation || el instanceof DataType) {
                components.add((NamedElement) el);
            }
        }
        for (AnnexLibrary annex : AnnexUtil.getAllActualAnnexLibraries(((AadlPackage) ctx), AgreePackage.eINSTANCE.getAgreeContractLibrary())) {
            AgreeContract contract = (AgreeContract) ((AgreeContractLibrary) annex).getContract();
            components.addAll(getNamedElementsFromSpecs(contract.getSpecs()));
        }
        components.add((AadlPackage) ctx);
    } else {
        components.addAll(getNamedElementsFromClassifier((Classifier) ctx, false));
    }
    return components;
}
Also used : AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) AadlPackage(org.osate.aadl2.AadlPackage) PublicPackageSection(org.osate.aadl2.PublicPackageSection) Element(org.osate.aadl2.Element) NamedElement(org.osate.aadl2.NamedElement) DataImplementation(org.osate.aadl2.DataImplementation) DataType(org.osate.aadl2.DataType) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) AnnexLibrary(org.osate.aadl2.AnnexLibrary) NamedElement(org.osate.aadl2.NamedElement) HashSet(java.util.HashSet)

Aggregations

AgreeContract (com.rockwellcollins.atc.agree.agree.AgreeContract)16 SpecStatement (com.rockwellcollins.atc.agree.agree.SpecStatement)9 AadlPackage (org.osate.aadl2.AadlPackage)9 ConstStatement (com.rockwellcollins.atc.agree.agree.ConstStatement)8 ArrayList (java.util.ArrayList)8 AnnexLibrary (org.osate.aadl2.AnnexLibrary)8 NamedElement (org.osate.aadl2.NamedElement)8 HashMap (java.util.HashMap)7 AnnexSubclause (org.osate.aadl2.AnnexSubclause)7 Classifier (org.osate.aadl2.Classifier)7 ComponentClassifier (org.osate.aadl2.ComponentClassifier)7 ComponentImplementation (org.osate.aadl2.ComponentImplementation)7 EList (org.eclipse.emf.common.util.EList)6 ComponentType (org.osate.aadl2.ComponentType)6 AgreeContractLibrary (com.rockwellcollins.atc.agree.agree.AgreeContractLibrary)5 AgreeContractSubclause (com.rockwellcollins.atc.agree.agree.AgreeContractSubclause)5 EqStatement (com.rockwellcollins.atc.agree.agree.EqStatement)5 NodeDef (com.rockwellcollins.atc.agree.agree.NodeDef)5 Map (java.util.Map)5 Arg (com.rockwellcollins.atc.agree.agree.Arg)4