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