View Javadoc

1   package org.wcb.autohome.implementations;
2   
3   import java.io.Serializable;
4   
5   /***
6    * Copyright (C) 1999  Walter Bogaardt
7    *
8    * This library is free software; you can redistribute it and/or
9    * modify it under the terms of the GNU Lesser General Public
10   * License as published by the Free Software Foundation; either
11   * version 2 of the License, or (at your option) any later version.
12   *
13   * This library is distributed in the hope that it will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16   * Lesser General Public License for more details.
17   *
18   * You should have received a copy of the GNU Lesser General Public
19   * License along with this library; if not, write to the Free Software
20   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
21   *
22   * SerialPortBean.java
23   *
24   * Created on February 2, 2004, 7:59 PM
25   *
26   * @author  wbogaardt
27   *
28   *  Project:   Home Automation Interface
29   *  Filename:  $Id: SerialPortBean.java,v 1.2 2004/02/24 23:16:19 wbogaardt Exp $
30   *  Abstract:  This allows persistence of centeralized values accross the sessions and gateways.
31   *
32   *  $Log: SerialPortBean.java,v $
33   *  Revision 1.2  2004/02/24 23:16:19  wbogaardt
34   *  fixed formating to be compliant with checkstyles
35   *
36   *  Revision 1.1  2004/02/03 00:35:10  wbogaardt
37   *  reogranized files so that serial port settings are maintained in a bean to interface with config file
38   *
39   */
40  public class SerialPortBean implements Serializable {
41  
42      private String sPort;
43      private int iBaud;
44      private int iDataBit;
45      private int iStopBit;
46      private String sParity;
47  
48      /***
49       * Takes in the port id value of the serial port
50       * this can be either COM1 for windows or /dev/TTYS01 for unix.
51       * @param sPortName Serial port identifier as a string
52       */
53      public SerialPortBean(String sPortName) {
54          this.sPort = sPortName;
55      }
56  
57      /***
58       * Sets the serial port to the passed in string value.
59       * In windows environment this would be the string of
60       * COM1 or COM2. For Unix based it would be something like
61       * /dev/ttys0 or /dev/ttys1.
62       *
63       * @param sPortName SerialPortBean representation of the port and values
64       */
65      public void setPort(String sPortName) {
66          this.sPort = sPortName;
67      }
68      /***
69       * Allows interface to set the baud rate of
70       * the serial port
71       *
72       * @param iB should be one of these values 300, 2400, 4800, 9600, 14400, 28800, 38400, 57600, 115200
73       */
74      public void setBaud(int iB) {
75          this.iBaud = iB;
76      }
77  
78      /***
79       * Sets the data bit value for the serial port.
80       * @param idata should be a value of 5, 6, 7, or 8
81       */
82      public void setDataBit(int idata) {
83          this.iDataBit = idata;
84      }
85       /***
86       * Sets the serial port stop bit value
87       *
88       * @param iStop  should be int value of 1 or 2
89       */
90      public void setStopBit(int iStop) {
91          this.iStopBit = iStop;
92      }
93  
94        /***
95       * Sets the serial port party to a string value.
96       * @param sparity should be a string value of None, Even, or Odd
97       */
98      public void setParity(String sparity) {
99          this.sParity = sparity;
100     }
101 
102      /***
103      * Returns the string name of the serial port.
104      * @return defaults to null value.
105      */
106     public String getPort() {
107         return this.sPort;
108     }
109 
110     /***
111      * Returns the baud rate.
112      * @return defaults to 4800
113      */
114     public int getBaud() {
115         return this.iBaud;
116     }
117 
118     /***
119      * Returns the data bit.
120      * @return defaults to 8
121      */
122     public int getDataBit() {
123         return this.iDataBit;
124     }
125 
126     /***
127      * Returns the stop bit of the interface's serial connection.
128      * @return defaults to 1.
129      */
130     public int getStopBit() {
131         return this.iStopBit;
132     }
133 
134     /***
135      * Returns the parity of the serial connection.
136      * @return defaults to "None"
137      */
138     public String getParity() {
139         return this.sParity;
140     }
141 }