]> git.basschouten.com Git - openhab-addons.git/blob
ea43b207435b9784afa352e34721b003b6298c0c
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.message;
14
15 /**
16  * All defined alarm types
17  *
18  * @author Laurent Garnier - Initial contribution
19  */
20 public enum PowermaxAlarmType {
21
22     ALARM_TYPE_1(0x01, "Intruder"),
23     ALARM_TYPE_2(0x02, "Intruder"),
24     ALARM_TYPE_3(0x03, "Intruder"),
25     ALARM_TYPE_4(0x04, "Intruder"),
26     ALARM_TYPE_5(0x05, "Intruder"),
27     ALARM_TYPE_6(0x06, "Tamper"),
28     ALARM_TYPE_7(0x07, "Tamper"),
29     ALARM_TYPE_8(0x08, "Tamper"),
30     ALARM_TYPE_9(0x09, "Tamper"),
31     ALARM_TYPE_10(0x0B, "Panic"),
32     ALARM_TYPE_11(0x0C, "Panic"),
33     ALARM_TYPE_12(0x20, "Fire"),
34     ALARM_TYPE_13(0x23, "Emergency"),
35     ALARM_TYPE_14(0x49, "Gas"),
36     ALARM_TYPE_15(0x4D, "Flood");
37
38     private int code;
39     private String label;
40
41     private PowermaxAlarmType(int code, String label) {
42         this.code = code;
43         this.label = label;
44     }
45
46     /**
47      * @return the code identifying the alarm type
48      */
49     public int getCode() {
50         return code;
51     }
52
53     /**
54      * @return the label associated to the alarm type
55      */
56     public String getLabel() {
57         return label;
58     }
59
60     /**
61      * Get the ENUM value from its identifying code
62      *
63      * @param code the identifying code
64      *
65      * @return the corresponding ENUM value
66      *
67      * @throws IllegalArgumentException if no ENUM value corresponds to this code
68      */
69     public static PowermaxAlarmType fromCode(int code) throws IllegalArgumentException {
70         for (PowermaxAlarmType alarmType : PowermaxAlarmType.values()) {
71             if (alarmType.getCode() == code) {
72                 return alarmType;
73             }
74         }
75
76         throw new IllegalArgumentException("Invalid code: " + code);
77     }
78 }