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.powermax.internal.state;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
18 * Used to store main characteristics of each Visonic alarm panel type in an ENUM
20 * @author Laurent Garnier - Initial contribution
23 public enum PowermaxPanelType {
25 POWERMAX((byte) 0, "PowerMax", 1, 250, 8, 8, 2, 2, 8, 0, 28, 2, 0),
26 POWERMAX_PLUS((byte) 1, "PowerMax+", 1, 250, 8, 8, 2, 2, 8, 0, 28, 2, 5),
27 POWERMAX_PRO((byte) 2, "PowerMaxPro", 1, 250, 8, 8, 2, 2, 8, 8, 28, 2, 5),
28 POWERMAX_COMPLETE((byte) 3, "PowerMaxComplete", 1, 250, 8, 8, 2, 2, 8, 0, 28, 2, 5),
29 POWERMAX_PRO_PART((byte) 4, "PowerMaxProPart", 3, 250, 8, 8, 2, 2, 8, 8, 28, 2, 5),
30 POWERMAX_COMPLETE_PART((byte) 5, "PowerMaxCompletePart", 3, 250, 8, 8, 2, 2, 8, 8, 28, 2, 5),
31 POWERMAX_EXPRESS((byte) 6, "PowerMaxExpress", 1, 250, 8, 8, 2, 2, 8, 0, 28, 1, 5),
32 POWERMASTER_10((byte) 7, "PowerMaster10", 3, 250, 8, 0, 8, 4, 8, 8, 29, 1, 5),
33 POWERMASTER_30((byte) 8, "PowerMaster30", 3, 1000, 32, 0, 32, 8, 48, 32, 62, 2, 5);
35 private final byte code;
36 private final String label;
37 private final int partitions;
38 private final int events;
39 private final int keyfobs;
40 private final int keypads1w;
41 private final int keypads2w;
42 private final int sirens;
43 private final int userCodes;
44 private final int prontags;
45 private final int wireless;
46 private final int wired;
47 private final int customZones;
49 private PowermaxPanelType(byte code, String label, int partitions, int events, int keyfobs, int keypads1w,
50 int keypads2w, int sirens, int userCodes, int prontags, int wireless, int wired, int customZones) {
53 this.partitions = partitions;
55 this.keyfobs = keyfobs;
56 this.keypads1w = keypads1w;
57 this.keypads2w = keypads2w;
59 this.userCodes = userCodes;
60 this.prontags = prontags;
61 this.wireless = wireless;
63 this.customZones = customZones;
67 * @return the code (number) stored in the panel setup
69 public byte getCode() {
74 * @return the panel type as a string
76 public String getLabel() {
81 * @return the number of managed partitions
83 public int getPartitions() {
88 * @return the number of events stored in the event log
90 public int getEvents() {
95 * @return the number of managed keyfobs
97 public int getKeyfobs() {
102 * @return the number of managed uni-directional keypads
104 public int getKeypads1w() {
109 * @return the number of managed bi-directional keypads
111 public int getKeypads2w() {
116 * @return the number of managed sirens
118 public int getSirens() {
123 * @return the number of managed user codes
125 public int getUserCodes() {
129 public int getProntags() {
134 * @return the number of managed wireless zones
136 public int getWireless() {
141 * @return the number of managed wired zones
143 public int getWired() {
148 * @return the number of zones that can be customized by the user
150 public int getCustomZones() {
155 * @return true is the panel is a PowerMaster panel type
157 public boolean isPowerMaster() {
158 return this == PowermaxPanelType.POWERMASTER_10 || this == PowermaxPanelType.POWERMASTER_30;
162 * Get the ENUM value from its code number
164 * @param panelCode the code stored by the panel
166 * @return the corresponding ENUM value
168 * @throws IllegalArgumentException if no ENUM value corresponds to this code
170 public static PowermaxPanelType fromCode(byte panelCode) throws IllegalArgumentException {
171 for (PowermaxPanelType panelType : PowermaxPanelType.values()) {
172 if (panelType.getCode() == panelCode) {
177 throw new IllegalArgumentException("Invalid code: " + panelCode);
181 * Get the ENUM value from its label
183 * @param label the label
185 * @return the corresponding ENUM value
187 * @throws IllegalArgumentException if no ENUM value corresponds to this label
189 public static PowermaxPanelType fromLabel(String label) throws IllegalArgumentException {
190 for (PowermaxPanelType panelType : PowermaxPanelType.values()) {
191 if (panelType.getLabel().equalsIgnoreCase(label)) {
196 throw new IllegalArgumentException("Invalid label: " + label);