View Javadoc

1   package org.wcb.autohome;
2   
3   
4   /* java swing stuff */
5   import javax.swing.JPanel;
6   
7   /* standard java stuff */
8   import java.awt.BorderLayout;
9   /***
10   * Copyright (C) 1999  Walter Bogaardt
11   *
12   * This library is free software; you can redistribute it and/or
13   * modify it under the terms of the GNU Lesser General Public
14   * License as published by the Free Software Foundation; either
15   * version 2 of the License, or (at your option) any later version.
16   *
17   * This library is distributed in the hope that it will be useful,
18   * but WITHOUT ANY WARRANTY; without even the implied warranty of
19   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20   * Lesser General Public License for more details.
21   *
22   * You should have received a copy of the GNU Lesser General Public
23   * License along with this library; if not, write to the Free Software
24   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
25   *
26   *  Project:   Home Automation Interface
27   *
28   *  Filename:  $Id: SerialPanel.java,v 1.11 2004/02/24 23:16:17 wbogaardt Exp $
29   *
30   * Abstract:  Control panel for initiating serial port.
31   * X10 communications list
32   * A0  All Units off
33   * L1  All lights ON
34   * ON  On
35   * OF  Off
36   * DI  Dim
37   * BR  Bright
38   * L0  All Lights off
39   * EC  Extend Code
40   * HR  Hail Request
41   * HA  Hail Acknowledge
42   * P0  Pre-set Dim 0
43   * P1  Pre-set Dim 1
44   * ED  Extended Data (analog)
45   * S1  Status=ON
46   * S0  Status=OFF
47   * SR  Status Request
48   *
49   *  $Log: SerialPanel.java,v $
50   *  Revision 1.11  2004/02/24 23:16:17  wbogaardt
51   *  fixed formating to be compliant with checkstyles
52   *
53   *  Revision 1.10  2003/12/30 00:56:45  wbogaardt
54   *  added more internationalization to table column names.
55   *
56   *  Revision 1.9  2003/12/22 20:51:29  wbogaardt
57   *  refactored name assignments and formatted code for readability.
58   *
59   *  Revision 1.8  2003/12/18 00:02:50  wbogaardt
60   *  more javadoc comments
61   *
62   *  Revision 1.7  2003/12/17 21:27:06  wbogaardt
63   *  Improved error traping of CM11A send command to all house
64   *
65   *  Revision 1.6  2003/12/12 01:34:28  wbogaardt
66   *  fixed message interface was throwing stack overflow. Fixed display bug with Serial panel.
67   *
68   *  Revision 1.5  2003/12/12 00:37:34  wbogaardt
69   *  cleaned up message printing interfaces. Also cleand up what is spoken by the speech engine
70   *
71   *  Revision 1.4  2003/12/11 23:10:07  wbogaardt
72   *  cleaned up exception handeling and logging of system.out messages
73   *
74   *  Revision 1.3  2003/12/08 23:20:55  wbogaardt
75   *  refactored loading of properties files to allow specify of directory for servlet reuse
76   *
77   *  Revision 1.2  2003/10/10 00:50:43  wbogaardt
78   *  decoupled the ConfigurationPanel to SerialConfigurationPanel
79   *
80   */
81  public class SerialPanel extends JPanel {
82  
83      private SerialConfigurationPanel configPanel;
84      private TimePanel tpTimePanel;
85  
86      /***
87       * Default constructor which calls the setup components
88       * to create the panel and its functional components.
89       */
90      public SerialPanel() {
91          setupComponents();
92      }
93  
94      /***
95       * Setsup the components on the panel
96       */
97      private void setupComponents() {
98          setLayout(new BorderLayout());
99          tpTimePanel = new TimePanel();
100         configPanel = new SerialConfigurationPanel(this);
101         add(configPanel, BorderLayout.NORTH);
102         add(tpTimePanel, BorderLayout.CENTER);
103         configPanel.setPortValue();
104     }
105 
106     /***
107      * If the device gateway selected is the CM11A then enable
108      * the time panel which allows storing of time to the CM11A device only.
109      * This is disabled if it is any other device.
110      * @param b set true if CM11A
111      */
112     public void timePanelEnable(boolean b)
113     {
114         tpTimePanel.setEnabled(b);
115     }
116 
117     /***
118      * This saves the properties values of the currently selected
119      * serial port settings.
120      */
121     public void saveProperties() {
122         AutoHomeAdminSession.getInstance().setInterfaceType(configPanel.getInterfaceType());
123         /* refresh the status bar information */
124         tpTimePanel.refresh();
125         /* save all the information to text file */
126         tpTimePanel.saveProperties();
127     }
128 
129     /***
130      * Initializes the serial port to the selected port
131      * value in the configuration panel combo box.
132      */
133     public void setPort()
134     {
135         AutoHomeAdminSession.getInstance().getAppProperties();
136     }
137 }
138 
139 
140 
141