org.wcb.autohome
Class AutoHomeSession

java.lang.Object
  extended byorg.wcb.autohome.AutoHomeSession
All Implemented Interfaces:
X10DeviceConstants
Direct Known Subclasses:
AutoHomeAdminSession, AutoHomeDaemonSession

public class AutoHomeSession
extends java.lang.Object
implements X10DeviceConstants

This class is a base class that holds most of the common methods that are accessed either via the command line daemon or the gui. Most of the functions handled through this class are for communications between the interface layer and the serial port, although all of the real process handled on the serial port end is done by the HAGateway object.

Version:
1.0
Author:
Walter Bogaardt

Field Summary
static java.lang.String CURRENT_FILENAME
          The Current File name loaded into the application.
protected  IDeviceRemote deviceFactory
           
protected  IHAGateway gateway
           
 
Fields inherited from interface org.wcb.autohome.interfaces.X10DeviceConstants
APPLIANCE_MODULE_OFF, APPLIANCE_MODULE_ON, BAUD, BAUD_RATE_ARRAY, BRIGHT_ACTION, BROWSER, CM11A_TRANSMITTER, CM17A_TRANSMITTER, CONNECT_ON_START, COUNTRY, DATA_BIT, DATA_BITS_ARRAY, DEVICE_ARRAY, DIM_ACTION, EMAIL_AUTHORIZE, EMAIL_FREQUENCY, EMAIL_FROM, EMAIL_PASSWORD, EMAIL_SMTP, EMAIL_TO, EMAIL_USERNAME, FALSE, HOUSE_CODES_ARRAY, INTERFACE_TYPE, LAMP_MODULE_OFF, LAMP_MODULE_ON, LANGUAGE, LAST_FILE, LOCALHOST, LOOK_AND_FEEL, MAC, METAL, MOTIF, OFF_ACTION, ON_ACTION, PARITY, PARITY_ARRAY, RECOVER_CM11A, RMI_HOST, SEPARATOR, SERIAL_PORT, SPEECH_ENGINE, STOP_BIT, STOP_BITS_ARRAY, TEST_TRANSMITTER, TIMER_EVENT, TRIGGER_EVENT, TRUE, USER_HOME, WINDOWS
 
Constructor Summary
AutoHomeSession()
           
 
Method Summary
 void buildTriggerMacros(boolean bClear)
          This builds the macro trigger events for both the timer type triggers and for the macro module initiators.
 void clearMacroEventsFromCM11A()
          Clears only the event driven macros from the CM11A.
 void clearTimerMacrosFromCM11A()
          Clears only the timer event driven macros from the CM11A.
 void closeSerialPort()
          This closes the port that had been opend by the user to the CM11A or CM17A interface module
 void connectPortToDevice(int iDeviceType)
          Based on the user's select it will set the port to the string variable that is sent.
 void connectSerialOnStartup(boolean bVal)
          The User may opt to want to automatically connect the serial port to the X10 gateway on subsequent start up of the application.
 boolean connectToSerialPortOnStartup()
          After reading in jhome.prop if initial.on.start indicates true then return a true to have the application automatically connect serial port up.
 void createNewFile(java.lang.String sfilename)
          Creates a new file and sets the current file name sets settings to default value.
 void deleteMacro(IMacro mac)
          Removes the indicated macro from the file system.
 boolean disableMonitorCM11A()
          Disables the monitoring of the CM11A device.
 void enableSpeechEngine(boolean bValue)
          This allows the user to enable the speech engine or disable it if it gets irratating when listening to messages.
 java.util.Vector getAvailablePorts()
          Calls the HAGateway class, which uses the java comm api to enumerate through the serial and parallel ports on the operating system.
 int getCM11ABatteryUsage()
          Retrieves the CM11A's current battery usage.
 java.util.GregorianCalendar getCM11ADate()
          Get the current date that the CM11A thinks it is.
 java.lang.String getCountry()
          Gets the last saved country value for internationalization.
 EmailHeaderBean getEmailInformation()
          This allows the getting of email configruations from the HASConfig.ini file in a single object bean.
 java.util.ResourceBundle getI18n()
          Get internationalization resources.
 java.lang.String getLookAndFeel()
          Gets the Swing ui look and feel for the user.
 SerialPortBean getSerialPort()
          Returns the string name of the serial port.
 int getX10GatewayType()
          Gets the x10 interfae type, which is either a CM11A or CM17A serial port device.
 boolean isAutoRecoverCM11A()
          This returns the value of the HASConfig file which indicates that the user wants to or does not want to auto recover the CM11A on a power failure.
 boolean isEventDaemonRunning()
          Checks if the events daemon is already running
 boolean isSpeechEnabled()
          Returns a true if the speech engine is enabled by the user other wise it returns false.
 boolean isX10GatwayConnected()
          returns a boolean based on if the selected port has been activated or shutdown by the user/application.
 void lampIntensity(IX10Module x10Evt, int cmnd, int iPercentage)
          This controls the lights for only for dim and brighten events
 java.util.Vector loadAllAliceEvents()
          Loads from file all the IX10Events, which are specific to the Alice system.
 java.util.Vector loadAllAliceMonitors()
          Gets a vector from the saved file settings all of the monitor events that the user wants to monitor
 java.util.Vector loadAllCM11AMacros()
          Loads all the macros that have been stored in a file system.
 java.util.Vector loadAllX10Devices()
          Loads from a file all the X10 devices that have been saved under the modules panel of the gui or website.
 java.util.Vector loadCM11AMacroTriggers()
          Loads from file all the macro triggers for a set macro.
protected  void loadServices(UIDefaultsLoader props)
          Deprecated.  
protected  void loadStandAloneService(java.lang.String sDirectory)
          Starts up all the services for the Alice gui or web application.
 void loadX10File(java.lang.String sfilename)
          Loads the serialized file of objects from the user's operating system.
 boolean monitorCM11A()
          Enables monitoring of the CM11A device.
 void recoverCM11A(boolean bValue)
          Indicates that the user either wants the CM11A to autorecover upon detecting a power failure.
 boolean runEventsDaemon()
          Starts the events daemon which runs the events of times and on off for various modules.
 void saveAllAliceEvents(java.util.Vector vEvents)
          Saves to a file all the IX10Events, which are specific to the Alice system.
 void saveAllAliceMonitors(java.util.Vector vMonitors)
          Allows saving of monitor events panel to the file system
 void saveAllCM11AMacros(java.util.Vector vMacros)
          Saves to the file system all the IMacro objects.
 void saveAllX10Devices(java.util.Vector vX10Devices)
          Saves to a file all the X10 devices added or modified in the modules tab of the gui or web interface.
 void saveCM11AMacroTriggers(java.util.Vector vMacroTrig)
          Saves a vector of IMacroTrigger objects to the file system.
 void saveFile(java.lang.String sfileName)
          Saves all of the module information to the user selected save to file this method is usually called from a save or save as command.
 void saveMacro(IMacro mac)
          Save the IMacro to the file system in memory.
 void saveServerFile()
          Saves the server file settings, which are the serial port information, email information, and look and feel for the swing gui.
 void sendCommandToSection(char cHouseCode, int iCmnd)
          These are commands that can be sent to the entire house code in a particular section regardless if it is an appliance or light module.
 void sendCommandToX10Module(IX10Module x10module, int iCmd)
          This controls the appliance modules for only On/Off events The commands are either X10DeviceConstants.OFF_ACTION = 0 X10DeviceConstants.ON_ACTION = 1
 void setCM11AClock(java.util.Calendar calendar, char houseCode, boolean batteryTimer, boolean clrMonitored, boolean purgeTimer)
          allows the user to set or send commands to set the CM11A clock settings This command needs the hours,minutes, seconds, month, day , day of week, house code character value, whether to reset the battery timer, clear the CM11A from monitoring the house, or purge the macro timer.
 void setCountry(int iCountry)
          allows setting of country for internationalization 1 is dutch, 2 is german, 3 is GB english, default is US english
 void setEmailInformation(EmailHeaderBean bean)
          This sets the configuration files settings from a bean object.
 void setInterfaceType(int iType)
          This is either the CM11A or CM17A devices identified as X10DeviceConstants.CM11A_TRANSMITTER = 1 or X10DeviceConstants.CM17A_TRANSMITER = 2
 void setLookAndFeel(java.lang.String sLF)
          Sets the look and feel from the user selected option and saves this to the HAConfig.ini file for subsequent reload of the application.
 void setMonitorModel(MonitorTableModel mModel)
          This allows the gateway to have reference to the monitor table modle so that when the user decides to monitor the table object events and the table can update each other.
 void setSerialPort(SerialPortBean sPortName)
          Sets the serial port to the passed in string value.
protected  void showMessage(java.lang.String sMessages)
          simple method to print messages to gui or console This will also speak the message if the speech plugin has been loaded by the class loader.
 void stopEventsDaemon()
          Stops the events daemon which is the table of on off and devices and times table.
 void updateCM11AStatus()
          Update the Status of the CM11A device
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CURRENT_FILENAME

public static java.lang.String CURRENT_FILENAME
The Current File name loaded into the application.


deviceFactory

protected IDeviceRemote deviceFactory

gateway

protected IHAGateway gateway
Constructor Detail

AutoHomeSession

public AutoHomeSession()
Method Detail

loadServices

protected void loadServices(UIDefaultsLoader props)
Deprecated.  

Load the HAGateway and DeviceFactory based on the 'client.server' property.

Parameters:
props - Properties file with key value pair

loadStandAloneService

protected void loadStandAloneService(java.lang.String sDirectory)
Starts up all the services for the Alice gui or web application. The passed in directory is the location where the ini and config files can be found. If no config or ini files are found then they will be created in the indicated directory.

Parameters:
sDirectory - Directory string path where the ini files can be found.

getI18n

public java.util.ResourceBundle getI18n()
Get internationalization resources.

Returns:
Resource for i18n;

getCountry

public java.lang.String getCountry()
Gets the last saved country value for internationalization.

Returns:
defaults to US

setCountry

public void setCountry(int iCountry)
allows setting of country for internationalization 1 is dutch, 2 is german, 3 is GB english, default is US english

Parameters:
iCountry - Country code

getAvailablePorts

public java.util.Vector getAvailablePorts()
Calls the HAGateway class, which uses the java comm api to enumerate through the serial and parallel ports on the operating system.

Returns:
Vector of strings of all the operating systems serial ports.

isX10GatwayConnected

public boolean isX10GatwayConnected()
returns a boolean based on if the selected port has been activated or shutdown by the user/application.

Returns:
a false indicates X10 interface is not connected.

closeSerialPort

public void closeSerialPort()
                     throws HomeException
This closes the port that had been opend by the user to the CM11A or CM17A interface module

Throws:
HomeException - Caught exception but needs to be reported to user.

runEventsDaemon

public boolean runEventsDaemon()
Starts the events daemon which runs the events of times and on off for various modules.

Returns:
succes running events

stopEventsDaemon

public void stopEventsDaemon()
Stops the events daemon which is the table of on off and devices and times table.


isEventDaemonRunning

public boolean isEventDaemonRunning()
Checks if the events daemon is already running

Returns:
true if daemon is running

getX10GatewayType

public int getX10GatewayType()
Gets the x10 interfae type, which is either a CM11A or CM17A serial port device. The return value should be one of the following: 1 - CM11A 2 - CM17A

Returns:
a 1 or 2, which indicates the x10 gatway type.

setInterfaceType

public void setInterfaceType(int iType)
This is either the CM11A or CM17A devices identified as X10DeviceConstants.CM11A_TRANSMITTER = 1 or X10DeviceConstants.CM17A_TRANSMITER = 2

Parameters:
iType - should be a 1 or 2.

getCM11ABatteryUsage

public int getCM11ABatteryUsage()
Retrieves the CM11A's current battery usage. The value is is initialized after a call to updateStatus(); The returned value is the number of minutes.

Returns:
minutes

sendCommandToX10Module

public void sendCommandToX10Module(IX10Module x10module,
                                   int iCmd)
                            throws HomeException
This controls the appliance modules for only On/Off events The commands are either X10DeviceConstants.OFF_ACTION = 0 X10DeviceConstants.ON_ACTION = 1

Parameters:
x10module - Module that the command is being sent.
iCmd - Numeric value of command to send this is either a 0 or 1.
Throws:
HomeException - Caught exception but needs to be reported to user.

sendCommandToSection

public void sendCommandToSection(char cHouseCode,
                                 int iCmnd)
                          throws HomeException
These are commands that can be sent to the entire house code in a particular section regardless if it is an appliance or light module. This is separate from sendCommandToHouse which affects the entire house.

Parameters:
cHouseCode - the house code value 'A' through 'P'
iCmnd - 0 is all lights off, 1 all lights on, 2 all x10 devices off.
Throws:
HomeException - Caught exception but needs to be reported to user.

recoverCM11A

public void recoverCM11A(boolean bValue)
Indicates that the user either wants the CM11A to autorecover upon detecting a power failure. If it is set to true, when the CM11A detects a power failure signal the command to set the clock will be sent. if set to false, it is up to another device to set the clock via a call to setCM11AClock before the CM11A can be used.

Parameters:
bValue - true indicates to recover the CM11A device.

isAutoRecoverCM11A

public boolean isAutoRecoverCM11A()
This returns the value of the HASConfig file which indicates that the user wants to or does not want to auto recover the CM11A on a power failure.

Returns:
true indicates auto recover mode.

updateCM11AStatus

public void updateCM11AStatus()
Update the Status of the CM11A device


getCM11ADate

public java.util.GregorianCalendar getCM11ADate()
Get the current date that the CM11A thinks it is.

Returns:
Current date on the CM11A

setCM11AClock

public void setCM11AClock(java.util.Calendar calendar,
                          char houseCode,
                          boolean batteryTimer,
                          boolean clrMonitored,
                          boolean purgeTimer)
                   throws HomeException
allows the user to set or send commands to set the CM11A clock settings This command needs the hours,minutes, seconds, month, day , day of week, house code character value, whether to reset the battery timer, clear the CM11A from monitoring the house, or purge the macro timer.

Parameters:
calendar - Calendar date and time to send to the CM11A
houseCode - The house code which should be A
batteryTimer - Reset the battery timer use True
clrMonitored - Clear monitored macros use True
purgeTimer - Purge timed macros use True.
Throws:
HomeException - Caught exception but needs to be reported to user.

connectPortToDevice

public void connectPortToDevice(int iDeviceType)
                         throws HomeException
Based on the user's select it will set the port to the string variable that is sent. This first detects if a current port is open and closes it then it will intiate connection to the user selected port.

Parameters:
iDeviceType - either a 1 for CM11A or 2 for CM17A.
Throws:
HomeException - Caught exception but needs to be reported to user.

setSerialPort

public void setSerialPort(SerialPortBean sPortName)
Sets the serial port to the passed in string value. In windows environment this would be the string of COM1 or COM2. For Unix based it would be something like /dev/ttys0 or /dev/ttys1.

Parameters:
sPortName - SerialPortBean representation of the port and values

getSerialPort

public SerialPortBean getSerialPort()
Returns the string name of the serial port.

Returns:
defaults to null value.

getLookAndFeel

public java.lang.String getLookAndFeel()
Gets the Swing ui look and feel for the user. The default return is the Swing METAL look and feel.

Returns:
Java Metal Look and feel.

setLookAndFeel

public void setLookAndFeel(java.lang.String sLF)
Sets the look and feel from the user selected option and saves this to the HAConfig.ini file for subsequent reload of the application.

Parameters:
sLF - Class package name of the look and feel.

getEmailInformation

public EmailHeaderBean getEmailInformation()
This allows the getting of email configruations from the HASConfig.ini file in a single object bean.

Returns:
Single object of configuration file settings

setEmailInformation

public void setEmailInformation(EmailHeaderBean bean)
This sets the configuration files settings from a bean object.

Parameters:
bean - contains information to be stored in HASConfig.ini file.

lampIntensity

public void lampIntensity(IX10Module x10Evt,
                          int cmnd,
                          int iPercentage)
                   throws HomeException
This controls the lights for only for dim and brighten events

Parameters:
x10Evt - x10 module
cmnd - Either 0 for dim 1 for brighten
iPercentage - percentation to change between 1 and 100.
Throws:
HomeException - Caught exception but needs to be reported to user.

saveServerFile

public void saveServerFile()
Saves the server file settings, which are the serial port information, email information, and look and feel for the swing gui.


connectSerialOnStartup

public void connectSerialOnStartup(boolean bVal)
The User may opt to want to automatically connect the serial port to the X10 gateway on subsequent start up of the application.

Parameters:
bVal - True sets automatic connect to serial port

enableSpeechEngine

public void enableSpeechEngine(boolean bValue)
This allows the user to enable the speech engine or disable it if it gets irratating when listening to messages.

Parameters:
bValue - true enables speech false disables.

connectToSerialPortOnStartup

public boolean connectToSerialPortOnStartup()
After reading in jhome.prop if initial.on.start indicates true then return a true to have the application automatically connect serial port up.

Returns:
true indicates automatically connect to serial port.

isSpeechEnabled

public boolean isSpeechEnabled()
Returns a true if the speech engine is enabled by the user other wise it returns false.

Returns:
true speech is enabled.

buildTriggerMacros

public void buildTriggerMacros(boolean bClear)
                        throws HomeException
This builds the macro trigger events for both the timer type triggers and for the macro module initiators. For CM11A type computer interfaces.

Parameters:
bClear - true value clears all macros from the interface before uploading.
Throws:
HomeException - - Either remote exception or unable to build a macro trigger

clearTimerMacrosFromCM11A

public void clearTimerMacrosFromCM11A()
                               throws HomeException
Clears only the timer event driven macros from the CM11A.

Throws:
HomeException - Caught exception but needs to be reported to user.

clearMacroEventsFromCM11A

public void clearMacroEventsFromCM11A()
                               throws HomeException
Clears only the event driven macros from the CM11A.

Throws:
HomeException - Caught exception but needs to be reported to user.

monitorCM11A

public boolean monitorCM11A()
Enables monitoring of the CM11A device.

Returns:
true indicates can monitor port false indicates cannot.

disableMonitorCM11A

public boolean disableMonitorCM11A()
Disables the monitoring of the CM11A device.

Returns:
true indicates can disable monitor to port false indicates cannot.

setMonitorModel

public void setMonitorModel(MonitorTableModel mModel)
This allows the gateway to have reference to the monitor table modle so that when the user decides to monitor the table object events and the table can update each other.

Parameters:
mModel - The monitoring table model

saveMacro

public void saveMacro(IMacro mac)
Save the IMacro to the file system in memory.

Parameters:
mac - Macro to save in the file system.

deleteMacro

public void deleteMacro(IMacro mac)
Removes the indicated macro from the file system.

Parameters:
mac - Macro to be removed

loadAllX10Devices

public java.util.Vector loadAllX10Devices()
Loads from a file all the X10 devices that have been saved under the modules panel of the gui or website. The return will be a vector of IX10Module classes.

Returns:
Vector of IX10Module

saveAllX10Devices

public void saveAllX10Devices(java.util.Vector vX10Devices)
Saves to a file all the X10 devices added or modified in the modules tab of the gui or web interface.

Parameters:
vX10Devices - Vector of IX10Module

loadAllAliceEvents

public java.util.Vector loadAllAliceEvents()
Loads from file all the IX10Events, which are specific to the Alice system. These events are run by an events daemon to fire off actions such as turn x10 device A1 on or off at a certain time and date.

Returns:
Vector of IX10Events objects

saveAllAliceEvents

public void saveAllAliceEvents(java.util.Vector vEvents)
Saves to a file all the IX10Events, which are specific to the Alice system.

Parameters:
vEvents - Vector of IX10Events

saveAllAliceMonitors

public void saveAllAliceMonitors(java.util.Vector vMonitors)
Allows saving of monitor events panel to the file system

Parameters:
vMonitors - Vector of IX10MonitorEvents objects

loadAllAliceMonitors

public java.util.Vector loadAllAliceMonitors()
Gets a vector from the saved file settings all of the monitor events that the user wants to monitor

Returns:
Vector of IX10MonitorEvent objects

loadAllCM11AMacros

public java.util.Vector loadAllCM11AMacros()
Loads all the macros that have been stored in a file system. These macros do not come from the CMA11 module but may have been sent to it at a previous time.

Returns:
Vector of IMacro objects

saveAllCM11AMacros

public void saveAllCM11AMacros(java.util.Vector vMacros)
Saves to the file system all the IMacro objects.

Parameters:
vMacros - Vector of IMacro objects

loadCM11AMacroTriggers

public java.util.Vector loadCM11AMacroTriggers()
Loads from file all the macro triggers for a set macro.

Returns:
Vector of IMacroTrigger

saveCM11AMacroTriggers

public void saveCM11AMacroTriggers(java.util.Vector vMacroTrig)
Saves a vector of IMacroTrigger objects to the file system.

Parameters:
vMacroTrig - Vector of IMacroTrigger

loadX10File

public void loadX10File(java.lang.String sfilename)
Loads the serialized file of objects from the user's operating system. The passed in string should be the full path plus file name and extension. If the file is not found a default serialized object will be returned. This is so the application can assume that this is a new file or a new application.

Parameters:
sfilename - Full path and file name

createNewFile

public void createNewFile(java.lang.String sfilename)
Creates a new file and sets the current file name sets settings to default value.

Parameters:
sfilename - The file name for the new file.

saveFile

public void saveFile(java.lang.String sfileName)
              throws HomeException
Saves all of the module information to the user selected save to file this method is usually called from a save or save as command. This also writes the information to the diskdrive.

Parameters:
sfileName - Full path and file name
Throws:
HomeException - Caught exception but needs to be reported to user.

showMessage

protected void showMessage(java.lang.String sMessages)
simple method to print messages to gui or console This will also speak the message if the speech plugin has been loaded by the class loader.

Parameters:
sMessages - text message to print.


Copyright © 1999-2004 Walter Bogaardt. All Rights Reserved.