2 * Copyright (c) 2010-2023 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.caddx.internal.handler;
15 import java.util.HashMap;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
22 * All the log event types
24 * @author Georgios Moutsos - Initial contribution
27 public enum LogEventType {
28 ALARM(0, ZoneUserDevice.ZONE, true, "Alarm"),
29 ALARM_RESTORE(1, ZoneUserDevice.ZONE, true, "Alarm restore"),
30 BYPASS(2, ZoneUserDevice.ZONE, true, "Bypass"),
31 BYPASS_RESTORE(3, ZoneUserDevice.ZONE, true, "Bypass restore"),
32 TAMPER(4, ZoneUserDevice.ZONE, true, "Tamper"),
33 TAMPER_RESTORE(5, ZoneUserDevice.ZONE, true, "Tamper restore"),
34 TROUBLE(6, ZoneUserDevice.ZONE, true, "Trouble"),
35 TROUBLE_RESTORE(7, ZoneUserDevice.ZONE, true, "Trouble restore"),
36 TX_LOW_BATTERY(8, ZoneUserDevice.ZONE, true, "TX low battery"),
37 TX_LOW_BATTERY_RESTORE(9, ZoneUserDevice.ZONE, true, "TX low battery restore"),
38 ZONE_LOST(10, ZoneUserDevice.ZONE, true, "Zone lost"),
39 ZONE_LOST_RESTORE(11, ZoneUserDevice.ZONE, true, "Zone lost restore"),
40 START_OF_CROSS_TIME(12, ZoneUserDevice.ZONE, true, "Start of cross time"),
41 SPECIAL_EXPANSION_EVENT(17, ZoneUserDevice.NONE, false, "Special expansion event"),
42 DURESS(18, ZoneUserDevice.NONE, true, "Duress"),
43 MANUAL_FIRE(19, ZoneUserDevice.NONE, true, "Manual fire"),
44 AUXILIARY2_PANIC(20, ZoneUserDevice.NONE, true, "Auxiliary 2 panic"),
45 PANIC(22, ZoneUserDevice.NONE, true, "Panic"),
46 KEYPAD_TAMPER(23, ZoneUserDevice.NONE, true, "Keypad tamper"),
47 CONTROL_BOX_TAMPER(24, ZoneUserDevice.DEVICE, false, "Control box tamper"),
48 CONTROL_BOX_TAMPER_RESTORE(25, ZoneUserDevice.DEVICE, false, "Control box tamper restore"),
49 AC_FAIL(26, ZoneUserDevice.DEVICE, false, "AC fail"),
50 AC_FAIL_RESTORE(27, ZoneUserDevice.DEVICE, false, "AC fail restore"),
51 LOW_BATTERY(28, ZoneUserDevice.DEVICE, false, "Low battery"),
52 LOW_BATTERY_RESTORE(29, ZoneUserDevice.DEVICE, false, "Low battery restore"),
53 OVER_CURRENT(30, ZoneUserDevice.DEVICE, false, "Over-current"),
54 OVER_CURRENT_RESTORE(31, ZoneUserDevice.DEVICE, false, "Over-current restore"),
55 SIREN_TAMPER(32, ZoneUserDevice.DEVICE, false, "Siren tamper"),
56 SIREN_TAMPER_RESTORE(33, ZoneUserDevice.DEVICE, false, "Siren tamper restore"),
57 TELEPHONE_FAULT(34, ZoneUserDevice.NONE, false, "Telephone fault"),
58 TELEPHONE_FAULT_RESTORE(35, ZoneUserDevice.NONE, false, "Telephone fault restore"),
59 EXPANDER_TROUBLE(36, ZoneUserDevice.DEVICE, false, "Expander trouble"),
60 EXPANDER_TROUBLE_RESTORE(37, ZoneUserDevice.DEVICE, false, "Expander trouble restore"),
61 FAIL_TO_COMMUNICATE(38, ZoneUserDevice.NONE, false, "Fail to communicate"),
62 LOG_FULL(39, ZoneUserDevice.NONE, false, "Log full"),
63 OPENING(40, ZoneUserDevice.USER, true, "Opening"),
64 CLOSING(41, ZoneUserDevice.USER, true, "Closing"),
65 EXIT_ERROR(42, ZoneUserDevice.USER, true, "Exit error"),
66 RECENT_CLOSING(43, ZoneUserDevice.USER, true, "Recent closing"),
67 AUTO_TEST(44, ZoneUserDevice.NONE, false, "Auto-test"),
68 START_PROGRAM(45, ZoneUserDevice.NONE, false, "Start program"),
69 END_PROGRAM(46, ZoneUserDevice.NONE, false, "End program"),
70 START_DOWNLOAD(47, ZoneUserDevice.NONE, false, "Start download"),
71 END_DOWNLOAD(48, ZoneUserDevice.NONE, false, "End download"),
72 CANCEL(49, ZoneUserDevice.USER, true, "Cancel"),
73 GROUND_FAULT(50, ZoneUserDevice.NONE, false, "Ground fault"),
74 GROUND_FAULT_RESTORE(51, ZoneUserDevice.NONE, false, "Ground fault restore"),
75 MANUAL_TEST(52, ZoneUserDevice.NONE, false, "Manual test"),
76 CLOSED_WITH_ZONES_BYPASSED(53, ZoneUserDevice.USER, true, "Closed with zones bypassed"),
77 START_OF_LISTEN_IN(54, ZoneUserDevice.NONE, false, "Start of listen in"),
78 TECHNICIAN_ON_SITE(55, ZoneUserDevice.NONE, false, "Technician on site"),
79 TECHNICIAN_LEFT(56, ZoneUserDevice.NONE, false, "Technician left"),
80 CONTROL_POWER_UP(57, ZoneUserDevice.NONE, false, "Control power up"),
81 FIRST_TO_OPEN(120, ZoneUserDevice.USER, true, "First to open"),
82 LAST_TO_CLOSE(121, ZoneUserDevice.USER, true, "Last toC close"),
83 PIN_ENTERED_WITH_BIT7_SET(122, ZoneUserDevice.USER, true, "PIN entered with bit 7 set"),
84 BEGIN_WALK_TEST(123, ZoneUserDevice.NONE, false, "Begin walk-test"),
85 END_WALK_TEST(124, ZoneUserDevice.NONE, false, "End walk-test"),
86 RE_EXIT(125, ZoneUserDevice.NONE, true, "Re-exit"),
87 OUTPUT_TRIP(126, ZoneUserDevice.USER, false, "Output trip"),
88 DATA_LOST(127, ZoneUserDevice.NONE, false, "Data Lost");
90 private static final Map<Integer, LogEventType> BY_LOG_EVENT_TYPE = new HashMap<>();
91 public final int eventType;
92 public final ZoneUserDevice zud;
93 public final boolean isPartitionValid;
94 public final String description;
96 LogEventType(int eventType, ZoneUserDevice zud, boolean isPartitionValid, String description) {
97 this.eventType = eventType;
99 this.isPartitionValid = isPartitionValid;
100 this.description = description;
104 for (LogEventType logEventType : values()) {
105 BY_LOG_EVENT_TYPE.put(logEventType.eventType, logEventType);
109 public static @Nullable LogEventType valueOfLogEventType(int eventType) {
110 return BY_LOG_EVENT_TYPE.get(eventType);