Search in sources :

Example 1 with AgreeConnection

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

the class AgreeASTPrettyprinter method visit.

@Override
public Void visit(AgreeNode node) {
    write("agree node ");
    write(node.id);
    write("(");
    newline();
    agreeVarDecls(node.inputs);
    newline();
    write(") returns (");
    newline();
    agreeVarDecls(node.outputs);
    newline();
    write(");");
    newline();
    if (!node.locals.isEmpty()) {
        write("var");
        newline();
        agreeVarDecls(node.locals);
        write(";");
        newline();
    }
    if (node.id.equals(main)) {
        write("  --%MAIN;");
        newline();
    }
    write("let");
    newline();
    if (!node.connections.isEmpty()) {
        for (AgreeConnection connection : node.connections) {
            connection(connection);
        }
        newline();
    }
    write("  children {");
    for (AgreeNode subNode : node.subNodes) {
        write(subNode.id);
        write(" ");
    }
    write("  }");
    newline();
    newline();
    statementList("assertions", node.assertions);
    statementList("assumptions", node.assumptions);
    statementList("guarantees", node.guarantees);
    statementList("lemmas", node.lemmas);
    statementList("pattern props", node.patternProps);
    for (AgreeEquation equation : node.localEquations) {
        write("  ");
        visit(equation);
        newline();
        newline();
    }
    if (node.clockConstraint != null) {
        write("  clock constraint: ");
        node.clockConstraint.accept(this);
        newline();
    }
    if (node.initialConstraint != null) {
        write("  initial constraint: ");
        node.initialConstraint.accept(this);
        newline();
    }
    if (node.clockVar != null) {
        write("  clock variable: ");
        visit(node.clockVar);
        newline();
    }
    write("  timing model: " + node.timing);
    newline();
    write("  -- TBD: event models to go along with timing model");
    newline();
    newline();
    write("tel;");
    return null;
}
Also used : AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) AgreeConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeConnection) AgreeEquation(com.rockwellcollins.atc.agree.analysis.ast.AgreeEquation)

Example 2 with AgreeConnection

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

the class AgreeASTMapVisitor method visit.

@Override
public AgreeNode visit(AgreeNode e) {
    String id = e.id;
    List<AgreeVar> inputs = new ArrayList<>();
    for (AgreeVar input : e.inputs) {
        inputs.add(this.visit(input));
    }
    List<AgreeVar> outputs = new ArrayList<>();
    for (AgreeVar output : e.outputs) {
        outputs.add(this.visit(output));
    }
    List<AgreeVar> locals = new ArrayList<>();
    for (AgreeVar local : e.locals) {
        locals.add(this.visit(local));
    }
    // Note that nodes and connections contain cross-references to each
    // other. But, valid model structure requires that connections
    // refer only to features on the this node and the sub-nodes. Thus,
    // we may visit the sub-nodes first, and then use the result of that
    // in visiting the connections.
    // 
    List<AgreeNode> subNodes = new ArrayList<>();
    for (AgreeNode subnode : e.subNodes) {
        subNodes.add(this.visit(subnode));
    }
    List<AgreeConnection> connections = new ArrayList<>();
    for (AgreeConnection conn : e.connections) {
        connections.add(this.visit(conn));
    }
    List<AgreeStatement> assertions = new ArrayList<>();
    for (AgreeStatement stmt : e.assertions) {
        assertions.add(this.visit(stmt));
    }
    List<AgreeStatement> assumptions = new ArrayList<>();
    for (AgreeStatement stmt : e.assumptions) {
        assumptions.add(this.visit(stmt));
    }
    List<AgreeStatement> guarantees = new ArrayList<>();
    for (AgreeStatement stmt : e.guarantees) {
        guarantees.add(this.visit(stmt));
    }
    List<AgreeStatement> lemmas = new ArrayList<>();
    for (AgreeStatement stmt : e.lemmas) {
        lemmas.add(this.visit(stmt));
    }
    List<AgreeStatement> patternProps = new ArrayList<>();
    for (AgreeStatement stmt : e.patternProps) {
        patternProps.add(this.visit(stmt));
    }
    List<AgreeEquation> localEqs = new ArrayList<>();
    for (AgreeEquation eq : e.localEquations) {
        localEqs.add(this.visit(eq));
    }
    Expr clockConstraint = e.clockConstraint.accept(this);
    Expr initialConstraint = e.initialConstraint.accept(this);
    AgreeVar clockVar = this.visit(e.clockVar);
    EObject reference = e.reference;
    TimingModel timing = e.timing;
    // ComponentInstance compinst = e.compInst;
    AgreeNodeBuilder builder = new AgreeNodeBuilder(id);
    builder.addInput(inputs);
    builder.addOutput(outputs);
    builder.addLocal(locals);
    builder.addConnection(connections);
    builder.addSubNode(subNodes);
    builder.addAssertion(assertions);
    builder.addAssumption(assumptions);
    builder.addGuarantee(guarantees);
    builder.addLemma(lemmas);
    builder.addLocalEquation(localEqs);
    builder.addPatternProp(patternProps);
    builder.setClockConstraint(clockConstraint);
    builder.setInitialConstraint(initialConstraint);
    builder.setClockVar(clockVar);
    builder.setReference(reference);
    builder.setTiming(timing);
    builder.setCompInst(e.compInst);
    builder.addTimeFall(e.timeFallMap);
    builder.addTimeRise(e.timeRiseMap);
    builder.addTimeOf(e.timeOfMap);
    AgreeNode result = builder.build();
    visitedNodes.put(e.compInst, result);
    return result;
}
Also used : AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) ArrayList(java.util.ArrayList) AgreeEquation(com.rockwellcollins.atc.agree.analysis.ast.AgreeEquation) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar) Expr(jkind.lustre.Expr) IdExpr(jkind.lustre.IdExpr) TimingModel(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode.TimingModel) EObject(org.eclipse.emf.ecore.EObject) AgreeConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeConnection) AgreeNodeBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder)

Example 3 with AgreeConnection

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

the class LinearizationAgreeASTVisitor method visit.

@Override
public AgreeNode visit(AgreeNode e) {
    List<AgreeVar> inputs = new ArrayList<>();
    for (AgreeVar input : e.inputs) {
        inputs.add(this.visit(input));
    }
    List<AgreeVar> outputs = new ArrayList<>();
    for (AgreeVar output : e.outputs) {
        outputs.add(this.visit(output));
    }
    List<AgreeVar> locals = new ArrayList<>();
    for (AgreeVar local : e.locals) {
        locals.add(this.visit(local));
    }
    // Note that nodes and connections contain cross-references to each
    // other. But, valid model structure requires that connections
    // refer only to features on the this node and the sub-nodes. Thus,
    // we may visit the sub-nodes first, and then use the result of that
    // in visiting the connections.
    // 
    List<AgreeNode> subNodes = new ArrayList<>();
    for (AgreeNode subnode : e.subNodes) {
        subNodes.add(this.visit(subnode));
    }
    List<AgreeConnection> connections = new ArrayList<>();
    for (AgreeConnection conn : e.connections) {
        connections.add(this.visit(conn));
    }
    List<AgreeStatement> assertions = new ArrayList<>();
    for (AgreeStatement stmt : e.assertions) {
        if (stmt.expr != null) {
            LinearizationResult linResult = linearizeStatement(e, stmt, jkind.lustre.BinaryOp.AND);
            outputs.addAll(linResult.addedLocals);
            assertions.addAll(linResult.liftedConstraints);
            assertions.add(linResult.linearizedStatement);
        } else {
            assertions.add(stmt);
        }
    }
    List<AgreeStatement> assumptions = new ArrayList<>();
    for (AgreeStatement stmt : e.assumptions) {
        if (stmt.expr != null) {
            LinearizationResult linResult = linearizeStatement(e, stmt, jkind.lustre.BinaryOp.AND);
            outputs.addAll(linResult.addedLocals);
            assertions.addAll(linResult.liftedConstraints);
            assumptions.add(linResult.linearizedStatement);
        } else {
            assumptions.add(stmt);
        }
    }
    List<AgreeStatement> guarantees = new ArrayList<>();
    for (AgreeStatement stmt : e.guarantees) {
        if (stmt.expr != null) {
            LinearizationResult linResult = linearizeStatement(e, stmt, jkind.lustre.BinaryOp.IMPLIES);
            outputs.addAll(linResult.addedLocals);
            guarantees.addAll(linResult.liftedConstraints);
            guarantees.add(linResult.linearizedStatement);
        } else {
            guarantees.add(stmt);
        }
    }
    List<AgreeStatement> lemmas = new ArrayList<>();
    for (AgreeStatement stmt : e.lemmas) {
        if (stmt.expr != null) {
            LinearizationResult linResult = linearizeStatement(e, stmt, jkind.lustre.BinaryOp.IMPLIES);
            outputs.addAll(linResult.addedLocals);
            assertions.addAll(linResult.liftedConstraints);
            lemmas.add(linResult.linearizedStatement);
        } else {
            lemmas.add(stmt);
        }
    }
    Expr clockConstraint = e.clockConstraint.accept(this);
    Expr initialConstraint = e.initialConstraint.accept(this);
    AgreeVar clockVar = this.visit(e.clockVar);
    AgreeNodeBuilder builder = new AgreeNodeBuilder(e);
    builder.clearInputs();
    builder.addInput(inputs);
    builder.clearOutputs();
    builder.addOutput(outputs);
    builder.clearLocals();
    builder.addLocal(locals);
    builder.clearConnections();
    builder.addConnection(connections);
    builder.clearSubNodes();
    builder.addSubNode(subNodes);
    builder.clearAssertions();
    builder.addAssertion(assertions);
    builder.clearAssumptions();
    builder.addAssumption(assumptions);
    builder.clearGuarantees();
    builder.addGuarantee(guarantees);
    builder.clearLemmas();
    builder.addLemma(lemmas);
    builder.setClockConstraint(clockConstraint);
    builder.setInitialConstraint(initialConstraint);
    builder.setClockVar(clockVar);
    AgreeNode result = builder.build();
    visitedNodes.put(e.compInst, result);
    return result;
}
Also used : AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) NodeCallExpr(jkind.lustre.NodeCallExpr) Expr(jkind.lustre.Expr) ArrayList(java.util.ArrayList) AgreeConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeConnection) AgreeNodeBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 4 with AgreeConnection

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

the class AddFaultsToNodeVisitor method changeTopNodeAsymConnections.

/**
 * Method changes top level connections to reflect communication nodes for
 * asymmetric faults. Finds old connections from sender to receiver and removes
 * them. Then adds new connections from sender to communication nodes and from
 * communication nodes to receivers.
 *
 * @param nb   NodeBuilder for this top node.
 * @param node The top node of the program.
 * @return SafetyNodeBuilder with connections changed.
 */
private SafetyNodeBuilder changeTopNodeAsymConnections(AgreeNodeBuilder nb, AgreeNode node) {
    SafetyNodeBuilder sb = new SafetyNodeBuilder(node);
    List<AgreeConnection> agreeConns = new ArrayList<AgreeConnection>();
    int i = 0;
    // Make sure we have AgreeAADLConnection and cast to access AgreeVar
    for (AgreeConnection ac : sb.getConnections()) {
        if (ac instanceof AgreeAADLConnection) {
            AgreeAADLConnection aac = (AgreeAADLConnection) ac;
            AgreeVar sourceName = aac.sourceVarName;
            AgreeVar destName = aac.destinationVarName;
            // cannot perform this removal of connections.
            if ((sourceName.compInst == null) || (destName.compInst == null)) {
                continue;
            }
            String senderName = sourceName.compInst.getName() + "." + sourceName.id;
            String receiverName = destName.compInst.getName() + "." + destName.id;
            // remove that element from agreeConns.
            for (String sendKey : mapSenderToReceiver.keySet()) {
                if (senderName.contentEquals(sendKey)) {
                    for (String receiveVal : mapSenderToReceiver.get(sendKey)) {
                        if (receiverName.equals(receiveVal)) {
                            agreeConns.add(ac);
                            break;
                        }
                    }
                }
            }
        }
        i++;
    }
    List<AgreeConnection> connList = sb.getConnections();
    for (AgreeConnection j : agreeConns) {
        connList.remove(j);
    }
    FaultASTBuilder.resetAsymMaps();
    return sb;
}
Also used : AgreeAADLConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection) SafetyNodeBuilder(edu.umn.cs.crisys.safety.analysis.ast.SafetyNodeBuilder) AgreeConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeConnection) ArrayList(java.util.ArrayList) TransientConstraint(edu.umn.cs.crisys.safety.safety.TransientConstraint) PermanentConstraint(edu.umn.cs.crisys.safety.safety.PermanentConstraint) TemporalConstraint(edu.umn.cs.crisys.safety.safety.TemporalConstraint) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 5 with AgreeConnection

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

the class LustreAstBuilder method addConnectionConstraints.

protected static void addConnectionConstraints(AgreeNode agreeNode, List<AgreeStatement> assertions) {
    for (AgreeConnection conn : agreeNode.connections) {
        if (conn instanceof AgreeAADLConnection) {
            AgreeAADLConnection aadlConn = (AgreeAADLConnection) conn;
            String destName = aadlConn.destinationNode == null ? "" : aadlConn.destinationNode.id + AgreeASTBuilder.dotChar;
            destName = destName + aadlConn.destinationVarName.id;
            String sourName = aadlConn.sourceNode == null ? "" : aadlConn.sourceNode.id + AgreeASTBuilder.dotChar;
            sourName = sourName + aadlConn.sourceVarName.id;
            Expr aadlConnExpr;
            if (!aadlConn.delayed) {
                aadlConnExpr = new BinaryExpr(new IdExpr(sourName), BinaryOp.EQUAL, new IdExpr(destName));
            } else {
                // we need to get the correct type for the aadlConnection
                // we can assume that the source and destination types are
                // the same at this point
                Expr initExpr = AgreeUtils.getInitValueFromType(aadlConn.sourceVarName.type);
                Expr preSource = new UnaryExpr(UnaryOp.PRE, new IdExpr(sourName));
                Expr sourExpr = new BinaryExpr(initExpr, BinaryOp.ARROW, preSource);
                aadlConnExpr = new BinaryExpr(sourExpr, BinaryOp.EQUAL, new IdExpr(destName));
            }
            assertions.add(new AgreeStatement("", aadlConnExpr, aadlConn.reference));
        } else {
            AgreeOverriddenConnection agreeConn = (AgreeOverriddenConnection) conn;
            assertions.add(agreeConn.statement);
        }
    }
}
Also used : AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) UnaryExpr(jkind.lustre.UnaryExpr) Expr(jkind.lustre.Expr) IntExpr(jkind.lustre.IntExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) IdExpr(jkind.lustre.IdExpr) IdExpr(jkind.lustre.IdExpr) AgreeAADLConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection) BinaryExpr(jkind.lustre.BinaryExpr) AgreeOverriddenConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeOverriddenConnection) AgreeConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeConnection) UnaryExpr(jkind.lustre.UnaryExpr)

Aggregations

AgreeConnection (com.rockwellcollins.atc.agree.analysis.ast.AgreeConnection)5 AgreeNode (com.rockwellcollins.atc.agree.analysis.ast.AgreeNode)3 AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)3 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)3 ArrayList (java.util.ArrayList)3 Expr (jkind.lustre.Expr)3 AgreeAADLConnection (com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection)2 AgreeEquation (com.rockwellcollins.atc.agree.analysis.ast.AgreeEquation)2 AgreeNodeBuilder (com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder)2 IdExpr (jkind.lustre.IdExpr)2 NodeCallExpr (jkind.lustre.NodeCallExpr)2 TimingModel (com.rockwellcollins.atc.agree.analysis.ast.AgreeNode.TimingModel)1 AgreeOverriddenConnection (com.rockwellcollins.atc.agree.analysis.ast.AgreeOverriddenConnection)1 SafetyNodeBuilder (edu.umn.cs.crisys.safety.analysis.ast.SafetyNodeBuilder)1 PermanentConstraint (edu.umn.cs.crisys.safety.safety.PermanentConstraint)1 TemporalConstraint (edu.umn.cs.crisys.safety.safety.TemporalConstraint)1 TransientConstraint (edu.umn.cs.crisys.safety.safety.TransientConstraint)1 BinaryExpr (jkind.lustre.BinaryExpr)1 BoolExpr (jkind.lustre.BoolExpr)1 IntExpr (jkind.lustre.IntExpr)1