View Javadoc

1   package org.wcb.autohome.implementations;
2   
3   import org.wcb.autohome.interfaces.IX10MonitorEvent;
4   import org.wcb.autohome.interfaces.IX10Module;
5   import org.wcb.autohome.interfaces.IRunEvent;
6   
7   import java.util.Calendar;
8   import java.io.Serializable;
9   
10  /****
11   * Copyright (C) 1999  Walter Bogaardt
12   *
13   * This library is free software; you can redistribute it and/or
14   * modify it under the terms of the GNU Lesser General Public
15   * License as published by the Free Software Foundation; either
16   * version 2 of the License, or (at your option) any later version.
17   *
18   * This library is distributed in the hope that it will be useful,
19   * but WITHOUT ANY WARRANTY; without even the implied warranty of
20   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21   * Lesser General Public License for more details.
22   *
23   * You should have received a copy of the GNU Lesser General Public
24   * License along with this library; if not, write to the Free Software
25   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
26   *
27   * Project: Alice X10 Home Automation
28   * Filename:  $Id: X10MonitorEvent.java,v 1.6 2004/02/28 00:21:49 wbogaardt Exp $<BR>
29   * Abstract: Used to display monitoring information on the monitor panel and run the
30   *           displays the events table.
31   *
32   * $Log: X10MonitorEvent.java,v $
33   * Revision 1.6  2004/02/28 00:21:49  wbogaardt
34   * fixed formating to be compliant with sun coding convention
35   *
36   * Revision 1.5  2004/01/19 22:35:37  wbogaardt
37   * added fixes to runing events and emails so they work and added a testing of a monitored event through the
38   * table popup on a right mouse click.
39   *
40   * Revision 1.4  2004/01/18 00:48:33  wbogaardt
41   * refactored out unnecessary code and now have a functional initial design of monitoring panel
42   *
43   * Revision 1.3  2004/01/17 07:21:17  wbogaardt
44   * added serialization to run events and allow monitoring of these events to the file system to reload later
45   *
46   * Revision 1.2  2004/01/17 06:21:55  wbogaardt
47   * added new Run event interfaces
48   *
49   * Revision 1.1  2004/01/16 22:59:05  wbogaardt
50   * new classes for the monitor panel
51   *
52   */
53  public class X10MonitorEvent implements IX10MonitorEvent, Serializable {
54  
55      private IX10Module iX10MonitorDevice;
56      private String sDescription;
57      private String sLocation;
58      private IRunEvent[] iEvent;
59      private Calendar cTime;
60      private String sStatus;
61  
62      /***
63       * Default constructor that builds a default
64       * monitor on X10 device code of A1
65       */
66      public X10MonitorEvent()
67      {
68          this(new X10Module(), "Default Monitor");
69      }
70  
71      /***
72       * Create a basic montitor event object passing in the
73       * X10 module being monitored and the description of the monitoring.
74       * @param iMod X10Module object to monitor
75       * @param sDesc brief description of why monitoring.
76       */
77      public X10MonitorEvent(IX10Module iMod, String sDesc)
78      {
79          this.iX10MonitorDevice = iMod;
80          this.sDescription = sDesc;
81      }
82  
83      /***
84       * Create the X10 monitor event using the interface
85       * @param iNewO The interface to create an object from.
86       */
87      public X10MonitorEvent(IX10MonitorEvent iNewO) {
88          this(iNewO.getMonitoringModule(), iNewO.getDescription());
89      }
90  
91      /***
92       * Set the module to be monitored to this monitoring object
93       *
94       * @param iModule the x10 device to monitor events.
95       */
96      public void setMonitoringModule(IX10Module iModule)
97      {
98          this.iX10MonitorDevice = iModule;
99      }
100 
101     /***
102      * Allows the user to set a good description of the
103      * event they are monitoring.
104      * @param sDesc Description information.
105      */
106     public void setDescription(String sDesc) {
107         this.sDescription = sDesc;
108     }
109 
110     /***
111      * Location information of the monitoring module
112      * @param sLoc User defined location name
113      */
114     public void setLocation(String sLoc) {
115         this.sLocation = sLoc;
116     }
117 
118     /***
119      * This is usually set by a monitoring listener to
120      * set a time/date stamp of when a particular monitored
121      * event occured.
122      * @param cal Stamp of date and time.
123      */
124     public void setTimeDetected(Calendar cal) {
125         this.cTime = cal;
126     }
127 
128     /***
129      * Sets the string information or status of an event
130      * to let the user know if a monitored light or appliance
131      * had been turned on the reflect a turn on message.
132      * @param sStat message of event
133      */
134     public void setStatus(String sStat) {
135         this.sStatus = sStat;
136     }
137 
138     /***
139      * THe monitored event might have an action such
140      * as run another program or do some other event.
141      * So this will use a IRunEvent interface.
142      * @param iRunEvent an array of events
143      */
144     public void setRunEvent(IRunEvent[] iRunEvent) {
145         this.iEvent = iRunEvent;
146     }
147 
148     /***
149      * Return the module that is being monitored
150      * by this this monitoring event.
151      * @return the monitored IX10Module object
152      */
153     public IX10Module getMonitoringModule()
154     {
155         if (this.iX10MonitorDevice == null)
156         {
157             this.iX10MonitorDevice = new X10Module();
158         }
159         return this.iX10MonitorDevice;
160     }
161 
162     /***
163      * The description of the monitoring event
164      * @return user defined descripition of the event
165      */
166     public String getDescription() {
167         return this.sDescription;
168     }
169 
170     /***
171      * Returns the location name of the monitoring module
172      * @return Location name.
173      */
174     public String getLocation() {
175         return this.sLocation;
176     }
177 
178     /***
179      * The time that a monitored event last took
180      * place.
181      * @return  the date and time of last event.
182      */
183     public Calendar getTimeDetected() {
184         return this.cTime;
185     }
186 
187     /***
188      * The last status of a monitored event.
189      * @return Status string
190      */
191     public String getStatus() {
192         return this.sStatus;
193     }
194 
195     /***
196      * The interface of a IRunEvent object.
197      * @return IRunEvent object
198      */
199     public IRunEvent[] getRunEvent() {
200         if (iEvent == null)
201         {
202             RunEvent[] runEvent = {new RunEvent()};
203             this.iEvent = runEvent;
204         }
205         return this.iEvent;
206     }
207 
208 }