2 * Copyright (c) 2010-2021 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;
16 * Used to store main characteristics of each Visonic alarm panel type in an ENUM
18 * @author Laurent Garnier - Initial contribution
20 public enum PowermaxPanelType {
22 POWERMAX((byte) 0, "PowerMax", 1, 250, 8, 8, 2, 2, 8, 0, 28, 2, 0),
23 POWERMAX_PLUS((byte) 1, "PowerMax+", 1, 250, 8, 8, 2, 2, 8, 0, 28, 2, 5),
24 POWERMAX_PRO((byte) 2, "PowerMaxPro", 1, 250, 8, 8, 2, 2, 8, 8, 28, 2, 5),
25 POWERMAX_COMPLETE((byte) 3, "PowerMaxComplete", 1, 250, 8, 8, 2, 2, 8, 0, 28, 2, 5),
26 POWERMAX_PRO_PART((byte) 4, "PowerMaxProPart", 3, 250, 8, 8, 2, 2, 8, 8, 28, 2, 5),
27 POWERMAX_COMPLETE_PART((byte) 5, "PowerMaxCompletePart", 3, 250, 8, 8, 2, 2, 8, 8, 28, 2, 5),
28 POWERMAX_EXPRESS((byte) 6, "PowerMaxExpress", 1, 250, 8, 8, 2, 2, 8, 0, 28, 1, 5),
29 POWERMASTER_10((byte) 7, "PowerMaster10", 3, 250, 8, 0, 8, 4, 8, 8, 29, 1, 5),
30 POWERMASTER_30((byte) 8, "PowerMaster30", 3, 1000, 32, 0, 32, 8, 48, 32, 62, 2, 5);
34 private int partitions;
37 private int keypads1w;
38 private int keypads2w;
40 private int userCodes;
44 private int customZones;
46 private PowermaxPanelType(byte code, String label, int partitions, int events, int keyfobs, int keypads1w,
47 int keypads2w, int sirens, int userCodes, int prontags, int wireless, int wired, int customZones) {
50 this.partitions = partitions;
52 this.keyfobs = keyfobs;
53 this.keypads1w = keypads1w;
54 this.keypads2w = keypads2w;
56 this.userCodes = userCodes;
57 this.prontags = prontags;
58 this.wireless = wireless;
60 this.customZones = customZones;
64 * @return the code (number) stored in the panel setup
66 public byte getCode() {
71 * @return the panel type as a string
73 public String getLabel() {
78 * @return the number of managed partitions
80 public int getPartitions() {
85 * @return the number of events stored in the event log
87 public int getEvents() {
92 * @return the number of managed keyfobs
94 public int getKeyfobs() {
99 * @return the number of managed uni-directional keypads
101 public int getKeypads1w() {
106 * @return the number of managed bi-directional keypads
108 public int getKeypads2w() {
113 * @return the number of managed sirens
115 public int getSirens() {
120 * @return the number of managed user codes
122 public int getUserCodes() {
126 public int getProntags() {
131 * @return the number of managed wireless zones
133 public int getWireless() {
138 * @return the number of managed wired zones
140 public int getWired() {
145 * @return the number of zones that can be customized by the user
147 public int getCustomZones() {
152 * @return true is the panel is a PowerMaster panel type
154 public boolean isPowerMaster() {
155 return this == PowermaxPanelType.POWERMASTER_10 || this == PowermaxPanelType.POWERMASTER_30;
159 * Get the ENUM value from its code number
161 * @param panelCode the code stored by the panel
163 * @return the corresponding ENUM value
165 * @throws IllegalArgumentException if no ENUM value corresponds to this code
167 public static PowermaxPanelType fromCode(byte panelCode) throws IllegalArgumentException {
168 for (PowermaxPanelType panelType : PowermaxPanelType.values()) {
169 if (panelType.getCode() == panelCode) {
174 throw new IllegalArgumentException("Invalid code: " + panelCode);
178 * Get the ENUM value from its label
180 * @param label the label
182 * @return the corresponding ENUM value
184 * @throws IllegalArgumentException if no ENUM value corresponds to this label
186 public static PowermaxPanelType fromLabel(String label) throws IllegalArgumentException {
187 for (PowermaxPanelType panelType : PowermaxPanelType.values()) {
188 if (panelType.getLabel().equalsIgnoreCase(label)) {
193 throw new IllegalArgumentException("Invalid label: " + label);