jmri.jmrix.powerline
Class X10Sequence

java.lang.Object
  extended by jmri.jmrix.powerline.X10Sequence

public class X10Sequence
extends Object

Represent a sequence of one or more X10 commands (addresses and functions).

These are X10 specific, but not device/interface specific.

A sequence should consist of addressing (1 or more), and then one or more commands. It can address multiple devices, but not more than one house-code.

House codes and devices within this class are sequential numbers (1-16 for house code, 1-16 for device code). These must be translated to line coding by other code that converts the sequence to adapter-specific messages. The encode(int) and decode(int) functions are provided to make that easier by converting to and from the standard line-code sequences, but you should check the coding of your new specific adapter before using them.

Author:
Bob Jacobsen Copyright (C) 2008

Nested Class Summary
static class X10Sequence.Address
          Represent a single "set address" X10 command
static interface X10Sequence.Command
          Represent a single X10 command, which is either a "set address" or "do function" operation
static class X10Sequence.ExtData
          Represent a single "Extended Data" X10 command
static class X10Sequence.Function
          Represent a single "do function" X10 command
 
Field Summary
static int EXTCMD_DIM
           
static int FUNCTION_ALL_LIGHTS_OFF
           
static int FUNCTION_ALL_LIGHTS_ON
           
static int FUNCTION_ALL_UNITS_OFF
           
static int FUNCTION_BRIGHT
           
static int FUNCTION_DIM
           
static int FUNCTION_EXTENDED_CODE
           
static int FUNCTION_EXTENDED_DATA_TRANSFER
           
static int FUNCTION_HAIL_ACKNOWLEDGE
           
static int FUNCTION_HAIL_REQUEST
           
static int FUNCTION_OFF
           
static int FUNCTION_ON
           
static int FUNCTION_PRESET_DIM_1
           
static int FUNCTION_PRESET_DIM_2
           
static int FUNCTION_STATUS_OFF
           
static int FUNCTION_STATUS_ON
           
static int FUNCTION_STATUS_REQUEST
           
 
Constructor Summary
X10Sequence()
           
 
Method Summary
 void addAddress(int house, int device)
          Append a new "set address" operation to the sequence
 void addExtData(int house, int device, int cmd, int data)
          Append a new "do function" operation to the sequence
 void addFunction(int house, int function, int dimcount)
          Append a new "do function" operation to the sequence
static int decode(int i)
          Get house (A-P as 1-16) or device (1-16) from line-coded value.
static int encode(int i)
          For the house (A-P) and device (1-16) codes, get the line-coded value.
static String formatAddressByte(int b)
          Pretty-print an address code
static String formatCommandByte(int b)
          Pretty-print a function code
static String functionName(int i)
          Return a human-readable name for a function code
 X10Sequence.Command getCommand()
          Retrieve the next command in the sequence
static String houseCodeToText(int hC)
          Translate House Code to text
static String houseValueToText(int hV)
          Translate House Value (1 to 16) to text
 void reset()
          Next getCommand will be the first in the sequence
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FUNCTION_ALL_UNITS_OFF

public static final int FUNCTION_ALL_UNITS_OFF
See Also:
Constant Field Values

FUNCTION_ALL_LIGHTS_ON

public static final int FUNCTION_ALL_LIGHTS_ON
See Also:
Constant Field Values

FUNCTION_ON

public static final int FUNCTION_ON
See Also:
Constant Field Values

FUNCTION_OFF

public static final int FUNCTION_OFF
See Also:
Constant Field Values

FUNCTION_DIM

public static final int FUNCTION_DIM
See Also:
Constant Field Values

FUNCTION_BRIGHT

public static final int FUNCTION_BRIGHT
See Also:
Constant Field Values

FUNCTION_ALL_LIGHTS_OFF

public static final int FUNCTION_ALL_LIGHTS_OFF
See Also:
Constant Field Values

FUNCTION_EXTENDED_CODE

public static final int FUNCTION_EXTENDED_CODE
See Also:
Constant Field Values

FUNCTION_HAIL_REQUEST

public static final int FUNCTION_HAIL_REQUEST
See Also:
Constant Field Values

FUNCTION_HAIL_ACKNOWLEDGE

public static final int FUNCTION_HAIL_ACKNOWLEDGE
See Also:
Constant Field Values

FUNCTION_PRESET_DIM_1

public static final int FUNCTION_PRESET_DIM_1
See Also:
Constant Field Values

FUNCTION_PRESET_DIM_2

public static final int FUNCTION_PRESET_DIM_2
See Also:
Constant Field Values

FUNCTION_EXTENDED_DATA_TRANSFER

public static final int FUNCTION_EXTENDED_DATA_TRANSFER
See Also:
Constant Field Values

FUNCTION_STATUS_ON

public static final int FUNCTION_STATUS_ON
See Also:
Constant Field Values

FUNCTION_STATUS_OFF

public static final int FUNCTION_STATUS_OFF
See Also:
Constant Field Values

FUNCTION_STATUS_REQUEST

public static final int FUNCTION_STATUS_REQUEST
See Also:
Constant Field Values

EXTCMD_DIM

public static final int EXTCMD_DIM
See Also:
Constant Field Values
Constructor Detail

X10Sequence

public X10Sequence()
Method Detail

addFunction

public void addFunction(int house,
                        int function,
                        int dimcount)
Append a new "do function" operation to the sequence


addAddress

public void addAddress(int house,
                       int device)
Append a new "set address" operation to the sequence


addExtData

public void addExtData(int house,
                       int device,
                       int cmd,
                       int data)
Append a new "do function" operation to the sequence


reset

public void reset()
Next getCommand will be the first in the sequence


getCommand

public X10Sequence.Command getCommand()
Retrieve the next command in the sequence


functionName

public static String functionName(int i)
Return a human-readable name for a function code


encode

public static int encode(int i)
For the house (A-P) and device (1-16) codes, get the line-coded value. Argument is from 1 to 16 only.


decode

public static int decode(int i)
Get house (A-P as 1-16) or device (1-16) from line-coded value.


formatAddressByte

public static String formatAddressByte(int b)
Pretty-print an address code


formatCommandByte

public static String formatCommandByte(int b)
Pretty-print a function code


houseValueToText

public static String houseValueToText(int hV)
Translate House Value (1 to 16) to text


houseCodeToText

public static String houseCodeToText(int hC)
Translate House Code to text



Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads