lejos.robotics.subsumption
Class Arbitrator

java.lang.Object
  extended by lejos.robotics.subsumption.Arbitrator

public class Arbitrator
extends Object

Arbitrator controls which behavior should become active in a behavior control system. Make sure to call start() after the Arbitrator is instantiated.
This class has three major responsibilities:
1. Determine the highest priority behavior that returns true to takeControl()
2. Suppress the 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 Behavior becomes active. Chances since release 0.7:
1. It assumes that a Behavior is no longer active when action() exits.
2. Therefore it will only call suppress() on the Behavior whose action() method is running.
3. It can make consecutives calls of action() on the same Behavior.
4. Requirements for a Behavior:
When suppress() is called, terminate action() immediately.

Author:
Roger Glassey
See Also:
Behavior

Constructor Summary
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.
 
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
 

Constructor Detail

Arbitrator

public Arbitrator(Behavior[] behaviorList,
                  boolean returnWhenInactive)
Allocates an Arbitrator object and initializes it with an array of Behavior objects. The index of a behavior in this array is its priority level, so the behavior of the largest index has the highest the priority level. The behaviors in an Arbitrator can not be changed once the arbitrator is initialized.
NOTE: Once the Arbitrator is initialized, the method start() must be called to begin the arbitration.

Parameters:
behaviorList - an array of Behavior objects.
returnWhenInactive - if true, the start() method returns when no Behavior is active.

Arbitrator

public Arbitrator(Behavior[] behaviorList)
Same as Arbitrator(behaviorList, false) Arbitrator start() never exits

Parameters:
behaviorList - An array of Behavior objects.
Method Detail

start

public void start()
This method starts the arbitration of Behaviors and runs an endless loop.
Note: Arbitrator does not run in a separate thread. The start() method will never return unless
1. no action() method is running and
2. no behavior takeControl() returns true and
3. the returnWhenInacative flag is true,