]> git.basschouten.com Git - openhab-addons.git/blob
6d30c125c16c5481bd5061519f82ecd7210dc626
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.modbus.sunspec.internal;
14
15 /**
16  * Possible values for an inverter's status field
17  *
18  * @author Nagy Attila Gábor - Initial contribution
19  */
20 public enum InverterStatus {
21
22     OFF(1),
23     SLEEP(2),
24     ON(4),
25     UNKNOWN(-1);
26
27     private final int code;
28
29     InverterStatus(int code) {
30         this.code = code;
31     }
32
33     public int code() {
34         return this.code;
35     }
36
37     public static InverterStatus getByCode(int code) {
38         switch (code) {
39             case 1:
40                 return InverterStatus.OFF;
41             case 2:
42                 return InverterStatus.SLEEP;
43             case 4:
44                 return InverterStatus.ON;
45             default:
46                 return InverterStatus.UNKNOWN;
47         }
48     }
49 }