Search in sources :

Example 36 with AgreeVar

use of com.rockwellcollins.atc.agree.analysis.ast.AgreeVar 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 37 with AgreeVar

use of com.rockwellcollins.atc.agree.analysis.ast.AgreeVar in project AMASE by loonwerks.

the class AddFaultsToNodeVisitor method faultToActual.

/**
 * Finds the lustre expr for output that fault is attached to. Ex: val_out ->
 * Sender__fault_3__node__val_out
 *
 * @param f  Fault in question
 * @param ex Expression of output
 * @return Lustre expression with id set correctly.
 */
private Expr faultToActual(Fault f, Expr ex) {
    // Match pair.ex -> key of faultOutputMap
    // If this expression is not in map, return exception message
    String outputName = f.faultOutputMap.get(ex);
    if (outputName == null) {
        new SafetyException("Cannot find fault output for fault " + f.id);
    }
    // Use outputName to get value from outputParamToActualMap
    AgreeVar actual = f.outputParamToActualMap.get(outputName);
    if (f.outputParamToActualMap.isEmpty()) {
        new SafetyException("Something went wrong with fault output parameter. Fault is: " + f.id + " and expr is: " + ex.toString());
    }
    // Create IdExpr out of actual string
    return new IdExpr(actual.id);
}
Also used : IdExpr(jkind.lustre.IdExpr) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 38 with AgreeVar

use of com.rockwellcollins.atc.agree.analysis.ast.AgreeVar in project AMASE by loonwerks.

the class AddFaultsToNodeVisitor method addNodeCall.

/**
 * Method adds fault node call and nested trigger expression to the node
 * builder. Ex fault node call: Sender__fault_1__node__val_out =
 * Common_Faults__fail_to_real(__fault__nominal__sender_out, 1.0,
 * fault__trigger__Sender__fault_1);
 *
 * Ex nested trigger expr: agree_node_output = if fault__trigger_1 then
 * fault__node_1__val_out else if fault__trigger_2 then fault__node_2__val_out
 * ... else __fault__nominal__output)
 *
 * @param nb NodeBuilder has these expressions added in assert stmts.
 * @param f  Fault that holds this fault node call information.
 */
private void addNodeCall(AgreeNodeBuilder nb, Fault f, Map<Fault, Expr> localFaultTriggerMap) {
    List<IdExpr> lhsOfNodeCall = new ArrayList<IdExpr>();
    // populate outputParamToActualMap
    for (VarDecl v : f.faultNode.outputs) {
        String lhsId = this.createFaultNodeEqId(f.id, v.id);
        AgreeVar actual = new AgreeVar(lhsId, v.type, f.faultStatement);
        nb.addLocal(actual);
        lhsOfNodeCall.add(new IdExpr(lhsId));
        f.outputParamToActualMap.put(v.id, actual);
    }
    // Call fault node and put this into lustre node as local equation.
    AgreeEquation eq = new AgreeEquation(lhsOfNodeCall, new NodeCallExpr(f.faultNode.id, constructNodeInputs(f, localFaultTriggerMap)), f.faultStatement);
    nb.addLocalEquation(eq);
}
Also used : IdExpr(jkind.lustre.IdExpr) VarDecl(jkind.lustre.VarDecl) NodeCallExpr(jkind.lustre.NodeCallExpr) ArrayList(java.util.ArrayList) AgreeEquation(com.rockwellcollins.atc.agree.analysis.ast.AgreeEquation) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 39 with AgreeVar

use of com.rockwellcollins.atc.agree.analysis.ast.AgreeVar in project AMASE by loonwerks.

the class AddFaultsToNodeVisitor method addAssumeHistStmts.

/**
 * Method is used to assert that the assume hist statements for each comm node
 * is true. This is added to main. Ex: assert
 * (asym_node_0__Sender__sender_out____ASSUME__HIST = __HIST(true));
 *
 * @param nb NodeBuilder that will have these assertions added.
 */
private void addAssumeHistStmts(AgreeNodeBuilder nb) {
    for (String commNodes : mapCommNodeToInputs.keySet()) {
        List<AgreeVar> inputs = mapCommNodeToInputs.get(commNodes);
        for (AgreeVar input : inputs) {
            if (input.id.contains("__ASSUME__HIST")) {
                NodeCallExpr nodeCall = new NodeCallExpr("__HIST", new BoolExpr(true));
                Expr eq = new BinaryExpr(new IdExpr(input.id), BinaryOp.EQUAL, nodeCall);
                nb.addAssertion(new AgreeStatement("", eq, topNode.reference));
                break;
            }
        }
    }
}
Also used : BoolExpr(jkind.lustre.BoolExpr) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) RecordAccessExpr(jkind.lustre.RecordAccessExpr) UnaryExpr(jkind.lustre.UnaryExpr) Expr(jkind.lustre.Expr) IntExpr(jkind.lustre.IntExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) IdExpr(jkind.lustre.IdExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) BinaryExpr(jkind.lustre.BinaryExpr) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 40 with AgreeVar

use of com.rockwellcollins.atc.agree.analysis.ast.AgreeVar in project AMASE by loonwerks.

the class AddFaultsToNodeVisitor method addLocalsForCommNodes.

/**
 * Method is used when asymmetric fault is being added to the top node. It adds
 * all locals to the top node that are present in new comm nodes. Ex:
 * asym_node_1__Sender__input : Base_Types__Float; asym_node_1__Sender__output :
 * Base_Types__Float; asym_node_1__Sender____ASSUME__HIST : bool;
 *
 * ... etc
 *
 * @param nb NodeBuilder that will have this information added.
 */
private void addLocalsForCommNodes(AgreeNodeBuilder nb) {
    // Access inputs for each comm node.
    for (String commNodes : mapCommNodeToInputs.keySet()) {
        List<AgreeVar> inputs = mapCommNodeToInputs.get(commNodes);
        List<AgreeVar> inputsToAdd = new ArrayList<AgreeVar>();
        List<AgreeVar> intputsToRemove = new ArrayList<AgreeVar>();
        for (AgreeVar var : inputs) {
            if (!(var.id.contains(commNodes))) {
                // Create new AgreeVar with new id
                AgreeVar newVar = new AgreeVar(commNodes + "__" + var.id, var.type, var.reference);
                // Delete old agree var
                intputsToRemove.add(var);
                inputsToAdd.add(newVar);
            }
        }
        for (AgreeVar varToAdd : inputsToAdd) {
            inputs.add(varToAdd);
        }
        for (AgreeVar varToRemove : intputsToRemove) {
            inputs.remove(varToRemove);
        }
        nb.addInput(mapCommNodeToInputs.get(commNodes));
    }
}
Also used : ArrayList(java.util.ArrayList) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Aggregations

AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)69 IdExpr (jkind.lustre.IdExpr)49 Expr (jkind.lustre.Expr)45 NodeCallExpr (jkind.lustre.NodeCallExpr)42 BinaryExpr (jkind.lustre.BinaryExpr)41 AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)39 BoolExpr (jkind.lustre.BoolExpr)38 UnaryExpr (jkind.lustre.UnaryExpr)37 ArrayList (java.util.ArrayList)28 IfThenElseExpr (jkind.lustre.IfThenElseExpr)25 VarDecl (jkind.lustre.VarDecl)19 Equation (jkind.lustre.Equation)15 RealExpr (jkind.lustre.RealExpr)15 AgreeEquation (com.rockwellcollins.atc.agree.analysis.ast.AgreeEquation)14 AgreeNode (com.rockwellcollins.atc.agree.analysis.ast.AgreeNode)13 IntExpr (jkind.lustre.IntExpr)13 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)12 AgreeNodeBuilder (com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder)12 NodeBuilder (jkind.lustre.builders.NodeBuilder)11 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)9