]> git.basschouten.com Git - openhab-addons.git/blob
272a46c98ea2ad4356e699bd820792a3f994fda3
[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.paradoxalarm.internal.model;
14
15 import java.util.Arrays;
16
17 import org.openhab.binding.paradoxalarm.internal.parsers.IParadoxParser;
18 import org.openhab.core.util.HexUtils;
19
20 /**
21  * The {@link ParadoxInformation} Class that provides the basic panel
22  * information (serial number, panel type, application, hardware and bootloader
23  * versions. It's the object representation of 37 bytes 0x72 serial response.
24  *
25  * @author Konstantin Polihronov - Initial contribution
26  */
27 public class ParadoxInformation {
28
29     private PanelType panelType;
30     private String serialNumber;
31     private Version applicationVersion;
32     private Version hardwareVersion;
33     private Version bootloaderVersion;
34
35     public ParadoxInformation(byte[] panelInfoBytes, IParadoxParser parser) {
36         panelType = ParadoxInformationConstants.parsePanelType(panelInfoBytes);
37
38         applicationVersion = parser.parseApplicationVersion(panelInfoBytes);
39         hardwareVersion = parser.parseHardwareVersion(panelInfoBytes);
40         bootloaderVersion = parser.parseBootloaderVersion(panelInfoBytes);
41
42         byte[] serialNumberBytes = Arrays.copyOfRange(panelInfoBytes, 12, 16);
43         serialNumber = HexUtils.bytesToHex(serialNumberBytes);
44     }
45
46     public PanelType getPanelType() {
47         return panelType;
48     }
49
50     public Version getApplicationVersion() {
51         return applicationVersion;
52     }
53
54     public Version getHardwareVersion() {
55         return hardwareVersion;
56     }
57
58     public Version getBootLoaderVersion() {
59         return bootloaderVersion;
60     }
61
62     public String getSerialNumber() {
63         return serialNumber;
64     }
65
66     @Override
67     public String toString() {
68         return "ParadoxInformation [panelType=" + panelType + ", serialNumber=" + serialNumber + ", applicationVersion="
69                 + applicationVersion + ", hardwareVersion=" + hardwareVersion + ", bootloaderVersion="
70                 + bootloaderVersion + "]";
71     }
72 }