Search in sources :

Example 91 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project AMASE by loonwerks.

the class FaultsVerifyAllHandler method isProbabilisticAnalysis.

private boolean isProbabilisticAnalysis() {
    List<Classifier> classifiers = getClassifiers();
    if (classifiers == null) {
        return false;
    }
    // TODO: Finish addressing this issue.
    for (Classifier cl : classifiers) {
        // Get impl of this level
        if (cl instanceof ComponentImplementationImpl) {
            List<AnnexSubclause> asList = cl.getOwnedAnnexSubclauses();
            for (AnnexSubclause as : asList) {
                if (as.getName().equalsIgnoreCase("safety")) {
                    if (as instanceof DefaultAnnexSubclauseImpl) {
                        DefaultAnnexSubclauseImpl defaultAnnex = (DefaultAnnexSubclauseImpl) as;
                        SafetyContractSubclauseImpl safetyAnnex = (SafetyContractSubclauseImpl) defaultAnnex.getParsedAnnexSubclause();
                        // Get analysis stmt
                        List<SpecStatement> specs = ((SafetyContract) safetyAnnex.getContract()).getSpecs();
                        for (SpecStatement spec : specs) {
                            if (spec instanceof AnalysisStatement) {
                                if (!(((AnalysisStatement) spec).getBehavior() instanceof ProbabilityBehavior)) {
                                    return false;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return true;
}
Also used : SafetyContractSubclauseImpl(edu.umn.cs.crisys.safety.safety.impl.SafetyContractSubclauseImpl) AnalysisStatement(edu.umn.cs.crisys.safety.safety.AnalysisStatement) ComponentImplementationImpl(org.osate.aadl2.impl.ComponentImplementationImpl) DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) ProbabilityBehavior(edu.umn.cs.crisys.safety.safety.ProbabilityBehavior) SpecStatement(edu.umn.cs.crisys.safety.safety.SpecStatement) Classifier(org.osate.aadl2.Classifier) SafetyContract(edu.umn.cs.crisys.safety.safety.SafetyContract) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Example 92 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project AMASE by loonwerks.

the class FaultDisableHandler method makeMap.

/**
 * Checks classifiers in AadlPackage for any ComponentTypeImpl
 * and then collects safety annex spec statements to gather
 * fault names specific to that component.
 *
 * @param classifiers Classifiers in this AadlPackage
 */
private void makeMap(List<Classifier> classifiers) {
    for (Classifier cl : classifiers) {
        if (cl instanceof ComponentTypeImpl) {
            String compName = cl.getName();
            List<String> faultNameList = new ArrayList<String>();
            List<AnnexSubclause> asList = cl.getOwnedAnnexSubclauses();
            for (AnnexSubclause as : asList) {
                if (as.getName().equalsIgnoreCase("safety")) {
                    if (as instanceof DefaultAnnexSubclauseImpl) {
                        DefaultAnnexSubclauseImpl defaultAnnex = (DefaultAnnexSubclauseImpl) as;
                        SafetyContractSubclauseImpl safetyAnnex = (SafetyContractSubclauseImpl) defaultAnnex.getParsedAnnexSubclause();
                        List<SpecStatement> specs = ((SafetyContract) safetyAnnex.getContract()).getSpecs();
                        for (SpecStatement spec : specs) {
                            if (spec instanceof FaultStatementImpl) {
                                FaultStatementImpl fs = (FaultStatementImpl) spec;
                                faultNameList.add(fs.getName());
                            }
                        }
                    }
                }
            }
            // If list nonempty, add to map for this component
            if (!faultNameList.isEmpty()) {
                mapCompNameToFaults.put(compName, faultNameList);
            }
        }
    }
}
Also used : SafetyContractSubclauseImpl(edu.umn.cs.crisys.safety.safety.impl.SafetyContractSubclauseImpl) DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) ArrayList(java.util.ArrayList) ComponentTypeImpl(org.osate.aadl2.impl.ComponentTypeImpl) SpecStatement(edu.umn.cs.crisys.safety.safety.SpecStatement) Classifier(org.osate.aadl2.Classifier) FaultStatementImpl(edu.umn.cs.crisys.safety.safety.impl.FaultStatementImpl) SafetyContract(edu.umn.cs.crisys.safety.safety.SafetyContract) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Example 93 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project AMASE by loonwerks.

the class SafetyValidator method collectFaultsFromPackages.

/**
 * Get packages defined in this component impl and collect all faults from
 * all included packages.
 * @param compImpl
 * @return Map<String, List<String>> mapping from component instance name
 * to a list of associated faults.
 */
private Map<String, List<String>> collectFaultsFromPackages(ComponentImplementation compImpl) {
    Map<String, List<String>> mapCompNameToFaultNames = new HashMap<String, List<String>>();
    List<AadlPackageImpl> packages = new ArrayList<AadlPackageImpl>();
    AadlPackageImpl aadlPackage = getAadlPackageImpl(compImpl);
    packages.add(aadlPackage);
    PublicPackageSection pps = aadlPackage.getOwnedPublicSection();
    // Collect all imported packages and iterate through
    // annexes to find safety annexes with faults.
    List<ModelUnit> imports = pps.getImportedUnits();
    for (ModelUnit imp : imports) {
        if (imp instanceof AadlPackageImpl) {
            packages.add((AadlPackageImpl) imp);
        }
    }
    for (AadlPackageImpl aadlPack : packages) {
        PublicPackageSection pub = aadlPack.getPublicSection();
        for (Classifier cl : pub.getOwnedClassifiers()) {
            if (cl instanceof SystemType) {
                for (AnnexSubclause sub : cl.getOwnedAnnexSubclauses()) {
                    if (sub.getName().contains("safety")) {
                        for (Element child : sub.getChildren()) {
                            List<String> faultNames = new ArrayList<String>();
                            if (child instanceof SafetyContractSubclause) {
                                SafetyContractSubclause safetyChild = (SafetyContractSubclause) child;
                                SafetyContract cont = (SafetyContract) safetyChild.getContract();
                                faultNames.addAll(getFaultNamesFromSpecs(cont.getSpecs()));
                                mapCompNameToFaultNames.put(cl.getName(), faultNames);
                            }
                        }
                    }
                }
            }
        }
    }
    return mapCompNameToFaultNames;
}
Also used : HashMap(java.util.HashMap) Element(org.osate.aadl2.Element) NamedElement(org.osate.aadl2.NamedElement) ArrayList(java.util.ArrayList) SystemType(org.osate.aadl2.SystemType) Classifier(org.osate.aadl2.Classifier) AadlPackageImpl(org.osate.aadl2.impl.AadlPackageImpl) SafetyContractSubclause(edu.umn.cs.crisys.safety.safety.SafetyContractSubclause) PublicPackageSection(org.osate.aadl2.PublicPackageSection) ModelUnit(org.osate.aadl2.ModelUnit) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) SafetyContract(edu.umn.cs.crisys.safety.safety.SafetyContract) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Example 94 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project AMASE by loonwerks.

the class SafetyScopeProvider method scope_GetPropertyExpr_prop.

protected IScope scope_GetPropertyExpr_prop(GetPropertyExpr ctx, EReference ref) {
    IScope prevScope = prevScope(ctx, ref);
    ComponentRef cr = ctx.getComponentRef();
    if (cr instanceof ThisRef) {
        List<Property> ps = new ArrayList<>();
        EObject container = ctx.getContainingClassifier();
        while (container != null) {
            if (container instanceof Classifier) {
                List<PropertyAssociation> pas = ((Classifier) container).getAllPropertyAssociations();
                for (PropertyAssociation pa : pas) {
                    ps.add(pa.getProperty());
                }
                container = ((Classifier) container).eContainer();
            } else if (container instanceof AadlPackage) {
                for (PropertySet propSet : EcoreUtil2.getAllContentsOfType(container, PropertySet.class)) {
                    for (Property p : propSet.getOwnedProperties()) {
                        ps.add(p);
                    }
                // =======
                // EList<EObject> refs  = null;
                // 
                // if (container instanceof NestedDotID) {
                // NestedDotID parent = (NestedDotID) container;
                // refs = parent.eCrossReferences();
                // 
                // if (refs.size() != 1) {
                // return new HashSet<>(); // this will throw a parsing error
                // }
                // container = refs.get(0); // figure out what this type this portion
                // 
                // // of the nest id is so we can figure out
                // // what we could possibly link to
                // 
                // if (container instanceof ThreadSubcomponent) {
                // container = ((ThreadSubcomponent) container).getComponentType();
                // result.addAll(getAadlElements(container));
                // } else if (container instanceof Subcomponent) {
                // container = ((Subcomponent) container).getComponentImplementation();
                // if (container == null) { // no implementation is provided
                // container = refs.get(0);
                // container = ((Subcomponent) container).getClassifier();
                // }
                // result.addAll(getAadlElements(container));
                // } else if (container instanceof DataPort) {
                // container = ((DataPort) container).getDataFeatureClassifier();
                // result.addAll(getAadlElements(container));
                // } else if (container instanceof EventDataPort) {
                // container = ((EventDataPort) container).getDataFeatureClassifier();
                // result.addAll(getAadlElements(container));
                // } else if (container instanceof AadlPackage) {
                // result.addAll(getAadlElements(container));
                // } else if (container instanceof FeatureGroupImpl) {
                // container = ((FeatureGroupImpl) container).getAllFeatureGroupType();
                // result.addAll(getAadlElements(container));
                // } else if (container instanceof Arg || container instanceof ConstStatement) {
                // Type type;
                // 
                // if (container instanceof Arg) {
                // type = ((Arg) container).getType();
                // } else {
                // type = ((ConstStatement) container).getType();
                // }
                // 
                // if (type instanceof RecordType) {
                // DoubleDotRef elID = ((RecordType) type).getRecord();
                // NamedElement namedEl = elID.getElm();
                // 
                // if (namedEl instanceof ComponentImplementation) {
                // ComponentImplementation componentImplementation = (ComponentImplementation) namedEl;
                // EList<Subcomponent> subs = componentImplementation.getAllSubcomponents();
                // result.addAll(subs);
                // } else if (namedEl instanceof RecordDefExpr) {
                // result.addAll(((RecordDefExpr) namedEl).getArgs());
                // >>>>>>> origin/develop
                }
                container = null;
            } else {
                container = container.eContainer();
            }
        }
        return Scopes.scopeFor(ps, prevScope);
    } else if (cr instanceof DoubleDotRef) {
        NamedElement ne = ((DoubleDotRef) cr).getElm();
        if (ne instanceof Subcomponent) {
            List<PropertyAssociation> pas = ((Subcomponent) ne).getOwnedPropertyAssociations();
            List<Property> ps = new ArrayList<>();
            for (PropertyAssociation pa : pas) {
                ps.add(pa.getProperty());
            }
            return Scopes.scopeFor(ps, prevScope);
        }
    }
    return IScope.NULLSCOPE;
}
Also used : AadlPackage(org.osate.aadl2.AadlPackage) PropertyAssociation(org.osate.aadl2.PropertyAssociation) ArrayList(java.util.ArrayList) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) ThisRef(com.rockwellcollins.atc.agree.agree.ThisRef) EObject(org.eclipse.emf.ecore.EObject) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) FaultSubcomponent(edu.umn.cs.crisys.safety.safety.FaultSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) IScope(org.eclipse.xtext.scoping.IScope) PropertySet(org.osate.aadl2.PropertySet) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) EList(org.eclipse.emf.common.util.EList) ComponentRef(com.rockwellcollins.atc.agree.agree.ComponentRef) Property(org.osate.aadl2.Property) NamedElement(org.osate.aadl2.NamedElement)

Example 95 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier 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

Classifier (org.osate.aadl2.Classifier)203 ComponentClassifier (org.osate.aadl2.ComponentClassifier)90 ComponentImplementation (org.osate.aadl2.ComponentImplementation)49 NamedElement (org.osate.aadl2.NamedElement)40 AadlPackage (org.osate.aadl2.AadlPackage)38 Subcomponent (org.osate.aadl2.Subcomponent)37 ComponentType (org.osate.aadl2.ComponentType)34 EObject (org.eclipse.emf.ecore.EObject)31 ArrayList (java.util.ArrayList)29 BasicEList (org.eclipse.emf.common.util.BasicEList)28 Feature (org.osate.aadl2.Feature)26 DataClassifier (org.osate.aadl2.DataClassifier)22 FeatureGroupType (org.osate.aadl2.FeatureGroupType)21 ProcessorClassifier (org.osate.aadl2.ProcessorClassifier)21 AnnexSubclause (org.osate.aadl2.AnnexSubclause)17 Element (org.osate.aadl2.Element)17 EList (org.eclipse.emf.common.util.EList)15 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)15 FeatureGroup (org.osate.aadl2.FeatureGroup)14 PropertyExpression (org.osate.aadl2.PropertyExpression)14