1 package org.wcb.autohome.implementations;
2 /***
3 * Copyright (C) 1999 Walter Bogaardt
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 *
19 * Project: Alice X10 Home Automation
20 */
21 import java.io.Serializable;
22 import java.util.Calendar;
23
24 import org.wcb.autohome.interfaces.X10DeviceConstants;
25 import org.wcb.autohome.interfaces.IX10Module;
26 import org.wcb.autohome.interfaces.IX10Events;
27
28 /***
29 *Filename: $Id: X10Events.java,v 1.7 2004/02/28 00:21:49 wbogaardt Exp $
30 *
31 *Abstract: This is the events to take place when we are running the EventsDaemon
32 * It is also a type a wrapper or solution to the CM17A not being able
33 * to execute macros and in part run a set a programed timed events.
34 * These events are only associated on the Events Panel and should not be
35 * confused with the MacroEvent module which is for CM11A uploading of macro
36 * information.
37 *
38 * $Log: X10Events.java,v $
39 * Revision 1.7 2004/02/28 00:21:49 wbogaardt
40 * fixed formating to be compliant with sun coding convention
41 *
42 * Revision 1.6 2004/02/24 23:16:19 wbogaardt
43 * fixed formating to be compliant with checkstyles
44 *
45 * Revision 1.5 2004/01/16 00:53:43 wbogaardt
46 * Fixed a very obscure bug with the Macro Panel that it didn't added new
47 * x10 devices to the drop down of available x10 device for the macro. Modified Macro triggers to change the events to
48 * integer verses strings cleaner this way.
49 *
50 * Revision 1.4 2004/01/15 21:05:20 wbogaardt
51 * major revamp of Modules and interfaces changes overall structure of how information is stored
52 *
53 * Revision 1.3 2003/12/12 23:17:36 wbogaardt
54 * javadoc comments refactored methods so they are more descriptive
55 *
56 * Revision 1.2 2003/10/10 18:39:12 wbogaardt
57 * changed date time information from a string to a calendar object
58 *
59 *
60 *@author wbogaardt
61 *@version 1.1
62 */
63 public class X10Events implements org.wcb.autohome.interfaces.IX10Events, Serializable, X10DeviceConstants {
64
65
66 private String description;
67 private String eventAction;
68 private boolean sunday = false;
69 private boolean monday = false;
70 private boolean tuesday = false;
71 private boolean wednesday = false;
72 private boolean thursday = false;
73 private boolean friday = false;
74 private boolean saturday = false;
75 private Calendar datetime;
76 private IX10Module module;
77
78 /***
79 * This creates the X10Event with the bar minimum parameters to make
80 * a functional event.
81 *
82 * @param iModule X10 Module for the event
83 * @param desc Description of the event
84 * @param act string action of the event
85 * @param time time to execute the event.
86 */
87 public X10Events(IX10Module iModule, String desc, String act, Calendar time) {
88
89 this.module = iModule;
90 this.description = new String(desc);
91 this.eventAction = new String(act);
92 this.datetime = time;
93 }
94
95 /***
96 * Default constructor
97 */
98 public X10Events() {
99 this(new X10Module(), new String("NO DESCRIPTION"), "ON", Calendar.getInstance());
100 }
101 /***
102 * Cloning constructor
103 * @param newO Interface used to clone object
104 */
105 public X10Events(IX10Events newO) {
106 this(newO.getModule(), newO.getDescription(), newO.getAction(), newO.getTime());
107 }
108
109 /***
110 * method to allow printing to console some information.
111 */
112 public void print() {
113 System.out.println(module.getFullDeviceCode() + "\t" + description + "\t"
114 + eventAction + "\t " + datetime.toString());
115 }
116
117
118
119 /***
120 * Set the x10 module device to this event
121 * @param imodule The module device that this event will fire action on.
122 */
123 public void setDeviceModule(IX10Module imodule) {
124 this.module = imodule;
125 }
126
127 /***
128 *User description for this event
129 *
130 *@param desc - description
131 */
132 public void setDescription(String desc) {
133 this.description = new String(desc);
134 }
135 /***
136 * actions to take when this event is scheduled for
137 * executing. This could be turning on or off devices
138 * or Brightening or diming lights.
139 * @param act - Value of action
140 */
141 public void setAction(String act) {
142 this.eventAction = new String(act);
143 }
144
145 /***
146 * Set the time of the event
147 * @param time Time to set the event to execute.
148 */
149 public void setTime(Calendar time) {
150 this.datetime = time;
151 }
152
153 /***
154 * Enable Sunday dates to execute event
155 * @param s enable/disable Sunday
156 */
157 public void setSunday(boolean s) {
158 this.sunday = s;
159 }
160
161 /***
162 * Enable Monday weekday to execute event
163 * @param m enable/disable Monday
164 */
165 public void setMonday(boolean m) {
166 this.monday = m;
167 }
168
169 /***
170 * Enable Tuesday weekday to execute event
171 * @param t enable/disable Tuesday
172 */
173 public void setTuesday(boolean t) {
174 this.tuesday = t;
175 }
176
177 /***
178 * Enable Wednesday weekday to execute event
179 * @param w enable/disable Wednesday
180 */
181 public void setWednesday(boolean w) {
182 this.wednesday = w;
183 }
184
185 /***
186 * Enable Thursday weekday to execute event
187 * @param t enable/disable Thursday
188 */
189 public void setThursday(boolean t) {
190 this.thursday = t;
191 }
192
193 /***
194 * Enable Friday weekday to execute event
195 * @param f enable/disable Friday
196 */
197 public void setFriday(boolean f) {
198 this.friday = f;
199 }
200
201 /***
202 * Enable Saturday weekday to execute event
203 * @param s enable/disable Saturday
204 */
205 public void setSaturday(boolean s) {
206 this.saturday = s;
207 }
208
209 /***
210 * Get the Enable/disable value of the event for Sunday
211 * @return true enable, false don't execute
212 */
213 public boolean getSunday() {
214 return this.sunday;
215 }
216
217 /***
218 * Get the Enable/disable value of the event for Monday
219 * @return true enable, false don't execute
220 */
221 public boolean getMonday() {
222 return this.monday;
223 }
224
225 /***
226 * Get the Enable/disable value of the event for Tuesday
227 * @return true enable, false don't execute
228 */
229 public boolean getTuesday() {
230 return this.tuesday;
231 }
232
233 /***
234 * Get the Enable/disable value of the event for Wednesday
235 * @return true enable, false don't execute
236 */
237 public boolean getWednesday() {
238 return this.wednesday;
239 }
240
241 /***
242 * Get the Enable/disable value of the event for Thursday
243 * @return true enable, false don't execute
244 */
245 public boolean getThursday() {
246 return this.thursday;
247 }
248
249 /***
250 * Get the Enable/disable value of the event for Friday
251 * @return true enable, false don't execute
252 */
253 public boolean getFriday() {
254 return this.friday;
255 }
256
257 /***
258 * Get the Enable/disable value of the event for Saturday
259 * @return true enable, false don't execute
260 */
261 public boolean getSaturday() {
262 return this.saturday;
263 }
264
265
266 /***
267 * The X10 Module associated with this event
268 * @return X10module interface for the event
269 */
270 public IX10Module getModule() {
271 if (this.module == null)
272 {
273 this.module = new X10Module();
274 }
275 return module;
276 }
277
278 /***
279 * Gets the description of the event
280 * @return Defaults to NO DESCRIPTION
281 */
282 public String getDescription() {
283 if (description == null)
284 {
285 return "NO DESCRIPTION";
286 }
287 return description;
288 }
289
290 /***
291 * Get the action type for the event this is a string
292 * of on, off, dim, or brighten
293 * @return String of action to send to module.
294 */
295 public String getAction() {
296 return eventAction;
297 }
298
299 /***
300 * The time of day to execute the event
301 * @return Gregorian Calendar of time to execute.
302 */
303 public Calendar getTime() {
304 return datetime;
305 }
306 }
307