super.preinitialize();
Iterator ports = outputPortList().iterator();
while (ports.hasNext()) {
TypedIOPort port = (TypedIOPort) ports.next();
// Ensure that the production rate is one.
// FIXME: This may not be right if there is no
// actual source of data for this port (e.g. no
// SetVariable actor).
Variable rate = (Variable) port.getAttribute("tokenProductionRate");
if (rate == null) {
try {
rate = new Variable(port, "tokenProductionRate");
} catch (NameDuplicationException e) {
throw new InternalErrorException(e);
}
}
rate.setToken(new IntToken(1));
String portName = port.getName();
Attribute attribute = getAttribute(portName);
if (attribute == null) {
try {
workspace().getWriteAccess();
attribute = new Variable(this, portName);
} catch (NameDuplicationException ex) {
throw new InternalErrorException(ex);
} finally {
workspace().doneWriting();
}
}
// attribute is now assured to be non-null.
if (attribute instanceof Variable) {
port.setTypeAtLeast((Variable) attribute);
} else {
// Assume the port type must be a string.
port.setTypeEquals(BaseType.STRING);
}
}
}