x10
Class CM11ASerialController

java.lang.Object
  extended byx10.CM11ASerialController
All Implemented Interfaces:
Controller, java.lang.Runnable

public class CM11ASerialController
extends java.lang.Object
implements java.lang.Runnable, Controller

CM11ASerialController is an X10 Controller that bridges x10 hardware and software by communicating via a SerialPort with the x10 "CM11A" module.

This class requires the javax.comm package from Sun Microsystems.


Field Summary
static byte DATA_POLL
          DATA_POLL byte - the x10 "CM11A" protocol DATA_POLL byte.
static byte OK
          OK byte - the x10 "CM11A" protocol OK byte.
static byte PC_READY
          PC_READY byte - the x10 "CM11A" protocol PC_READY byte.
static byte READY
          READY byte - the x10 "CM11A" protocol READY byte.
static byte TIME
          TIME byte - the x10 "CM11A" protocol TIME byte.
static byte TIME_POLL
          TIME_POLL byte - the x10 "CM11A" protocol TIME_POLL byte.
 
Constructor Summary
CM11ASerialController(java.lang.String comport)
          CM11ASerialController constructs and starts the Controller on the specified comport.
 
Method Summary
 void addCommand(Command command)
          addCommand adds a command to the queue to be dispatched.
 void addUnitListener(UnitListener listener)
          addUnitListener registers the UnitListener for events.
protected  void finalize()
          finalize disconnects the serial port connection and closes the Controller.
 void removeUnitListener(UnitListener listener)
          removeUnitListener unregisters the UnitListener for events.
 void run()
          run is the thread loop that constantly blocks and reads events off of the serial port from the "CM11A" module.
 void shutdown(long millis)
          shutdown tells the controller to finish all commands in the queue and then gracefully disconnects the serial port connection.
 void shutdownNow()
          shutdownNow shuts down the controller and closes the serial port immediately.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OK

public static final byte OK
OK byte - the x10 "CM11A" protocol OK byte.

See Also:
Constant Field Values

READY

public static final byte READY
READY byte - the x10 "CM11A" protocol READY byte.

See Also:
Constant Field Values

TIME

public static final byte TIME
TIME byte - the x10 "CM11A" protocol TIME byte.

See Also:
Constant Field Values

TIME_POLL

public static final byte TIME_POLL
TIME_POLL byte - the x10 "CM11A" protocol TIME_POLL byte.

See Also:
Constant Field Values

DATA_POLL

public static final byte DATA_POLL
DATA_POLL byte - the x10 "CM11A" protocol DATA_POLL byte.

See Also:
Constant Field Values

PC_READY

public static final byte PC_READY
PC_READY byte - the x10 "CM11A" protocol PC_READY byte.

See Also:
Constant Field Values
Constructor Detail

CM11ASerialController

public CM11ASerialController(java.lang.String comport)
                      throws java.io.IOException
CM11ASerialController constructs and starts the Controller on the specified comport. On a Windows based PC, the comport is of the form "COM1".

Parameters:
comport - the communications port in which the "CM11A" module is connected.
Throws:
java.io.IOException - if an error occurs while trying to connect to the specified Communications Port.
Method Detail

addUnitListener

public void addUnitListener(UnitListener listener)
addUnitListener registers the UnitListener for events.

Specified by:
addUnitListener in interface Controller
Parameters:
listener - the listener to register for events.
See Also:
UnitEvent

removeUnitListener

public void removeUnitListener(UnitListener listener)
removeUnitListener unregisters the UnitListener for events.

Specified by:
removeUnitListener in interface Controller
Parameters:
listener - the listener to remove.

addCommand

public void addCommand(Command command)
addCommand adds a command to the queue to be dispatched.

Specified by:
addCommand in interface Controller
Parameters:
command - the Command to be dispatched.

finalize

protected void finalize()
finalize disconnects the serial port connection and closes the Controller.


shutdown

public void shutdown(long millis)
              throws OperationTimedOutException,
                     java.lang.InterruptedException
shutdown tells the controller to finish all commands in the queue and then gracefully disconnects the serial port connection.

Parameters:
millis - the number of milliseconds to wait for a graceful shutdown.
Throws:
OperationTimedOutException - thrown if the Controller has not completely shutdown in the amount of time specified.
java.lang.InterruptedException - thrown if the thread is unexpectedly interrupted

shutdownNow

public void shutdownNow()
shutdownNow shuts down the controller and closes the serial port immediately. shutdown(long) is the preferred method of shutting down the controller, but this method provides an immediate, unclean, non-graceful means to shut down the controller.


run

public void run()
run is the thread loop that constantly blocks and reads events off of the serial port from the "CM11A" module.

Specified by:
run in interface java.lang.Runnable


Copyright ©2000-2005 Wade Wassenberg.
On the web: http://x10.homelinux.org.
Send bug reports to x10@wass.homelinux.net.
Last Modified June 1, 2005