Search in sources :

Example 1 with AgreeAADLConnection

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

the class AgreeASTPrettyprinter method connection.

// Note: this method (and the fact that I'm using instanceof)
// means that the AGREE Ast visitor is broken
private void connection(AgreeConnection conn) {
    if (conn instanceof AgreeAADLConnection) {
        AgreeAADLConnection aadl = (AgreeAADLConnection) conn;
        write("  ");
        write(aadl.type);
        write(aadl.delayed ? " delayed" : "");
        write(aadl.latched ? " latched" : "");
        write(" connection {");
        newline();
        write("    ");
        write(aadl.sourceNode == null ? "NULL NODE" : aadl.sourceNode.id);
        write("." + aadl.sourceVarName.id);
        write(" ->");
        write(aadl.destinationNode == null ? " NULL NODE" : " " + aadl.destinationNode.id);
        write("." + aadl.destinationVarName.id);
        newline();
        write("  }");
        newline();
    } else if (conn instanceof AgreeOverriddenConnection) {
        AgreeOverriddenConnection aadl = (AgreeOverriddenConnection) conn;
        write("  connection {");
        newline();
        write("    ");
        aadl.statement.accept(this);
        newline();
        write("    aadl: " + aadl.aadlConn.toString());
        newline();
        write("  }");
        newline();
    }
}
Also used : AgreeAADLConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection) AgreeOverriddenConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeOverriddenConnection)

Example 2 with AgreeAADLConnection

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

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

the class AgreeASTMapVisitor method visit.

@Override
public AgreeConnection visit(AgreeConnection e) {
    if (e instanceof AgreeAADLConnection) {
        AgreeAADLConnection aadlConn = (AgreeAADLConnection) e;
        AgreeNode sourceNode = null;
        if (aadlConn.sourceNode != null) {
            sourceNode = visitedNodes.get(aadlConn.sourceNode.compInst);
        }
        AgreeNode destinationNode = null;
        if (aadlConn.destinationNode != null) {
            destinationNode = visitedNodes.get(aadlConn.destinationNode.compInst);
        }
        AgreeVar sourVar = visit(aadlConn.sourceVarName);
        AgreeVar destVar = visit(aadlConn.destinationVarName);
        ConnectionType type = aadlConn.type;
        boolean latched = aadlConn.latched;
        boolean delayed = aadlConn.delayed;
        EObject reference = aadlConn.reference;
        return new AgreeAADLConnection(sourceNode, destinationNode, sourVar, destVar, type, latched, delayed, reference);
    } else if (e instanceof AgreeOverriddenConnection) {
        AgreeOverriddenConnection overriddenCon = (AgreeOverriddenConnection) e;
        AgreeStatement statement = visit(overriddenCon.statement);
        return new AgreeOverriddenConnection(statement, overriddenCon.aadlConn);
    }
    throw new AgreeException("Unhandled Agree connection type " + e.getClass());
}
Also used : AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) ConnectionType(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection.ConnectionType) AgreeAADLConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection) EObject(org.eclipse.emf.ecore.EObject) AgreeOverriddenConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeOverriddenConnection) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 4 with AgreeAADLConnection

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

AgreeAADLConnection (com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection)4 AgreeOverriddenConnection (com.rockwellcollins.atc.agree.analysis.ast.AgreeOverriddenConnection)3 AgreeConnection (com.rockwellcollins.atc.agree.analysis.ast.AgreeConnection)2 AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)2 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)2 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)1 ConnectionType (com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection.ConnectionType)1 AgreeNode (com.rockwellcollins.atc.agree.analysis.ast.AgreeNode)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 ArrayList (java.util.ArrayList)1 BinaryExpr (jkind.lustre.BinaryExpr)1 BoolExpr (jkind.lustre.BoolExpr)1 Expr (jkind.lustre.Expr)1 IdExpr (jkind.lustre.IdExpr)1 IntExpr (jkind.lustre.IntExpr)1 NodeCallExpr (jkind.lustre.NodeCallExpr)1 UnaryExpr (jkind.lustre.UnaryExpr)1