]> git.basschouten.com Git - openhab-addons.git/blob
7a7a12c2001b1517ac2fcc548a4d246d04fb1a6d
[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.omnilink.internal;
14
15 import static org.openhab.binding.omnilink.internal.OmnilinkBindingConstants.*;
16
17 import java.math.BigInteger;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20
21 /**
22  * The {@link AreaAlarm} class defines the different types of alarms supported
23  * by the OmniLink Protocol.
24  *
25  * @author Craig Hamilton - Initial contribution
26  */
27 @NonNullByDefault
28 public enum AreaAlarm {
29     BURGLARY(CHANNEL_AREA_ALARM_BURGLARY, 0),
30     FIRE(CHANNEL_AREA_ALARM_FIRE, 1),
31     GAS(CHANNEL_AREA_ALARM_GAS, 2),
32     AUXILIARY(CHANNEL_AREA_ALARM_AUXILIARY, 3),
33     FREEZE(CHANNEL_AREA_ALARM_FREEZE, 4),
34     WATER(CHANNEL_AREA_ALARM_WATER, 5),
35     DURESS(CHANNEL_AREA_ALARM_DURESS, 6),
36     TEMPERATURE(CHANNEL_AREA_ALARM_TEMPERATURE, 7);
37
38     private final String channelUID;
39     private final int bit;
40
41     AreaAlarm(String channelUID, int bit) {
42         this.channelUID = channelUID;
43         this.bit = bit;
44     }
45
46     public boolean isSet(BigInteger alarmBits) {
47         return alarmBits.testBit(bit);
48     }
49
50     public boolean isSet(int alarmBits) {
51         return isSet(BigInteger.valueOf(alarmBits));
52     }
53
54     public String getChannelUID() {
55         return channelUID;
56     }
57 }