Search in sources :

Example 1 with BaseFault

use of edu.umn.cs.crisys.safety.analysis.transform.BaseFault in project AMASE by loonwerks.

the class AddFaultsToNodeVisitor method findFaultInCompInst.

/**
 * Identify the fault associated with a ComponentInstance given the fault name
 * and the component path.
 *
 * @param faultName      Name of fault to be found
 * @param faultComp_Path Component instance path
 * @return Fault with name matching string.
 */
public BaseFault findFaultInCompInst(String faultName, NamedElement faultComp_Path) {
    List<ComponentInstance> compInsts = new ArrayList<ComponentInstance>(faultMap.keySet());
    for (ComponentInstance compInst : compInsts) {
        if (compInst.getName().equals(faultComp_Path.getName())) {
            List<Fault> faults = new ArrayList<Fault>(faultMap.get(compInst));
            for (Fault fault : faults) {
                if (fault.name.equals(faultName)) {
                    return fault;
                }
            }
        }
    }
    compInsts = new ArrayList<ComponentInstance>(hwfaultMap.keySet());
    for (ComponentInstance compInst : compInsts) {
        if (compInst.getName().equals(faultComp_Path.getName())) {
            List<HWFault> hwfaults = new ArrayList<HWFault>(hwfaultMap.get(compInst));
            for (HWFault hwfault : hwfaults) {
                if (hwfault.name.equals(faultName)) {
                    return hwfault;
                }
            }
        }
    }
    return null;
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ArrayList(java.util.ArrayList) HWFault(edu.umn.cs.crisys.safety.analysis.transform.HWFault) BaseFault(edu.umn.cs.crisys.safety.analysis.transform.BaseFault) Fault(edu.umn.cs.crisys.safety.analysis.transform.Fault) HWFault(edu.umn.cs.crisys.safety.analysis.transform.HWFault)

Example 2 with BaseFault

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

Example 3 with BaseFault

use of edu.umn.cs.crisys.safety.analysis.transform.BaseFault in project AMASE by loonwerks.

the class AddFaultsToNodeVisitor method getSrcFaultExprList.

/**
 * Method collect the list of expressions for the source faults in the
 * propagations whose target fault is the current fault.
 *
 * @param f          Fault in question (base fault)
 * @param faultExprs List of all fault expressions.
 */
public void getSrcFaultExprList(BaseFault f, List<Expr> faultExprs) {
    for (SafetyPropagation propagation : propagations) {
        if (propagation.destFault.equals(f)) {
            if (propagation.srcFault instanceof HWFault) {
                // use the triggering event for HW fault in the src fault expr, so to get the
                // effect
                // from both hw dependent and hw independent faults
                String interfaceVarId = addPathDelimiters(((HWFault) propagation.srcFault).path, this.createFaultNodeTriggerId(((HWFault) propagation.srcFault).id));
                faultExprs.add(new IdExpr(interfaceVarId));
            } else if (propagation.srcFault instanceof Fault) {
                String base = addPathDelimiters(((Fault) propagation.srcFault).path, ((Fault) propagation.srcFault).id);
                faultExprs.add(new IdExpr(this.createFaultIndependentActiveId(base)));
            }
        }
    }
}
Also used : IdExpr(jkind.lustre.IdExpr) SafetyPropagation(edu.umn.cs.crisys.safety.analysis.ast.SafetyPropagation) HWFault(edu.umn.cs.crisys.safety.analysis.transform.HWFault) BaseFault(edu.umn.cs.crisys.safety.analysis.transform.BaseFault) Fault(edu.umn.cs.crisys.safety.analysis.transform.Fault) HWFault(edu.umn.cs.crisys.safety.analysis.transform.HWFault)

Example 4 with BaseFault

use of edu.umn.cs.crisys.safety.analysis.transform.BaseFault in project AMASE by loonwerks.

the class AddFaultsToNodeVisitor method gatherFaultPropagation.

/**
 * Method gathers source and destination faults for hardware (dependent) faults.
 * Adds these to propagations list.
 *
 * @param node Agree Node with these spec statements.
 */
public void gatherFaultPropagation(AgreeNode node) {
    List<SpecStatement> specs = SafetyUtil.collapseAnnexes(SafetyUtil.getSafetyAnnexes(node, true));
    for (SpecStatement s : specs) {
        if (s instanceof PropagateStatement) {
            PropagateStatement ps = (PropagateStatement) s;
            Iterator<String> srcFaultIt = ps.getSrcFaultList().iterator();
            Iterator<NamedElement> srcCompPathIt = ps.getSrcComp_path().iterator();
            // create a SafetyPropagation
            BaseFault srcFault = null;
            // for each src fault name and path, locate the fault
            while (srcFaultIt.hasNext() && srcCompPathIt.hasNext()) {
                NamedElement srcCompPath = srcCompPathIt.next();
                String srcFaultName = srcFaultIt.next();
                srcFault = findFaultInCompInst(srcFaultName, srcCompPath);
                if (srcFault != null) {
                    // for each destination fault name and path, locate the fault
                    BaseFault destFault = null;
                    Iterator<String> destFaultIt = ps.getDestFaultList().iterator();
                    Iterator<NamedElement> destCompPathIt = ps.getDestComp_path().iterator();
                    while (destFaultIt.hasNext() && destCompPathIt.hasNext()) {
                        NamedElement destCompPath = destCompPathIt.next();
                        String destFaultName = destFaultIt.next();
                        destFault = findFaultInCompInst(destFaultName, destCompPath);
                        SafetyPropagation propagation = new SafetyPropagation(srcFault, destFault);
                        propagations.add(propagation);
                    }
                } else {
                    throw new SafetyException("Unable to identify fault in propagation statement:" + " a possibility is that the source or destination fault is disabled.");
                }
            }
        }
    }
}
Also used : BaseFault(edu.umn.cs.crisys.safety.analysis.transform.BaseFault) SafetyPropagation(edu.umn.cs.crisys.safety.analysis.ast.SafetyPropagation) SpecStatement(edu.umn.cs.crisys.safety.safety.SpecStatement) PropagateStatement(edu.umn.cs.crisys.safety.safety.PropagateStatement) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException) NamedElement(org.osate.aadl2.NamedElement)

Example 5 with BaseFault

use of edu.umn.cs.crisys.safety.analysis.transform.BaseFault in project AMASE by loonwerks.

the class AddFaultsToNodeVisitor method adjustForDependentFaults.

/**
 * Method adjusts allowable combinations for the dependent faults.
 *
 * If the propagations set is not empty, then for each fault in each valid fault
 * combination, see if it appears as a source fault in the propagations. If yes,
 * insert the destination fault in the same valid fault combination (fault set)
 * without changing the fault set's probability.
 *
 * @param faultCombinationsAboveThreshold Allowable combinations
 * @param elementProbabilities            Prob of elements
 */
private void adjustForDependentFaults(ArrayList<FaultSetProbability> faultCombinationsAboveThreshold, ArrayList<FaultProbability> elementProbabilities) {
    if (!propagations.isEmpty()) {
        int index = 0;
        // go through the fault combinations
        for (FaultSetProbability fsp : faultCombinationsAboveThreshold) {
            FaultSetProbability currentSet = fsp;
            boolean changed = false;
            // for each fault probability in a combination set
            for (FaultProbability fp : fsp.elements) {
                // see if the fault appears as a source fault in a propagation
                for (SafetyPropagation propagation : propagations) {
                    // if yes, get the destination fault
                    if (propagation.srcFault.equals(fp.fault)) {
                        BaseFault newFault = propagation.destFault;
                        changed = true;
                        // will be removed from the original list later)
                        for (FaultProbability element : elementProbabilities) {
                            if (newFault.equals(element.fault)) {
                                currentSet = new FaultSetProbability(fsp.probability, currentSet, element);
                            }
                        }
                    }
                }
            }
            if (changed) {
                faultCombinationsAboveThreshold.set(index, currentSet);
            }
            index++;
        }
    }
}
Also used : BaseFault(edu.umn.cs.crisys.safety.analysis.transform.BaseFault) SafetyPropagation(edu.umn.cs.crisys.safety.analysis.ast.SafetyPropagation) TransientConstraint(edu.umn.cs.crisys.safety.safety.TransientConstraint) PermanentConstraint(edu.umn.cs.crisys.safety.safety.PermanentConstraint) TemporalConstraint(edu.umn.cs.crisys.safety.safety.TemporalConstraint)

Aggregations

BaseFault (edu.umn.cs.crisys.safety.analysis.transform.BaseFault)5 SafetyPropagation (edu.umn.cs.crisys.safety.analysis.ast.SafetyPropagation)3 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)2 Fault (edu.umn.cs.crisys.safety.analysis.transform.Fault)2 HWFault (edu.umn.cs.crisys.safety.analysis.transform.HWFault)2 SpecStatement (edu.umn.cs.crisys.safety.safety.SpecStatement)2 NamedElement (org.osate.aadl2.NamedElement)2 FaultActivationAssignment (edu.umn.cs.crisys.safety.analysis.ast.FaultActivationAssignment)1 ActivationStatement (edu.umn.cs.crisys.safety.safety.ActivationStatement)1 PermanentConstraint (edu.umn.cs.crisys.safety.safety.PermanentConstraint)1 PropagateStatement (edu.umn.cs.crisys.safety.safety.PropagateStatement)1 TemporalConstraint (edu.umn.cs.crisys.safety.safety.TemporalConstraint)1 TransientConstraint (edu.umn.cs.crisys.safety.safety.TransientConstraint)1 ArrayList (java.util.ArrayList)1 IdExpr (jkind.lustre.IdExpr)1 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)1