} else if (port.isInput()) {
List sinks = port.insideSinkPortList();
if (sinks.size() > 0) {
IOPort connectedPort = (IOPort) sinks.get(0);
Entity entity = (Entity) connectedPort.getContainer();
String name = connectedPort.getName(model);
String identifier = name.replaceAll("\\.", "::");
String sinkExpression;
Variable sinkRateVariable = DFUtilities.getRateVariable(
connectedPort, "tokenConsumptionRate");
if (sinkRateVariable == null) {
sinkExpression = "1";
} else {
sinkExpression = identifier + "::"
+ sinkRateVariable.getName();
}
String expression = sinkExpression + " * "
+ entity.getName() + "::firingsPerIteration";
DFUtilities.setExpressionIfNotDefined(port,
"tokenConsumptionRate", expression);
if (_debugging && VERBOSE) {
_debug("Setting tokenConsumptionRate to " + expression);
}
}
} else if (port.isOutput()) {
List sources = port.insideSourcePortList();
if (sources.size() > 0) {
IOPort connectedPort = (IOPort) sources.get(0);
Entity entity = (Entity) connectedPort.getContainer();
String name = connectedPort.getName(model);
String identifier = name.replaceAll("\\.", "::");
Variable sourceRateVariable = DFUtilities.getRateVariable(
connectedPort, "tokenProductionRate");
String sourceExpression;
if (sourceRateVariable == null) {
sourceExpression = "1";
} else {
sourceExpression = identifier + "::"
+ sourceRateVariable.getName();
}
String expression = sourceExpression + " * "
+ entity.getName() + "::firingsPerIteration";
DFUtilities.setExpressionIfNotDefined(port,
"tokenProductionRate", expression);
if (_debugging && VERBOSE) {