Search in sources :

Example 16 with AgreeNode

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

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

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

the class AddFaultsToNodeVisitor method getFaultProbExprList.

/**
 * Get probabilities of all faults.
 *
 * @param currentNode   Agree node we are visiting currently
 * @param path          path to this agree node
 * @param probabilities prob list
 */
public void getFaultProbExprList(AgreeNode currentNode, List<String> path, List<FaultProbability> probabilities) {
    List<Fault> faults = this.faultMap.get(currentNode.compInst);
    for (Fault f : faults) {
        String base = addPathDelimiters(path, f.id);
        probabilities.add(new FaultProbability(this.createFaultIndependentActiveId(base), f.probability, f));
    }
    for (AgreeNode n : currentNode.subNodes) {
        List<String> ext = new ArrayList<>(path);
        ext.add(n.id);
        getFaultProbExprList(n, ext, probabilities);
    }
}
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)

Example 19 with AgreeNode

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

use of com.rockwellcollins.atc.agree.analysis.ast.AgreeNode in project AGREE by loonwerks.

the class AgreePatternTranslator method translateNode.

private AgreeNode translateNode(AgreeNode node, boolean isTopNode) {
    AgreeNodeBuilder builder = new AgreeNodeBuilder(node);
    // this has to be done first because the pattern translation
    // for guarantees/lemmas/assumptions add additional assertions
    builder.clearAssertions();
    createTimeFunctions(node, builder);
    for (AgreeStatement statement : node.assertions) {
        if (statement instanceof AgreePattern) {
            containsRealTimePatterns = true;
            Expr transExpr = translatePattern((AgreePattern) statement, builder, false);
            statement = new AgreeStatement(statement.string, transExpr, statement.reference);
        }
        builder.addAssertion(statement);
    }
    builder.clearGuarantees();
    for (AgreeStatement statement : node.guarantees) {
        if (statement instanceof AgreePattern) {
            containsRealTimePatterns = true;
            Expr transExpr = translatePattern((AgreePattern) statement, builder, isTopNode);
            statement = new AgreeStatement(statement.string, transExpr, statement.reference);
        }
        builder.addGuarantee(statement);
    }
    builder.clearLemmas();
    for (AgreeStatement statement : node.lemmas) {
        if (statement instanceof AgreePattern) {
            containsRealTimePatterns = true;
            Expr transExpr = translatePattern((AgreePattern) statement, builder, isTopNode);
            statement = new AgreeStatement(statement.string, transExpr, statement.reference);
        }
        builder.addLemma(statement);
    }
    builder.clearAssumptions();
    for (AgreeStatement statement : node.assumptions) {
        if (statement instanceof AgreePattern) {
            containsRealTimePatterns = true;
            Expr transExpr = translatePattern((AgreePattern) statement, builder, !isTopNode);
            statement = new AgreeStatement(statement.string, transExpr, statement.reference);
        }
        builder.addAssumption(statement);
    }
    builder.clearSubNodes();
    for (AgreeNode subNode : node.subNodes) {
        builder.addSubNode(new AgreePatternTranslator().translateNode(subNode, false));
    }
    builder.addInput(new AgreeVar(timeExpr.id, NamedType.REAL, null, node.compInst, null));
    return builder.build();
}
Also used : AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) UnaryExpr(jkind.lustre.UnaryExpr) Expr(jkind.lustre.Expr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) AgreeNodeBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Aggregations

AgreeNode (com.rockwellcollins.atc.agree.analysis.ast.AgreeNode)30 ArrayList (java.util.ArrayList)17 Node (jkind.lustre.Node)15 AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)13 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)13 IdExpr (jkind.lustre.IdExpr)12 AgreeNodeBuilder (com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder)11 Expr (jkind.lustre.Expr)11 NodeCallExpr (jkind.lustre.NodeCallExpr)10 AgreeProgram (com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram)9 BinaryExpr (jkind.lustre.BinaryExpr)9 BoolExpr (jkind.lustre.BoolExpr)9 UnaryExpr (jkind.lustre.UnaryExpr)9 Program (jkind.lustre.Program)7 TypeDef (jkind.lustre.TypeDef)7 ProgramBuilder (jkind.lustre.builders.ProgramBuilder)7 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)6 AgreeEquation (com.rockwellcollins.atc.agree.analysis.ast.AgreeEquation)6 VarDecl (jkind.lustre.VarDecl)6 Equation (jkind.lustre.Equation)5