Package repast.simphony.engine.schedule
Class AbstractAction
- java.lang.Object
-
- repast.simphony.engine.schedule.AbstractAction
-
- All Implemented Interfaces:
IAction
,ISchedulableAction
- Direct Known Subclasses:
DefaultAction
,ThreadedAction
public abstract class AbstractAction extends Object implements ISchedulableAction
Abstract base action used by the default scheduling mechanism.- Author:
- Nick Collier
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AbstractAction.IntervalRescheduler
Reschedules this AbstractAction for execution by resetting its nextTime to the last time it executed plus the interval of execution.protected static class
AbstractAction.OneTimeRescheduler
Empty implementation because an action scheduled not to repeat does not need to be rescheduled.protected static interface
AbstractAction.Rescheduler
An rescheduler is responsible for rescheduling an action in the ActionQueue.
-
Field Summary
Fields Modifier and Type Field Description protected Frequency
frequency
The Frequency of this AbstractAction.protected double
interval
The interval at which to execute this action.protected double
nextTime
The next clock tick that this AbstractAction should be executed.protected boolean
nonModelAction
If the action is a back-end action (true) or if it is a model action (false).protected double
priority
The priority of this AbstractAction with respect to other actions scheduled for the same clock tick.protected PriorityType
pType
protected AbstractAction.Rescheduler
rescheduler
The Rescheduler used by this AbstractAction to reschedule it for execution.
-
Constructor Summary
Constructors Constructor Description AbstractAction(ScheduleParameters params)
Creates an AbstractAction using the specified ScheduleParameters.AbstractAction(ScheduleParameters params, long orderIndex)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addForExecution(ScheduleGroup group)
Add this ScheduableAction to the specified group for execution.double
getNextTime()
Returns the next time this AbstractAction should be executed.long
getOrderIndex()
Gets an index indicating where this IAction was added to a schedule w/r to all other actions added to a schedule.double
getPriority()
Gets the priority of this action.PriorityType
getPriorityType()
Gets the PriorityType of this action.boolean
isNonModelAction()
This is used by the schedule to determine if the action is a model related action or a back-end action.void
reschedule(ActionQueue queue)
Reschedule this AbstractAction for execution.protected void
setFrequency(Frequency freq)
Sets the frequency of this AbstractAction.protected void
setIsNonModelAction(boolean nonModelAction)
protected void
setIsNonModelAction(IAction action)
-
-
-
Field Detail
-
frequency
protected Frequency frequency
The Frequency of this AbstractAction.
-
nextTime
protected double nextTime
The next clock tick that this AbstractAction should be executed.
-
pType
protected PriorityType pType
-
interval
protected double interval
The interval at which to execute this action.
-
priority
protected double priority
The priority of this AbstractAction with respect to other actions scheduled for the same clock tick.
-
nonModelAction
protected boolean nonModelAction
If the action is a back-end action (true) or if it is a model action (false).
-
rescheduler
protected AbstractAction.Rescheduler rescheduler
The Rescheduler used by this AbstractAction to reschedule it for execution.
-
-
Constructor Detail
-
AbstractAction
public AbstractAction(ScheduleParameters params, long orderIndex)
-
AbstractAction
public AbstractAction(ScheduleParameters params)
Creates an AbstractAction using the specified ScheduleParameters. The AbstractAction's scheduling data is set from the ScheduleParameters argument.- Parameters:
params
- the scheduling data used by this AbstractAction
-
-
Method Detail
-
getNextTime
public double getNextTime()
Returns the next time this AbstractAction should be executed.- Specified by:
getNextTime
in interfaceISchedulableAction
- Returns:
- the next time this AbstractAction should be executed.
-
setIsNonModelAction
protected void setIsNonModelAction(IAction action)
-
setIsNonModelAction
protected void setIsNonModelAction(boolean nonModelAction)
-
isNonModelAction
public boolean isNonModelAction()
Description copied from interface:ISchedulableAction
This is used by the schedule to determine if the action is a model related action or a back-end action. NormalIAction
s useNonModelAction
to specify this, butISchedulableAction
s should use this method.- Specified by:
isNonModelAction
in interfaceISchedulableAction
- Returns:
- if this is a back-end type action or not
-
setFrequency
protected void setFrequency(Frequency freq)
Sets the frequency of this AbstractAction.- Parameters:
freq
- the new Frequency of execution of this AbstractAction.
-
reschedule
public void reschedule(ActionQueue queue)
Reschedule this AbstractAction for execution.- Specified by:
reschedule
in interfaceISchedulableAction
-
addForExecution
public void addForExecution(ScheduleGroup group)
Add this ScheduableAction to the specified group for execution.- Specified by:
addForExecution
in interfaceISchedulableAction
- Parameters:
group
- the group to add the ISchedulableAction to.
-
getPriority
public double getPriority()
Gets the priority of this action. The priority refers to this AbstractAction's place in the order of execution with respect to all the other actions that will execute at the same clock tick. The range is from Double.NEGATIVE_INFINITY (execute first) to Double.POSITIVE_INFINITY (execute last). The default is ScheduleParameters.RANDOM_PRIORITY which means the priority will be randomly assigned from a uniform distribution.- Specified by:
getPriority
in interfaceISchedulableAction
- Returns:
- the priority of this AbstractAction.
-
getPriorityType
public PriorityType getPriorityType()
Description copied from interface:ISchedulableAction
Gets the PriorityType of this action.- Specified by:
getPriorityType
in interfaceISchedulableAction
- Returns:
- the PriorityType of this action.
-
getOrderIndex
public long getOrderIndex()
Gets an index indicating where this IAction was added to a schedule w/r to all other actions added to a schedule.- Specified by:
getOrderIndex
in interfaceISchedulableAction
- Returns:
- an index indicating where this IAction was added to a schedule w/r to all other actions added to a schedule.
-
-