|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttfg.subsumption.ArbitratorEx
public class ArbitratorEx
ArbitratorS controls which behavior should currently be active in
a behavior control system. Make sure to call start() after the
ArbitratorS is instantiated.
This class has three major responsibilities:
1. Determine the highest priority behavior that returns true to takeControl()
2. Suppress the currently active behavior if its priority is less than highest
priority.
3. When the action() method exits, it calls action() on the Behavior of highest priority.
this class ia a simplified version of Arbitrator. The differences are:
It assumes that a Behavior is no longer active when action() exits.
Therefore it will only call suppress() on the Behavior whose action() method is running.
It can make consecutive calls of action() on the same Behavior.
Requirements for a Behavior:
When suppress() is called, terminate action() immediately.
Behavior
Nested Class Summary | |
---|---|
private class |
ArbitratorEx.Monitor
Finds the highest priority behavior that returns true to takeControl(); If this priority is higher than the current behavior, it calls current.suppress(). |
Field Summary | |
---|---|
private Behavior[] |
_behavior
|
private int |
_current
|
private int |
_highestPriority
|
private boolean |
_returnWhenInactive
|
private ArbitratorEx.Monitor |
monitor
Monitor is an inner class. |
private int |
NONE
|
Constructor Summary | |
---|---|
ArbitratorEx(Behavior[] behaviorList)
Same as Arbitrator(behaviorList, false) Arbitrator start() never exits |
|
ArbitratorEx(Behavior[] behaviorList,
boolean returnWhenInactive)
Allocates an ArbitratorS object and initializes it with an array of Behavior objects. |
Method Summary | |
---|---|
void |
start()
This method starts the arbitration of Behaviors and runs an endless loop. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final int NONE
private Behavior[] _behavior
private int _highestPriority
private int _current
private boolean _returnWhenInactive
private ArbitratorEx.Monitor monitor
Constructor Detail |
---|
public ArbitratorEx(Behavior[] behaviorList, boolean returnWhenInactive)
behaviorList
- an array of Behavior objects.returnWhenInactive
- if true, the start() method returns when no Behavior is active.public ArbitratorEx(Behavior[] behaviorList)
behaviorList
- An array of Behavior objects.Method Detail |
---|
public void start()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |