public DatagramWriter(CompositeEntity container, String name)
throws NameDuplicationException, IllegalActionException {
super(container, name);
// Ports
remoteAddress = new TypedIOPort(this, "remoteAddress");
remoteAddress.setInput(true);
remoteAddress.setMultiport(true);
remoteAddress.setTypeEquals(BaseType.STRING);
remoteSocketNumber = new TypedIOPort(this, "remoteSocketNumber");
remoteSocketNumber.setInput(true);
remoteSocketNumber.setMultiport(true);
remoteSocketNumber.setTypeEquals(BaseType.INT);
data = new TypedIOPort(this, "data");
data.setInput(true);
data.setTypeEquals(new ArrayType(BaseType.UNSIGNED_BYTE));
// Parameters that are default values for ports
//defaultRemoteAddress =
// new StringAttribute(this, "defaultRemoteAddress");
//defaultRemoteAddress.setExpression("localhost");
// Above way was set w/o quotes vs constant which is set with them.
// This has been confusing, so I've switched to the approach below.
defaultRemoteAddress = new Parameter(this, "defaultRemoteAddress");
defaultRemoteAddress.setTypeEquals(BaseType.STRING);
defaultRemoteAddress.setToken(new StringToken("localhost"));
defaultRemoteSocketNumber = new Parameter(this,
"defaultRemoteSocketNumber");
defaultRemoteSocketNumber.setTypeEquals(BaseType.INT);
defaultRemoteSocketNumber.setExpression("4004"); //setExpression works
// Pure parameters
localSocketNumber = new Parameter(this, "localSocketNumber");
localSocketNumber.setTypeEquals(BaseType.INT);
localSocketNumber.setToken(new IntToken(4003)); //setToken works too
// Added for SDF usability. Empty Token() is output, just a trigger.
triggerOutput = new TypedIOPort(this, "triggerOutput");
triggerOutput.setTypeEquals(BaseType.GENERAL);
// 'INT' works too in place of 'GENERAL'.
triggerOutput.setOutput(true);
}