]> git.basschouten.com Git - openhab-addons.git/blob
506a9e87beb9653bb1905d7e0ea666118baa48cb
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.digitalstrom.internal.lib.structure.devices.deviceparameters.constants;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 /**
19  * The {@link OutputModeEnum} lists all available digitalSTROM-device output modes.
20  *
21  * @author Michael Ochel - Initial contribution
22  * @author Matthias Siegele - Initial contribution
23  * @see <a href="http://developer.digitalstrom.org/Architecture/ds-basics.pdf">Table 36: Output Mode Register, page
24  *      51</a>
25  */
26 public enum OutputModeEnum {
27     /*
28      * | Output Mode | Description |
29      * ------------------------------------------------------------------------------
30      * | 0 | No output or output disabled |
31      * | 16 | Switched |
32      * | 17 | RMS (root mean square) dimmer |
33      * | 18 | RMS dimmer with characteristic curve |
34      * | 19 | Phase control dimmer |
35      * | 20 | Phase control dimmer with characteristic curve |
36      * | 21 | Reverse phase control dimmer |
37      * | 22 | Reverse phase control dimmer with characteristic curve |
38      * | 23 | PWM (pulse width modulation) |
39      * | 24 | PWM with characteristic curve |
40      * | 30 | PWM to control heating control valve | (from dS web configurator, it dosn't stand in the ds-basic.pdf from
41      * 19.08.2015)
42      * | 33 | Positioning control |
43      * | 34 | combined 2 stage switch [Both relais switch combined in tow steps depending on the output value. Output >
44      * 33% - relais 1 is on. Output > 66% - relais 1 and 2 are on.] | (from ds web configurator, it dosn't stand in the
45      * ds-basic.pdf from 19.08.2015)
46      * | 35 | single switch | (from ds web configurator, it dosn't stand in the ds-basic.pdf from 19.08.2015)
47      * | 38 | combined 3 stage switch [Both relais switch combined in tow steps depending on the output value. Output >
48      * 25% - relais 1 is on. Output > 50% - relais 1 is off and relais 2 is on. Output > 75% - relais 1 and 2 are on.] |
49      * (from ds web configurator, it dosn't stand in the
50      * ds-basic.pdf from 19.08.2015)
51      * | 39 | Relay with switched mode scene table configuration |
52      * | 40 | Relay with wiped mode scene table configuration |
53      * | 41 | Relay with saving mode scene table configuration |
54      * | 42 | Positioning control for uncalibrated shutter |
55      * | 43 | combined switch | (from dS web configurator, it dosn't stand in the ds-basic.pdf from 19.08.2015)
56      * | 49 | dimmed 0-10V [dimming with 0-10V control power] | (from dS web configurator, it dosn't stand in the
57      * ds-basic.pdf from 02.06.2015)
58      * | 51 | dimmed 1-10V [dimming with 1-10V control power] | (from dS web configurator, it dosn't stand in the
59      * ds-basic.pdf from 02.06.2015)
60      * | 64 | temperature controlled switch for heating though the dSS | (from dS web configurator, it dosn't stand in
61      * the ds-basic.pdf from 19.08.2015)
62      * | 65 | temperature controlled pwm for heating though the dSS | (from dS web configurator, it dosn't stand in the
63      * ds-basic.pdf from 19.08.2015)
64      *
65      */
66     DISABLED(0),
67     SWITCHED(16),
68     RMS_DIMMER(17),
69     RMS_DIMMER_CC(18),
70     PC_DIMMER(19),
71     PC_DIMMER_CC(20),
72     RPC_DIMMER(21),
73     RPC_DIMMER_CC(22),
74     PWM(23),
75     PWM_CC(24),
76     HEATING_PWM(30),
77     POSITION_CON(33),
78     COMBINED_2_STAGE_SWITCH(34),
79     SINGLE_SWITCH(35),
80     COMBINED_3_STAGE_SWITCH(38),
81     SWITCH(39),
82     WIPE(40),
83     POWERSAVE(41),
84     POSITION_CON_US(42),
85     COMBINED_SWITCH(43),
86     DIMMED_0_10V(49),
87     DIMMED_1_10V(51),
88     TEMPRETURE_SWITCHED(54),
89     TEMPRETURE_PWM(54);
90
91     private final int mode;
92
93     static final Map<Integer, OutputModeEnum> OUTPUT_MODES = new HashMap<>();
94
95     static {
96         for (OutputModeEnum out : OutputModeEnum.values()) {
97             OUTPUT_MODES.put(out.getMode(), out);
98         }
99     }
100
101     /**
102      * Returns true, if the output mode id contains in digitalSTROM, otherwise false.
103      *
104      * @param modeID to be checked
105      * @return true, if contains, otherwise false
106      */
107     public static boolean containsMode(Integer modeID) {
108         return OUTPUT_MODES.keySet().contains(modeID);
109     }
110
111     /**
112      * Returns true, if the output mode is a dimmable output mode, otherwise false.
113      *
114      * @param outputMode to check
115      * @return true, if outputMode is dimmable, otherwise false
116      */
117     public static boolean outputModeIsDimmable(OutputModeEnum outputMode) {
118         if (outputMode == null) {
119             return false;
120         }
121         switch (outputMode) {
122             case RMS_DIMMER:
123             case RMS_DIMMER_CC:
124             case PC_DIMMER:
125             case PC_DIMMER_CC:
126             case RPC_DIMMER:
127             case RPC_DIMMER_CC:
128             case DIMMED_0_10V:
129             case DIMMED_1_10V:
130             case HEATING_PWM:
131                 return true;
132             default:
133                 return false;
134         }
135     }
136
137     /**
138      * Returns true, if the output mode is a switchable output mode, otherwise false.
139      *
140      * @param outputMode to check
141      * @return true, if outputMode is switchable, otherwise false
142      */
143     public static boolean outputModeIsSwitch(OutputModeEnum outputMode) {
144         if (outputMode == null) {
145             return false;
146         }
147         switch (outputMode) {
148             case SWITCHED:
149             case SWITCH:
150             case COMBINED_SWITCH:
151             case SINGLE_SWITCH:
152             case WIPE:
153             case POWERSAVE:
154                 return true;
155             default:
156                 return false;
157         }
158     }
159
160     /**
161      * Returns true, if the output mode is a shade control output mode, otherwise false.
162      *
163      * @param outputMode to check
164      * @return true, if outputMode is for shade control, otherwise false
165      */
166     public static boolean outputModeIsShade(OutputModeEnum outputMode) {
167         if (outputMode == null) {
168             return false;
169         }
170         switch (outputMode) {
171             case POSITION_CON:
172             case POSITION_CON_US:
173                 return true;
174             default:
175                 return false;
176         }
177     }
178
179     /**
180      * Returns true, if the output mode is a temperature controlled output mode, otherwise false.<br>
181      * <br>
182      * <b>Note:</b>
183      * This output mode will be automatically controlled through the digitalSTROM-Server and can't be set manually.
184      *
185      * @param outputMode to check
186      * @return true, if outputMode is temperature controlled, otherwise false
187      */
188     public static boolean outputModeIsTemperationControlled(OutputModeEnum outputMode) {
189         if (outputMode == null) {
190             return false;
191         }
192         switch (outputMode) {
193             case TEMPRETURE_PWM:
194             case TEMPRETURE_SWITCHED:
195                 return true;
196             default:
197                 return false;
198         }
199     }
200
201     /**
202      * Returns the {@link OutputModeEnum} for the given modeID, otherwise null.
203      *
204      * @param modeID of the {@link OutputModeEnum}
205      * @return OutputModeEnum or null
206      */
207     public static OutputModeEnum getMode(Integer modeID) {
208         return OUTPUT_MODES.get(modeID);
209     }
210
211     private OutputModeEnum(int outputMode) {
212         this.mode = outputMode;
213     }
214
215     /**
216      * Returns the id of this {@link OutputModeEnum} object.
217      *
218      * @return mode id
219      */
220     public int getMode() {
221         return mode;
222     }
223 }