Search in sources :

Example 11 with NodeCallExpr

use of jkind.lustre.NodeCallExpr in project AGREE by loonwerks.

the class AgreePatternTranslator method getTimeFall.

private AgreeVar getTimeFall(String varName, AgreeNodeBuilder builder, EObject reference) {
    Map<String, AgreeVar> timeFallMap = builder.build().timeFallMap;
    if (timeFallMap.containsKey(varName)) {
        return timeFallMap.get(varName);
    }
    AgreeVar timeFall = new AgreeVar(varName + FALL_SUFFIX, NamedType.REAL, reference);
    builder.addOutput(timeFall);
    Expr Fall = new NodeCallExpr(AgreeRealtimeCalendarBuilder.FALL_NODE_NAME, new IdExpr(varName));
    Expr timeVarExpr = expr("timeFall = (if Fall then time else (-1.0 -> pre timeFall))", to("timeFall", timeFall), to("Fall", Fall), to("time", timeExpr));
    builder.addAssertion(new AgreeStatement(null, timeVarExpr, reference));
    Expr lemmaExpr = expr("timeFall <= time and timeFall >= -1.0", to("timeFall", timeFall), to("time", timeExpr));
    // add this assertion to help with proofs (it should always be true)
    builder.addAssertion(new AgreeStatement("", lemmaExpr, reference));
    builder.addTimeFall(varName, timeFall);
    return timeFall;
}
Also used : AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) 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) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 12 with NodeCallExpr

use of jkind.lustre.NodeCallExpr in project AGREE by loonwerks.

the class AgreeRealtimeCalendarBuilder method getTimeConstraint.

public static Expr getTimeConstraint(Set<AgreeVar> events) {
    IdExpr timeId = AgreePatternTranslator.timeExpr;
    Expr preTime = new UnaryExpr(UnaryOp.PRE, timeId);
    Expr nodeCall = new BinaryExpr(timeId, BinaryOp.MINUS, preTime);
    for (AgreeVar eventVar : events) {
        Expr event = new IdExpr(eventVar.id);
        BinaryExpr timeChange = new BinaryExpr(event, BinaryOp.MINUS, timeId);
        Expr preTimeChange = new UnaryExpr(UnaryOp.PRE, timeChange);
        nodeCall = new NodeCallExpr(MIN_POS_NODE_NAME, preTimeChange, nodeCall);
    }
    nodeCall = new BinaryExpr(preTime, BinaryOp.PLUS, nodeCall);
    Expr timeExpr = new BinaryExpr(timeId, BinaryOp.EQUAL, nodeCall);
    timeExpr = new BinaryExpr(new BoolExpr(true), BinaryOp.ARROW, timeExpr);
    Expr timeGrtPreTime = new BinaryExpr(timeId, BinaryOp.GREATER, preTime);
    Expr timeInitZero = new BinaryExpr(timeId, BinaryOp.EQUAL, new RealExpr(BigDecimal.ZERO));
    timeInitZero = new BinaryExpr(timeInitZero, BinaryOp.ARROW, timeGrtPreTime);
    return new BinaryExpr(timeInitZero, BinaryOp.AND, timeExpr);
}
Also used : BoolExpr(jkind.lustre.BoolExpr) IdExpr(jkind.lustre.IdExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) UnaryExpr(jkind.lustre.UnaryExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) Expr(jkind.lustre.Expr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) BinaryExpr(jkind.lustre.BinaryExpr) UnaryExpr(jkind.lustre.UnaryExpr) RealExpr(jkind.lustre.RealExpr) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 13 with NodeCallExpr

use of jkind.lustre.NodeCallExpr in project AGREE by loonwerks.

the class LustreCondactNodeVisitor method visit.

@Override
public Expr visit(NodeCallExpr e) {
    if (globalLustreNodeNames.contains(e.node)) {
        List<Expr> newArgs = new ArrayList<>();
        newArgs.add(new IdExpr(clockVarName));
        newArgs.add(new IdExpr(initVarName));
        newArgs.addAll(acceptList(e.args));
        return new NodeCallExpr(AgreeMakeClockedLustreNodes.clockedNodePrefix + e.node, newArgs);
    } else {
        return new NodeCallExpr(e.node, acceptList(e.args));
    }
}
Also used : BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) UnaryExpr(jkind.lustre.UnaryExpr) CondactExpr(jkind.lustre.CondactExpr) Expr(jkind.lustre.Expr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) ArrayList(java.util.ArrayList)

Example 14 with NodeCallExpr

use of jkind.lustre.NodeCallExpr in project AGREE by loonwerks.

the class LinearizationAgreeASTVisitor method visit.

@Override
public Expr visit(NodeCallExpr e) {
    // If the call is to a linearization, generate ephemeral
    // var and constraint then substitute an id expr to the ephemeral
    // var for the fn call.
    String linCallDef = linearizationMap.get(e.node);
    if (linCallDef != null) {
        AgreeVar ephemeral = new AgreeVar(ephemeralBaseName + Integer.toString(ephemeralIndex), jkind.lustre.NamedType.REAL, null, contextStack.peek().componentInstance, null);
        ++ephemeralIndex;
        List<Expr> args = visitExprs(e.args);
        args.add(new jkind.lustre.IdExpr(ephemeral.id));
        jkind.lustre.NodeCallExpr constraintExpr = new jkind.lustre.NodeCallExpr(linCallDef, args);
        contextStack.peek().addedVars.add(ephemeral);
        contextStack.peek().liftedConstraintExprs.add(constraintExpr);
        return new jkind.lustre.IdExpr(ephemeral.id);
    }
    return new NodeCallExpr(e.location, e.node, visitExprs(e.args));
}
Also used : NodeCallExpr(jkind.lustre.NodeCallExpr) Expr(jkind.lustre.Expr) NodeCallExpr(jkind.lustre.NodeCallExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 15 with NodeCallExpr

use of jkind.lustre.NodeCallExpr 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)

Aggregations

NodeCallExpr (jkind.lustre.NodeCallExpr)21 Expr (jkind.lustre.Expr)20 IdExpr (jkind.lustre.IdExpr)20 BinaryExpr (jkind.lustre.BinaryExpr)17 BoolExpr (jkind.lustre.BoolExpr)16 UnaryExpr (jkind.lustre.UnaryExpr)15 ArrayList (java.util.ArrayList)13 IfThenElseExpr (jkind.lustre.IfThenElseExpr)13 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)9 IntExpr (jkind.lustre.IntExpr)7 RecordAccessExpr (jkind.lustre.RecordAccessExpr)7 TupleExpr (jkind.lustre.TupleExpr)7 AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)6 Node (jkind.lustre.Node)6 ArrayAccessExpr (jkind.lustre.ArrayAccessExpr)5 RealExpr (jkind.lustre.RealExpr)5 CondactExpr (jkind.lustre.CondactExpr)4 VarDecl (jkind.lustre.VarDecl)4 ArrayLiteralExpr (com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr)3 ArraySubExpr (com.rockwellcollins.atc.agree.agree.ArraySubExpr)3