com.jpeterson.x10.module
Class TimerInitiator

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

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

See Also:
Serialized Form

Field Summary
static int SIZEOF_TIMER_INITIATOR
           
 
Constructor Summary
TimerInitiator()
          Create a new TimerInitiator.
 
Method Summary
 void addDayOfWeek(int weekDay)
          Add a day of the week that this TimerInitiator is for.
 boolean checkDayOfWeek(int weekDay)
          Check to see if a day of the week is set for this TimerInitiator.
 void clearDaysOfWeek()
          Clear the days of the week for this TimerInitiator.
 byte[] getBytes(int startMacroOffset, int stopMacroOffset)
          Get the byte array representing this macro initiator.
 int[] getDaysOfWeek()
          Retrieve an array of the weekdays set for this TimerInitiator.
 int getStartDay()
          Retrieve the start day for this TimerInitiator.
 int getStartHour()
          Get the start hour for this TimerInitiator.
 Macro getStartMacro()
          Get the start macro.
 int getStartMinute()
          Get the start minute for this TimerInitiator.
 int getStartMonth()
          Retrieve the start month for this TimerInitiator.
 int getStopDay()
          Retrieve the stop day for this TimerInitiator.
 int getStopHour()
          Get the stop hour for this TimerInitiator.
 Macro getStopMacro()
          Get the stop macro.
 int getStopMinute()
          Get the stop minute for this TimerInitiator.
 int getStopMonth()
          Retrieve the stop month for this TimerInitiator.
 void removeDayOfWeek(int weekDay)
          Remove a day of the week that this TimerInitiator is for.
 void setStartDate(int month, int day)
          Set the start date for this TimerInitiator.
 void setStartMacro(Macro macro)
          Set the start macro.
 void setStartTime(int hour, int minute)
          Set the start time for this TimerInitiator.
 void setStopDate(int month, int day)
          Set the stop day for this TimerInitiator.
 void setStopMacro(Macro macro)
          Set the stop macro.
 void setStopTime(int hour, int minute)
          Set the stop time for this TimerInitiator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIZEOF_TIMER_INITIATOR

public static final int SIZEOF_TIMER_INITIATOR
Constructor Detail

TimerInitiator

public TimerInitiator()
Create a new TimerInitiator. Initialized with start date set to January 1 and stop date set to December 31.
Method Detail

addDayOfWeek

public void addDayOfWeek(int weekDay)
Add a day of the week that this TimerInitiator is for.
Parameters:
weekDay - A day of the week constant from the class java.util.Calendar. Should be one of the following: Calendar.SUNDAY, Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.FRIDAY, or Calendar.SATURDAY.
See Also:
Calendar

removeDayOfWeek

public void removeDayOfWeek(int weekDay)
Remove a day of the week that this TimerInitiator is for.
Parameters:
weekDay - A day of the week constant from the class java.util.Calendar. Should be one of the following: Calendar.SUNDAY, Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.FRIDAY, or Calendar.SATURDAY.
See Also:
Calendar

checkDayOfWeek

public boolean checkDayOfWeek(int weekDay)
Check to see if a day of the week is set for this TimerInitiator.
Parameters:
weekDay - A day of the week constant from the class java.util.Calendar. Should be one of the following: Calendar.SUNDAY, Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.FRIDAY, or Calendar.SATURDAY.
See Also:
Calendar

getDaysOfWeek

public int[] getDaysOfWeek()
Retrieve an array of the weekdays set for this TimerInitiator.
Returns:
An array with the weekdays set for this TimerInitiator. The number of elements in the array indicate the number of days set. Each element is one of the following: Calendar.SUNDAY, Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.FRIDAY, or Calendar.SATURDAY. The
See Also:
Calendar

clearDaysOfWeek

public void clearDaysOfWeek()
Clear the days of the week for this TimerInitiator.

setStartDate

public void setStartDate(int month,
                         int day)
Set the start date for this TimerInitiator. The day of the week and day of the year are anded together, so both have to match the current time before the event will trigger a macro.
Parameters:
month - Month, zero based. e.g., 0 for January, 1 for February.
day - Day

getStartDay

public int getStartDay()
Retrieve the start day for this TimerInitiator.
Returns:
The start day for this TimerInitiator.

getStartMonth

public int getStartMonth()
Retrieve the start month for this TimerInitiator.
Returns:
The start month for this TimerInitiator.

setStartTime

public void setStartTime(int hour,
                         int minute)
Set the start time for this TimerInitiator. Event is triggered if current day is within window of start day and stop day, and current time matches this time.
Parameters:
hour - Hour in 24 hour time, 0 - 23. Example: 14 = 2 PM.
minute - Minute, 0 - 59.

getStartHour

public int getStartHour()
Get the start hour for this TimerInitiator.
Returns:
Start hour for this timer initiator.

getStartMinute

public int getStartMinute()
Get the start minute for this TimerInitiator.
Returns:
Start minute for this timer initiator.

setStopDate

public void setStopDate(int month,
                        int day)
Set the stop day for this TimerInitiator. The day of the week and day of the year are anded together, so both have to match the current time before the event will trigger a macro.
Parameters:
month - Month, zero based. e.g., 0 for January, 1 for February.
day - Day

getStopDay

public int getStopDay()
Retrieve the stop day for this TimerInitiator.
Returns:
The stop day for this TimerInitiator.

getStopMonth

public int getStopMonth()
Retrieve the stop month for this TimerInitiator.
Returns:
The stop month for this TimerInitiator.

setStopTime

public void setStopTime(int hour,
                        int minute)
Set the stop time for this TimerInitiator. Event is triggered if current day is within window of start day and stop day, and current time matches this time.
Parameters:
hour - Hour in 24 hour time, 0 - 23. Example: 14 = 2 PM.
minute - Minute, 0 - 59.

getStopHour

public int getStopHour()
Get the stop hour for this TimerInitiator.
Returns:
Stop hour for this timer initiator.

getStopMinute

public int getStopMinute()
Get the stop minute for this TimerInitiator.
Returns:
Stop minute for this timer initiator.

setStartMacro

public void setStartMacro(Macro macro)
Set the start macro. Triggered at the start time if current day is is within the start day and stop day and the day of the week is set.
Parameters:
macro - Macro to invoke.

getStartMacro

public Macro getStartMacro()
Get the start macro.
Returns:
The start macro.

setStopMacro

public void setStopMacro(Macro macro)
Set the stop macro. Triggered at the stop time if current day is is within the start day and stop day and the day of the week is set.
Parameters:
macro - Macro to invoke.

getStopMacro

public Macro getStopMacro()
Get the stop macro.
Returns:
The stop macro.

getBytes

public byte[] getBytes(int startMacroOffset,
                       int stopMacroOffset)
Get the byte array representing this macro initiator.
Parameters:
startMacroOffset - Integer offset to start macro to initiate.
stopMacroOffset - Integer offset to stop macro to initiate.
Returns:
Byte array containing the macro initiator.