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();
}
}
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;
}
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());
}
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);
}
}
}
Aggregations