serial
Class LynX10

java.lang.Object
  |
  +--serial.Serial
        |
        +--serial.LynX10

public class LynX10
extends Serial

This is a software controller for the LynX10 coprocessor device

See Also:
Serial

Fields inherited from class serial.Serial
answerTimeout, cancelEcho, device, listener, semaphore, serial, serial_in, serial_out, timeout_wait, waitingForResponse
 
Constructor Summary
LynX10()
           
 
Method Summary
 boolean brightenBy(char house, int module, int delta)
           
 boolean brightenTo(char house, int module, int level)
          There is no difference between dimTo and brightenTo with this controller
 boolean dimBy(char house, int module, int delta)
          Applies only to devices connected to lamp modules.
 boolean dimTo(char house, int module, int level)
          Dims a lamp connected to a lamp module to level specified in argument level.
protected  String encodeDevice(char house, int module)
           
protected  String encodeHouse(char house)
          Takes a house code (like a, b, C ...) and converts it into internal LynX10 encoding
protected  String encodeLevel(int level)
           
protected  String encodeModule(int module)
           
static Serial getNewInstance()
          This method is here so that children of this class can override it so that main() calls appropriate constructor
 boolean issueCommand(String cmd)
           
 boolean issueCommand(String cmd, int tryCnt)
          Internal tool for sending X10 commands (exposed for debugging)
 void open(String in_device)
          Opens connection to an X10 controller on a given port and sets default X10 parameters for that port
protected  boolean relativeChange(boolean dim, char house, int delta)
          Uses raw X10 codes to dim (if dim=true)/brighten a preselected device by delta
protected  boolean selectDevice(char house, int module)
          Selects the device to be talked to for the next raw X10 command (used here by dimBy and brightenBy methods)
 boolean turnOff(char house, int module)
           
 boolean turnOn(char house, int module)
          turns on specified device
 
Methods inherited from class serial.Serial
addEventListener, close, main, open, open, openNoParams, processSerialEvent, read, readBytes, readString, ready, send, send, sendSynch, sendSynch, sendSynch, serialEvent, setFlowControlMode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LynX10

public LynX10()
Method Detail

open

public void open(String in_device)
          throws javax.comm.NoSuchPortException,
                 javax.comm.PortInUseException,
                 IOException
Opens connection to an X10 controller on a given port and sets default X10 parameters for that port
Overrides:
open in class Serial
Tags copied from class: Serial
Parameters:
in_device - the name of the serial device to speak to. Uses standard port settings. (e.g. "/dev/term/ttyrg" DONT FORGET ABOUT TERM)

issueCommand

public boolean issueCommand(String cmd,
                            int tryCnt)
Internal tool for sending X10 commands (exposed for debugging)
Parameters:
cmd - command to be sent
tryCnt - how many attempts to make in case there are problems
Returns:
true if everything went well or false otherwise

issueCommand

public boolean issueCommand(String cmd)

encodeHouse

protected String encodeHouse(char house)
Takes a house code (like a, b, C ...) and converts it into internal LynX10 encoding

encodeModule

protected String encodeModule(int module)

encodeLevel

protected String encodeLevel(int level)

encodeDevice

protected String encodeDevice(char house,
                              int module)

turnOn

public boolean turnOn(char house,
                      int module)
turns on specified device

turnOff

public boolean turnOff(char house,
                       int module)

selectDevice

protected boolean selectDevice(char house,
                               int module)
Selects the device to be talked to for the next raw X10 command (used here by dimBy and brightenBy methods)

dimBy

public boolean dimBy(char house,
                     int module,
                     int delta)
Applies only to devices connected to lamp modules. Allows you to dim the lamp by delta. Full brightness is level 20, off is level 0;

relativeChange

protected boolean relativeChange(boolean dim,
                                 char house,
                                 int delta)
Uses raw X10 codes to dim (if dim=true)/brighten a preselected device by delta

dimTo

public boolean dimTo(char house,
                     int module,
                     int level)
Dims a lamp connected to a lamp module to level specified in argument level. It does it by first dimming the lamp all the way down and then brightening it up to the desired level. Contrast this with brightenTo()

brightenBy

public boolean brightenBy(char house,
                          int module,
                          int delta)
See Also:
dimBy(char, int, int)

brightenTo

public boolean brightenTo(char house,
                          int module,
                          int level)
There is no difference between dimTo and brightenTo with this controller

getNewInstance

public static Serial getNewInstance()
Description copied from class: Serial
This method is here so that children of this class can override it so that main() calls appropriate constructor