org.robokind.api.motion.servos
Class AbstractServoController<IdType,ServoConf extends ServoConfig<IdType>,S extends Servo<IdType,ServoConf>,ControllerConf extends ServoControllerConfig<IdType,ServoConf>>

java.lang.Object
  extended by org.robokind.api.common.property.PropertyChangeNotifier
      extended by org.robokind.api.motion.servos.AbstractServoController<IdType,ServoConf,S,ControllerConf>
Type Parameters:
IdType - Id Type use by this ServoController's Servos
S - Servo type used by this AbstractServoController
ControllerConf - ServoControllerConfig type used
ServoConf - ServoConfig type used by S and Conf
All Implemented Interfaces:
org.robokind.api.common.property.PropertyChangeSource, ServoController<IdType,ServoConf,S,ControllerConf>

public abstract class AbstractServoController<IdType,ServoConf extends ServoConfig<IdType>,S extends Servo<IdType,ServoConf>,ControllerConf extends ServoControllerConfig<IdType,ServoConf>>
extends org.robokind.api.common.property.PropertyChangeNotifier
implements ServoController<IdType,ServoConf,S,ControllerConf>

Provides common functionality for ServoControllers.

Author:
Matthew Stevenson

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.robokind.api.motion.servos.ServoController
ServoController.Id, ServoController.ServoId<ServoIdType>
 
Field Summary
protected  org.robokind.api.common.property.PropertyChangeMonitor myChangeMonitor
          The Controllers's PropertyChangeMonitor to listen for changes in Servos and configs.
protected  ControllerConf myConfig
          ServoController's Confgiuration parameters.
protected  ConnectionStatus myConnectionStatus
          The Controller's ConnectionStatus.
protected  Map<ServoController.ServoId<IdType>,S> myServoMap
          Map of the Controller's Servos and their ids.
protected  List<S> myServos
          List of the Coontroller's Servos.
 
Fields inherited from interface org.robokind.api.motion.servos.ServoController
PROP_CONNECTION_STATUS, PROP_ENABLED, PROP_ERROR_MESSAGES, PROP_SERVO_ADD, PROP_SERVO_REMOVE, PROP_SERVOS, PROP_VERSION
 
Constructor Summary
AbstractServoController(ControllerConf config)
          Creates a new AbstractServoController from the given config.
 
Method Summary
protected  void addingServo(ServoConf config)
          Called when a Servo is added to the underlying ServoControllerConfig.
 void addServo(ServoConf config)
          Add a Servo the ServoController.
protected  void changeServoId(ServoController.ServoId<IdType> oldId, ServoController.ServoId<IdType> newId)
          Called when the id of a Servo changes in the underlying ServoControllerConfig.
protected abstract  S connectServo(ServoConf config)
          Called when a new Servo is being added.
 boolean containsId(ServoController.ServoId<IdType> id)
          Returns true if the controller contains a Servo for the given Servo id.
 boolean containsIds(Set<ServoController.ServoId<IdType>> ids)
          Returns true if the controller contains a Servo for each of the given Servo ids.
protected abstract  boolean disconnectServo(ServoController.ServoId<IdType> id)
          Called when a Servo is being removed.
 ControllerConf getConfig()
          Returns the ServoController's ServoControllerConfig.
 ConnectionStatus getConnectionStatus()
          Return the current ConnectionStatus.
 ServoController.Id getId()
          Returns the ServoController.Id identifying this ServoController.
 S getServo(ServoController.ServoId<IdType> id)
          Returns the Servo with the given id.
 List<S> getServos()
          Returns a List of the controller's Servos.
 void removeServo(S servo)
          Remove a Servo from the ServoController.
protected  void removingServo(ServoController.ServoId<IdType> id)
          Called when a Servo is removed from the underlying ServoControllerConfig.
protected  ServoController.ServoId<IdType> servoId(IdType id)
          Creates a ServoController.ServoId from this ServoController's Id and a Servo's Id
protected  void setConnectStatus(ConnectionStatus status)
          Set the ServoController's ConnectionStatus.
 
Methods inherited from class org.robokind.api.common.property.PropertyChangeNotifier
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.robokind.api.motion.servos.ServoController
connect, disconnect, getEnabled, getErrorMessages, getServoIdClass, moveAllServos, moveServo, moveServos, setEnabled
 
Methods inherited from interface org.robokind.api.common.property.PropertyChangeSource
addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener
 

Field Detail

myConfig

protected ControllerConf extends ServoControllerConfig<IdType,ServoConf> myConfig
ServoController's Confgiuration parameters.


myServos

protected List<S extends Servo<IdType,ServoConf>> myServos
List of the Coontroller's Servos.


myServoMap

protected Map<ServoController.ServoId<IdType>,S extends Servo<IdType,ServoConf>> myServoMap
Map of the Controller's Servos and their ids.


myConnectionStatus

protected ConnectionStatus myConnectionStatus
The Controller's ConnectionStatus.


myChangeMonitor

protected org.robokind.api.common.property.PropertyChangeMonitor myChangeMonitor
The Controllers's PropertyChangeMonitor to listen for changes in Servos and configs.

Constructor Detail

AbstractServoController

public AbstractServoController(ControllerConf config)
Creates a new AbstractServoController from the given config.

Parameters:
config - the Controller's cofig
Method Detail

getId

public final ServoController.Id getId()
Description copied from interface: ServoController
Returns the ServoController.Id identifying this ServoController.

Specified by:
getId in interface ServoController<IdType,ServoConf extends ServoConfig<IdType>,S extends Servo<IdType,ServoConf>,ControllerConf extends ServoControllerConfig<IdType,ServoConf>>
Returns:

connectServo

protected abstract S connectServo(ServoConf config)
Called when a new Servo is being added. The overriding method should make the Servo available from the given ServoConfig.

Parameters:
config -
Returns:
a new Servo from the ServoConfig

disconnectServo

protected abstract boolean disconnectServo(ServoController.ServoId<IdType> id)
Called when a Servo is being removed. The overriding method should remove references to the Servo from the ServoController.

Parameters:
id - Servo's id
Returns:
true if successful

addServo

public void addServo(ServoConf config)
Add a Servo the ServoController.

Parameters:
config - Servo's configuration parameters

removeServo

public void removeServo(S servo)
Remove a Servo from the ServoController.

Parameters:
servo - Servo to remove

setConnectStatus

protected void setConnectStatus(ConnectionStatus status)
Set the ServoController's ConnectionStatus.

Parameters:
status - new ConnectionStatus

getServo

public S getServo(ServoController.ServoId<IdType> id)
Description copied from interface: ServoController
Returns the Servo with the given id.

Specified by:
getServo in interface ServoController<IdType,ServoConf extends ServoConfig<IdType>,S extends Servo<IdType,ServoConf>,ControllerConf extends ServoControllerConfig<IdType,ServoConf>>
Parameters:
id - the Servo id
Returns:
Servo with the given id

getServos

public List<S> getServos()
Description copied from interface: ServoController
Returns a List of the controller's Servos.

Specified by:
getServos in interface ServoController<IdType,ServoConf extends ServoConfig<IdType>,S extends Servo<IdType,ServoConf>,ControllerConf extends ServoControllerConfig<IdType,ServoConf>>
Returns:
List of the controller's Servos

containsIds

public boolean containsIds(Set<ServoController.ServoId<IdType>> ids)
Description copied from interface: ServoController
Returns true if the controller contains a Servo for each of the given Servo ids.

Specified by:
containsIds in interface ServoController<IdType,ServoConf extends ServoConfig<IdType>,S extends Servo<IdType,ServoConf>,ControllerConf extends ServoControllerConfig<IdType,ServoConf>>
Parameters:
ids - Set of Servo ids to check
Returns:
true if the controller contains a Servo for each of the given Servo ids

containsId

public boolean containsId(ServoController.ServoId<IdType> id)
Description copied from interface: ServoController
Returns true if the controller contains a Servo for the given Servo id.

Specified by:
containsId in interface ServoController<IdType,ServoConf extends ServoConfig<IdType>,S extends Servo<IdType,ServoConf>,ControllerConf extends ServoControllerConfig<IdType,ServoConf>>
Parameters:
id - Servo id to check
Returns:
true if the controller contains a Servo for the given Servo id

getConnectionStatus

public ConnectionStatus getConnectionStatus()
Description copied from interface: ServoController
Return the current ConnectionStatus.

Specified by:
getConnectionStatus in interface ServoController<IdType,ServoConf extends ServoConfig<IdType>,S extends Servo<IdType,ServoConf>,ControllerConf extends ServoControllerConfig<IdType,ServoConf>>
Returns:
current ConnectionStatus

addingServo

protected void addingServo(ServoConf config)
Called when a Servo is added to the underlying ServoControllerConfig.

Parameters:
config - the Servo's configuration parameters

removingServo

protected void removingServo(ServoController.ServoId<IdType> id)
Called when a Servo is removed from the underlying ServoControllerConfig.

Parameters:
id - id of the Servo being removed

changeServoId

protected void changeServoId(ServoController.ServoId<IdType> oldId,
                             ServoController.ServoId<IdType> newId)
Called when the id of a Servo changes in the underlying ServoControllerConfig.

Parameters:
oldId - old id
newId - new id

getConfig

public ControllerConf getConfig()
Description copied from interface: ServoController
Returns the ServoController's ServoControllerConfig.

Specified by:
getConfig in interface ServoController<IdType,ServoConf extends ServoConfig<IdType>,S extends Servo<IdType,ServoConf>,ControllerConf extends ServoControllerConfig<IdType,ServoConf>>
Returns:
this ServoController's ServoControllerConfig

servoId

protected ServoController.ServoId<IdType> servoId(IdType id)
Creates a ServoController.ServoId from this ServoController's Id and a Servo's Id

Parameters:
id - Servo Id to use
Returns:
ServoController.ServoId containing this ServoController's Id and the give Servo Id


Copyright © 2011. All Rights Reserved.