Class TimedAction

  • All Implemented Interfaces:
    ObservableIfc, GetNameIfc, IdentityIfc

    public class TimedAction
    extends SchedulingElement
    A TimedAction represents a set of actions associated with an event that can be repeated at regular intervals. Each TimedAction can have any number of TimedActionListeners attached that represent the actions that should occur when the event occurs. The attached listeners are called in the order defined by their priority. By default, the event will be automatically scheduled to occur at the start of each replication. By default the event will automatically repeat according to the provided interval.
    • Constructor Detail

      • TimedAction

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

        public TimedAction​(ModelElement parent,
                           double time)
        Parameters:
        parent - the parent model element
        time - the time between actions
      • TimedAction

        public TimedAction​(ModelElement parent,
                           double time,
                           java.lang.String name)
        Parameters:
        parent - the parent model element
        time - the time between actions
        name - the name of the model element
      • TimedAction

        public TimedAction​(ModelElement parent,
                           RandomIfc actionTime)
        Parameters:
        parent - the parent model element
        actionTime - the time between actions
      • TimedAction

        public TimedAction​(ModelElement parent,
                           RandomIfc actionTime,
                           boolean schedInitFlag,
                           boolean repeatActionFlag,
                           java.lang.String name)
        Creates a Timed Action
        Parameters:
        parent - the parent model element
        actionTime - the time between actions
        schedInitFlag - Indicates whether to schedule initial action at initialization
        repeatActionFlag - Indicates whether the actions will automatically repeat after their first occurrence
        name - the name of the model element
    • Method Detail

      • getTimeBetweenActions

        public final RandomIfc getTimeBetweenActions()
        Returns:
        Returns the actionTime.
      • getTimeBetweenActionsForReplications

        public final RandomIfc getTimeBetweenActionsForReplications()
        Returns:
        Returns the actionTime.
      • setTimeBetweenActionsInitialRandomSource

        public final void setTimeBetweenActionsInitialRandomSource​(double time)
        Sets the time between actions to be a constant time for all replications
        Parameters:
        time - the initial time between actions
      • setTimeBetweenActionsInitialRandomSource

        public final void setTimeBetweenActionsInitialRandomSource​(RandomIfc actionTime)
        Sets the time between actions for all replications
        Parameters:
        actionTime - The actionTime to set.
      • setTimeBetweenActions

        public final void setTimeBetweenActions​(double time)
        Sets the time between actions to be a constant time for the current replication
        Parameters:
        time - the time between actions
      • setTimeBetweenActions

        public final void setTimeBetweenActions​(RandomIfc actionTime)
        Sets the time between actions for the current replication
        Parameters:
        actionTime - The actionTime to set.
      • getScheduleOnInitializeFlag

        public boolean getScheduleOnInitializeFlag()
        This flag indicates whether or not the action will automatically be scheduled when initialize() is called. By default this option is false.
        Returns:
        true means that it is automatic
      • setScheduleOnInitializeFlag

        public void setScheduleOnInitializeFlag​(boolean flag)
        Sets the flag that indicates whether or not the action will be automatically scheduled when initialize() is called. WARNING: If this is changed, it affects the next replication to be initialized() and all subsequent replications. Thus, the initialization of replications may not be the same. The recommended use is prior to any replications being executed.
        Parameters:
        flag - true means it will be scheduled
      • cancelAction

        public final void cancelAction()
        Causes the event associated with the actions to be canceled if it had been scheduled. The next scheduled action will not occur.
      • getRepeatActionFlag

        public final boolean getRepeatActionFlag()
        True means the action will repeat. By default the action will repeat.
        Returns:
        Returns the repeatActionFlag.
      • setRepeatActionFlag

        public final void setRepeatActionFlag​(boolean repeatActionFlag)
        True means the action will repeat. By default the action will repeat. WARNING: If this is changed, this controls whether the action will be repeated after the next event occurs. The actions will not be repeated for the rest of the replication and for any subsequent replications. Thus, replications may not be the same. The recommended use is prior to any replications being executed.
        Parameters:
        repeatActionFlag - The repeatActionFlag to set.
      • attachTimedActionListener

        protected void attachTimedActionListener​(TimedActionListener listener)
        Adds a listener to react to the action event Listeners are ordered by their compareTo() method
        Parameters:
        listener - the timed action listener
      • removeTimedActionListener

        public boolean removeTimedActionListener​(TimedActionListener listener)
        Removes the listener so that it does not react to the action event
        Parameters:
        listener - , the listener to be removed
        Returns:
        true if it was removed
      • scheduleAction

        public final void scheduleAction()
        If the action has not been previously scheduled this method causes the action to be scheduled according to it's action time distribution. If the action has been canceled, then the action is scheduled for a new time according to it's action time. If the action is already scheduled and not canceled, this method has no effect.
      • 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
      • notifyTimedActionListeners

        protected final void notifyTimedActionListeners​(JSLEvent event)