com.jpeterson.x10.module
Class Macro

java.lang.Object
  |
  +--com.jpeterson.x10.module.Macro

public class Macro
extends java.lang.Object
implements java.io.Serializable

A macro, when triggered by being initiated by a TimerInitiator or MacroInitiator, will issue X10 events. A macro's execution can be delayed up to 4 hours once it is initiaited. A macro contains one or more macro element. Each macro element is an X10 function. When the macro executes, all of the macro's MacroElement function's will be executed.

See Also:
Serialized Form

Constructor Summary
Macro()
          Create a new macro with no timer offset.
Macro(int timerOffset)
          Create a new macro.
 
Method Summary
 void addCommand(FunctionEvent function)
          Add a command for this macro to execute.
 void addCommand(int device, FunctionEvent function)
          Add a command for this macro to execute.
 void addCommand(int device, FunctionEvent function, boolean brightenFirst)
          Add a command for this macro to execute.
 java.util.Enumeration elements()
          Returns an enumeration of the MacroElements for this macro.
 boolean equals(java.lang.Object object)
          Determine if this Macro is equal to the target object.
 byte[] getBytes()
          Get the byte array representing this macro and all of its macro elements.
 int getTimerOffset()
          Retrieve the macro's timer offset value.
 void removeElement(MacroElement element)
          This method provides a way to remove a macro element from the macro.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Macro

public Macro()
Create a new macro with no timer offset.

Macro

public Macro(int timerOffset)
Create a new macro. Each macro can multiple macro elements performing multiple functions.
Parameters:
timerOffset - Offset in minutes from the time at which the macro is called to the time when the macro actually takes effect. 0 to 240 minutes (4 hours).
Throws:
java.lang.IllegalArgumentException - Thrown if timer offset is less than 0 or greater than 240.
Method Detail

getTimerOffset

public int getTimerOffset()
Retrieve the macro's timer offset value.
Returns:
The macro's timer offset in minutes

addCommand

public void addCommand(int device,
                       FunctionEvent function)
                throws java.lang.IllegalArgumentException
Add a command for this macro to execute. When the macro is executed, this command will be carried out. The house code for the address and function must both be the same. The maximum number of commands is 255. Commands added after 255 are silently ignored.
Parameters:
device - Device number. Must be between 1 and 16, inclusive.
function - A FunctionEvent for a command that the macro will execute. For proper use in this case for a macro, the source of the X10Event will be ignored.
Throws:
java.lang.IllegalArgumentException - Thrown if the device number is less than 1 or greater than 16.

addCommand

public void addCommand(int device,
                       FunctionEvent function,
                       boolean brightenFirst)
                throws java.lang.IllegalArgumentException
Add a command for this macro to execute. When the macro is executed, this command will be carried out. The house code for the address and function must both be the same. The maximum number of commands is 255. Commands added after 255 are silently ignored.
Parameters:
device - Device number. Must be between 1 and 16, inclusive.
function - A FunctionEvent for a command that the macro will execute. For proper use in this case for a macro, the source of the X10Event will be ignored.
brightenFirst - If true and Functin Event is a dim or bright command, the device will be brought to maximum brightness before applying the dim amount. This functionality is global per dim/bright command per macro. It is updated each time a device is added.
Throws:
java.lang.IllegalArgumentException - Thrown if the device number is less than 1 or greater than 16.

addCommand

public void addCommand(FunctionEvent function)
Add a command for this macro to execute. When the macro is executed, this command will be carried out. The maximum number of commands is 255. Commands added after 255 are silently ignored.
Parameters:
function - A FunctionEvent command that the macro will execute. For proper use in this case for a macro, the source of the X10Event will be ignored.

removeElement

public void removeElement(MacroElement element)
This method provides a way to remove a macro element from the macro. You can retrieve all of the macro elements in this macro from the elements method.
Parameters:
element - the macro element to remove.

elements

public java.util.Enumeration elements()
Returns an enumeration of the MacroElements for this macro.
Returns:
An enumeration of the MacroElements in this macro.

equals

public boolean equals(java.lang.Object object)
Determine if this Macro is equal to the target object.
Overrides:
equals in class java.lang.Object
Parameters:
object - Target object to determine if it is equal to this Macro.
Returns:
True if the target object equals this one, false otherwise.

getBytes

public byte[] getBytes()
Get the byte array representing this macro and all of its macro elements.
Returns:
Byte array containing the macro and all of its elements.
Throws:
ArrayIndexOutOfBoundsException - if copying would cause access of data outside array bounds.
ArrayStoreException - if an element in the src array could not be stored into the dest array because of a type mismatch.