com.jpeterson.x10.event
Class X10Event

java.lang.Object
  |
  +--java.util.EventObject
        |
        +--com.jpeterson.x10.event.X10Event
Direct Known Subclasses:
AddressEvent, FunctionEvent

public class X10Event
extends java.util.EventObject

An X10 event represents an X10 transmission packet. This is the base class for subclasses that implement the different X10 messages.

See Also:
Serialized Form

Fields inherited from class java.util.EventObject
source
 
Constructor Summary
X10Event(java.lang.Object source, boolean function, byte hiNibble, byte loNibble)
          Create an X10 event.
X10Event(java.lang.Object source, int dims, boolean function, boolean extended, byte hiNibble, byte loNibble, int dimMax)
          Create an X10 event, specifying all parameters.
 
Method Summary
 boolean equals(java.lang.Object object)
          Determines if two objects are equals.
 byte getChecksum()
          Retrieve the checksum of the bytes in the message or the X10 transmission.
 int getDimMax()
          Retrieve the maximum number of dims in the event.
 int getDims()
          Retrieve the number of dims in the event.
 byte getHiNibble()
          Retrieve the high nibble of the 'code' portion of the packet.
 byte getLoNibble()
          Retrieve the low nibble of the 'code' portion of the packet.
 byte[] getPacket()
          Retrieve the bytes that compose the X10 event.
 int hashCode()
          Calculate a hash code for the event.
 boolean isExtended()
          Determine if the event is an extended event.
 boolean isFunction()
          Determine if the event is a function or address event.
 java.lang.String toString()
          Create a string that represents the X10 event.
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

X10Event

public X10Event(java.lang.Object source,
                int dims,
                boolean function,
                boolean extended,
                byte hiNibble,
                byte loNibble,
                int dimMax)
Create an X10 event, specifying all parameters.
Parameters:
source - The event source.
dims - The number of dims.
funtion - True if the event is a function event, false if the event is an address event.
extended - True if the event is an extended event, false otherwise
hiNibble - The upper four bits of the 'Code' portion of the X10 event. This is usually the housecode
loNibble - The lower four bits of the 'Code' portion of the X10 event. This is typically the device code in an address event or the function code in a function event.
dimMax - The maximum number of dims for the event.

X10Event

public X10Event(java.lang.Object source,
                boolean function,
                byte hiNibble,
                byte loNibble)
Create an X10 event. This constructor is normally used for standard address and function events that do not have dim values or extended characteristics. It is provided for convenience. The maximum number of dims is 22.
Parameters:
source - The event source.
funtion - True if the event is a function event, false if the event is an address event.
hiNibble - The upper four bits of the 'Code' portion of the X10 event. This is usually the housecode
loNibble - The lower four bits of the 'Code' portion of the X10 event. This is typically the device code in an address event or the function code in a function event.
Method Detail

getPacket

public byte[] getPacket()
Retrieve the bytes that compose the X10 event.
Returns:
Array of bytes that constitute the payload of the X10 event. For standard events, the array will have a size of 2. For extended events, the size will be 4.

getChecksum

public byte getChecksum()
Retrieve the checksum of the bytes in the message or the X10 transmission.
Returns:
the checksum

isFunction

public boolean isFunction()
Determine if the event is a function or address event.
Returns:
True if a function event, false if an address event.

isExtended

public boolean isExtended()
Determine if the event is an extended event.
Returns:
True if an extended event, false otherwise.

getDims

public int getDims()
Retrieve the number of dims in the event.
Returns:
number of dims

getDimMax

public int getDimMax()
Retrieve the maximum number of dims in the event.
Returns:
maximum number of dims

getHiNibble

public byte getHiNibble()
Retrieve the high nibble of the 'code' portion of the packet. This is the 'housecode'.
Returns:
the high nibble of the 'code' portion of the packet.

getLoNibble

public byte getLoNibble()
Retrieve the low nibble of the 'code' portion of the packet. This is the 'device code' for address messages or the 'function' for function messages.
Returns:
the low nibble of the 'code' portion of the packet.

hashCode

public int hashCode()
Calculate a hash code for the event. Uses the checksum.
Overrides:
hashCode in class java.lang.Object
Returns:
Hash code value for the event.

equals

public boolean equals(java.lang.Object object)
Determines if two objects are equals. This tests all X10Event attributes of the objects for equallity.
Overrides:
equals in class java.lang.Object
Returns:
True if the target object equals this object, false otherwise.

toString

public java.lang.String toString()
Create a string that represents the X10 event.
Overrides:
toString in class java.util.EventObject
Returns:
string representation of the X10 event