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.message;
16 * All defined trouble types
18 * @author Laurent Garnier - Initial contribution
20 public enum PowermaxTroubleType {
22 TROUBLE_TYPE_1(0x0A, "Communication"),
23 TROUBLE_TYPE_2(0x0F, "General"),
24 TROUBLE_TYPE_3(0x29, "Battery"),
25 TROUBLE_TYPE_4(0x2B, "Power"),
26 TROUBLE_TYPE_5(0x2D, "Battery"),
27 TROUBLE_TYPE_6(0x2F, "Jamming"),
28 TROUBLE_TYPE_7(0x31, "Communication"),
29 TROUBLE_TYPE_8(0x33, "Telephone"),
30 TROUBLE_TYPE_9(0x36, "Power"),
31 TROUBLE_TYPE_10(0x38, "Battery"),
32 TROUBLE_TYPE_11(0x3B, "Battery"),
33 TROUBLE_TYPE_12(0x3C, "Battery"),
34 TROUBLE_TYPE_13(0x40, "Battery"),
35 TROUBLE_TYPE_14(0x43, "Battery");
40 private PowermaxTroubleType(int code, String label) {
46 * @return the code identifying the trouble type
48 public int getCode() {
53 * @return the label associated to the trouble type
55 public String getLabel() {
60 * Get the ENUM value from its identifying code
62 * @param code the identifying code
64 * @return the corresponding ENUM value
66 * @throws IllegalArgumentException if no ENUM value corresponds to this code
68 public static PowermaxTroubleType fromCode(int code) throws IllegalArgumentException {
69 for (PowermaxTroubleType troubleType : PowermaxTroubleType.values()) {
70 if (troubleType.getCode() == code) {
75 throw new IllegalArgumentException("Invalid code: " + code);