2 * Copyright (c) 2010-2020 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 private static final String[] ZONE_TYPES = { "Non-Alarm", "Emergency", "Flood", "Gas", "Delay 1", "Delay 2",
23 "Interior-Follow", "Perimeter", "Perimeter-Follow", "24 Hours Silent", "24 Hours Audible", "Fire",
24 "Interior", "Home Delay", "Temperature", "Outdoor" };
26 private static final String[] ZONE_CHIMES = { "Off", "Melody", "Zone" };
31 private String sensorType;
32 private boolean[] partitions;
33 private boolean alwaysInAlarm;
35 public PowermaxZoneSettings(String name, byte type, byte chime, String sensorType, boolean[] partitions) {
37 this.type = ((type & 0x000000FF) < ZONE_TYPES.length) ? ZONE_TYPES[type & 0x000000FF] : null;
38 this.chime = ((chime & 0x000000FF) < ZONE_CHIMES.length) ? ZONE_CHIMES[chime & 0x000000FF] : null;
39 this.sensorType = sensorType;
40 this.partitions = partitions;
41 this.alwaysInAlarm = ((type == 2) || (type == 3) || (type == 9) || (type == 10) || (type == 11)
46 * @return the zone name
48 public String getName() {
49 return (name == null) ? "Unknown" : name;
55 * @param name the zone name
57 public void setName(String name) {
62 * @return the zone type
64 public String getType() {
65 return (type == null) ? "Unknown" : type;
71 * @param type the zone type as an internal code
73 public void setType(byte type) {
74 this.type = ((type & 0x000000FF) < ZONE_TYPES.length) ? ZONE_TYPES[type & 0x000000FF] : null;
75 this.alwaysInAlarm = ((type == 2) || (type == 3) || (type == 9) || (type == 10) || (type == 11)
79 public String getChime() {
80 return (chime == null) ? "Unknown" : chime;
84 * @return the sensor type of this zone
86 public String getSensorType() {
87 return (sensorType == null) ? "Unknown" : sensorType;
91 * Set the sensor type of this zone
93 * @param sensorType the sensor type
95 public void setSensorType(String sensorType) {
96 this.sensorType = sensorType;
100 * @return true if the sensor type of this zone is a motion sensor
102 public boolean isMotionSensor() {
103 return PowermaxSensorType.MOTION_SENSOR_1.getLabel().equalsIgnoreCase(getSensorType());
107 * @param number the partition number (first partition is number 1)
109 * @return true if the zone is attached to this partition; false if not
111 public boolean isInPartition(int number) {
112 return ((number <= 0) || (number > partitions.length)) ? false : partitions[number - 1];
116 * @return true if the zone type is always in alarm; false if not
118 public boolean isAlwaysInAlarm() {
119 return alwaysInAlarm;