2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.ihc.internal.ws.datatypes;
15 import java.io.IOException;
16 import java.time.ZonedDateTime;
17 import java.time.format.DateTimeParseException;
19 import javax.xml.xpath.XPathExpressionException;
21 import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
24 * Class for WSProjectInfo complex type.
26 * @author Pauli Anttila - Initial contribution
28 public class WSSystemInfo {
31 private ZonedDateTime realtimeclock;
32 private String serialNumber;
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;
43 public WSSystemInfo() {
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) {
50 this.realtimeclock = realtimeclock;
51 this.serialNumber = serialNumber;
53 this.version = version;
54 this.hwRevision = hwRevision;
56 this.applicationIsWithoutViewer = applicationIsWithoutViewer;
57 this.productionDate = productionDate;
58 this.datalineVersion = datalineVersion;
59 this.rfModuleSoftwareVersion = rfModuleSoftwareVersion;
60 this.rfModuleSerialNumber = rfModuleSerialNumber;
64 * Gets the uptime value for this WSSystemInfo.
66 * @return uptime in milliseconds
68 public long getUptime() {
73 * Sets the uptime value for this WSSystemInfo.
75 * @param uptime uptime in milliseconds
77 public void setUptime(long uptime) {
82 * Gets the RealTimeClock value for this WSSystemInfo.
84 * @return Real Time Clock
86 public ZonedDateTime getRealTimeClock() {
91 * Sets the RealTimeClock value for this WSSystemInfo.
93 * @param RealTimeClock
95 public void setRealTimeClock(ZonedDateTime realtimeclock) {
96 this.realtimeclock = realtimeclock;
100 * Gets the SerialNumber value for this WSSystemInfo.
102 * @return SerialNumber
104 public String getSerialNumber() {
109 * Sets the SerialNumber value for this WSSystemInfo.
111 * @param SerialNumber
113 public void setSerialNumber(String serialNumber) {
114 this.serialNumber = serialNumber;
118 * Gets the brand value for this WSSystemInfo.
122 public String getBrand() {
127 * Sets the brand value for this WSSystemInfo.
131 public void setBrand(String brand) {
136 * Gets the version value for this WSSystemInfo.
140 public String getVersion() {
145 * Sets the version value for this WSSystemInfo.
149 public void setVersion(String version) {
150 this.version = version;
154 * Gets the hwRevision value for this WSSystemInfo.
158 public String getHwRevision() {
163 * Sets the hwRevision value for this WSSystemInfo.
167 public void setHwRevision(String hwRevision) {
168 this.hwRevision = hwRevision;
172 * Gets the swDate value for this WSSystemInfo.
176 public ZonedDateTime getSwDate() {
181 * Sets the swDate value for this WSSystemInfo.
185 public void setSwDate(ZonedDateTime swDate) {
186 this.swDate = swDate;
190 * Gets the applicationIsWithoutViewer value for this WSSystemInfo.
192 * @return applicationIsWithoutViewer
194 public boolean getApplicationIsWithoutViewer() {
195 return applicationIsWithoutViewer;
199 * Sets the applicationIsWithoutViewer value for this WSSystemInfo.
201 * @param applicationIsWithoutViewer
203 public void setApplicationIsWithoutViewer(boolean applicationIsWithoutViewer) {
204 this.applicationIsWithoutViewer = applicationIsWithoutViewer;
208 * Gets the productionDate value for this WSSystemInfo.
210 * @return productionDate
212 public String getProductionDate() {
213 return productionDate;
217 * Sets the productionDate value for this WSSystemInfo.
219 * @param productionDate
221 public void setProductionDate(String productionDate) {
222 this.productionDate = productionDate;
226 * Gets the datalineVersion value for this WSSystemInfo.
228 * @return datalineVersion
230 public String getDatalineVersion() {
231 return datalineVersion;
235 * Sets the datalineVersion value for this WSSystemInfo.
237 * @param datalineVersion
239 public void setDatalineVersion(String datalineVersion) {
240 this.datalineVersion = datalineVersion;
244 * Gets the rfModuleSoftwareVersion value for this WSSystemInfo.
246 * @return rfModuleSoftwareVersion
248 public String getRfModuleSoftwareVersion() {
249 return rfModuleSoftwareVersion;
253 * Sets the rfModuleSoftwareVersion value for this WSSystemInfo.
255 * @param rfModuleSoftwareVersion
257 public void setRfModuleSoftwareVersion(String rfModuleSoftwareVersion) {
258 this.rfModuleSoftwareVersion = rfModuleSoftwareVersion;
262 * Gets the rfModuleSerialNumber value for this WSSystemInfo.
264 * @return rfModuleSerialNumber
266 public String getRfModuleSerialNumber() {
267 return rfModuleSerialNumber;
271 * Sets the rfModuleSerialNumber value for this WSSystemInfo.
273 * @param rfModuleSerialNumber
275 public void setRfModuleSerialNumber(String rfModuleSerialNumber) {
276 this.rfModuleSerialNumber = rfModuleSerialNumber;
279 public WSSystemInfo parseXMLData(String data) throws IhcExecption {
281 String value = XPathUtils.parseXMLValue(data,
282 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:uptime");
283 setUptime(Long.parseLong(value));
285 value = XPathUtils.parseXMLValue(data,
286 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:serialNumber");
287 setSerialNumber(value);
289 value = XPathUtils.parseXMLValue(data,
290 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:realtimeclock");
291 setRealTimeClock(ZonedDateTime.parse(value));
293 value = XPathUtils.parseXMLValue(data, "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:brand");
296 value = XPathUtils.parseXMLValue(data, "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:version");
299 value = XPathUtils.parseXMLValue(data,
300 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:hwRevision");
301 setHwRevision(value);
303 value = XPathUtils.parseXMLValue(data, "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:swDate");
304 setSwDate(ZonedDateTime.parse(value));
306 value = XPathUtils.parseXMLValue(data,
307 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:applicationIsWithoutViewer");
308 setApplicationIsWithoutViewer(Boolean.parseBoolean(value));
310 value = XPathUtils.parseXMLValue(data,
311 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:productionDate");
312 setProductionDate(value);
314 value = XPathUtils.parseXMLValue(data,
315 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:datalineVersion");
316 setDatalineVersion(value);
318 value = XPathUtils.parseXMLValue(data,
319 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:rfModuleSoftwareVersion");
320 setRfModuleSoftwareVersion(value);
322 value = XPathUtils.parseXMLValue(data,
323 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getSystemInfo1/ns1:rfModuleSerialNumber");
324 setRfModuleSerialNumber(value);
327 } catch (IOException | XPathExpressionException | NumberFormatException | DateTimeParseException e) {
328 throw new IhcExecption("Error occured during XML data parsing", e);
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);