x10
Class CM17ASerialController

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

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

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

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


Constructor Summary
CM17ASerialController(java.lang.String comport)
          CM17ASerialController 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 writes events to the serial port to the "Firecracker" 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
 

Constructor Detail

CM17ASerialController

public CM17ASerialController(java.lang.String comport)
                      throws java.io.IOException
CM17ASerialController 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 "Firecracker" 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 writes events to the serial port to the "Firecracker" 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