Search in sources :

Example 1 with HWFault

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

the class AddFaultsToNodeVisitor method addTopLevelFaultDeclarations.

/**
 * Method adds fault information to main node. This includes locals and inputs.
 * It also checks to see if IVC analysis is being performed. If so, the fault
 * indep vars are added to lustre (set equal to false) and given the IVC
 * command.
 *
 * @param currentNode Top node
 * @param nb          Node builder has assertions, locals, etc added.
 */
public void addTopLevelFaultDeclarations(AgreeNode currentNode, AgreeNodeBuilder nb) {
    List<Fault> faults = this.faultMap.get(currentNode.compInst);
    // whether or not fault is currently active.
    for (Fault f : faults) {
        String base = addPathDelimiters(f.path, f.id);
        nb.addInput(new AgreeVar(this.createFaultEventId(base), NamedType.BOOL, f.faultStatement));
        addFaultIndepVarsToLustre(base, f, nb);
        // Add dependent as per usual.
        nb.addInput(new AgreeVar(this.createFaultDependentActiveId(base), NamedType.BOOL, f.faultStatement));
        addToLustreFaultMap(base, f);
        // constrain fault-active depending on transient / permanent & map it to a
        // fault in the node interface
        // take the propagation map when constrainFaultActive
        constrainFaultActive(f, base, nb);
        mapFaultActiveToNodeInterface(f, f.path, base, nb);
    }
    List<HWFault> hwfaults = this.hwfaultMap.get(currentNode.compInst);
    addLocalsAndInputForHWFaults(hwfaults, nb);
    // Add hw faults to lustre fault mapping
    for (HWFault hwf : hwfaults) {
        String base = addPathDelimiters(hwf.path, hwf.id);
        addToLustreHWFaultMap(base, hwf);
    }
    for (AgreeNode n : currentNode.subNodes) {
        addTopLevelFaultDeclarations(n, nb);
    }
}
Also used : AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) 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) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 2 with HWFault

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

the class AddFaultsToNodeVisitor method collectFaultPath.

/**
 * Method updates fault map with the path, also sets path for each fault. (Path
 * corresponds to agree node.)
 *
 * @param currentNode Agree node with this fault.
 * @param path        Path name (node name)
 */
public void collectFaultPath(AgreeNode currentNode, List<String> path) {
    List<Fault> faults = this.faultMap.get(currentNode.compInst);
    List<HWFault> hwfaults = this.hwfaultMap.get(currentNode.compInst);
    // Add unconstrained input and constrained local to represent fault event and
    // whether or not fault is currently active.
    int index = 0;
    for (Fault f : faults) {
        // update fault name base
        f.setPath(path);
        // update fault list
        faults.set(index, f);
        index++;
    }
    // update faultMap
    this.faultMap.put(currentNode.compInst, faults);
    index = 0;
    for (HWFault hwf : hwfaults) {
        // update fault name base
        hwf.setPath(path);
        // update fault list
        hwfaults.set(index, hwf);
        index++;
    }
    // update faultMap
    this.faultMap.put(currentNode.compInst, faults);
    this.hwfaultMap.put(currentNode.compInst, hwfaults);
    // repeating it for the decendents of the node
    for (AgreeNode n : currentNode.subNodes) {
        List<String> ext = new ArrayList<>(path);
        ext.add(n.id);
        collectFaultPath(n, ext);
    }
}
Also used : AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) 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) 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 HWFault

use of edu.umn.cs.crisys.safety.analysis.transform.HWFault 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 4 with HWFault

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

the class AddFaultsToNodeVisitor method getFaultCountExprList.

/**
 * Get the list of faults that will contribute to the count.
 *
 * @param currentNode This agree node.
 * @param sumExprs    Expressions to be summed.
 */
public void getFaultCountExprList(AgreeNode currentNode, List<Expr> sumExprs) {
    List<Fault> faults = this.faultMap.get(currentNode.compInst);
    for (Fault f : faults) {
        // only add independently active fault to sumExprs
        String base = addPathDelimiters(f.path, f.id);
        sumExprs.add(createSumExpr(new IdExpr(this.createFaultIndependentActiveId(base))));
    }
    for (HWFault hwf : this.hwfaultMap.get(currentNode.compInst)) {
        String base = addPathDelimiters(hwf.path, hwf.id);
        sumExprs.add(createSumExpr(new IdExpr(this.createFaultIndependentActiveId(base))));
    }
    for (AgreeNode n : currentNode.subNodes) {
        // List<String> ext = new ArrayList<>(path);
        // ext.add(n.id);
        getFaultCountExprList(n, sumExprs);
    }
}
Also used : AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) IdExpr(jkind.lustre.IdExpr) 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 5 with HWFault

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

the class AddFaultsToNodeVisitor method visit.

// ////////////////////////////////////////////////////////////////
// 
// AGREE NODE TRAVERSAL STARTS HERE.
// 
// /////////////////////////////////////////////////////////////////
@Override
public AgreeNode visit(AgreeNode node) {
    Map<String, List<Pair>> parentFaultyVarsExpr = faultyVarsExpr;
    boolean isTop = (node == this.topNode);
    // Gather non-hardware (dependent) faults
    List<Fault> faults = gatherFaults(globalLustreNodes, node, isTop);
    // Gather HW faults
    List<HWFault> hwFaults = gatherHWFaults(globalLustreNodes, node, isTop);
    // Rename var names in faults: fault_varName
    faults = renameFaultEqs(faults);
    if (faultMap.containsKey(node.compInst) || hwfaultMap.containsKey(node.compInst)) {
        throw new SafetyException("Node: " + node.id + " has been visited twice.");
    }
    faultMap.put(node.compInst, faults);
    hwfaultMap.put(node.compInst, hwFaults);
    faultyVarsExpr = gatherFaultyOutputs(faults, node);
    // this will traverse through the child nodes
    node = super.visit(node);
    AgreeNodeBuilder nb = new AgreeNodeBuilder(node);
    // Change this nodes flag to reflect fault tree generation or not.
    if (AddFaultsToAgree.getIsGenMCS()) {
        nb.setFaultTreeFlag(true);
    }
    // If asymmetric, only add fault triggers to agree node.
    for (Fault f : faults) {
        if ((f.propType == null) || (f.propType.getPty() instanceof symmetric)) {
            addFaultInputs(f, nb);
            addFaultLocalEqsAndAsserts(f, nb);
        } else {
            addFaultInputs(f, nb);
        }
    }
    addHWFaultInputs(hwFaults, nb);
    addToMutualExclusionList();
    addNominalVars(node, nb);
    addFaultNodeEqs(faults, nb);
    if (isTop) {
        topNodeVisit(nb, node);
    }
    node = nb.build();
    faultyVarsExpr = parentFaultyVarsExpr;
    // for asymmetric faults.
    if (!this.mapSenderToReceiver.isEmpty() && isTop) {
        SafetyNodeBuilder sb = changeTopNodeAsymConnections(nb, node);
        return sb.build();
    } else {
        return node;
    }
}
Also used : SafetyNodeBuilder(edu.umn.cs.crisys.safety.analysis.ast.SafetyNodeBuilder) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) 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) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException) AgreeNodeBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder) HWFault(edu.umn.cs.crisys.safety.analysis.transform.HWFault) edu.umn.cs.crisys.safety.safety.asymmetric(edu.umn.cs.crisys.safety.safety.asymmetric) edu.umn.cs.crisys.safety.safety.symmetric(edu.umn.cs.crisys.safety.safety.symmetric)

Aggregations

HWFault (edu.umn.cs.crisys.safety.analysis.transform.HWFault)8 BaseFault (edu.umn.cs.crisys.safety.analysis.transform.BaseFault)6 Fault (edu.umn.cs.crisys.safety.analysis.transform.Fault)6 ArrayList (java.util.ArrayList)4 AgreeNode (com.rockwellcollins.atc.agree.analysis.ast.AgreeNode)3 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)2 IdExpr (jkind.lustre.IdExpr)2 AgreeNodeBuilder (com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder)1 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)1 SafetyNodeBuilder (edu.umn.cs.crisys.safety.analysis.ast.SafetyNodeBuilder)1 SafetyPropagation (edu.umn.cs.crisys.safety.analysis.ast.SafetyPropagation)1 HWFaultASTBuilder (edu.umn.cs.crisys.safety.analysis.transform.HWFaultASTBuilder)1 HWFaultStatement (edu.umn.cs.crisys.safety.safety.HWFaultStatement)1 PermanentConstraint (edu.umn.cs.crisys.safety.safety.PermanentConstraint)1 SpecStatement (edu.umn.cs.crisys.safety.safety.SpecStatement)1 TemporalConstraint (edu.umn.cs.crisys.safety.safety.TemporalConstraint)1 TransientConstraint (edu.umn.cs.crisys.safety.safety.TransientConstraint)1 edu.umn.cs.crisys.safety.safety.asymmetric (edu.umn.cs.crisys.safety.safety.asymmetric)1 edu.umn.cs.crisys.safety.safety.symmetric (edu.umn.cs.crisys.safety.safety.symmetric)1 List (java.util.List)1