Class ActionSchedule

  • All Implemented Interfaces:
    ObservableIfc, GetNameIfc, IdentityIfc

    public class ActionSchedule
    extends SchedulingElement
    This class allows the creation of a schedule that represents a list of actions with the time between each action specified. The user adds a ScheduleAction or a duration/action pair and can specify when the schedule should start invoking the actions with a start time. The actions can be repeated after all duration/action pairs have been invoked only if their total duration does not exceed the time remaining until the end of the action schedule's cycle length. Model m = Model.createModel(); ActionSchedule s = new ActionSchedule(m); s.addScheduledAction(eventAction1, 20, "action 1"); s.addScheduledAction(eventAction1, 15, "action 2"); After 20 time units, action 1 will be invoked, after another 15 time units action 2 will be invoked. This pattern will be repeated. Thus the duration represents the time until the action is invoked after the previous action (or start of the schedule).

    The entire schedule has a cycle length. The total of all the durations added must be less than the action schedule's cycle length. The schedule can be repeated after all actions have been completed. The default length of a schedule's cycle length is positive infinity

    • Field Detail

      • myAutomaticStartFlag

        protected boolean myAutomaticStartFlag
        Indicates whether or not the schedule should be started automatically upon initialization, default is true
      • myActionRepeatFlag

        protected boolean myActionRepeatFlag
        Indicates whether or not the actions on the schedule should be repeated after completing all the scheduled actions. The default is to repeat the actions
      • myInitialStartTime

        protected double myInitialStartTime
        The time from the beginning of the replication to the time that the schedule is to start
      • myCycleStartTime

        protected double myCycleStartTime
        The time that the schedule started for its current cycle
      • myScheduleRepeatFlag

        protected boolean myScheduleRepeatFlag
        The schedule repeat flag controls whether or not the entire schedule will repeat after its entire duration has elapsed. The default is to repeat the schedule. The use of this flag only makes sense if a finite schedule length is specified
      • myScheduleLength

        protected double myScheduleLength
        Represents the total length of time of the schedule. The total of the durations added to the schedule cannot exceed this amount After this time has elapsed the entire schedule can repeat if the schedule repeat flag is true. The default is infinite.
      • myDurationTotal

        protected double myDurationTotal
        Keeps track of the total of the durations that have been added to the schedule.
      • myActions

        protected java.util.List<ScheduledAction> myActions
        Holds the actions to be invoked by time
      • myStartEvent

        protected JSLEvent<java.lang.Object> myStartEvent
        Represents the event scheduled to start the schedule
      • myActionEvent

        protected JSLEvent<java.lang.Object> myActionEvent
        Represents the event for the actions on the schedule
      • myEndEvent

        protected JSLEvent<java.lang.Object> myEndEvent
        Represents the event for the end of the schedule
      • myActionIterator

        protected java.util.Iterator<ScheduledAction> myActionIterator
        An iterator over the actions
      • myNextScheduledAction

        protected ScheduledAction myNextScheduledAction
        The action that is currently scheduled, next to occur
    • Constructor Detail

      • ActionSchedule

        public ActionSchedule​(ModelElement parent)
        Parameters:
        parent - the parent model element
      • ActionSchedule

        public ActionSchedule​(ModelElement parent,
                              java.lang.String name)
        Parameters:
        parent - the parent model element
        name - the name of the ActionSchedule as a model element, must be unique
      • ActionSchedule

        public ActionSchedule​(ModelElement parent,
                              double scheduleLength)
        Parameters:
        parent - the parent model element
        scheduleLength - The total time available for the schedule
      • ActionSchedule

        public ActionSchedule​(ModelElement parent,
                              double startTime,
                              double scheduleLength)
        Parameters:
        parent - the parent model element
        startTime - The time that the schedule should start
        scheduleLength - The total time available for the schedule
      • ActionSchedule

        public ActionSchedule​(ModelElement parent,
                              double scheduleLength,
                              java.lang.String name)
        Parameters:
        parent - the parent model element
        scheduleLength - The total time available for the schedule
        name - the name of the ActionSchedule as a model element, must be unique
      • ActionSchedule

        public ActionSchedule​(ModelElement parent,
                              double startTime,
                              double scheduleLength,
                              java.lang.String name)
        Parameters:
        parent - the parent model element
        startTime - The time that the schedule should start
        scheduleLength - The total time available for the schedule
        name - the name of the ActionSchedule as a model element, must be unique
      • ActionSchedule

        public ActionSchedule​(ModelElement parent,
                              double startTime,
                              double scheduleLength,
                              boolean repeatSchedule,
                              boolean repeatActions,
                              boolean startAutomatically,
                              java.lang.String name)
        Parameters:
        parent - the parent model element
        startTime - The time that the schedule should start
        scheduleLength - The total time available for the schedule
        repeatSchedule - Whether or not the schedule will repeat
        repeatActions - Whether or not the actions may repeat
        startAutomatically - Whether or not the start of the schedule is scheduled automatically
        name - the name of the ActionSchedule as a model element, must be unique
    • Method Detail

      • setAutomaticStartFlag

        public final void setAutomaticStartFlag​(boolean flag)
        Sets the flag that indicates whether or not the first action will automatically schedule when initialize() is called.
        Parameters:
        flag - true means start automatically
      • getAutomaticStartFlag

        public final boolean getAutomaticStartFlag()
        This flag indicates whether or not the action will automatically scheduled when initialize() is called. By default this option is true.
        Returns:
        true means it starts automatically
      • getActionRepeatFlag

        public final boolean getActionRepeatFlag()
        True means the scheduled actions will repeat after all actions have been invoked. By default the scheduled actions will repeat.
        Returns:
        Returns the repeatActionFlag.
      • setActionRepeatFlag

        public final void setActionRepeatFlag​(boolean repeatActionFlag)
        True means the scheduled actions will repeat after all actions have been invoked. By default the scheduled actions will repeat.
        Parameters:
        repeatActionFlag - The repeatActionFlag to set.
      • getInitialStartTime

        public final double getInitialStartTime()
        Gets the time after the beginning of the replication that represents the starting time for the schedule
        Returns:
        the initial start time
      • setInitialStartTime

        protected final void setInitialStartTime​(double startTime)
        Sets the starting time after the beginning of the replication for the schedule to start.
        Parameters:
        startTime - Must be >= zero
      • getCycleStartTime

        public final double getCycleStartTime()
        Returns the time that the schedule started its current cycle
        Returns:
        the time that the schedule started its current cycle
      • getElapsedCycleTime

        public final double getElapsedCycleTime()
        The time that has elapsed into the current cycle
        Returns:
        time that has elapsed into the current cycle
      • getRemainingCycleTime

        public final double getRemainingCycleTime()
        The time remaining within the current cycle
        Returns:
        time remaining within the current cycle
      • setScheduleRepeatFlag

        public final void setScheduleRepeatFlag​(boolean flag)
        Sets whether or not the schedule will repeat after it reaches it length
        Parameters:
        flag - true indicates it will repeat
      • getScheduleRepeatFlag

        public final boolean getScheduleRepeatFlag()
        Returns whether or not the schedule will repeat after it reaches it length
        Returns:
        true indicates that it will repeat
      • setScheduleLength

        protected final void setScheduleLength​(double scheduleLength)
        Sets the total length of the schedule
        Parameters:
        scheduleLength - Must be > 0
      • getScheduleLength

        public final double getScheduleLength()
        Gets the total length of the schedule. The total length of the schedule must be >= the total of the durations on the schedule
        Returns:
        the total length of the schedule.
      • getDurationRemainingOnSchedule

        public final double getDurationRemainingOnSchedule()
        Returns the amount of time left within the schedule cycle length for possible duration/actions
        Returns:
        the amount of time left within the schedule cycle length for possible duration/actions
      • getDurationTotal

        public final double getDurationTotal()
        Returns how much of the schedule's length has been covered by actions
        Returns:
        how much of the schedule's length has been covered by actions
      • getNumberOfActions

        public final int getNumberOfActions()
        The number of actions that have been scheduled
        Returns:
        number of actions that have been scheduled
      • addScheduledAction

        public final void addScheduledAction​(EventAction eventAction,
                                             double duration)
        Parameters:
        duration - the duration from the start of the schedule, must be positive
        eventAction - the event action that will be invoked, cannot be null
      • addScheduledAction

        public final void addScheduledAction​(EventAction eventAction,
                                             double duration,
                                             java.lang.String name)
        Parameters:
        duration - the duration from the start of the schedule, must be positive
        eventAction - the event action that will be invoked, cannot be null
        name - the name of the scheduled action
      • scheduleStart

        public final void scheduleStart()
        Schedules the start of the schedule for the start time of the schedule if it has not already be started
      • initialize

        protected void initialize()
        Description copied from class: ModelElement
        This method should be overridden by subclasses that need actions performed to initialize prior to a replication. It is called once before each replication occurs if the model element wants initialization. It is called after beforeReplication() is called
        Overrides:
        initialize in class ModelElement
      • afterReplication

        protected void afterReplication()
        Description copied from class: ModelElement
        This method should be overridden by subclasses that need actions performed after each replication. It is called after replicationEnded() has been called.
        Overrides:
        afterReplication in class ModelElement
      • scheduleNextAction

        protected void scheduleNextAction()