]> git.basschouten.com Git - openhab-addons.git/blob
073888011151fe54ea1607ff62f0f286d13670e5
[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.powermax.internal.state;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16
17 /**
18  * Used to store main characteristics of each Visonic alarm panel type in an ENUM
19  *
20  * @author Laurent Garnier - Initial contribution
21  */
22 @NonNullByDefault
23 public enum PowermaxPanelType {
24
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);
34
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;
48
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) {
51         this.code = code;
52         this.label = label;
53         this.partitions = partitions;
54         this.events = events;
55         this.keyfobs = keyfobs;
56         this.keypads1w = keypads1w;
57         this.keypads2w = keypads2w;
58         this.sirens = sirens;
59         this.userCodes = userCodes;
60         this.prontags = prontags;
61         this.wireless = wireless;
62         this.wired = wired;
63         this.customZones = customZones;
64     }
65
66     /**
67      * @return the code (number) stored in the panel setup
68      */
69     public byte getCode() {
70         return code;
71     }
72
73     /**
74      * @return the panel type as a string
75      */
76     public String getLabel() {
77         return label;
78     }
79
80     /**
81      * @return the number of managed partitions
82      */
83     public int getPartitions() {
84         return partitions;
85     }
86
87     /**
88      * @return the number of events stored in the event log
89      */
90     public int getEvents() {
91         return events;
92     }
93
94     /**
95      * @return the number of managed keyfobs
96      */
97     public int getKeyfobs() {
98         return keyfobs;
99     }
100
101     /**
102      * @return the number of managed uni-directional keypads
103      */
104     public int getKeypads1w() {
105         return keypads1w;
106     }
107
108     /**
109      * @return the number of managed bi-directional keypads
110      */
111     public int getKeypads2w() {
112         return keypads2w;
113     }
114
115     /**
116      * @return the number of managed sirens
117      */
118     public int getSirens() {
119         return sirens;
120     }
121
122     /**
123      * @return the number of managed user codes
124      */
125     public int getUserCodes() {
126         return userCodes;
127     }
128
129     public int getProntags() {
130         return prontags;
131     }
132
133     /**
134      * @return the number of managed wireless zones
135      */
136     public int getWireless() {
137         return wireless;
138     }
139
140     /**
141      * @return the number of managed wired zones
142      */
143     public int getWired() {
144         return wired;
145     }
146
147     /**
148      * @return the number of zones that can be customized by the user
149      */
150     public int getCustomZones() {
151         return customZones;
152     }
153
154     /**
155      * @return true is the panel is a PowerMaster panel type
156      */
157     public boolean isPowerMaster() {
158         return this == PowermaxPanelType.POWERMASTER_10 || this == PowermaxPanelType.POWERMASTER_30;
159     }
160
161     /**
162      * Get the ENUM value from its code number
163      *
164      * @param panelCode the code stored by the panel
165      *
166      * @return the corresponding ENUM value
167      *
168      * @throws IllegalArgumentException if no ENUM value corresponds to this code
169      */
170     public static PowermaxPanelType fromCode(byte panelCode) throws IllegalArgumentException {
171         for (PowermaxPanelType panelType : PowermaxPanelType.values()) {
172             if (panelType.getCode() == panelCode) {
173                 return panelType;
174             }
175         }
176
177         throw new IllegalArgumentException("Invalid code: " + panelCode);
178     }
179
180     /**
181      * Get the ENUM value from its label
182      *
183      * @param label the label
184      *
185      * @return the corresponding ENUM value
186      *
187      * @throws IllegalArgumentException if no ENUM value corresponds to this label
188      */
189     public static PowermaxPanelType fromLabel(String label) throws IllegalArgumentException {
190         for (PowermaxPanelType panelType : PowermaxPanelType.values()) {
191             if (panelType.getLabel().equalsIgnoreCase(label)) {
192                 return panelType;
193             }
194         }
195
196         throw new IllegalArgumentException("Invalid label: " + label);
197     }
198 }