2 * Copyright (c) 2010-2021 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.powermax.internal.state;
16 * A class to store the settings of a zone
18 * @author Laurent Garnier - Initial contribution
20 public class PowermaxZoneSettings {
22 // Note: PowermaxStatusMessage contains hardcoded references to some of these strings
24 private static final String[] ZONE_TYPES = { "Non-Alarm", "Emergency", "Flood", "Gas", "Delay 1", "Delay 2",
25 "Interior-Follow", "Perimeter", "Perimeter-Follow", "24 Hours Silent", "24 Hours Audible", "Fire",
26 "Interior", "Home Delay", "Temperature", "Outdoor" };
28 private static final String[] ZONE_CHIMES = { "Off", "Melody", "Zone" };
33 private String sensorType;
34 private boolean[] partitions;
35 private boolean alwaysInAlarm;
37 public PowermaxZoneSettings(String name, byte type, byte chime, String sensorType, boolean[] partitions) {
39 this.type = ((type & 0x000000FF) < ZONE_TYPES.length) ? ZONE_TYPES[type & 0x000000FF] : null;
40 this.chime = ((chime & 0x000000FF) < ZONE_CHIMES.length) ? ZONE_CHIMES[chime & 0x000000FF] : null;
41 this.sensorType = sensorType;
42 this.partitions = partitions;
43 this.alwaysInAlarm = ((type == 2) || (type == 3) || (type == 9) || (type == 10) || (type == 11)
48 * @return the zone name
50 public String getName() {
51 return (name == null) ? "Unknown" : name;
57 * @param name the zone name
59 public void setName(String name) {
64 * @return the zone type
66 public String getType() {
67 return (type == null) ? "Unknown" : type;
73 * @param type the zone type as an internal code
75 public void setType(byte type) {
76 this.type = ((type & 0x000000FF) < ZONE_TYPES.length) ? ZONE_TYPES[type & 0x000000FF] : null;
77 this.alwaysInAlarm = ((type == 2) || (type == 3) || (type == 9) || (type == 10) || (type == 11)
81 public String getChime() {
82 return (chime == null) ? "Unknown" : chime;
86 * @return the sensor type of this zone
88 public String getSensorType() {
89 return (sensorType == null) ? "Unknown" : sensorType;
93 * Set the sensor type of this zone
95 * @param sensorType the sensor type
97 public void setSensorType(String sensorType) {
98 this.sensorType = sensorType;
102 * @return true if the sensor type of this zone is a motion sensor
104 public boolean isMotionSensor() {
105 return PowermaxSensorType.MOTION_SENSOR_1.getLabel().equalsIgnoreCase(getSensorType());
109 * @param number the partition number (first partition is number 1)
111 * @return true if the zone is attached to this partition; false if not
113 public boolean isInPartition(int number) {
114 return ((number <= 0) || (number > partitions.length)) ? false : partitions[number - 1];
118 * @return true if the zone type is always in alarm; false if not
120 public boolean isAlwaysInAlarm() {
121 return alwaysInAlarm;