]> git.basschouten.com Git - openhab-addons.git/blob
2d6822f43a050a2b8a4a6accf4e4bf58b1305fb1
[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.echonetlite.internal;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16
17 /**
18  * @author Michael Barker - Initial contribution
19  */
20 @NonNullByDefault
21 public enum EchonetClass {
22     AIRCON_HOMEAC(0x01, 0x30, (Epc[]) Epc.Device.values(), (Epc[]) Epc.AcGroup.values(), (Epc[]) Epc.HomeAc.values()),
23     MANAGEMENT_CONTROLLER(0x05, 0xFF, new Epc[0], new Epc[0], new Epc[0]),
24     NODE_PROFILE(0x0e, 0xf0, (Epc[]) Epc.Profile.values(), (Epc[]) Epc.ProfileGroup.values(),
25             (Epc[]) Epc.NodeProfile.values());
26
27     private final int groupCode;
28     private final int classCode;
29     private final Epc[] deviceProperties;
30     private final Epc[] groupProperties;
31     private final Epc[] classProperties;
32
33     EchonetClass(final int groupCode, final int classCode, Epc[] deviceProperties, Epc[] groupProperties,
34             Epc[] classProperties) {
35         this.groupCode = groupCode;
36         this.classCode = classCode;
37         this.deviceProperties = deviceProperties;
38         this.groupProperties = groupProperties;
39         this.classProperties = classProperties;
40     }
41
42     public static EchonetClass resolve(final int groupCode, final int classCode) {
43         final EchonetClass[] values = values();
44         for (EchonetClass value : values) {
45             if (value.groupCode == groupCode && value.classCode == classCode) {
46                 return value;
47             }
48         }
49
50         throw new IllegalArgumentException("Unable to find class: " + groupCode + "/" + classCode);
51     }
52
53     public int groupCode() {
54         return groupCode;
55     }
56
57     public int classCode() {
58         return classCode;
59     }
60
61     Epc[] deviceProperties() {
62         return deviceProperties;
63     }
64
65     Epc[] groupProperties() {
66         return groupProperties;
67     }
68
69     Epc[] classProperties() {
70         return classProperties;
71     }
72
73     @Override
74     public String toString() {
75         return name() + "{" + "groupCode=0x" + Integer.toHexString(groupCode) + ", classCode=0x"
76                 + Integer.toHexString(0xFF & classCode) + '}';
77     }
78 }