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 org.wcb.autohome.interfaces.X10DeviceConstants;
23 import org.wcb.autohome.interfaces.IMacroEvent;
24 import org.wcb.autohome.interfaces.IX10Module;
25 /***
26 *Filename: $Id: MacroEvent.java,v 1.5 2004/02/28 00:21:49 wbogaardt Exp $
27 *
28 *Abstract: This is the events for an assigned macro
29 *
30 * $Log: MacroEvent.java,v $
31 * Revision 1.5 2004/02/28 00:21:49 wbogaardt
32 * fixed formating to be compliant with sun coding convention
33 *
34 * Revision 1.4 2004/01/16 00:53:43 wbogaardt
35 * Fixed a very obscure bug with the Macro Panel that it didn't added new
36 * x10 devices to the drop down of available x10 device for the macro. Modified Macro triggers to change the events
37 * to integer verses strings cleaner this way.
38 *
39 * Revision 1.3 2004/01/15 21:05:20 wbogaardt
40 * major revamp of Modules and interfaces changes overall structure of how information is stored
41 *
42 * Revision 1.2 2003/12/13 05:36:52 wbogaardt
43 * fixed javadoc comments.
44 *
45 *
46 */
47 public class MacroEvent implements IMacroEvent, Serializable, X10DeviceConstants {
48
49 private String macroName;
50 private int actionEvent;
51 private IX10Module iX10Device;
52
53 /***
54 * Macro events are events that take place when a stored macro
55 * is executed
56 * @param n Event or macro name
57 * @param iMod X10 module that will execute the event
58 * @param act The event action that the X10 Mondule will execute ON_ACTION or OFF_ACTION
59 */
60 public MacroEvent(String n, IX10Module iMod, int act) {
61
62 this.macroName = n;
63 this.actionEvent = act;
64 this.iX10Device = iMod;
65 }
66
67 /***
68 * Default constructor with a macro name of Macro1 and
69 * default X10 Module set to A1 and an ON_Action call
70 */
71 public MacroEvent() {
72 this(new String("Macro1"), new X10Module(), ON_ACTION);
73 }
74
75 /***
76 * Clone constructor for the macro event using the passed in interface.
77 * @param newO Interface to clone as an object
78 */
79 public MacroEvent(IMacroEvent newO) {
80 this(newO.getMacroName(), newO.getX10Module(), newO.getAction());
81 }
82
83 /***
84 * Print routine for debugging purpose
85 */
86 public void print() {
87 System.out.println(macroName + " " + this.actionEvent);
88 }
89
90
91 /***
92 * Sets the macro name
93 * @param n Name of the macro
94 */
95 public void setMacroName(String n) {
96 this.macroName = new String(n);
97 }
98
99 /***
100 * Sets the x10 module identifier
101 * @param iMod X10Module object
102 */
103 public void setX10Module(IX10Module iMod) {
104 this.iX10Device = iMod;
105 }
106
107 /***
108 * Sets the action when the event is told to execute
109 * @param act ON_ACTION or OFF_ACTION events
110 */
111 public void setAction(int act) {
112 this.actionEvent = act;
113 }
114
115
116 /***
117 * Gets the name of the macro
118 * @return name of macro
119 */
120 public String getMacroName() {
121 return this.macroName;
122 }
123
124 /***
125 * Gets the X10module object interface for this event.
126 * @return X10Module interface for event.
127 */
128 public IX10Module getX10Module() {
129 if (this.iX10Device == null)
130 {
131 this.iX10Device = new X10Module();
132 }
133 return this.iX10Device;
134 }
135
136 /***
137 * Get the action type for the macro event these can
138 * be on or off actions.
139 * @return Int value of action constants ON_ACTION or OFF_ACTION
140 */
141 public int getAction() {
142 return this.actionEvent;
143 }
144
145 }
146
147