Class EntityGenerator

  • All Implemented Interfaces:
    GetEntityReceiverIfc, EventGeneratorIfc, ObservableIfc, GetNameIfc, IdentityIfc
    Direct Known Subclasses:
    EntityProcessGenerator

    public class EntityGenerator
    extends EventGenerator
    implements GetEntityReceiverIfc
    An EntityGenerator creates entities according to a entity type and sends them to a receiver according to the specified sending option. A general pattern of creation can be specified, see EventGenerator SendOption {DIRECT, SEQ, BY_TYPE} DIRECT, client must use setDirectEntityReceiver() to set the receiver SEQ, entity uses predefined sequence in its EntityType BY_TYPE, entity uses its EntityType to determine next receiver The default sending option is DIRECT. If the user does not supply a receiver via setDirectEntityReceiver() then an error will occur. If the SEQ option is used, the user is responsible for providing a sequence for the EntityType generated. If BY_TYPE then the user is responsible for overriding the getNextReceiver() method for the EntityType. To specify the type of entity generated, there are four options 1) override the getEntityType() method to determine the type 2) supply an object that implements GetEntityTypeIfc 3) supply an EntityType via setEntityType() 4) indicate that the generator should use the default entity type via useDefaultEntityType() option If one of these options is not used, then an error will occur
    • Constructor Detail

      • EntityGenerator

        public EntityGenerator​(ModelElement parent)
        Creates an EntityGenerator
        Parameters:
        parent -
      • EntityGenerator

        public EntityGenerator​(ModelElement parent,
                               java.lang.String name)
        Creates an EntityGenerator
        Parameters:
        parent -
        name -
      • EntityGenerator

        public EntityGenerator​(ModelElement parent,
                               RandomIfc timeUntilFirst)
        Creates an EntityGenerator
        Parameters:
        parent -
        timeUntilFirst - A RandomIfc object that supplies the time until the first event
      • EntityGenerator

        public EntityGenerator​(ModelElement parent,
                               RandomIfc timeUntilFirst,
                               java.lang.String name)
        Creates an EntityGenerator
        Parameters:
        parent -
        timeUntilFirst - A RandomIfc object that supplies the time until the first event
        name -
      • EntityGenerator

        public EntityGenerator​(ModelElement parent,
                               RandomIfc timeUntilFirst,
                               RandomIfc timeUntilNext)
        Creates an EntityGenerator.
        Parameters:
        parent -
        timeUntilFirst - A RandomIfc object that supplies the time until the first event
        timeUntilNext - A RandomIfc object that supplies the time between events
      • EntityGenerator

        public EntityGenerator​(ModelElement parent,
                               RandomIfc timeUntilFirst,
                               RandomIfc timeUntilNext,
                               java.lang.String name)
        Creates an EntityGenerator.
        Parameters:
        parent -
        timeUntilFirst - A RandomIfc object that supplies the time until the first event
        timeUntilNext - A RandomIfc object that supplies the time between events
        name -
      • EntityGenerator

        public EntityGenerator​(ModelElement parent,
                               RandomIfc timeUntilFirst,
                               RandomIfc timeUntilNext,
                               long maxNum,
                               java.lang.String name)
        Creates an EntityGenerator
        Parameters:
        parent -
        timeUntilFirst - A RandomIfc object that supplies the time until the first event.
        timeUntilNext - A RandomIfc object that supplies the time between events.
        maxNum - A RandomIfc object that supplies the maximum number of events to generate. This is typically a constant. When the generator is created, this variable is used to set the number of events to generate. The number is rounded to the closest long. Each time an event is to be scheduled the maximum number of events is checked. If the maximum has been reached, then the generator is turned off. If this variable is random, then it is only used once to set the number of events for the generator.
        name -
      • EntityGenerator

        public EntityGenerator​(ModelElement parent,
                               RandomIfc timeUntilFirst,
                               RandomIfc timeUntilNext,
                               long maxNum,
                               double timeUntilLast,
                               java.lang.String name)
        Creates an EntityGenerator that generates entities
        Parameters:
        parent -
        timeUntilFirst - A RandomIfc object that supplies the time until the first event.
        timeUntilNext - A RandomIfc object that supplies the time between events.
        maxNum - A RandomIfc object that supplies the maximum number of events to generate. This is typically a constant. When the generator is created, this variable is used to set the number of events to generate. The number is rounded to the closest long. Each time an event is to be scheduled the maximum number of events is checked. If the maximum has been reached, then the generator is turned off. If this variable is random, then it is only used once to set the number of events for the generator.
        timeUntilLast - A RandomIfc object that supplies a time to stop generating events. This is typically a constant. When the generator is created, this variable is used to set the ending time of the generator. Each time an event is to be scheduled the ending time is checked. If the time of the next event is past this time, then the generator is turned off and the event won't be scheduled. If this variable is random, then it is only used once to set the ending time of the generator.
        name - The name of the generator.
    • Method Detail

      • getEntityType

        protected EntityType getEntityType()
        Subclasses should override this to specify the type of entity that will be generated. By default, the default entity type is returned.
        Returns:
        Returns the type.
      • generate

        protected void generate​(JSLEvent event)
        Description copied from class: EventGenerator
        This method should be overridden by sub-classes that do not supply an EventGeneratorActionIfc to model the action that occur when the event happens.
        Overrides:
        generate in class EventGenerator
        Parameters:
        event - the event associated with the generations
      • setSendingOption

        public final void setSendingOption​(EntityType.SendOption option)
        Sets the sending option SendOption {DIRECT, SEQ, BY_TYPE} DIRECT, client must use setDirectEntityReceiver() to set receiver SEQ, entity uses predefined sequence in its EntityType BY_TYPE, entity uses its EntityType to determine next receiver
        Parameters:
        option - the sending option
      • getEntityTypeGetter

        public final GetEntityTypeIfc getEntityTypeGetter()
        The object that determines the type of the entity generated
        Returns:
        The object that determines the type
      • setEntityTypeGetter

        public final void setEntityTypeGetter​(GetEntityTypeIfc typeGetter)
        Can supply an object that will be used to determine the type of the entity that is generated. If no type is supplied getDefaultEntityType() is used
        Parameters:
        typeGetter - The object that determines the type
      • getDirectEntityReceiver

        public final EntityReceiverAbstract getDirectEntityReceiver()
        An object that will directly receive the entity
        Returns:
        the receiver
      • setDirectEntityReceiver

        public final void setDirectEntityReceiver​(EntityReceiverAbstract receiver)
        Can be used to supply a direct receiver. If used the sending option is automatically changed to direct
        Parameters:
        receiver - the receiver
      • setDirectEntityReceiver

        public final void setDirectEntityReceiver​(GetEntityReceiverIfc g)
        See setDirectEntityReceiver()
        Parameters:
        g - the thing that determines the receiver
      • setEntityType

        public void setEntityType​(EntityType entityType)
        Can be used to supply a pre-determined type to generate Can be null, if so, getEntityType() can be overridden or a EntityTypeGetter supplied
        Parameters:
        entityType - the type of the entity
      • useDefaultEntityType

        public void useDefaultEntityType()
        Indicates that the generator should use the default entity type
      • getEntityReceiver

        public final EntityReceiverAbstract getEntityReceiver()
        Allows the EntityGenerator to act like a location that can receive entities. It does not actually receive entities, but this method can be used to return a receiver so that the generator can be an origin point
        Specified by:
        getEntityReceiver in interface GetEntityReceiverIfc
        Returns:
        the receiver