]> git.basschouten.com Git - openhab-addons.git/blob
c4a7cb5dcdef552fad9f9c4bba9ee49578041802
[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.ihc.internal.ws.datatypes;
14
15 import java.io.IOException;
16 import java.time.ZonedDateTime;
17 import java.time.format.DateTimeParseException;
18
19 import javax.xml.xpath.XPathExpressionException;
20
21 import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
22
23 /**
24  * Class for WSProjectInfo complex type.
25  *
26  * @author Pauli Anttila - Initial contribution
27  */
28 public class WSSystemInfo {
29
30     private long uptime;
31     private ZonedDateTime realtimeclock;
32     private String serialNumber;
33     private String brand;
34     private String version;
35     private String hwRevision;
36     private ZonedDateTime swDate;
37     private boolean applicationIsWithoutViewer;
38     private String productionDate;
39     private String datalineVersion;
40     private String rfModuleSoftwareVersion;
41     private String rfModuleSerialNumber;
42
43     public WSSystemInfo() {
44     }
45
46     public WSSystemInfo(long uptime, ZonedDateTime realtimeclock, String serialNumber, String brand, String version,
47             String hwRevision, ZonedDateTime swDate, boolean applicationIsWithoutViewer, String productionDate,
48             String datalineVersion, String rfModuleSoftwareVersion, String rfModuleSerialNumber) {
49         this.uptime = uptime;
50         this.realtimeclock = realtimeclock;
51         this.serialNumber = serialNumber;
52         this.brand = brand;
53         this.version = version;
54         this.hwRevision = hwRevision;
55         this.swDate = swDate;
56         this.applicationIsWithoutViewer = applicationIsWithoutViewer;
57         this.productionDate = productionDate;
58         this.datalineVersion = datalineVersion;
59         this.rfModuleSoftwareVersion = rfModuleSoftwareVersion;
60         this.rfModuleSerialNumber = rfModuleSerialNumber;
61     }
62
63     /**
64      * Gets the uptime value for this WSSystemInfo.
65      *
66      * @return uptime in milliseconds
67      */
68     public long getUptime() {
69         return uptime;
70     }
71
72     /**
73      * Sets the uptime value for this WSSystemInfo.
74      *
75      * @param uptime uptime in milliseconds
76      */
77     public void setUptime(long uptime) {
78         this.uptime = uptime;
79     }
80
81     /**
82      * Gets the RealTimeClock value for this WSSystemInfo.
83      *
84      * @return Real Time Clock
85      */
86     public ZonedDateTime getRealTimeClock() {
87         return realtimeclock;
88     }
89
90     /**
91      * Sets the RealTimeClock value for this WSSystemInfo.
92      *
93      * @param realtimeclock
94      */
95     public void setRealTimeClock(ZonedDateTime realtimeclock) {
96         this.realtimeclock = realtimeclock;
97     }
98
99     /**
100      * Gets the SerialNumber value for this WSSystemInfo.
101      *
102      * @return SerialNumber
103      */
104     public String getSerialNumber() {
105         return serialNumber;
106     }
107
108     /**
109      * Sets the SerialNumber value for this WSSystemInfo.
110      *
111      * @param serialNumber
112      */
113     public void setSerialNumber(String serialNumber) {
114         this.serialNumber = serialNumber;
115     }
116
117     /**
118      * Gets the brand value for this WSSystemInfo.
119      *
120      * @return brand
121      */
122     public String getBrand() {
123         return brand;
124     }
125
126     /**
127      * Sets the brand value for this WSSystemInfo.
128      *
129      * @param brand
130      */
131     public void setBrand(String brand) {
132         this.brand = brand;
133     }
134
135     /**
136      * Gets the version value for this WSSystemInfo.
137      *
138      * @return version
139      */
140     public String getVersion() {
141         return version;
142     }
143
144     /**
145      * Sets the version value for this WSSystemInfo.
146      *
147      * @param version
148      */
149     public void setVersion(String version) {
150         this.version = version;
151     }
152
153     /**
154      * Gets the hwRevision value for this WSSystemInfo.
155      *
156      * @return hwRevision
157      */
158     public String getHwRevision() {
159         return hwRevision;
160     }
161
162     /**
163      * Sets the hwRevision value for this WSSystemInfo.
164      *
165      * @param hwRevision
166      */
167     public void setHwRevision(String hwRevision) {
168         this.hwRevision = hwRevision;
169     }
170
171     /**
172      * Gets the swDate value for this WSSystemInfo.
173      *
174      * @return swDate
175      */
176     public ZonedDateTime getSwDate() {
177         return swDate;
178     }
179
180     /**
181      * Sets the swDate value for this WSSystemInfo.
182      *
183      * @param swDate
184      */
185     public void setSwDate(ZonedDateTime swDate) {
186         this.swDate = swDate;
187     }
188
189     /**
190      * Gets the applicationIsWithoutViewer value for this WSSystemInfo.
191      *
192      * @return applicationIsWithoutViewer
193      */
194     public boolean getApplicationIsWithoutViewer() {
195         return applicationIsWithoutViewer;
196     }
197
198     /**
199      * Sets the applicationIsWithoutViewer value for this WSSystemInfo.
200      *
201      * @param applicationIsWithoutViewer
202      */
203     public void setApplicationIsWithoutViewer(boolean applicationIsWithoutViewer) {
204         this.applicationIsWithoutViewer = applicationIsWithoutViewer;
205     }
206
207     /**
208      * Gets the productionDate value for this WSSystemInfo.
209      *
210      * @return productionDate
211      */
212     public String getProductionDate() {
213         return productionDate;
214     }
215
216     /**
217      * Sets the productionDate value for this WSSystemInfo.
218      *
219      * @param productionDate
220      */
221     public void setProductionDate(String productionDate) {
222         this.productionDate = productionDate;
223     }
224
225     /**
226      * Gets the datalineVersion value for this WSSystemInfo.
227      *
228      * @return datalineVersion
229      */
230     public String getDatalineVersion() {
231         return datalineVersion;
232     }
233
234     /**
235      * Sets the datalineVersion value for this WSSystemInfo.
236      *
237      * @param datalineVersion
238      */
239     public void setDatalineVersion(String datalineVersion) {
240         this.datalineVersion = datalineVersion;
241     }
242
243     /**
244      * Gets the rfModuleSoftwareVersion value for this WSSystemInfo.
245      *
246      * @return rfModuleSoftwareVersion
247      */
248     public String getRfModuleSoftwareVersion() {
249         return rfModuleSoftwareVersion;
250     }
251
252     /**
253      * Sets the rfModuleSoftwareVersion value for this WSSystemInfo.
254      *
255      * @param rfModuleSoftwareVersion
256      */
257     public void setRfModuleSoftwareVersion(String rfModuleSoftwareVersion) {
258         this.rfModuleSoftwareVersion = rfModuleSoftwareVersion;
259     }
260
261     /**
262      * Gets the rfModuleSerialNumber value for this WSSystemInfo.
263      *
264      * @return rfModuleSerialNumber
265      */
266     public String getRfModuleSerialNumber() {
267         return rfModuleSerialNumber;
268     }
269
270     /**
271      * Sets the rfModuleSerialNumber value for this WSSystemInfo.
272      *
273      * @param rfModuleSerialNumber
274      */
275     public void setRfModuleSerialNumber(String rfModuleSerialNumber) {
276         this.rfModuleSerialNumber = rfModuleSerialNumber;
277     }
278
279     public WSSystemInfo parseXMLData(String data) throws IhcExecption {
280         try {
281             String value = XPathUtils.parseXMLValue(data,
282                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:uptime");
283             setUptime(Long.parseLong(value));
284
285             value = XPathUtils.parseXMLValue(data,
286                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:serialNumber");
287             setSerialNumber(value);
288
289             value = XPathUtils.parseXMLValue(data,
290                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:realtimeclock");
291             setRealTimeClock(ZonedDateTime.parse(value));
292
293             value = XPathUtils.parseXMLValue(data, "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:brand");
294             setBrand(value);
295
296             value = XPathUtils.parseXMLValue(data, "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:version");
297             setVersion(value);
298
299             value = XPathUtils.parseXMLValue(data,
300                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:hwRevision");
301             setHwRevision(value);
302
303             value = XPathUtils.parseXMLValue(data, "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:swDate");
304             setSwDate(ZonedDateTime.parse(value));
305
306             value = XPathUtils.parseXMLValue(data,
307                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:applicationIsWithoutViewer");
308             setApplicationIsWithoutViewer(Boolean.parseBoolean(value));
309
310             value = XPathUtils.parseXMLValue(data,
311                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:productionDate");
312             setProductionDate(value);
313
314             value = XPathUtils.parseXMLValue(data,
315                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:datalineVersion");
316             setDatalineVersion(value);
317
318             value = XPathUtils.parseXMLValue(data,
319                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:rfModuleSoftwareVersion");
320             setRfModuleSoftwareVersion(value);
321
322             value = XPathUtils.parseXMLValue(data,
323                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:rfModuleSerialNumber");
324             setRfModuleSerialNumber(value);
325
326             return this;
327         } catch (IOException | XPathExpressionException | NumberFormatException | DateTimeParseException e) {
328             throw new IhcExecption("Error occured during XML data parsing", e);
329         }
330     }
331
332     @Override
333     public String toString() {
334         return String.format(
335                 "[ uptime=%d, realtimeclock=%s, serialNumber=%s, brand=%s, version=%s, hwRevision=%s, swDate=%s, applicationIsWithoutViewer=%b, productionDate=%s, datalineVersion=%s, rfModuleSoftwareVersion=%s, rfModuleSerialNumber=%s ]",
336                 uptime, realtimeclock, serialNumber, brand, version, hwRevision, swDate, applicationIsWithoutViewer,
337                 productionDate, datalineVersion, rfModuleSoftwareVersion, rfModuleSerialNumber);
338     }
339 }