Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

desmoj
Class Entity  view Entity download Entity.java

java.lang.Object
  extended bydesmoj.NamedObject
      extended bydesmoj.ModelComponent
          extended bydesmoj.Schedulable
              extended bydesmoj.Entity
Direct Known Subclasses:
SimProcess

public abstract class Entity
extends Schedulable

Represents the superclass for all entities of a model. Entities are supposed to be scheduled together with a compatible event at a certain point of simulation time or relative to another event in present or future simulation time.

Entities typically encapsulate all information about a model's entity that is relevant to the modeller. Events can manipulate these informations when the scheduled point of simulation time is reached and thus change the state of the model. When modelling different types of entities you need to derive different classes from this superclass. Each carrying the specific information to represent its counterpart in the system modelled. Thus a simulation of i.e. a factory would require both machines and material to be subclasses of class Entity. They can act on each other by scheduling themselves or other Entities with the appropriate Events. To use more than one Entity of one type, created the needed amount of instances. For better identification, all instances created from a subclass of class NamedObjectImp (just as Entity is) get an individual identification number as a suffix to their name so there is no need to name each individual different yourself.

Entities can carry a priority that can be modified after the Entity has been instantiated. It is relevant for queueing Entities into any kind of Queues. The entity's priority determines it's position inside the queue when entering it. Although within a model all attributes of an entity could be made public it is advisable to support data hiding by providing methods for accessing the internal attributes, as always in oo-design.

Version:
DESMO-J, Ver. 1.5 copyright (c) 2001 licensed under GNU GPL

Field Summary
private  int myPriority
          The priority of an entity is essential for inserting into queues.
private  QueueLink myQLink
          Reference to the queue-links of this entity.
 
Fields inherited from class desmoj.Schedulable
myNote
 
Fields inherited from class desmoj.ModelComponent
 
Fields inherited from class desmoj.NamedObject
 
Constructor Summary
Entity(Model owner, java.lang.String name, boolean showInTrace)
          Constructs an entity with the given name for the given model and the specified trace option.
 
Method Summary
(package private)  void addQueueLink(QueueLink newQ)
          Adds a reference to the queue this entity was just inserted in.
 int getPriority()
          Returns the entity's priority.
(package private)  QueueLink getQueueLink(QueueList qList)
          Returns a reference to the QueueLink of the given QueueList if this Entity is inside that QueueList.
static boolean isEqual(Entity a, Entity b)
          Checks if the two entities have the same priority.
static boolean isLarger(Entity a, Entity b)
          Checks if the first of the two entities has a higher priority than the second.
static boolean isLargerOrEqual(Entity a, Entity b)
          Checks if the first of the two entities has higher or same priority than the second.
static boolean isNotEqual(Entity a, Entity b)
          Checks if the first of the two entities have different priorities.
 boolean isSimProcess()
          Tests if this entity actually is a simprocess.
static boolean isSmaller(Entity a, Entity b)
          Checks if the first of the two entities has a lower priority than the second.
static boolean isSmallerOrEqual(Entity a, Entity b)
          Checks if the first of the two entities has lower or same priority than the second.
 int numQueues()
          Returns the number of Queues this Entity is currently queued in.
(package private)  void removeQueueLink(QueueLink removeQ)
          Removes a reference to the Queue this Entity was just removed from.
 void schedule(Event what, SimTime dt)
          Schedules this entity to be manipulated by the given event at the given offset to the current simulation time.
 void scheduleAfter(Schedulable after, Event what)
          Schedules this entity with the given event to occur directly after the given schedulable that is already scheduled.
 void scheduleBefore(Schedulable before, Event what)
          Schedules this entity with the given event to occur directly before the given schedulable that is scheduled.
 void setPriority(int newPriority)
          Sets the entity's priority to a given integer value.
 
Methods inherited from class desmoj.Schedulable
cancel, getEventNote, isCurrent, isScheduled, nextEntity, nextEvent, nextSchedulable, removeEventNote, rename, reSchedule, scheduledAt, setEventNote
 
Methods inherited from class desmoj.ModelComponent
current, currentEntity, currentEvent, currentModel, currentSimProcess, currentTime, debugIsOn, debugOff, debugOn, epsilon, getModel, isExperimentCompatible, isModelCompatible, sendDebugNote, sendMessage, sendTraceNote, sendWarning, setOwner, skipTraceNote, skipTraceNote, traceIsOn, traceOff, traceOn
 
Methods inherited from class desmoj.NamedObject
getName, getQuotedName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myPriority

private int myPriority
The priority of an entity is essential for inserting into queues.


myQLink

private QueueLink myQLink
Reference to the queue-links of this entity. They reference the places this entity is queued in in multiple queues. Implemented as a single linked list.

Constructor Detail

Entity

public Entity(Model owner,
              java.lang.String name,
              boolean showInTrace)
Constructs an entity with the given name for the given model and the specified trace option. The default priority is zero.

Method Detail

addQueueLink

void addQueueLink(QueueLink newQ)
Adds a reference to the queue this entity was just inserted in. The given queue-link is an element of a single linked list that always references to the next queue this entity is in.


getPriority

public int getPriority()
Returns the entity's priority. Default priority of an entity is zero. Higher priorities are positive, lower priorities negative.


getQueueLink

QueueLink getQueueLink(QueueList qList)
Returns a reference to the QueueLink of the given QueueList if this Entity is inside that QueueList. The Entity's single linked List of Queues it is currently queued in is scanned for a QueueLink that contains a reference to the given QueueList. That QueueLink is returned. It returns null if the Entity is not yet queued in the given QueueList.


isEqual

public static final boolean isEqual(Entity a,
                                    Entity b)
Checks if the two entities have the same priority. Note that this is a static method available through calling the entity's class i.e. Entity.isEqual(a,b) where a and b are valid entity objects.


isLarger

public static final boolean isLarger(Entity a,
                                     Entity b)
Checks if the first of the two entities has a higher priority than the second. Note that this is a static method available through calling the entity's class i.e. Entity.isLarger(a,b) where a and b are valid entity objects.


isLargerOrEqual

public static final boolean isLargerOrEqual(Entity a,
                                            Entity b)
Checks if the first of the two entities has higher or same priority than the second. Note that this is a static method available through calling the entity's class i.e. Entity.isLargerOrEqual(a,b) where a and b are valid entity objects.


isNotEqual

public static final boolean isNotEqual(Entity a,
                                       Entity b)
Checks if the first of the two entities have different priorities. Note that this is a static method available through calling the entity's class i.e. Entity.isNotEqual(a,b) where a and b are valid entity objects.


isSimProcess

public boolean isSimProcess()
Tests if this entity actually is a simprocess. Although simprocesses have an individual lifecycle, they can alsao be handled like entities and be scheduled to be manipulated by an event.


isSmaller

public static final boolean isSmaller(Entity a,
                                      Entity b)
Checks if the first of the two entities has a lower priority than the second. Note that this is a static method available through calling the entity's class i.e. Entity.isSmaller(a,b) where a and b are valid entity objects.


isSmallerOrEqual

public static final boolean isSmallerOrEqual(Entity a,
                                             Entity b)
Checks if the first of the two entities has lower or same priority than the second. Note that this is a static method available through calling the entity's class i.e. Entity.isSmallerOrEqual(a,b) where a and b are valid entity objects.


numQueues

public int numQueues()
Returns the number of Queues this Entity is currently queued in. Note that Entities that enter Queues for statistical reasons ("zeros") have that Queue registered with them for a short period of time. This might bias the value returned.


removeQueueLink

void removeQueueLink(QueueLink removeQ)
Removes a reference to the Queue this Entity was just removed from. The given QueueLink is an element of a single linked list that always references the next queue this Entity is in.


schedule

public void schedule(Event what,
                     SimTime dt)
Schedules this entity to be manipulated by the given event at the given offset to the current simulation time. Note that the given point in simulation time is the positive offset to the current simulation time as displayed by the simulation clock. Method returns with a warning message if either Entity or Event are already scheduled in the event-list.


scheduleAfter

public void scheduleAfter(Schedulable after,
                          Event what)
Schedules this entity with the given event to occur directly after the given schedulable that is already scheduled. Note that this event's point of simulation time will be set to be the same as the schedulable's time. Thus this event will occur directly after the given schedulable but the simulation clock will not change. Will return with a warning message if the schedulable given as parameter is not scheduled.


scheduleBefore

public void scheduleBefore(Schedulable before,
                           Event what)
Schedules this entity with the given event to occur directly before the given schedulable that is scheduled. Note that this event's point of simulation time will be set to be the same as the schedulable's time. Thus this event will occur directly before the given schedulable but the simulation clock will not change. Issues a warning message if the schedulable given is not scheduled.


setPriority

public void setPriority(int newPriority)
Sets the entity's priority to a given integer value. An entity's priority defines its position inside queues, when an entity enters any DESMO-J construction relying on queues. The entity with highest priority is always entered at the queue's first position. Entities with lower priority are enqueued behind entities with higher priority. Entities with same priority are enqueued following the FiFo strategy. Zero is default priority. Negative priorities are lower, positive priorities are higher. All values should be inside the range defined by Java's integral integer data type. [-2147483648, +2147483648]