public class Arbitrator
extends java.lang.Object
action()
and suppress()
methods on them.
takeControl()
. action()
method exits, call action()
on the Behavior of highest priority. action()
exits,
suppress()
on the active Behavior i.e. whose action()
method is running.
action()
on the same Behavior.
suppress()
is called, terminate action()
immediately.
action()
exits, the robot is in a safe state (e.g. motors stopped)
takeControl()
should continue to return true
go()
to start it running.
Behavior
Modifier and Type | Class and Description |
---|---|
private class |
Arbitrator.Monitor
Finds the highest priority behavior that returns true to
takeControl() ;
If this priority is higher than the active behavior, it calls active.suppress(). |
Modifier and Type | Field and Description |
---|---|
private int |
_active |
private Behavior[] |
_behavior |
private int |
_highestPriority |
private boolean |
_returnWhenInactive |
boolean |
keepRunning |
private Arbitrator.Monitor |
monitor
Monitor is an inner class.
|
private int |
NONE |
Constructor and Description |
---|
Arbitrator(Behavior[] behaviorList)
Same as Arbitrator(behaviorList, false) Arbitrator start() never exits
|
Arbitrator(Behavior[] behaviorList,
boolean returnWhenInactive)
Allocates an Arbitrator object and initializes it with an array of
Behavior objects.
|
Modifier and Type | Method and Description |
---|---|
void |
go()
This method starts the arbitration of Behaviors and runs an endless loop.
|
void |
stop() |
private final int NONE
private Behavior[] _behavior
private int _highestPriority
private int _active
private boolean _returnWhenInactive
public boolean keepRunning
private Arbitrator.Monitor monitor
public Arbitrator(Behavior[] behaviorList, boolean returnWhenInactive)
behaviorList
- an array of Behavior objects.returnWhenInactive
- if true, the go() method returns when no Behavior is active.public Arbitrator(Behavior[] behaviorList)
behaviorList
- An array of Behavior objects.public void go()
no action()
method is running and
takeControl()
returns true and
public void stop()