]> git.basschouten.com Git - openhab-addons.git/blob
c59a3482795e33c858331952c3b63d999368c339
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.dsmr.internal.device;
14
15 import org.apache.commons.lang.StringUtils;
16
17 /**
18  * Class describing the DSMR bridge user configuration
19  *
20  * @author M. Volaart - Initial contribution
21  * @author Hilbrand Bouwkamp - added receivedTimeout configuration
22  */
23 public class DSMRDeviceConfiguration {
24     /**
25      * Serial port name
26      */
27     public String serialPort;
28
29     /**
30      * Serial port baud rate
31      */
32     public int baudrate;
33
34     /**
35      * Serial port data bits
36      */
37     public int databits;
38
39     /**
40      * Serial port parity
41      */
42     public String parity;
43
44     /**
45      * Serial port stop bits
46      */
47     public String stopbits;
48
49     /**
50      * The Luxembourgish smart meter decryption key
51      */
52     public String decryptionKey;
53
54     /**
55      * When no message was received after the configured number of seconds action will be taken.
56      */
57     public int receivedTimeout;
58
59     /**
60      * @return true if serial port settings are all set.
61      */
62     public boolean isSerialFixedSettings() {
63         return baudrate > 0 && databits > 0 && !StringUtils.isBlank(parity) && !StringUtils.isBlank(stopbits);
64     }
65
66     @Override
67     public String toString() {
68         return "DSMRDeviceConfiguration [serialPort=" + serialPort + ", Baudrate=" + baudrate + ", Databits=" + databits
69                 + ", Parity=" + parity + ", Stopbits=" + stopbits + ", decryptionKey=" + decryptionKey
70                 + ", receivedTimeout=" + receivedTimeout + "]";
71     }
72 }