Search in sources :

Example 1 with FaultActivationAssignment

use of edu.umn.cs.crisys.safety.analysis.ast.FaultActivationAssignment in project AMASE by loonwerks.

the class AddFaultsToNodeVisitor method gatherFaultActivation.

/**
 * Gathers list of fault activations for hardware faults. Adds to
 * faultActivations list.
 *
 * @param node Agree node with these spec statements.
 */
private void gatherFaultActivation(AgreeNode node) {
    List<SpecStatement> specs = SafetyUtil.collapseAnnexes(SafetyUtil.getSafetyAnnexes(node, true));
    for (SpecStatement s : specs) {
        if (s instanceof ActivationStatement) {
            ActivationStatement as = (ActivationStatement) s;
            String agreeBoolVarName = as.getAgreeBoolVarName();
            // the following can be null
            NamedElement agreeComp_Path = as.getAgreeComp_Path();
            String agreeBoolVarPrefix = "";
            if (agreeComp_Path != null) {
                agreeBoolVarPrefix = agreeComp_Path.getName() + "__";
            }
            // compose agreeBoolVarName in main node input
            agreeBoolVarName = agreeBoolVarPrefix + agreeBoolVarName;
            String faultName = as.getFaultName();
            // the following can be null
            NamedElement faultComp_Path = as.getFaultComp_Path();
            BaseFault fault = null;
            if (faultComp_Path != null) {
                fault = findFaultInCompInst(faultName, faultComp_Path);
            }
            if (fault != null) {
                FaultActivationAssignment faultActAssign = new FaultActivationAssignment(agreeBoolVarName, fault, faultComp_Path.getName());
                faultActivations.add(faultActAssign);
            } else {
                throw new SafetyException("Unable to identify fault in fault activation statement:" + " a possibility is that this fault is disabled.");
            }
        }
    }
}
Also used : BaseFault(edu.umn.cs.crisys.safety.analysis.transform.BaseFault) SpecStatement(edu.umn.cs.crisys.safety.safety.SpecStatement) ActivationStatement(edu.umn.cs.crisys.safety.safety.ActivationStatement) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException) NamedElement(org.osate.aadl2.NamedElement) FaultActivationAssignment(edu.umn.cs.crisys.safety.analysis.ast.FaultActivationAssignment)

Aggregations

SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)1 FaultActivationAssignment (edu.umn.cs.crisys.safety.analysis.ast.FaultActivationAssignment)1 BaseFault (edu.umn.cs.crisys.safety.analysis.transform.BaseFault)1 ActivationStatement (edu.umn.cs.crisys.safety.safety.ActivationStatement)1 SpecStatement (edu.umn.cs.crisys.safety.safety.SpecStatement)1 NamedElement (org.osate.aadl2.NamedElement)1