RoboJDETM v2.0

com.ridgesoft.robotics.behaviors
Class AbstractBehavior2

java.lang.Object
  extended by com.ridgesoft.robotics.behaviors.AbstractBehavior2
All Implemented Interfaces:
Behavior, Behavior2
Direct Known Subclasses:
AvoidBehavior, GoToBehavior, StopBehavior

public abstract class AbstractBehavior2
extends Object
implements Behavior2

Implements an abstract class providing the functionality of the Behavior2 inteface.

See Also:
BehaviorArbiter, Behavior, Behavior2, BehaviorEvent, BehaviorListener, com.ridgesoft.robotics.behaviors

Field Summary
protected  boolean mEnabled
          Current enabled state.
protected  boolean mIsActive
          Current activation state.
protected  BehaviorListener mListener
          Reference to the BehaviorListener or null if none is registered.
 
Constructor Summary
protected AbstractBehavior2(boolean enabled)
          Initializes this class when a subclass is constructed.
 
Method Summary
abstract  boolean poll()
          This method is invoked at regular intervals to determine if the behavior desires to control the robot.
 void setActive(boolean isActive)
          Activates or deactivates the behavior.
 void setEnabled(boolean enabled)
          Enables or disables the behavior.
 void setListener(BehaviorListener listener)
          Sets or clears the listener for the behavior.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait
 

Field Detail

mEnabled

protected boolean mEnabled
Current enabled state.


mIsActive

protected boolean mIsActive
Current activation state.


mListener

protected BehaviorListener mListener
Reference to the BehaviorListener or null if none is registered.

Constructor Detail

AbstractBehavior2

protected AbstractBehavior2(boolean enabled)
Initializes this class when a subclass is constructed.

Parameters:
enabled - true if the behavior is to be initially enabled, otherwise false
Method Detail

poll

public abstract boolean poll()
This method is invoked at regular intervals to determine if the behavior desires to control the robot.

If the behavior is active, it may use this method as a means to update its control of the robot. However, this is not required. The behavior may also use a separate thread or a timer to accomplish its control functions.

Specified by:
poll in interface Behavior
Returns:
true if the behavior wants control of the robot, otherwise false

setActive

public void setActive(boolean isActive)
Activates or deactivates the behavior.

When a behavior is active, it must take control of the robot. When a behavior is inactive, it must not attempt to control the robot.

Specified by:
setActive in interface Behavior
Parameters:
isActive - true if the behavior is being activated, otherwise false

setEnabled

public void setEnabled(boolean enabled)
Enables or disables the behavior.

When a behavior is disabled, its polling method is still called, but it must always return false from the poll method, indicating it is not interested in controlling the robot.

Specified by:
setEnabled in interface Behavior2
Parameters:
enabled - true if the behavior is being enabled, otherwise false

setListener

public void setListener(BehaviorListener listener)
Sets or clears the listener for the behavior.

Specified by:
setListener in interface Behavior2
Parameters:
listener - the BehaviorListener, or null to clear the listener

RoboJDETM v2.0

Copyright (c) 2003-2009 RidgeSoft, LLC. All rights reserved.
www.ridgesoft.com