Search in sources :

Example 6 with SafetyContract

use of edu.umn.cs.crisys.safety.safety.SafetyContract 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)

Aggregations

SafetyContract (edu.umn.cs.crisys.safety.safety.SafetyContract)6 SafetyContractSubclause (edu.umn.cs.crisys.safety.safety.SafetyContractSubclause)4 ArrayList (java.util.ArrayList)4 AnnexSubclause (org.osate.aadl2.AnnexSubclause)4 SpecStatement (edu.umn.cs.crisys.safety.safety.SpecStatement)3 Classifier (org.osate.aadl2.Classifier)3 AnalysisStatement (edu.umn.cs.crisys.safety.safety.AnalysisStatement)2 ProbabilityBehavior (edu.umn.cs.crisys.safety.safety.ProbabilityBehavior)2 SafetyContractSubclauseImpl (edu.umn.cs.crisys.safety.safety.impl.SafetyContractSubclauseImpl)2 HashMap (java.util.HashMap)2 List (java.util.List)2 EList (org.eclipse.emf.common.util.EList)2 Element (org.osate.aadl2.Element)2 NamedElement (org.osate.aadl2.NamedElement)2 SystemType (org.osate.aadl2.SystemType)2 DefaultAnnexSubclauseImpl (org.osate.aadl2.impl.DefaultAnnexSubclauseImpl)2 InputStatement (com.rockwellcollins.atc.agree.agree.InputStatement)1 ActivationStatement (edu.umn.cs.crisys.safety.safety.ActivationStatement)1 ClosedSafetyInterval (edu.umn.cs.crisys.safety.safety.ClosedSafetyInterval)1 DisableStatement (edu.umn.cs.crisys.safety.safety.DisableStatement)1