Class Server

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, SequenceActor, TimedActor, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
    Direct Known Subclasses:
    PreemptableServer

    public class Server
    extends DETransformer
    This actor models a preemptive 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 the server 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 value at the time that the input arrived. If several inputs arrive while the server is busy, then they are served in an order determined by the value of the priority parameter at the time of arrival of the input, and for inputs with identical priorities, on a first-come, first-served basis. On every firing, produce an output indicating the final queue size.

    The service time and priority used for a job are the most recently arrived values prior to or simultaneous with the arrival of the job (not with the time at which service begins). Thus, if you want each job to have an independent service time or priority, you should provide each parameter as an input synchronized with each new job arrival.

    Since:
    Ptolemy II 0.3
    Version:
    $Id$
    Author:
    Lukito Muliadi, Edward A. Lee, Haiyang Zheng
    See Also:
    TimeDelay
    Pt.AcceptedRating:
    Yellow (hyzheng)
    Pt.ProposedRating:
    Yellow (hyzheng)
    • Field Detail

      • capacity

        public Parameter capacity
        The capacity of the queue. If the value is positive, then it specifies the capacity of the queue. If it is negative or 0, then it specifies that the capacity is infinite. This is an integer with default 0.
      • size

        public TypedIOPort size
        The current size of the queue. This port produces an output whenever the size changes. It has type int.
      • serviceTime

        public PortParameter serviceTime
        The service time. This is a double with default 1.0. It is required to be non-negative.
      • priority

        public PortParameter priority
        The priority. This is a double with default 0.0. A higher priority implies the task has precedence over tasks with lower priority values.
      • _nextTimeFree

        protected Time _nextTimeFree
        Next time the server becomes free.
      • _queues

        protected java.util.TreeMap<java.lang.Double,​java.util.PriorityQueue<ptolemy.domains.de.lib.Server.Job>> _queues
      • _queueSize

        protected int _queueSize
      • _queueCounter

        protected long _queueCounter
        The counter for tie-breaking the queue by insertion order.