]> git.basschouten.com Git - openhab-addons.git/blob
7c7df41d80e59288dd7accaab1f3affd7f7613b2
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.avmfritz.internal.dto;
14
15 import java.math.BigDecimal;
16
17 import javax.xml.bind.annotation.XmlAccessType;
18 import javax.xml.bind.annotation.XmlAccessorType;
19 import javax.xml.bind.annotation.XmlRootElement;
20 import javax.xml.bind.annotation.XmlType;
21
22 /**
23  * See {@link DeviceListModel}.
24  *
25  * @author Christoph Weitkamp - Initial contribution
26  */
27 @XmlAccessorType(XmlAccessType.FIELD)
28 @XmlType(propOrder = { "state" })
29 @XmlRootElement(name = "alert")
30 public class AlertModel {
31     public static final BigDecimal ON = BigDecimal.ONE;
32     public static final BigDecimal OFF = BigDecimal.ZERO;
33
34     private BigDecimal state;
35
36     public BigDecimal getState() {
37         return state;
38     }
39
40     public void setState(BigDecimal state) {
41         this.state = state;
42     }
43
44     public boolean hasObstructionAlarmOccurred() {
45         return (state.intValue() & 1) != 0;
46     }
47
48     public boolean hasTemperaturAlarmOccurred() {
49         return (state.intValue() & 2) != 0;
50     }
51
52     public boolean hasUnknownAlarmOccurred() {
53         return ((state.intValue() & 255) >> 2) != 0;
54     }
55
56     @Override
57     public String toString() {
58         return new StringBuilder().append("[state=").append(state).append("]").toString();
59     }
60 }