ptolemy.domains.de.lib
Class Server
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.domains.de.kernel.DEActor
ptolemy.domains.de.lib.DETransformer
ptolemy.domains.de.lib.Server
- All Implemented Interfaces:
- Actor, Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Executable, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, SequenceActor, java.io.Serializable, TimedActor, TypedActor
- public class Server
- extends DETransformer
This actor models a server with a fixed or variable service time.
A server is either busy (serving a customer) or not busy at any given time.
If an input arrives when it is not busy, then the input token is produced
on the output with a delay given by the serviceTime parameter.
If an input arrives while the server is busy, then that input is
queued until the server becomes free, at which point it is produced
on the output with a delay given by the serviceTime parameter.
If several inputs arrive while the server is busy, then they are
served on a first-come, first-served basis.
If the serviceTime parameter is not set, it defaults to 1.0.
The value of the parameter can be changed at any time during execution
of the model by providing an input event at the newServiceTime
input port. The token read at that port replaces the value of the
serviceTime parameter.
This actor declares that there is delay between the input
and the output ports and between newServiceTime
and output. The director uses this information for
assigning priorities to firings.
Like the TimedDelay actor, the output is produced with a future time
stamp (larger than current time by serviceTime). That output
token cannot be retracted once produced, even if the server actor
is deleted from the topology. If the service time is zero, then
the output event is queued to be processed in the next microstep,
after all events with the current time in the current microstep.
Thus, a service time of zero can be usefully viewed as an infinitesimal
service time.
- Since:
- Ptolemy II 0.3
- Version:
- $Id: Server.java,v 1.34.2.2 2004/07/31 02:24:37 cxh Exp $
- Author:
- Lukito Muliadi, Edward A. Lee
- See Also:
TimedDelay,
VariableDelay,
SampleDelay,
Serialized Form
- Accepted Rating:
- Proposed Rating:
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
|
Constructor Summary |
Server(CompositeEntity container,
java.lang.String name)
Construct an actor with the specified container and name. |
|
Method Summary |
void |
attributeChanged(Attribute attribute)
If the attribute is serviceTime, then check that
the value is non-negative. |
void |
fire()
If there is an input token, read it to begin servicing it.
|
void |
initialize()
Indicate that the server is not busy. |
boolean |
postfire()
If a token was read in the fire() method, then produce it on
the output and schedule a firing to occur when the service time elapses.
|
boolean |
prefire()
If the server is not busy, return true. |
void |
pruneDependencies()
Override the base class to declare that the output
does not depend on the input or newServiceTime
in a firing. |
| Methods inherited from class ptolemy.domains.de.kernel.DEActor |
newPort |
| Methods inherited from class ptolemy.actor.AtomicActor |
_createReceivers, clone, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, preinitialize, removeDependency, setContainer, stop, stopFire, terminate, wrapup |
| Methods inherited from class ptolemy.kernel.Entity |
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables |
| Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, workspace |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
newServiceTime
public DEIOPort newServiceTime
- A port to supply new service times. This port has type DoubleToken.
serviceTime
public Parameter serviceTime
- The service time. This parameter must contain a DoubleToken
with a non-negative value, or an exception will be thrown when
it is set.
Server
public Server(CompositeEntity container,
java.lang.String name)
throws NameDuplicationException,
IllegalActionException
- Construct an actor with the specified container and name.
- Parameters:
container - The composite actor to contain this one.name - The name of this actor.
- Throws:
IllegalActionException - If the entity cannot be contained
by the proposed container.
NameDuplicationException - If the container already has an
actor with this name.
attributeChanged
public void attributeChanged(Attribute attribute)
throws IllegalActionException
- If the attribute is serviceTime, then check that
the value is non-negative.
- Overrides:
attributeChanged in class NamedObj
- Parameters:
attribute - The attribute that changed.
- Throws:
IllegalActionException - If the service time is negative.
fire
public void fire()
throws IllegalActionException
- If there is an input token, read it to begin servicing it.
Note that service actually begins in the postfire() method,
which will produce the token that is read on the output.
- Specified by:
fire in interface Executable- Overrides:
fire in class AtomicActor
- Throws:
IllegalActionException - If there is no director.
initialize
public void initialize()
throws IllegalActionException
- Indicate that the server is not busy.
- Specified by:
initialize in interface Executable- Overrides:
initialize in class AtomicActor
- Throws:
IllegalActionException - If the base class throws it.
prefire
public boolean prefire()
throws IllegalActionException
- If the server is not busy, return true. Otherwise return false.
- Specified by:
prefire in interface Executable- Overrides:
prefire in class AtomicActor
- Returns:
- True if this actor is ready for firing, false otherwise.
- Throws:
IllegalActionException - If there is no director.
postfire
public boolean postfire()
throws IllegalActionException
- If a token was read in the fire() method, then produce it on
the output and schedule a firing to occur when the service time elapses.
The output is produced with a time offset equal to the value
of the serviceTime parameter.
- Specified by:
postfire in interface Executable- Overrides:
postfire in class AtomicActor
- Returns:
- True if execution can continue into the next iteration.
- Throws:
IllegalActionException - If there is no director.
pruneDependencies
public void pruneDependencies()
- Override the base class to declare that the output
does not depend on the input or newServiceTime
in a firing.
- Overrides:
pruneDependencies in class AtomicActor
- See Also:
TimedDelay,
AtomicActor.removeDependency(IOPort, IOPort),
FunctionDependencyOfAtomicActor