use of com.rockwellcollins.atc.agree.analysis.MNSynchronyElement in project AGREE by loonwerks.
the class AgreeASTBuilder method getMNSynchConstraint.
private Expr getMNSynchConstraint(MNSynchStatement sync) {
Set<String> nodeNames = new HashSet<>();
Expr clockAssertion = new BoolExpr(true);
for (int i = 0; i < sync.getComp1().size(); i++) {
Subcomponent maxComp = (Subcomponent) sync.getComp1().get(i);
Subcomponent minComp = (Subcomponent) sync.getComp2().get(i);
Expr maxClock = new IdExpr(maxComp.getName() + clockIDSuffix);
Expr minClock = new IdExpr(minComp.getName() + clockIDSuffix);
int max = Integer.valueOf(sync.getMax().get(i));
int min = Integer.valueOf(sync.getMin().get(i));
MNSynchronyElement elem = new MNSynchronyElement(maxClock, minClock, max, min);
String nodeName = "__calendar_node_" + elem.max + "_" + elem.min;
nodeName = getObjectLocationPrefix(sync) + nodeName;
if (!nodeNames.contains(nodeName)) {
nodeNames.add(nodeName);
Node calNode = AgreeCalendarUtils.getMNCalendar(nodeName, elem.max, elem.min);
addToNodeList(calNode);
}
NodeCallExpr nodeCall = new NodeCallExpr(nodeName, elem.maxClock, elem.minClock);
clockAssertion = LustreExprFactory.makeANDExpr(clockAssertion, nodeCall);
nodeCall = new NodeCallExpr(nodeName, elem.minClock, elem.maxClock);
clockAssertion = LustreExprFactory.makeANDExpr(clockAssertion, nodeCall);
}
return clockAssertion;
}
Aggregations