|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ptolemy.kernel.util.NamedObj ptolemy.kernel.InstantiableNamedObj ptolemy.kernel.Entity ptolemy.kernel.ComponentEntity ptolemy.actor.AtomicActor ptolemy.actor.TypedAtomicActor ptolemy.actor.lib.net.DatagramWriter
public class DatagramWriter
This actor sends its input as a Datagram over the network using the UDP protocol. Before being sent, the data is optionally encoded as a text string representing the value being sent. When this option is selected, any Ptolemy data type may be represented. See the encoding parameter.
NOTE: This actor has problems, the tests do not reliably pass.
For details, see https://chess.eecs.berkeley.edu/bugzilla/show_bug.cgi?id=54
.
The address and socket number towards which the datagram is sent are given by the optional inputs remoteAddress and remoteSocketNumber. However, unless/until token(s) arrive at these inputs, default values, given by defaultRemoteAddress and defaultRemoteSocketNumber are used. Note that some IP addresses are special broadcast addresses. An address such as "128.32.239.255" broadcasts to any IP addresses on the "128.23.239.X" subnet. This only works on your own subnet.
Each instance of this actor needs to allocate a local socket from which to transmit datagrams. Initially, the local socket number is set to 4003, just to pick a number. The socket is not allocated until the model is run.
Yellow (winthrop) |
Yellow (winthrop) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.Entity |
---|
Entity.ContainedObjectsIterator |
Field Summary | |
---|---|
private java.net.InetAddress |
_address
|
private int |
_localSocketNumber
|
private int |
_remoteSocketNumber
|
private java.net.DatagramSocket |
_socket
|
TypedIOPort |
data
Data to be sent. |
Parameter |
defaultRemoteAddress
The default remote address to which to send datagrams. |
Parameter |
defaultRemoteSocketNumber
The default remote UDP socket to which to launch the packet. |
Parameter |
localSocketNumber
The local socket number for this actor's socket. |
TypedIOPort |
remoteAddress
The remote address towards which to launch the packet. |
TypedIOPort |
remoteSocketNumber
The remote socket number towards which to launch the packet. |
TypedIOPort |
triggerOutput
The triggerOutput port. |
Fields inherited from class ptolemy.actor.AtomicActor |
---|
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested |
Fields inherited from class ptolemy.kernel.util.NamedObj |
---|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Fields inherited from interface ptolemy.actor.Executable |
---|
COMPLETED, NOT_READY, STOP_ITERATING |
Constructor Summary | |
---|---|
DatagramWriter(CompositeEntity container,
java.lang.String name)
Construct a DatagramWriter actor with given name in the given container. |
Method Summary | |
---|---|
void |
attributeChanged(Attribute attribute)
Override the base class to reinitialize the state if the localSocketNumber, defaultRemoteAddress or defaultRemoteSocketNumber parameter has changed. |
void |
fire()
Does up to three things, in this order: Set new remote address value, Set new remote socket number, transmit data as a UDP packet over the ethernet. |
void |
initialize()
Initialize allocates the socket and makes use of default parameters for the remote address and socket to which datagrams will be sent. |
void |
setContainer(CompositeEntity container)
Override the setContainer() method to call wrapup() if container is not equal to the result of getContainer(). |
void |
wrapup()
Wrap up. |
Methods inherited from class ptolemy.actor.TypedAtomicActor |
---|
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints |
Methods inherited from class ptolemy.kernel.ComponentEntity |
---|
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName |
Methods inherited from class ptolemy.kernel.Entity |
---|
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName |
Methods inherited from class ptolemy.kernel.InstantiableNamedObj |
---|
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ptolemy.actor.Actor |
---|
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList |
Methods inherited from interface ptolemy.actor.Executable |
---|
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate |
Methods inherited from interface ptolemy.actor.Initializable |
---|
addInitializable, preinitialize, removeInitializable |
Methods inherited from interface ptolemy.kernel.util.Nameable |
---|
description, getContainer, getDisplayName, getFullName, getName, getName, setName |
Methods inherited from interface ptolemy.kernel.util.Derivable |
---|
getDerivedLevel, getDerivedList, propagateValue |
Field Detail |
---|
public TypedIOPort triggerOutput
public Parameter localSocketNumber
public TypedIOPort data
public Parameter defaultRemoteAddress
public TypedIOPort remoteAddress
public Parameter defaultRemoteSocketNumber
public TypedIOPort remoteSocketNumber
private java.net.InetAddress _address
private int _remoteSocketNumber
private java.net.DatagramSocket _socket
private int _localSocketNumber
Constructor Detail |
---|
public DatagramWriter(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
container
- The container.name
- The name for this actor.
NameDuplicationException
- If the container already has an
actor with this name.
IllegalActionException
- If the actor cannot be contained by
this container.Method Detail |
---|
public void attributeChanged(Attribute attribute) throws IllegalActionException
If the parameter changed is localSocketNumber, then if the model is running (as evidenced by socket != null) then close socket and reopen with new socket number (even if it is the same as the old socket number). Do not close the socket until a new one has been successfully opened. If defaultRemoteAddress or defaultRemoteSocketNumber is changed, simply update these parameters, checking, in the case of the address, that it passes lookup anc conversion to an IP address. If the encoding parameter is changed, set the private encoding settings to the new values.
attributeChanged
in class NamedObj
attribute
- The attribute that changed.
IllegalActionException
- If the socket cannot be created.public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class AtomicActor
IllegalActionException
- Not thrown in this base class.public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class AtomicActor
IllegalActionException
- If
the default remote socket number is outside the range 0..65535,
the local socket number is outside the range 0..65535,
the local socket cannot be created with the given
socket number (such as because that number is already in use),
or translation of remote address fails to make an IP
address from the given address string (i.e. InetAddress.getByName()
fails in the address lookup attempt.public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
setContainer
in class AtomicActor
container
- The proposed container.
IllegalActionException
- If the action would result in a
recursive containment structure, or if
this entity and container are not in the same workspace.
NameDuplicationException
- If the container already has
an entity with the name of this entity.ComponentEntity.getContainer()
public void wrapup() throws IllegalActionException
wrapup
in interface Initializable
wrapup
in class AtomicActor
IllegalActionException
- If the socket was already null.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |