Search in sources :

Example 31 with AnnexSubclause

use of org.osate.aadl2.AnnexSubclause 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 32 with AnnexSubclause

use of org.osate.aadl2.AnnexSubclause in project AMASE by loonwerks.

the class SafetyValidator method collectFaultsFromSubcomponents.

/**
 * Collect all subcomponents of this component implementation and
 * iterate through them finding the faults defined for each.
 * @param compImpl
 * @return Map<String, List<String>> mapping from component instance name
 * to a list of associated faults.
 */
private Map<String, List<String>> collectFaultsFromSubcomponents(ComponentImplementation compImpl) {
    Map<String, List<String>> mapCompNameToFaultNames = new HashMap<String, List<String>>();
    for (Subcomponent sub : compImpl.getAllSubcomponents()) {
        if (sub.getComponentType() instanceof SystemType) {
            List<AnnexSubclause> annexes = ((SystemType) sub.getComponentType()).getOwnedAnnexSubclauses();
            for (AnnexSubclause annex : annexes) {
                if (annex.getName().contains("safety")) {
                    for (Element child : annex.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(sub.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) SafetyContractSubclause(edu.umn.cs.crisys.safety.safety.SafetyContractSubclause) Subcomponent(org.osate.aadl2.Subcomponent) 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 33 with AnnexSubclause

use of org.osate.aadl2.AnnexSubclause in project AMASE by loonwerks.

the class SafetyScopeProvider method getNamedElementsFromClassifier.

private Set<NamedElement> getNamedElementsFromClassifier(Classifier ctx, boolean fromCompImpl) {
    Set<NamedElement> components = new HashSet<>();
    for (AnnexSubclause annex : AnnexUtil.getAllAnnexSubclauses(ctx, AgreePackage.eINSTANCE.getAgreeContractSubclause())) {
        AgreeContract contract = (AgreeContract) ((AgreeContractSubclause) annex).getContract();
        components.addAll(getNamedElementsFromSpecs(contract.getSpecs()));
    }
    if (ctx instanceof ComponentImplementation) {
        components.addAll(((ComponentImplementation) ctx).getAllSubcomponents());
        components.addAll(((ComponentImplementation) ctx).getAllConnections());
        components.addAll(getNamedElementsFromClassifier(((ComponentImplementation) ctx).getType(), true));
    } else if (ctx instanceof ComponentType) {
        if (fromCompImpl) {
            List<Feature> fs = ((ComponentType) ctx).getAllFeatures();
            components.addAll(fs);
        } else {
            List<Feature> fs = ((ComponentType) ctx).getOwnedFeatures();
            components.addAll(fs);
        }
    }
    components.addAll(getNamedElements(getAadlContainer(ctx)));
    return components;
}
Also used : AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentType(org.osate.aadl2.ComponentType) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) EList(org.eclipse.emf.common.util.EList) NamedElement(org.osate.aadl2.NamedElement) AnnexSubclause(org.osate.aadl2.AnnexSubclause) HashSet(java.util.HashSet)

Example 34 with AnnexSubclause

use of org.osate.aadl2.AnnexSubclause 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 35 with AnnexSubclause

use of org.osate.aadl2.AnnexSubclause 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)

Aggregations

AnnexSubclause (org.osate.aadl2.AnnexSubclause)54 ArrayList (java.util.ArrayList)23 DefaultAnnexSubclause (org.osate.aadl2.DefaultAnnexSubclause)21 EObject (org.eclipse.emf.ecore.EObject)19 Classifier (org.osate.aadl2.Classifier)17 CyberReq (com.ge.research.osate.verdict.dsl.verdict.CyberReq)15 Statement (com.ge.research.osate.verdict.dsl.verdict.Statement)15 Verdict (com.ge.research.osate.verdict.dsl.verdict.Verdict)15 AnnexLibrary (org.osate.aadl2.AnnexLibrary)15 SafetyReq (com.ge.research.osate.verdict.dsl.verdict.SafetyReq)14 NamedElement (org.osate.aadl2.NamedElement)14 CyberMission (com.ge.research.osate.verdict.dsl.verdict.CyberMission)13 CyberRel (com.ge.research.osate.verdict.dsl.verdict.CyberRel)13 Event (com.ge.research.osate.verdict.dsl.verdict.Event)13 SafetyRel (com.ge.research.osate.verdict.dsl.verdict.SafetyRel)13 ComponentImplementation (org.osate.aadl2.ComponentImplementation)13 EventDataPort (org.osate.aadl2.EventDataPort)13 EventPort (org.osate.aadl2.EventPort)13 ComponentType (org.osate.aadl2.ComponentType)12 DataPort (org.osate.aadl2.DataPort)12