Package jmri.jmrix.powerline
Class X10Sequence
- java.lang.Object
-
- jmri.jmrix.powerline.X10Sequence
-
public class X10Sequence extends java.lang.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)
anddecode(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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
X10Sequence.Address
Represent a single "set address" X10 commandstatic interface
X10Sequence.Command
Represent a single X10 command, which is either a "set address" or "do function" operationstatic class
X10Sequence.ExtData
Represent a single "Extended Data" X10 commandstatic class
X10Sequence.Function
Represent a single "do function" X10 command
-
Field Summary
Fields Modifier and Type Field Description (package private) X10Sequence.Command[]
cmds
(package private) static int[]
decoder
(package private) static int[]
encoder
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
(package private) static java.lang.String[]
functionNames
Array of human readable names for X10 commands, indexed by the command numbers that are constants in this class.(package private) static java.lang.String[]
houseValueDecoder
(package private) int
index
-
Constructor Summary
Constructors Constructor Description X10Sequence()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAddress(int house, int device)
Append a new "set address" operation to the sequencevoid
addExtData(int house, int device, int cmd, int data)
Append a new "do function" operation to the sequencevoid
addFunction(int house, int function, int dimcount)
Append a new "do function" operation to the sequencestatic 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 java.lang.String
formatAddressByte(int b)
Pretty-print an address codestatic java.lang.String
formatCommandByte(int b)
Pretty-print a function codestatic java.lang.String
functionName(int i)
Return a human-readable name for a function codeX10Sequence.Command
getCommand()
Retrieve the next command in the sequencestatic java.lang.String
houseCodeToText(int hC)
Translate House Code to textstatic java.lang.String
houseValueToText(int hV)
Translate House Value (1 to 16) to textvoid
reset()
Next getCommand will be the first in the sequence
-
-
-
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
-
index
int index
-
cmds
X10Sequence.Command[] cmds
-
functionNames
static java.lang.String[] functionNames
Array of human readable names for X10 commands, indexed by the command numbers that are constants in this class.
-
encoder
static final int[] encoder
-
decoder
static final int[] decoder
-
houseValueDecoder
static java.lang.String[] houseValueDecoder
-
-
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- Parameters:
house
- house codefunction
- functiondimcount
- dimming step count
-
addAddress
public void addAddress(int house, int device)
Append a new "set address" operation to the sequence- Parameters:
house
- house code A-Pdevice
- device 1-16
-
addExtData
public void addExtData(int house, int device, int cmd, int data)
Append a new "do function" operation to the sequence- Parameters:
house
- A-Pdevice
- 1-16cmd
- command codedata
- additional data
-
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- Returns:
- next available command
-
functionName
public static java.lang.String functionName(int i)
Return a human-readable name for a function code- Parameters:
i
- value of function code- Returns:
- string translation
-
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.- Parameters:
i
- house or device code value- Returns:
- line code value
-
decode
public static int decode(int i)
Get house (A-P as 1-16) or device (1-16) from line-coded value.- Parameters:
i
- line code value- Returns:
- house or device code value
-
formatAddressByte
public static java.lang.String formatAddressByte(int b)
Pretty-print an address code- Parameters:
b
- address code value- Returns:
- human string form
-
formatCommandByte
public static java.lang.String formatCommandByte(int b)
Pretty-print a function code- Parameters:
b
- command code value- Returns:
- human string form
-
houseValueToText
public static java.lang.String houseValueToText(int hV)
Translate House Value (1 to 16) to text- Parameters:
hV
- device code value- Returns:
- human string form
-
houseCodeToText
public static java.lang.String houseCodeToText(int hC)
Translate House Code to text- Parameters:
hC
- house code- Returns:
- A-P
-
-