]> git.basschouten.com Git - openhab-addons.git/blob
8ab988edd216ba6ad07d9cc546ab55867a8e11c9
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.plclogo.internal.config;
14
15 import static org.openhab.binding.plclogo.internal.PLCLogoBindingConstants.NOT_SUPPORTED;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.plclogo.internal.PLCLogoBindingConstants;
20
21 /**
22  * The {@link PLCLogoBridgeConfiguration} hold configuration of Siemens LOGO! PLCs.
23  *
24  * @author Alexander Falkenstern - Initial contribution
25  */
26 @NonNullByDefault
27 public class PLCLogoBridgeConfiguration {
28
29     private String address = "";
30     private String family = NOT_SUPPORTED;
31     private String localTSAP = "0x3000";
32     private String remoteTSAP = "0x2000";
33     private Integer refresh = 100;
34
35     /**
36      * Get configured Siemens LOGO! device IP address.
37      *
38      * @return Configured Siemens LOGO! IP address
39      */
40     public String getAddress() {
41         return address;
42     }
43
44     /**
45      * Set IP address for Siemens LOGO! device.
46      *
47      * @param address IP address of Siemens LOGO! device
48      */
49     public void setAddress(final String address) {
50         this.address = address.trim();
51     }
52
53     /**
54      * Get configured Siemens LOGO! device family.
55      *
56      * @see PLCLogoBindingConstants#LOGO_0BA7
57      * @see PLCLogoBindingConstants#LOGO_0BA8
58      * @return Configured Siemens LOGO! device family
59      */
60     public String getFamily() {
61         return family;
62     }
63
64     /**
65      * Set Siemens LOGO! device family.
66      *
67      * @param family Family of Siemens LOGO! device
68      * @see PLCLogoBindingConstants#LOGO_0BA7
69      * @see PLCLogoBindingConstants#LOGO_0BA8
70      */
71     public void setFamily(final String family) {
72         this.family = family.trim();
73     }
74
75     /**
76      * Get configured local TSAP of Siemens LOGO! device.
77      *
78      * @return Configured local TSAP of Siemens LOGO!
79      */
80     public @Nullable Integer getLocalTSAP() {
81         Integer result = null;
82         if (localTSAP.startsWith("0x")) {
83             result = Integer.decode(localTSAP);
84         }
85         return result;
86     }
87
88     /**
89      * Set local TSAP of Siemens LOGO! device.
90      *
91      * @param tsap Local TSAP of Siemens LOGO! device
92      */
93     public void setLocalTSAP(final String tsap) {
94         this.localTSAP = tsap.trim();
95     }
96
97     /**
98      * Get configured remote TSAP of Siemens LOGO! device.
99      *
100      * @return Configured local TSAP of Siemens LOGO!
101      */
102     public @Nullable Integer getRemoteTSAP() {
103         Integer result = null;
104         if (remoteTSAP.startsWith("0x")) {
105             result = Integer.decode(remoteTSAP);
106         }
107         return result;
108     }
109
110     /**
111      * Set remote TSAP of Siemens LOGO! device.
112      *
113      * @param tsap Remote TSAP of Siemens LOGO! device
114      */
115     public void setRemoteTSAP(final String tsap) {
116         this.remoteTSAP = tsap.trim();
117     }
118
119     /**
120      * Get configured refresh rate of Siemens LOGO! device blocks in milliseconds.
121      *
122      * @return Configured refresh rate of Siemens LOGO! device blocks
123      */
124     public Integer getRefreshRate() {
125         return refresh;
126     }
127
128     /**
129      * Set refresh rate of Siemens LOGO! device blocks in milliseconds.
130      *
131      * @param rate Refresh rate of Siemens LOGO! device blocks
132      */
133     public void setRefreshRate(final Integer rate) {
134         this.refresh = rate;
135     }
136 }