serial
Class TwoWayX10

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

public class TwoWayX10
extends Serial

This is a software controller for the TwoWay X10 controller 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
TwoWayX10()
           
 
Method Summary
 boolean brightenBy(char house, int module, int delta)
           
 boolean brightenBy(int delta)
           
 boolean brightenTo(char house, int module, int level)
           
 boolean brightenTo(int level)
           
 boolean dimBy(char house, int module, int delta)
          Applies only to devices connected to lamp modules.
 boolean dimBy(int delta)
           
 boolean dimTo(char house, int module, int level)
          Dims a lamp connected to a lamp module to level specified in argument level.
 boolean dimTo(int level)
           
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
 boolean selectDevice(char house, int module)
          After calling this method all action methods without house/module code inputs will refer to the device you select here.
 boolean selectDevice(X10Data dev)
           
 boolean selectDevices(Vector devs)
          Similar to selectDevice except that it lets you select several devices at once.
 boolean turnOff()
           
 boolean turnOff(char house, int module)
           
 boolean turnOn()
          Turns on selected device
 boolean turnOn(char house, int module)
          Calls select device and then turnOn
 
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

TwoWayX10

public TwoWayX10()
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)

selectDevice

public boolean selectDevice(char house,
                            int module)
After calling this method all action methods without house/module code inputs will refer to the device you select here. The next time you call selectDevice(s) or any of the action methods that takes in house/module code as input, the selected device will change.
Parameters:
house - house code as char (i.e. 'a' or 'E', ...)
Returns:
true if command was transmitted without any problem and the X10 TwoWay module confirmed receiving the command; false if anything went wrong

selectDevice

public boolean selectDevice(X10Data dev)
See Also:
selectDevice(char, int)

selectDevices

public boolean selectDevices(Vector devs)
Similar to selectDevice except that it lets you select several devices at once. After calling this method, all subsequent calls to methods like turnOn() will act on all specified devices at once. YOU CAN ONLY ENTER DEVICES ON THE SAME HOUSE CODE!!!!
Parameters:
devs - a vector of X10Data objects
Returns:
true if things went well, false otherwise
See Also:
X10Data

turnOn

public boolean turnOn(char house,
                      int module)
Calls select device and then turnOn

turnOn

public boolean turnOn()
Turns on selected device

turnOff

public boolean turnOff(char house,
                       int module)

turnOff

public boolean turnOff()

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;

dimBy

public boolean dimBy(int 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()

dimTo

public boolean dimTo(int level)

brightenBy

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

brightenBy

public boolean brightenBy(int delta)

brightenTo

public boolean brightenTo(char house,
                          int module,
                          int level)
See Also:
dimTo(char, int, int)

brightenTo

public boolean brightenTo(int level)

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