Search in sources :

Example 1 with FaultSubcomponent

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

the class AddFaultsToNodeVisitor method getOutputNameFromFaultStatement.

/**
 * Given a fault statement, returns the string name of the output this fault
 * stmt is connected to.
 *
 * @param fs FaultStatement in question
 * @return String name of the output
 */
private String getOutputNameFromFaultStatement(FaultStatement fs) {
    String output = "";
    for (FaultSubcomponent fc : fs.getFaultDefinitions()) {
        if (fc instanceof OutputStatement) {
            EList<NamedElement> outputType = ((OutputStatement) fc).getNom_conn();
            // TODO: Assume the output is first in list. (????)
            if (outputType.size() > 0) {
                NamedElement id = outputType.get(0);
                // output = id.getBase().getName();
                output = id.toString();
                return output;
            }
            break;
        }
    }
    return output;
}
Also used : FaultSubcomponent(edu.umn.cs.crisys.safety.safety.FaultSubcomponent) NamedElement(org.osate.aadl2.NamedElement) OutputStatement(edu.umn.cs.crisys.safety.safety.OutputStatement)

Example 2 with FaultSubcomponent

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

the class AddFaultsToNodeVisitor method separateFaultStmts.

/**
 * This method uses a list of fault statements and divides them into multiple
 * asym faults on a single output and everything else.
 *
 * @param allFS          List<FaultStatement> All fault statements in this agree
 *                       node
 * @param remainderFS    List<FaultStatement> List to add all single asym faults
 *                       on single output AND sym faults.
 * @param multipleAsymFS List<FaultStatement> List to add all multiple asym
 *                       faults on single output.
 */
private void separateFaultStmts(List<FaultStatement> allFS, List<FaultStatement> remainderFS, Map<String, List<FaultStatement>> asymMap) {
    // Else append to multipleAsymFS list.
    for (FaultStatement fs : allFS) {
        int count = fs.getFaultDefinitions().size();
        for (FaultSubcomponent fc : fs.getFaultDefinitions()) {
            count--;
            if (fc instanceof PropagationTypeStatement) {
                if (((PropagationTypeStatement) fc).getPty() instanceof asymmetric) {
                    // Asym fault needs to be processed further and added to map.
                    String outputName = getOutputNameFromFaultStatement(fs);
                    if (outputName.isEmpty()) {
                        new SafetyException("Error processing asymmetric fault: the output name is undefined for fault statement:" + fs.getName());
                    } else {
                        List<FaultStatement> tempAsymFaults = new ArrayList<FaultStatement>();
                        tempAsymFaults.add(fs);
                        if (asymMap.containsKey(outputName)) {
                            asymMap.get(outputName).addAll(tempAsymFaults);
                        } else {
                            asymMap.put(outputName, tempAsymFaults);
                        }
                        break;
                    }
                } else {
                    // symmetric faults added to remainderFS list
                    remainderFS.add(fs);
                    break;
                }
            }
            // all definitions, then we have no prop type stmt. It is sym.
            if (count == 0) {
                remainderFS.add(fs);
            }
        }
    }
    // Add multiples to multiple list.
    for (String key : asymMap.keySet()) {
        if (asymMap.get(key).size() == 1) {
            remainderFS.addAll(asymMap.get(key));
        }
    }
}
Also used : FaultSubcomponent(edu.umn.cs.crisys.safety.safety.FaultSubcomponent) ArrayList(java.util.ArrayList) FaultStatement(edu.umn.cs.crisys.safety.safety.FaultStatement) HWFaultStatement(edu.umn.cs.crisys.safety.safety.HWFaultStatement) PropagationTypeStatement(edu.umn.cs.crisys.safety.safety.PropagationTypeStatement) edu.umn.cs.crisys.safety.safety.asymmetric(edu.umn.cs.crisys.safety.safety.asymmetric) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException) TransientConstraint(edu.umn.cs.crisys.safety.safety.TransientConstraint) PermanentConstraint(edu.umn.cs.crisys.safety.safety.PermanentConstraint) TemporalConstraint(edu.umn.cs.crisys.safety.safety.TemporalConstraint)

Example 3 with FaultSubcomponent

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

the class AddFaultsToNodeVisitor method isDisabled.

/**
 * Checks fault stmt for DisableStatement. If found, returns value of disable
 * statement. Else returns false.
 *
 * @param fs FaultStatement
 * @return bool: isDisabled
 */
private Boolean isDisabled(FaultStatement fs) {
    Boolean disableFound = false;
    List<FaultSubcomponent> subcomps = fs.getFaultDefinitions();
    for (FaultSubcomponent fsc : subcomps) {
        if (fsc instanceof DisableStatement) {
            disableFound = true;
            DisableStatement ds = (DisableStatement) fsc;
            BooleanLiteral bl = ds.getCond();
            return bl.getValue();
        }
    }
    return disableFound;
}
Also used : DisableStatement(edu.umn.cs.crisys.safety.safety.DisableStatement) FaultSubcomponent(edu.umn.cs.crisys.safety.safety.FaultSubcomponent) BooleanLiteral(org.osate.aadl2.BooleanLiteral)

Example 4 with FaultSubcomponent

use of edu.umn.cs.crisys.safety.safety.FaultSubcomponent 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 5 with FaultSubcomponent

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

Aggregations

FaultSubcomponent (edu.umn.cs.crisys.safety.safety.FaultSubcomponent)7 NamedElement (org.osate.aadl2.NamedElement)3 FaultStatement (edu.umn.cs.crisys.safety.safety.FaultStatement)2 OutputStatement (edu.umn.cs.crisys.safety.safety.OutputStatement)2 FaultStatementImpl (edu.umn.cs.crisys.safety.safety.impl.FaultStatementImpl)2 ProbabilityStatementImpl (edu.umn.cs.crisys.safety.safety.impl.ProbabilityStatementImpl)2 ArrayList (java.util.ArrayList)2 SpecStatement (com.rockwellcollins.atc.agree.agree.SpecStatement)1 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)1 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)1 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 DisableStatement (edu.umn.cs.crisys.safety.safety.DisableStatement)1 EqValue (edu.umn.cs.crisys.safety.safety.EqValue)1 HWFaultStatement (edu.umn.cs.crisys.safety.safety.HWFaultStatement)1 IntervalEq (edu.umn.cs.crisys.safety.safety.IntervalEq)1 PermanentConstraint (edu.umn.cs.crisys.safety.safety.PermanentConstraint)1 PropagationTypeStatement (edu.umn.cs.crisys.safety.safety.PropagationTypeStatement)1 SafetyEqStatement (edu.umn.cs.crisys.safety.safety.SafetyEqStatement)1