// to the same external input port. See
// BaseSDFScheduler.setContainerRates.
Iterator ports = model.portList().iterator();
while (ports.hasNext()) {
IOPort port = (IOPort) ports.next();
if (_debugging && VERBOSE) {
_debug("External Port " + port.getName());
}
if (port.isInput() && port.isOutput()) {
throw new NotSchedulableException(port,
"External port is both an input and an output, "
+ "which is not allowed in SDF.");
} 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;