Search in sources :

Example 1 with FaultStatementImpl

use of edu.umn.cs.crisys.safety.safety.impl.FaultStatementImpl in project AMASE by loonwerks.

the class IvcToFTGenerator method extractFaultMCSElem.

private void extractFaultMCSElem(String compName, AgreeRenaming renaming, FTAndNode mcsSetNode, String faultName, String faultRefName, String originalFaultName) {
    // differentiate same fault definitions activated in subcomponents of different parent components
    String updatedFaultName = MHSUtils.updateElemName(compName + "_" + faultName);
    // if mcsElem is not yet in leaf nodes
    if (!faultTree.leafNodes.containsKey(updatedFaultName)) {
        FaultStatementImpl faultStmtImpl = (FaultStatementImpl) renaming.getRefMap().get(faultRefName);
        // original fault name specified by the user
        String faultUserName = faultStmtImpl.getName();
        // original fault explanation specified by the user
        String faultUserExplanation = faultStmtImpl.getStr();
        // probability string
        String probStr = "";
        // failure probability
        float failureProb = (float) 0.0;
        for (FaultSubcomponent faultSub : faultStmtImpl.getFaultDefinitions()) {
            if (faultSub instanceof ProbabilityStatementImpl) {
                probStr = ((ProbabilityStatementImpl) faultSub).getProbability();
                failureProb = Float.parseFloat(probStr);
            }
        }
        // TODO: need to have component specify failure rate and exposure time in the future
        // currently treat exposure time and failure rate as (float) 1.0
        // and set the failure probability from the fault statement as the failure rate
        FTLeafNode ftLeafNode = new FTLeafNode(compName, updatedFaultName, (float) 1.0, (float) 1.0, failureProb, originalFaultName, faultUserName, faultUserExplanation);
        faultTree.addLeafNode(updatedFaultName, ftLeafNode);
        mcsSetNode.addChildNode(updatedFaultName, ftLeafNode);
        // update intermediate node
        faultTree.addIntermediateNode(mcsSetNode.nodeName, mcsSetNode);
    // ftLeafNode.addParentNode(mcsSetNode);
    } else {
        FTLeafNode leafNode = faultTree.leafNodes.get(updatedFaultName);
        mcsSetNode.addChildNode(updatedFaultName, leafNode);
        faultTree.addIntermediateNode(mcsSetNode.nodeName, mcsSetNode);
    // leafNode.addParentNode(mcsSetNode);
    }
}
Also used : FaultSubcomponent(edu.umn.cs.crisys.safety.safety.FaultSubcomponent) FaultStatementImpl(edu.umn.cs.crisys.safety.safety.impl.FaultStatementImpl) FTLeafNode(edu.umn.cs.crisys.safety.analysis.faultTree.FTLeafNode) ProbabilityStatementImpl(edu.umn.cs.crisys.safety.safety.impl.ProbabilityStatementImpl)

Example 2 with FaultStatementImpl

use of edu.umn.cs.crisys.safety.safety.impl.FaultStatementImpl in project AMASE by loonwerks.

the class IvcToFTGenerator method getMCSInfo.

/**
 * Gathers details about MCS element and returns descriptive string
 * including component name, fault/contract name and description.
 * @param mcsElem String of mcs element
 * @param renaming AgreeRenaming map
 * @param compName component name where this fault/contract can be found
 * @return descriptive string for hierarchical ft textual representation
 */
private String getMCSInfo(String mcsElem, AgreeRenaming renaming) {
    String refStr = renaming.getSupportRefString(mcsElem);
    if (mcsElem.startsWith("__fault")) {
        FaultStatementImpl faultStmtImpl = (FaultStatementImpl) renaming.getRefMap().get(refStr);
        String faultUserName = faultStmtImpl.getName();
        String faultUserExplanation = faultStmtImpl.getStr();
        return "Contributing fault found in component " + stripOutInstanceName(mcsElem) + ": " + faultUserName + ": " + faultUserExplanation + " (" + mcsElem + ")";
    } else {
        String name = mcsElem.substring(0, mcsElem.indexOf("."));
        return "Supporting contract in component " + name + ": " + refStr;
    }
}
Also used : FaultStatementImpl(edu.umn.cs.crisys.safety.safety.impl.FaultStatementImpl)

Example 3 with FaultStatementImpl

use of edu.umn.cs.crisys.safety.safety.impl.FaultStatementImpl in project AMASE by loonwerks.

the class IvcToSoteriaGenerator method extractFaultIvcElem.

private void extractFaultIvcElem(SoteriaComp comp, AgreeRenaming renaming, SoteriaFormulaSubgroup formulaSubgroup, String faultName, String faultRefName) {
    // get the fault name for that fault activation variable in ivcElement
    CompFaultActivation faultActivation = new CompFaultActivation(comp.componentName, faultName);
    formulaSubgroup.addFormulaElem(faultActivation);
    // if ivcElem is not yet in basicEvents
    if (!comp.basicEvents.containsKey(faultName)) {
        FaultStatementImpl faultStmtImpl = (FaultStatementImpl) renaming.getRefMap().get(faultRefName);
        for (FaultSubcomponent faultSub : faultStmtImpl.getFaultDefinitions()) {
            if (faultSub instanceof ProbabilityStatementImpl) {
                String probStr = ((ProbabilityStatementImpl) faultSub).getProbability();
                float failureProb = Float.parseFloat(probStr);
                // TODO: need to have component specify failure rate and exposure time in the future
                // currently treat exposure time as (float) 1.0
                // and treat the failure probability from the fault statement as the failure rate
                SoteriaFault basicEvent = new SoteriaFault(updateElemName(faultName), failureProb, (float) 1.0);
                comp.addBasicEvent(faultName, basicEvent);
            }
        }
    }
}
Also used : FaultSubcomponent(edu.umn.cs.crisys.safety.safety.FaultSubcomponent) FaultStatementImpl(edu.umn.cs.crisys.safety.safety.impl.FaultStatementImpl) SoteriaFault(edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFault) CompFaultActivation(edu.umn.cs.crisys.safety.analysis.soteria.CompFaultActivation) ProbabilityStatementImpl(edu.umn.cs.crisys.safety.safety.impl.ProbabilityStatementImpl)

Example 4 with FaultStatementImpl

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

Aggregations

FaultStatementImpl (edu.umn.cs.crisys.safety.safety.impl.FaultStatementImpl)4 FaultSubcomponent (edu.umn.cs.crisys.safety.safety.FaultSubcomponent)2 ProbabilityStatementImpl (edu.umn.cs.crisys.safety.safety.impl.ProbabilityStatementImpl)2 FTLeafNode (edu.umn.cs.crisys.safety.analysis.faultTree.FTLeafNode)1 CompFaultActivation (edu.umn.cs.crisys.safety.analysis.soteria.CompFaultActivation)1 SoteriaFault (edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFault)1 SafetyContract (edu.umn.cs.crisys.safety.safety.SafetyContract)1 SpecStatement (edu.umn.cs.crisys.safety.safety.SpecStatement)1 SafetyContractSubclauseImpl (edu.umn.cs.crisys.safety.safety.impl.SafetyContractSubclauseImpl)1 ArrayList (java.util.ArrayList)1 AnnexSubclause (org.osate.aadl2.AnnexSubclause)1 Classifier (org.osate.aadl2.Classifier)1 ComponentTypeImpl (org.osate.aadl2.impl.ComponentTypeImpl)1 DefaultAnnexSubclauseImpl (org.osate.aadl2.impl.DefaultAnnexSubclauseImpl)1