Class EntityType

  • All Implemented Interfaces:
    ObservableIfc, GetNameIfc, IdentityIfc

    public class EntityType
    extends SchedulingElement
    EntityType represents a generic classification of entities. Every entity must have an entity type. The entity type holds information that is "global" to all entities of the type. To create entities, the client must use an instance of EntityType
    • Field Detail

      • myTimeInSystem

        protected ResponseVariable myTimeInSystem
        For tracking system time for entities by EntityType
      • myNumInSystem

        protected TimeWeighted myNumInSystem
        For tracking number of entities by EntityType
      • myReceiverSequence

        protected java.util.List<EntityReceiverAbstract> myReceiverSequence
        Holds the entity's list of receivers to visit
      • myEntityReceivedListeners

        protected java.util.List<EntityReceivedListener> myEntityReceivedListeners
        Used to hold listeners called prior to an entity being received
      • myEntitySentListeners

        protected java.util.List<EntitySentListener> myEntitySentListeners
        Used to hold listeners called after an entity is sent
      • myActivityTimes

        protected java.util.Map<Delay,​RandomVariable> myActivityTimes
        Holds the time it takes for each activity experienced by the entity
    • Constructor Detail

      • EntityType

        public EntityType​(ModelElement parent)
        Creates an EntityType with a default name
        Parameters:
        parent -
      • EntityType

        public EntityType​(ModelElement parent,
                          java.lang.String name)
        Creates an EntityType with the given name
        Parameters:
        parent -
        name -
    • Method Detail

      • createEntity

        public Entity createEntity​(java.lang.String name)
        Creates an entity with the given name
        Overrides:
        createEntity in class ModelElement
        Parameters:
        name -
        Returns:
      • turnOnTimeInSystemCollection

        public void turnOnTimeInSystemCollection()
        Causes time in system statistics to be collected for the EntityType
      • turnOnNumberInSystemCollection

        public void turnOnNumberInSystemCollection()
        Causes number in system statistics to be collected for the EntityType
      • defineAttributeType

        public final AttributeType defineAttributeType​(java.lang.String name)
        Defines an attribute type with the given name and adds it to the available types for this entity type
        Parameters:
        name - the name of the attribute type, must be non-null and unique to this entity type
        Returns:
      • getAttributeTypes

        public final java.util.List<AttributeType> getAttributeTypes()
        Returns an unmodifiable list of the attribute types
        Returns:
      • addToSequence

        public final void addToSequence​(GetEntityReceiverIfc g)
        Convenience method See addEntityReceiver(EntityReceiverAbstract receiver)
        Parameters:
        g -
      • addToSequence

        public final void addToSequence​(EntityReceiverAbstract receiver)
        Adds a receiver to the receiver sequence
        Parameters:
        receiver -
      • getSequenceIterator

        public final EntityReceiverIteratorIfc getSequenceIterator()
        Gets an EntityReceiverIteratorIfc to the sequence of receivers positioned at the beginning of the sequence
        Returns:
        the iterator or null if no receiver list
      • isSequenceEmpty

        public final boolean isSequenceEmpty()
        Returns whether or not the entity receiver sequence is empty
        Returns:
      • getSequenceSize

        public final int getSequenceSize()
        Returns the size of the Entity's receiver sequence zero if no sequence or if empty
        Returns:
      • getEntityReceiver

        public final EntityReceiverAbstract getEntityReceiver​(int index)
        Returns the EntityReceiver at the supplied index If a sequence of receivers is not defined or the supplied index is out of bounds then null is returned. Indexing is 0 based
        Parameters:
        index -
        Returns:
      • getDestination

        protected DestinationIfc getDestination​(Entity e)
        By default the origin/destination mapping (if defined) is used to determine the next receiver; however, this method can be overridden in sub-classes to provide a general method of determining the destination
        Parameters:
        e -
        Returns:
      • sendToDestination

        protected final void sendToDestination​(Entity e)
        Uses the DestinationIfc returned by getDestination(Entity e) to send the entity to its destination (receiver)
        Parameters:
        e -
      • sendToReceiver

        protected void sendToReceiver​(Entity e,
                                      EntityReceiverAbstract receiver)
        Causes the entity to be received by the receiver, with no time delay
        Parameters:
        e -
        receiver -
      • sendToReceiver

        protected void sendToReceiver​(Entity e,
                                      EntityReceiverAbstract receiver,
                                      double time)
        Causes the entity to be received by the receiver, perhaps after the designated time delay.
        Parameters:
        e -
        receiver -
        time -
      • dispose

        protected void dispose​(Entity e)
        Disposes of the entity, collects statistics if turned on
        Parameters:
        e -
      • attachEntityReceivedListener

        public void attachEntityReceivedListener​(EntityReceivedListener listener)
        Attaches a listener that will be called immediately before the entity is received, i.e. prior to receive(Entity entity) being called
        Parameters:
        listener -
      • detachEntityReceivedListener

        public void detachEntityReceivedListener​(EntityReceivedListener listener)
        Detaches a previously attached listener
        Parameters:
        listener -
      • notifyEntityReceivedListeners

        protected void notifyEntityReceivedListeners​(Entity entity)
      • notifyEntitySentListeners

        protected void notifyEntitySentListeners​(Entity entity)
      • attachEntitySentListener

        public void attachEntitySentListener​(EntitySentListener listener)
        Attaches a listener that will be called immediately before the entity is sent, i.e. prior to sendEntity(Entity e) being called
        Parameters:
        listener -
      • detachEntitySentListener

        public void detachEntitySentListener​(EntitySentListener listener)
        Detaches a listener
        Parameters:
        listener -
      • addDestination

        public void addDestination​(EntityReceiverAbstract origin,
                                   EntityReceiverAbstract destination,
                                   RVariableIfc random)
        Associates a destination (DestinationIfc) with the supplied origin (EntityReceiverAbstract). The supplied RandomIfc indicates the delay to arrive at the destination
        Parameters:
        origin -
        destination -
        random -
      • addDestination

        public void addDestination​(EntityReceiverAbstract origin,
                                   EntityReceiverAbstract destination,
                                   GetValueIfc value)
        Associates a destination (DestinationIfc) with the supplied origin (EntityReceiverAbstract). The supplied GetValueIfc indicates the delay to arrive at the destination
        Parameters:
        origin -
        destination -
        value -
      • addDestination

        public void addDestination​(EntityReceiverAbstract origin,
                                   EntityReceiverAbstract destination,
                                   double time)
        Associates a destination (DestinationIfc) with the supplied origin (EntityReceiverAbstract). The supplied time indicates the delay to arrive at the destination
        Parameters:
        origin -
        destination -
        time -
      • addDestination

        public void addDestination​(EntityReceiverAbstract origin,
                                   EntityReceiverAbstract destination)
        Associates a destination (DestinationIfc) with the supplied origin (EntityReceiverAbstract). The supplied time indicates the delay to arrive at the destination
        Parameters:
        origin -
        destination -
      • addDestination

        public void addDestination​(GetEntityReceiverIfc origin,
                                   GetEntityReceiverIfc destination,
                                   double time)
        Associates a destination (DestinationIfc) with the supplied origin (GetEntityReceiverIfc). The supplied time indicates the delay to arrive at the destination (GetEntityReceiverIfc)
        Parameters:
        origin -
        destination -
        time -
      • addDestination

        public void addDestination​(GetEntityReceiverIfc origin,
                                   GetEntityReceiverIfc destination)
        Associates a destination (DestinationIfc) with the supplied origin (GetEntityReceiverIfc). The supplied time indicates the delay to arrive at the destination (GetEntityReceiverIfc)
        Parameters:
        origin -
        destination -
      • addDestination

        public void addDestination​(GetEntityReceiverIfc origin,
                                   EntityReceiverAbstract destination,
                                   double time)
        Associates a destination (DestinationIfc) with the supplied origin (GetEntityReceiverIfc). The supplied time indicates the delay to arrive at the destination
        Parameters:
        origin -
        destination -
        time -
      • addDestination

        public void addDestination​(GetEntityReceiverIfc origin,
                                   EntityReceiverAbstract destination)
        Associates a destination (DestinationIfc) with the supplied origin (GetEntityReceiverIfc). The supplied time indicates the delay to arrive at the destination
        Parameters:
        origin -
        destination -
      • addDestination

        public final void addDestination​(EntityReceiverAbstract origin,
                                         DestinationIfc d)
        Associates a destination (DestinationIfc) with the supplied origin (EntityReceiverAbstract)
        Parameters:
        origin -
        d -
      • numberOfOrigins

        public final int numberOfOrigins()
        Number of origins in the origin/destination mapping
        Returns:
      • isOriginDestinationNetworkEmpty

        public final boolean isOriginDestinationNetworkEmpty()
        Whether or not the origin/destination mapping is empty
        Returns:
      • containsOrigin

        public final boolean containsOrigin​(EntityReceiverAbstract origin)
        True if the origin has already been added to the O/D mapping
        Parameters:
        origin -
        Returns:
      • getActivityTime

        protected double getActivityTime​(Delay a)
      • containsActivity

        public final boolean containsActivity​(Delay a)
        True if the Activity has already been added
        Parameters:
        a -
        Returns:
      • addActivityTime

        public final void addActivityTime​(Delay a,
                                          double time)
        Associates a time with an Activity for the EntityType
        Parameters:
        a -
        time -
      • addActivityTime

        public final void addActivityTime​(Delay a,
                                          RVariableIfc r)
        Associates a activity (Activity) with the supplied random time
        Parameters:
        a - The activity
        r - The time