Class TCPPacketTransmitter
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity<T>
-
- ptolemy.actor.AtomicActor<TypedIOPort>
-
- ptolemy.actor.TypedAtomicActor
-
- ptolemy.domains.ptides.lib.OutputDevice
-
- ptolemy.domains.ptides.lib.qm.TCPPacketTransmitter
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class TCPPacketTransmitter extends OutputDevice
Build a TCP Packet containing a user-defined number of PTIDES events.This actor should be directly connected to a network output port and be used with a PTIDES director.
This actor is expected to be used in pairs with the
TCPPacketReceiver
.TCPPacketTransmitter
builds TCP packets containing PTIDES events, where each PTIDES event itself is assigned a data length in bits by the user. The bits/event parameter is constant right now and is an actor Parameter. At the destination platform,TCPPacketReceiver
consumes packages produced by this actor and releases PTIDES events into its enclosing director.This actor consumes frameSize number of input tokens and creates a RecordToken with two fields labeled as TCPlabel and tokens. Here, tokens itself is an array of RecordTokens, where each of the entries is a PTIDES RecordToken with labels: timestamp, microstep and payload. Once the number of received tokens equals frameSize, the RecordToken simulating the TCP Packet is sent to output port. During wrapup, the remaining tokens(if any) are sent to the output.
- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Ilge Akkaya
- Pt.AcceptedRating:
- Pt.ProposedRating:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description Parameter
defaultFrameSize
The default TCP Packet size parameter.PortParameter
frameSize
User-Defined frame size port parameter.TypedIOPort
input
The data input port.TypedIOPort
output
The data output port, which is a RecordToken.Parameter
priority
Default TCP Packet priority parameter.-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _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
Constructors Constructor Description TCPPacketTransmitter(CompositeEntity container, java.lang.String name)
Construct a TCPPacketTransmitter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Set<Inequality>
_defaultTypeConstraints()
Do not establish the usual default type constraints.void
attributeChanged(Attribute attribute)
If the argument is the defaultFrameSize or priority, then set the specified values.void
fire()
Create a RecordToken with two labels: TCPlabel and tokens tokens is a token array that contains the input tokens consumed TCPlabel is the TCP Header structure containing the fields defined in getTCPHeader() Once the number of received tokens equals specified frame size, an output packet is sent to the output port.RecordToken
getTCPHeader()
Fill-in and return fields of the TCP header as a RecordToken.void
preinitialize()
Perform a check to see if this device is connected to a network port on the outside.void
wrapup()
Send the remaining tokens to the output port during wrapup.-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate
-
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
_addPort, _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 ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
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.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, initialize, removeInitializable
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
input
public TypedIOPort input
The data input port.
-
output
public TypedIOPort output
The data output port, which is a RecordToken.
-
defaultFrameSize
public Parameter defaultFrameSize
The default TCP Packet size parameter. The initial default value is an integer with the value 5.
-
priority
public Parameter priority
Default TCP Packet priority parameter. The initial default value is an integer with the value 1.
-
frameSize
public PortParameter frameSize
User-Defined frame size port parameter. The initial default value is an integer with the value 5. The type is integer.
-
-
Constructor Detail
-
TCPPacketTransmitter
public TCPPacketTransmitter(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct a TCPPacketTransmitter.- Parameters:
container
- the container of the TCPPacketTransmitter.name
- the name of the TCPPacketTransmitter.- Throws:
IllegalActionException
- If the TCPPacketTransmitter cannot be constructed.NameDuplicationException
- If there is a name collision.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
If the argument is the defaultFrameSize or priority, then set the specified values.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If value is less than zero.
-
getTCPHeader
public RecordToken getTCPHeader() throws IllegalActionException
Fill-in and return fields of the TCP header as a RecordToken.- Returns:
- a record token
- Throws:
IllegalActionException
- If the RecordToken cannot be created.
-
fire
public void fire() throws IllegalActionException
Create a RecordToken with two labels: TCPlabel and tokens tokens is a token array that contains the input tokens consumed TCPlabel is the TCP Header structure containing the fields defined in getTCPHeader() Once the number of received tokens equals specified frame size, an output packet is sent to the output port.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- Thrown in case of no director, input token cannot be read or output token cannot be sent.
-
preinitialize
public void preinitialize() throws IllegalActionException
Perform a check to see if this device is connected to a network port on the outside. If not, throw an exception. Also call preinitialize of the super class.- Specified by:
preinitialize
in interfaceInitializable
- Overrides:
preinitialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If there are no outside sink ports, or if any of the outside sink ports is not a network port.
-
wrapup
public void wrapup() throws IllegalActionException
Send the remaining tokens to the output port during wrapup. These most likely will not be displayed but should not be left within the actor, since they affect correct execution in the next run- Specified by:
wrapup
in interfaceInitializable
- Overrides:
wrapup
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- Not thrown in this base class.
-
_defaultTypeConstraints
protected java.util.Set<Inequality> _defaultTypeConstraints()
Do not establish the usual default type constraints.- Overrides:
_defaultTypeConstraints
in classTypedAtomicActor
- Returns:
- null
-
-