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
Abstract base action used by the default scheduling mechanism.
- Author:
- Nick Collier
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classReschedules this AbstractAction for execution by resetting its nextTime to the last time it executed plus the interval of execution.protected static classEmpty implementation because an action scheduled not to repeat does not need to be rescheduled.protected static interfaceAn rescheduler is responsible for rescheduling an action in the ActionQueue. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FrequencyThe Frequency of this AbstractAction.protected doubleThe interval at which to execute this action.protected doubleThe next clock tick that this AbstractAction should be executed.protected booleanIf the action is a back-end action (true) or if it is a model action (false).protected doubleThe priority of this AbstractAction with respect to other actions scheduled for the same clock tick.protected PriorityTypeprotected AbstractAction.ReschedulerThe Rescheduler used by this AbstractAction to reschedule it for execution. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractAction(ScheduleParameters params) Creates an AbstractAction using the specified ScheduleParameters.AbstractAction(ScheduleParameters params, long orderIndex) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddForExecution(ScheduleGroup group) Add this ScheduableAction to the specified group for execution.doubleReturns the next time this AbstractAction should be executed.longGets an index indicating where this IAction was added to a schedule w/r to all other actions added to a schedule.doubleGets the priority of this action.Gets the PriorityType of this action.booleanThis is used by the schedule to determine if the action is a model related action or a back-end action.voidreschedule(ActionQueue queue) Reschedule this AbstractAction for execution.protected voidsetFrequency(Frequency freq) Sets the frequency of this AbstractAction.protected voidsetIsNonModelAction(boolean nonModelAction) protected voidsetIsNonModelAction(IAction action)
-
Field Details
-
frequency
The Frequency of this AbstractAction. -
nextTime
protected double nextTimeThe next clock tick that this AbstractAction should be executed. -
pType
-
interval
protected double intervalThe interval at which to execute this action. -
priority
protected double priorityThe priority of this AbstractAction with respect to other actions scheduled for the same clock tick. -
nonModelAction
protected boolean nonModelActionIf the action is a back-end action (true) or if it is a model action (false). -
rescheduler
The Rescheduler used by this AbstractAction to reschedule it for execution.
-
-
Constructor Details
-
AbstractAction
-
AbstractAction
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 Details
-
getNextTime
public double getNextTime()Returns the next time this AbstractAction should be executed.- Specified by:
getNextTimein interfaceISchedulableAction- Returns:
- the next time this AbstractAction should be executed.
-
setIsNonModelAction
-
setIsNonModelAction
protected void setIsNonModelAction(boolean nonModelAction) -
isNonModelAction
public boolean isNonModelAction()Description copied from interface:ISchedulableActionThis is used by the schedule to determine if the action is a model related action or a back-end action. NormalIActions useNonModelActionto specify this, butISchedulableActions should use this method.- Specified by:
isNonModelActionin interfaceISchedulableAction- Returns:
- if this is a back-end type action or not
-
setFrequency
Sets the frequency of this AbstractAction.- Parameters:
freq- the new Frequency of execution of this AbstractAction.
-
reschedule
Reschedule this AbstractAction for execution.- Specified by:
reschedulein interfaceISchedulableAction
-
addForExecution
Add this ScheduableAction to the specified group for execution.- Specified by:
addForExecutionin 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:
getPriorityin interfaceISchedulableAction- Returns:
- the priority of this AbstractAction.
-
getPriorityType
Description copied from interface:ISchedulableActionGets the PriorityType of this action.- Specified by:
getPriorityTypein 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:
getOrderIndexin interfaceISchedulableAction- Returns:
- an index indicating where this IAction was added to a schedule w/r to all other actions added to a schedule.
-