]> git.basschouten.com Git - openhab-addons.git/blob
3ab172befd8545f8e84d74021976c3bc76216043
[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.epsonprojector.internal.enums;
14
15 import java.util.Arrays;
16 import java.util.NoSuchElementException;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19
20 /**
21  * Messages for documented error codes.
22  *
23  * @author Pauli Anttila - Initial contribution
24  * @author Yannick Schaus - Refactoring
25  * @author Michael Lobstein - Improvements for OH3
26  */
27 @NonNullByDefault
28 public enum ErrorMessage {
29     NO_ERROR(0, "00 : No error"),
30     ERROR1(1, "01 : Fan error"),
31     ERROR3(3, "03 : Lamp failure at power on"),
32     ERROR4(4, "04 : High internal temperature error"),
33     ERROR6(6, "06 : Lamp error"),
34     ERROR7(7, "07 : Open Lamp cover door error"),
35     ERROR8(8, "08 : Cinema filter error"),
36     ERROR9(9, "09 : Electric dual-layered capacitor is disconnected"),
37     ERROR10(10, "0A : Auto iris error"),
38     ERROR11(11, "0B : Subsystem error"),
39     ERROR12(12, "0C : Low air flow error"),
40     ERROR13(13, "0D : Air filter air flow sensor error"),
41     ERROR14(14, "0E : Power supply unit error (ballast)"),
42     ERROR15(15, "0F : Shutter error"),
43     ERROR16(16, "10 : Cooling system error (peltier element)"),
44     ERROR17(17, "11 : Cooling system error (pump)"),
45     ERROR18(18, "12 : Static iris error"),
46     ERROR19(19, "13 : Power supply unit error (disagreement of ballast)"),
47     ERROR20(20, "14 : Exhaust shutter error"),
48     ERROR21(21, "15 : Obstacle detection error"),
49     ERROR22(22, "16 : IF board discernment error"),
50     ERROR23(23, "17 : Communication error of \"Stack projection function\""),
51     ERROR24(24, "18 : I2C error");
52
53     private final int code;
54     private final String message;
55
56     ErrorMessage(int code, String message) {
57         this.code = code;
58         this.message = message;
59     }
60
61     public String getMessage() {
62         return message;
63     }
64
65     public static String forCode(int code) {
66         try {
67             return Arrays.stream(values()).filter(e -> e.code == code).findFirst().get().getMessage();
68         } catch (NoSuchElementException e) {
69             // for example, will display 10 as '0A' to match format of error codes in the epson documentation
70             return "Unknown error code (hex): "
71                     + String.format("%2s", Integer.toHexString(code)).replace(' ', '0').toUpperCase();
72         }
73     }
74 }