com.jpeterson.x10.module
Class CM17A

java.lang.Object
  |
  +--com.jpeterson.x10.GatewayImpl
        |
        +--com.jpeterson.x10.SerialGateway
              |
              +--com.jpeterson.x10.module.CM17A

public class CM17A
extends SerialGateway
implements Transmitter, java.lang.Runnable

Gateway to X10 CM17A serial interface unit. The CM17A is purely a transmitter of X10Events. It is a very small device that connects to a serial port and transmitts X10 commands via an RF link to an X10 RF receiver. It is only able to send On, Off, Dim, and Bright commands. The Dim and Bright commands can only be sent in multiples of 5%. The CM17A is controlled by toggling the UART's RTS and DTR signals. Because of this fact, the CM17A device provides a passthrough capability, allowing a serial device to be connected to the CM17A.


Fields inherited from class com.jpeterson.x10.SerialGateway
baudRate, dataBits, parity, portName, stopBits
 
Fields inherited from class com.jpeterson.x10.GatewayImpl
gatewayListeners, gatewayQueue
 
Fields inherited from interface com.jpeterson.x10.Transmitter
QUEUE_EMPTY, QUEUE_NOT_EMPTY
 
Constructor Summary
CM17A()
          Construct a new CM17A object.
 
Method Summary
 void allocate()
          Start the serial link between the computer and the actual CM11A module.
 void deallocate()
          Stop the serial link between the computer and the actual CM11A module.
 void dispatchControlEvent(ControlEvent event)
          Calls TransmitterListener methods.
 boolean isRunning()
          Indicates if the the interface to the CM11A is up.
protected  void logical0()
          Set the CM17A to logical '0' state.
protected  void logical1()
          Set the CM17A to logical '1' state.
 void processTransmissionQueue()
          Process the queue of events to be processed by the CM11A.
protected  void reset()
          Set the CM17A to reset state.
 void run()
          Process CM11A events.
protected  void standby()
          Set the CM17A to standby state.
 void stateTransition(long state)
          Encapsulates state transition rules.
 void transmit(X10Event evt)
          Implementation of Transmitter.
 
Methods inherited from class com.jpeterson.x10.SerialGateway
getBaudRate, getDataBits, getParity, getPortName, getStopBits, setBaudRate, setDataBits, setParity, setPortName, setStopBits
 
Methods inherited from class com.jpeterson.x10.GatewayImpl
addGatewayListener, fireControlEvent, getGatewayQueue, getGatewayState, pause, removeGatewayListener, resume, setGatewayQueue, setGatewayState, testGatewayState, waitGatewayState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CM17A

public CM17A()
Construct a new CM17A object.
Method Detail

stateTransition

public void stateTransition(long state)
Encapsulates state transition rules. Only implements Transmitter specific states. Lets parent's stateTransition handle the generic gateway states.
Overrides:
stateTransition in class GatewayImpl

transmit

public void transmit(X10Event evt)
              throws GatewayStateError
Implementation of Transmitter. Other software components can send X10 events to the CM17A to have sent through the X10 protocol to X10 devices on the power line network. The CM17A only provides the ability to transmit a subset of the available X10 events. It is only able to transmit On, Off, Dim, and Bright commands. The device is also only able to address one device at a time. The object will only maintain one AddressEvent at a time. Meaning, if the following sequence is transmitted, A1, A2, On, the command is processed thus. The AddressEvent A1 is stored as the "current" device. The "current" device is immediately replaced with A2. Then, when the On event is seen, the device transmitts the command A2 ON to the X10 network, turning A2 on. The On and Off commands result in the "current" device being sent as an Address X10 event, followed by the associated On or Off X10 Function event. The Dim and Bright functions do not result in a device being addressed. Therefore, they will act only on previously addressed devices. This means that you will need to issue and On command, which will address the device, followed by a Dim or Bright command. Also, the Dim and Bright command are only sent in increments of 5%, so multiple commands are issued to make up the desired amount of the Dim or Bright Function event. All other events are ignored by this device.
Specified by:
transmit in interface Transmitter
Parameters:
evt - X10 event to transmit. Should be either an AddressEvent or an OnEvent, OffEvent, DimEvent, or BrightEvent. All other events are ignored.
Throws:
GatewayStateError - if called for a transmitter in the DEALLOCATED or DEALLOCATING_RESOURCES states

isRunning

public boolean isRunning()
Indicates if the the interface to the CM11A is up.
Returns:
Returns true if the interface is up, false if the interface connection is down.

allocate

public void allocate()
              throws GatewayException,
                     GatewayStateError
Start the serial link between the computer and the actual CM11A module.
Overrides:
allocate in class GatewayImpl
Tags copied from interface: Gateway
Throws:
GatewayException - if an allocation error occurred or the gateway is not operational.
GatewayStateError - is called for an engine in the DEALLOCATING_RESOURCES state
See Also:
getGatewayState, deallocate, ALLOCATED, GATEWAY_ALLOCATED

deallocate

public void deallocate()
Stop the serial link between the computer and the actual CM11A module.
Overrides:
deallocate in class GatewayImpl
Tags copied from interface: Gateway
Throws:
GatewayException - if a deallocation error occurs.
GatewayStateError - if called for a gateway in the ALLOCATING_RESOURCES state
See Also:
allocate, GATEWAY_DEALLOCATED, QUEUE_EMPTY

reset

protected void reset()
              throws GatewayStateError
Set the CM17A to reset state.

standby

protected void standby()
                throws GatewayStateError
Set the CM17A to standby state.

logical1

protected void logical1()
                 throws GatewayStateError
Set the CM17A to logical '1' state.

logical0

protected void logical0()
                 throws GatewayStateError
Set the CM17A to logical '0' state.

dispatchControlEvent

public void dispatchControlEvent(ControlEvent event)
Calls TransmitterListener methods. Lets parent's dispatchControlEvent call the GatewayListener methods.
Overrides:
dispatchControlEvent in class GatewayImpl
Tags copied from class: GatewayImpl
Parameters:
event - the ControlEvent to be propagated to the listeners
See Also:
fireControlEvent

run

public void run()
Process CM11A events.
Specified by:
run in interface java.lang.Runnable

processTransmissionQueue

public void processTransmissionQueue()
Process the queue of events to be processed by the CM11A.