|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.jpeterson.x10.GatewayImpl | +--com.jpeterson.x10.SerialGateway | +--com.jpeterson.x10.module.CM11A
Gateway to X10 CM11A serial interface unit. The CM11A is both a producer and consumer of X10Events. It receives X10Events from other software components and transmits the event through the X10 protocol. It sends X10Events that it receives on the power line.
Field Summary | |
static byte |
CM11_MACRO_INITIATED
|
static byte |
CM11_POWER_FAILURE
|
static byte |
CM11_RECEIVE_EVENT
|
Fields inherited from class com.jpeterson.x10.SerialGateway |
baudRate,
dataBits,
parity,
portName,
stopBits |
Fields inherited from class com.jpeterson.x10.GatewayImpl |
gatewayListeners,
gatewayQueue |
Fields inherited from interface com.jpeterson.x10.Transmitter |
QUEUE_EMPTY,
QUEUE_NOT_EMPTY |
Constructor Summary | |
CM11A()
Construct a new CM11A object. |
Method Summary | |
void |
addAddressListener(AddressListener l)
Add an X10 Address listener. |
void |
addCM11AListener(CM11AListener l)
Add a CM11A event listener. |
void |
addCM11AStatusListener(CM11AStatusListener l)
Add a CM11A status listener. |
void |
addFunctionListener(FunctionListener l)
Add an X10 Function listener. |
void |
addMacroInitiator(MacroInitiator macroInitiator)
Add a macro initiator. |
void |
addTimerInitiator(TimerInitiator timerInitiator)
Add a timer initiator. |
void |
allocate()
Start the serial link between the computer and the actual CM11A module. |
void |
clearMacroInitiators()
Clear all macro initiators. |
void |
clearTimerInitiators()
Clear all timer initiators. |
protected FunctionEvent |
createEvent(FunctionEvent function,
java.lang.Object newSource)
Create a copy of a FunctionEvent but with the specified source. |
protected static int |
dayOfYear(int month,
int day)
Convert a date in the format of month and day to day of year format. |
void |
deallocate()
Stop the serial link between the computer and the actual CM11A module. |
CM11AStatusEvent |
decodeStatus(byte[] bytes,
int off,
int len)
Decode a status buffer. |
void |
dispatchControlEvent(ControlEvent event)
Calls TransmitterListener methods. |
void |
downloadInitiators()
Transmit the CM11A macro initiators to the X10 CM11A device. |
protected int |
encodeEEPROM()
Encode the EEPROM array. |
protected int |
encodeMacro(Macro macro,
int macroOffset)
Encode a macro into the EEPROM array. |
static int |
extractDay(int julianDay)
Utility method to convert the Julian day returned in getJulianDay to a the day of the month represented. |
static int |
extractMonth(int julianDay)
Utility method to convert the Julian day returned in getJulianDay to the month the day represents. |
protected void |
fireCM11AEvent(CM11AEvent evt)
Fire a CM11A event. |
protected void |
fireCM11AStatusEvent(CM11AStatusEvent evt)
Fire a CM11A status event. |
protected void |
fireX10Event(X10Event evt)
Fire an X10 Transmission. |
int |
getBatteryUsage()
Retrieve the CM11A's idea of what the current battery usage is. |
int |
getCurrentDay()
Retrieve the CM11A's idea of what the current day is. |
java.util.BitSet |
getDimStatus()
Indication of the dim status as the CM11A sees it for the monitored house code. |
int |
getHours()
Retrieve the CM11A's idea of what the current hour is. |
int |
getJulianDay()
Retrieve the CM11A's idea of the current day of the year. |
java.util.BitSet |
getLastAddressedDevice()
Indication of the last addressed device as the CM11A sees it for the monitored house code. |
int |
getMinutes()
Retrieve the CM11A's idea of what the current minute is. |
char |
getMonitoredHouseCode()
Get the house code that the CM11A is configured to monitor. |
java.util.BitSet |
getOnOffStatus()
Indication of the On/Off status as the CM11A sees it for the monitored house code. |
boolean |
getPowerFailureAutoRecover()
Determine if this CM11A object has been configured to auto recover upon sensing a power failure at the CM11A device. |
int |
getSeconds()
Retrieve the CM11A's idea of what the current second is. |
boolean |
isRunning()
Indicates if the the interface to the CM11A is up. |
java.util.Enumeration |
macroInitiators()
Retrieve an Enumeration of all timer initiators. |
protected static int |
normalizeDay(int month,
int day)
Make sure that the day is valid. |
protected static int |
normalizeMonth(int month)
Make sure that the month is valid. |
void |
processPendingRequests()
Process the input stream, handling unsolicited events. |
void |
processTransmissionQueue()
Process the queue of events to be processed by the CM11A. |
void |
removeAddressListener(AddressListener l)
Remove an Address listener. |
void |
removeCM11AListener(CM11AListener l)
Remove a CM11A event listener. |
void |
removeCM11AStatusListener(CM11AStatusListener l)
Remove a CM11A status listener. |
void |
removeFunctionListener(FunctionListener l)
Remove a Function listener. |
boolean |
removeMacroInitiator(MacroInitiator macroInitiator)
Remove a macro initiator. |
boolean |
removeTimerInitiator(TimerInitiator timerInitiator)
Remove a timer initiator. |
void |
ringDisable()
Disable the serial Ring Indicator signal. |
void |
ringEnable()
Enable the serial Ring Indicator signal. |
void |
run()
Process CM11A events. |
void |
serialEvent(javax.comm.SerialPortEvent event)
Receive serial events from the CM11A module. |
void |
setClock(int hour,
int minute,
int second,
int month,
int day,
int dayOfWeek,
char houseCode,
boolean clearBatteryTimer,
boolean clearMonitoredStatus,
boolean purgeTimer)
Update the CM11A interface's internal clock, set the monitored house code, reset battery timer, clear monitored statuses, and purge timer. |
void |
setPowerFailureAutoRecover(boolean autoRecover)
Indicate if you want the CM11A object to autorecover upon detecting a power failure. |
void |
stateTransition(long state)
Encapsulates state transition rules. |
java.util.Enumeration |
timerInitiators()
Retrieve an Enumeration of all timer initiators. |
protected static byte[] |
toBytes(int value,
int len,
boolean bigEndian)
Convert an integer value to a byte array. |
void |
transmit(X10Event evt)
Implementation of Transmitter. |
void |
updateStatus()
Request the status from the CM11A interface. |
void |
updateStatus(CM11AStatusListener statusListener)
Request the status from the CM11A interface. |
Methods inherited from class com.jpeterson.x10.SerialGateway |
getBaudRate,
getDataBits,
getParity,
getPortName,
getStopBits,
setBaudRate,
setDataBits,
setParity,
setPortName,
setStopBits |
Methods inherited from class com.jpeterson.x10.GatewayImpl |
addGatewayListener,
fireControlEvent,
getGatewayQueue,
getGatewayState,
pause,
removeGatewayListener,
resume,
setGatewayQueue,
setGatewayState,
testGatewayState,
waitGatewayState |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final byte CM11_RECEIVE_EVENT
public static final byte CM11_POWER_FAILURE
public static final byte CM11_MACRO_INITIATED
Constructor Detail |
public CM11A()
Method Detail |
public void setPowerFailureAutoRecover(boolean autoRecover)
setClock
before the CM11A
can be used.
By default, auto recover is turned on.
autoRecover
- True if the object should automatically recover
upon detecting a power failure of the CM11A device.getPowerFailureAutoRecover
,
setClock
public boolean getPowerFailureAutoRecover()
By default, auto recover is turned on.
setPowerFailureAutoRecover
public void stateTransition(long state)
public void transmit(X10Event evt) throws GatewayStateError
evt
- X10 event to transmitpublic void updateStatus()
public void updateStatus(CM11AStatusListener statusListener)
statusListener
- Notification is sent to the listenerpublic char getMonitoredHouseCode()
setClock
to change the monitored house code.setClock
public java.util.BitSet getOnOffStatus()
updateStatus
.updateStatus
public java.util.BitSet getDimStatus()
updateStatus
.updateStatus
public java.util.BitSet getLastAddressedDevice()
updateStatus
.updateStatus
,
setClock
public int getCurrentDay()
updateStatus()
.updateStatus
,
setClock
public int getJulianDay()
updateStatus()
.
The utility methods CM11A.extractMonth()
and
CM11A.extractDay()
have been provided to convert this
value into month and day representations.
As far as I can tell, the CM11A has no way of determining leap years. It therefore always uses 366 days in a year. The caller is responsible for determining if the current day has been corrected for a non-leap year.
extractMonth
,
extractDay
public int getHours()
updateStatus()
.updateStatus
,
setClock
public int getMinutes()
updateStatus()
.updateStatus
,
setClock
public int getSeconds()
updateStatus()
.updateStatus
,
setClock
public int getBatteryUsage()
updateStatus()
.updateStatus
,
setClock
public void setClock(int hour, int minute, int second, int month, int day, int dayOfWeek, char houseCode, boolean clearBatteryTimer, boolean clearMonitoredStatus, boolean purgeTimer)
hour
- Current time, hours. 0 - 23.minute
- Current time, minutes. 0 - 59.second
- Current time, seconds. 0 - 59.month
- Current month, zero based. e.g., 0 for January
(Calendar.JANUARY), 1 for February (Calendar.FEBRUARY).dayOfWeek
- 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
.houseCode
- the house code of the event. Valid codes are 'A'
through 'P', uppercase.clearBatteryTimer
- If true, the interface's battery timer will be
cleared.clearMonitoredStatus
- If true, the interface's monitored statuses
will be cleared.purgeTimer
- If true, this will purge the interfaces timer, but I
don't know what that means???public void ringEnable()
public void ringDisable()
public void addCM11AListener(CM11AListener l)
l
- CM11AListener to add.removeCM11AListener
public void removeCM11AListener(CM11AListener l)
l
- CM11AListener to remove.addCM11AListener
protected void fireCM11AEvent(CM11AEvent evt)
evt
- The event to send to listeners.public void addCM11AStatusListener(CM11AStatusListener l)
l
- CM11AStatusListener to add.removeCM11AStatusListener
public void removeCM11AStatusListener(CM11AStatusListener l)
l
- CM11AStatusListener to remove.addCM11AStatusListener
protected void fireCM11AStatusEvent(CM11AStatusEvent evt)
evt
- The event to send to listeners.public void addAddressListener(AddressListener l)
l
- X10 AddressListener to add.removeAddressListener
public void removeAddressListener(AddressListener l)
l
- AddressListener to remove.addAddressListener
public void addFunctionListener(FunctionListener l)
l
- X10 FunctionListener to add.removeFunctionListener
public void removeFunctionListener(FunctionListener l)
l
- FunctionListener to remove.addFunctionListener
protected void fireX10Event(X10Event evt)
evt
- The event to send to X10Transmission listeners.public boolean isRunning()
public void allocate() throws GatewayException, GatewayStateError
DEALLOCATING_RESOURCES
stategetGatewayState
,
deallocate
,
ALLOCATED
,
GATEWAY_ALLOCATED
public void deallocate()
ALLOCATING_RESOURCES
stateallocate
,
GATEWAY_DEALLOCATED
,
QUEUE_EMPTY
public void dispatchControlEvent(ControlEvent event)
event
- the ControlEvent to be propagated to the listenersfireControlEvent
public void run()
public void processTransmissionQueue()
public void processPendingRequests()
protected FunctionEvent createEvent(FunctionEvent function, java.lang.Object newSource)
functionEvent
- FunctionEvent to copy with the new source.newSource
- The new source to use in the copied FunctionEvent.public void serialEvent(javax.comm.SerialPortEvent event)
public CM11AStatusEvent decodeStatus(byte[] bytes, int off, int len)
public void downloadInitiators() throws OutOfMacroMemoryException
protected static byte[] toBytes(int value, int len, boolean bigEndian)
value
- Integer value to convert.len
- Number of bytes to use.bigEndian
- If true, most significant byte is byte 0. If false,
least significant byte is byte 0.protected int encodeEEPROM() throws OutOfMacroMemoryException
protected int encodeMacro(Macro macro, int macroOffset)
macro
- Macro to encode.macroOffset
- Index in EEPROM to copy macro to.src
array could not be stored into the dest
array
because of a type mismatch.public void addTimerInitiator(TimerInitiator timerInitiator)
downloadInitiators()
timerInitiator
- A timer initiator to add to the CM11A.public boolean removeTimerInitiator(TimerInitiator timerInitiator)
downloadInitiators()
timerInitiator
- The timer initiator to remove.true
if the timer initiator was found,
false
otherwise.public void clearTimerInitiators()
public java.util.Enumeration timerInitiators()
Enumeration
of all timer initiators.public void addMacroInitiator(MacroInitiator macroInitiator)
downloadInitiators()
macroInitiator
- A macro initiator to add to the CM11A.public boolean removeMacroInitiator(MacroInitiator macroInitiator)
downloadInitiators()
macroInitiator
- The macro initiator to remove.true
if the macro initiator was found,
false
otherwise.public void clearMacroInitiators()
public java.util.Enumeration macroInitiators()
Enumeration
of all timer initiators.protected static int normalizeMonth(int month)
month
- Month, zero based. e.g., 0 for January, 1 for February.protected static int normalizeDay(int month, int day)
day
- Day to normalize.month
- Month, zero based. e.g., 0 for January, 1 for February.protected static int dayOfYear(int month, int day)
month
- Month, zero based. e.g., 0 for January, 1 for February.day
- Day of monthpublic static int extractMonth(int julianDay)
getJulianDay
to the month the day represents.
The month is zero based, i.e. 0 for January, 1 for February, ...,
11 for December.
As far as I can tell, the CM11A has no way of determining leap years. It therefore always uses 366 days in a year. The caller is responsible for determininging if the current day has been corrected for a non-leap year.
public static int extractDay(int julianDay)
getJulianDay
to a the day of the month represented.
As far as I can tell, the CM11A has no way of determining leap years. It therefore always uses 366 days in a year. The caller is responsible for determininging if the current day has been corrected for a non-leap year.
extractMonth
,
getJulianDay
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |