Package jsl.simulation
Class ConditionalActionProcessor
- java.lang.Object
-
- jsl.simulation.ConditionalActionProcessor
-
public class ConditionalActionProcessor extends java.lang.Object
Processes the ConditionalActions to check if their testCondition() is true, if so the action is executed. All actions are checked until no action's testCondition() is true To prevent conditional cycling the number of rescans is limited to DEFAULT_MAX_SCANS, which can be changed by the user or turned off via setMaxScanFlag()
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_SCANS
static int
DEFAULT_PRIORITY
protected OrderedList<ConditionalAction>
myActions
protected int
myMaxScans
-
Constructor Summary
Constructors Constructor Description ConditionalActionProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
changePriority(ConditionalAction action, int priority)
Changes the priority of a previously registered actionprotected boolean
executeConditionalActions()
Returns true at least one ConditionalAction was executed false means all actions tested falseboolean
getMaxScanFlag()
Returns the maximum scan flagint
getMaxScans()
Returns the maximum number of scans during the c phaseprotected void
performCPhase()
void
register(ConditionalAction action)
Registers the action with the default priorityvoid
register(ConditionalAction action, int priority)
Registers the action with the given priorityvoid
setMaxScanFlag(boolean flag)
Sets the maximum scan checking flag.void
setMaxScans(int max)
Sets the maximum number of scansvoid
unregister(ConditionalAction action)
Unregisters the action from the simulationvoid
unregisterAllActions()
Unregisters all actions that were previously registered.
-
-
-
Field Detail
-
DEFAULT_MAX_SCANS
public static final int DEFAULT_MAX_SCANS
- See Also:
- Constant Field Values
-
DEFAULT_PRIORITY
public static final int DEFAULT_PRIORITY
- See Also:
- Constant Field Values
-
myMaxScans
protected int myMaxScans
-
myActions
protected OrderedList<ConditionalAction> myActions
-
-
Method Detail
-
register
public void register(ConditionalAction action)
Registers the action with the default priority- Parameters:
action
- the action
-
register
public void register(ConditionalAction action, int priority)
Registers the action with the given priority- Parameters:
action
- the actionpriority
- the priority
-
changePriority
public void changePriority(ConditionalAction action, int priority)
Changes the priority of a previously registered action- Parameters:
action
- the actionpriority
- the priority
-
unregister
public void unregister(ConditionalAction action)
Unregisters the action from the simulation- Parameters:
action
- the action
-
unregisterAllActions
public final void unregisterAllActions()
Unregisters all actions that were previously registered.
-
executeConditionalActions
protected boolean executeConditionalActions()
Returns true at least one ConditionalAction was executed false means all actions tested false- Returns:
- true if at least one
-
getMaxScans
public final int getMaxScans()
Returns the maximum number of scans during the c phase- Returns:
- the max
-
setMaxScans
public final void setMaxScans(int max)
Sets the maximum number of scans- Parameters:
max
- , must be > 0
-
performCPhase
protected void performCPhase()
-
getMaxScanFlag
public final boolean getMaxScanFlag()
Returns the maximum scan flag- Returns:
- true means scans are monitored
-
setMaxScanFlag
public final void setMaxScanFlag(boolean flag)
Sets the maximum scan checking flag. If true the maximum number of scans is monitored during the c phase- Parameters:
flag
- true means monitor scans
-
-