de.jaetzold.art.platform
Class RobotInterfaceAdapter

java.lang.Object
  |
  +--de.jaetzold.art.platform.RobotInterfaceAdapter
All Implemented Interfaces:
RobotInterface
Direct Known Subclasses:
AWTRobotInterface, Fischertechnik, RCX

public abstract class RobotInterfaceAdapter
extends Object
implements RobotInterface

This base class implements methods from RobotInterface for retrieving Port-instances through specific arguments. They all rely on the Factory-Methods getSensorPorts() and getActuatorPorts() and these are therefore the only Port-related methods to implement.

Additionally it defines some useful methods for handling SerialPorts from the Java Communications API because it is not unusual for interface-hardware to be controllable through a serial connection.


Constructor Summary
RobotInterfaceAdapter()
           
 
Method Summary
 ActuatorPort getActuatorPorts(int index)
          Returns the SensorPort with the specified index.
 Port getPort(Object identifier)
          Returns a Port which is identified by the given Object.
 SensorPort getSensorPorts(int index)
          Returns the SensorPort with the specified index.
protected static String[] getSerialPortNames()
          Retunrs all names of serial ports known to JavaComm.
protected static String[] getSerialPortNames(int portNumber)
          Contructs names of serial ports out of a number.
protected static String[] getSerialPortNames(RobotInterfaceDefinition[] defs, String[] interfaceIds)
          Contruct names of serial ports.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.jaetzold.art.RobotInterface
conformsTo, getActuatorPorts, getInterfaceDefinition, getSensorPorts, isAlive, isConnected
 

Constructor Detail

RobotInterfaceAdapter

public RobotInterfaceAdapter()
Method Detail

getSerialPortNames

protected static String[] getSerialPortNames(RobotInterfaceDefinition[] defs,
                                             String[] interfaceIds)
Contruct names of serial ports. This is by now only done for the usual type of RobotInterfaceStringDefinition. The parameter interfaceIds tells the method which part at the beginning of the RobotInterfaceStringDefinition may just be an id which has nothing to do with the serial port identifier following it. For a more detailed description of these Strings see RobotInterfaceStringDefinition
See Also:
RobotInterfaceStringDefinition

getSerialPortNames

protected static String[] getSerialPortNames(int portNumber)
Contructs names of serial ports out of a number. The names returned include COM-n-, /dev/ttyS-n- and serial-n- where -n- is replaced by the argument portNumber. The method also returns the portName in the list of available CommPorts from JavaComm which is at the position number portnumber.
See Also:
javax.comm

getSerialPortNames

protected static String[] getSerialPortNames()
Retunrs all names of serial ports known to JavaComm.
See Also:
javax.comm

getActuatorPorts

public ActuatorPort getActuatorPorts(int index)
Description copied from interface: RobotInterface
Returns the SensorPort with the specified index. This method is only for convenience when using a RobotInterface as a JavaBean.
Specified by:
getActuatorPorts in interface RobotInterface
Following copied from interface: de.jaetzold.art.RobotInterface
Throws:
ArrayIndexOutOfBoundsException - if the specified index is not a legal index into the array of SensorPorts.
See Also:
RobotInterface.getActuatorPorts()

getSensorPorts

public SensorPort getSensorPorts(int index)
Description copied from interface: RobotInterface
Returns the SensorPort with the specified index. This method is only for convenience when using a RobotInterface as a JavaBean.
Specified by:
getSensorPorts in interface RobotInterface
Following copied from interface: de.jaetzold.art.RobotInterface
Throws:
ArrayIndexOutOfBoundsException - if the specified index is not a legal index into the array of SensorPorts.
See Also:
RobotInterface.getActuatorPorts()

getPort

public Port getPort(Object identifier)
Description copied from interface: RobotInterface
Returns a Port which is identified by the given Object. Which identifiers are legal and their meaning is defined by the actual implementation of RobotInterface. The implementations provided for Fischertechnik and Mindstorms use Strings which are equal to the names printed on the hardware-interface.
Specified by:
getPort in interface RobotInterface
Following copied from interface: de.jaetzold.art.RobotInterface
See Also:
RobotInterface.getSensorPorts(), RobotInterface.getActuatorPorts(), Port.getPortID(), Port.conformsTo(Object)