2 * Copyright (c) 2010-2021 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.rotel.internal.communication;
15 import java.util.ArrayList;
16 import java.util.List;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.rotel.internal.RotelException;
20 import org.openhab.core.types.StateOption;
23 * Represents the different DSP modes available for the Rotel equipments
25 * @author Laurent Garnier - Initial contribution
28 public enum RotelDsp {
30 CAT1_NONE(1, "NONE", "No DSP", RotelCommand.STEREO, "stereo"),
31 CAT1_STEREO3(1, "STEREO3", "Dolby 3 Stereo", RotelCommand.STEREO3, "dolby_3_stereo"),
32 CAT1_STEREO5(1, "STEREO5", "5 Channel Stereo", RotelCommand.STEREO5, "5_channel_stereo"),
33 CAT1_STEREO7(1, "STEREO7", "7 Channel Stereo", RotelCommand.STEREO7, "7_channel_stereo"),
34 CAT1_MUSIC1(1, "MUSIC1", "Music 1", RotelCommand.DSP1, "dsp1"),
35 CAT1_MUSIC2(1, "MUSIC2", "Music 2", RotelCommand.DSP2, "dsp2"),
36 CAT1_MUSIC3(1, "MUSIC3", "Music 3", RotelCommand.DSP3, "dsp3"),
37 CAT1_MUSIC4(1, "MUSIC4", "Music 4", RotelCommand.DSP4, "dsp4"),
38 CAT1_PROLOGIC(1, "PROLOGIC", "Dolby Pro Logic", RotelCommand.PROLOGIC, "dolby_prologic"),
39 CAT1_PLII_CINEMA(1, "PLIICINEMA", "Dolby PLII Cinema", RotelCommand.PLII_CINEMA, "dolby_plii_movie"),
40 CAT1_PLII_MUSIC(1, "PLIIMUSIC", "Dolby PLII Music", RotelCommand.PLII_MUSIC, "dolby_plii_music"),
41 CAT1_NEO6_CINEMA(1, "NEO6CINEMA", "dts Neo:6 Cinema", RotelCommand.NEO6_CINEMA, "dts_neo:6_cinema"),
42 CAT1_NEO6_MUSIC(1, "NEO6MUSIC", "dts Neo:6 Music", RotelCommand.NEO6_MUSIC, "dts_neo:6_music"),
44 CAT2_NONE(2, "NONE", "No DSP", RotelCommand.STEREO, "stereo"),
45 CAT2_STEREO3(2, "STEREO3", "Dolby 3 Stereo", RotelCommand.STEREO3, "dolby_3_stereo"),
46 CAT2_STEREO5(2, "STEREO5", "5 Channel Stereo", RotelCommand.STEREO5, "5_channel_stereo"),
47 CAT2_STEREO7(2, "STEREO7", "7 Channel Stereo", RotelCommand.STEREO7, "7_channel_stereo"),
48 CAT2_MUSIC1(2, "MUSIC1", "Music 1", RotelCommand.DSP1, "dsp1"),
49 CAT2_MUSIC2(2, "MUSIC2", "Music 2", RotelCommand.DSP2, "dsp2"),
50 CAT2_MUSIC3(2, "MUSIC3", "Music 3", RotelCommand.DSP3, "dsp3"),
51 CAT2_MUSIC4(2, "MUSIC4", "Music 4", RotelCommand.DSP4, "dsp4"),
52 CAT2_PROLOGIC(2, "PROLOGIC", "Dolby Pro Logic", RotelCommand.PROLOGIC, "dolby_prologic"),
53 CAT2_PLII_CINEMA(2, "PLIICINEMA", "Dolby PLII Cinema", RotelCommand.PLII_CINEMA, "dolby_plii_movie"),
54 CAT2_PLII_MUSIC(2, "PLIIMUSIC", "Dolby PLII Music", RotelCommand.PLII_MUSIC, "dolby_plii_music"),
55 CAT2_PLII_GAME(2, "PLIIGAME", "Dolby PLII Game", RotelCommand.PLII_GAME, "dolby_plii_game"),
56 CAT2_NEO6_CINEMA(2, "NEO6CINEMA", "dts Neo:6 Cinema", RotelCommand.NEO6_CINEMA, "dts_neo:6_cinema"),
57 CAT2_NEO6_MUSIC(2, "NEO6MUSIC", "dts Neo:6 Music", RotelCommand.NEO6_MUSIC, "dts_neo:6_music"),
59 CAT3_BYPASS(3, "BYPASS", "Analog Bypass", RotelCommand.BYPASS, "analog_bypass"),
60 CAT3_NONE(3, "NONE", "No DSP", RotelCommand.STEREO, "stereo"),
61 CAT3_STEREO3(3, "STEREO3", "Dolby 3 Stereo", RotelCommand.STEREO3, "dolby_3_stereo"),
62 CAT3_STEREO5(3, "STEREO5", "5 Channel Stereo", RotelCommand.STEREO5, "5_channel_stereo"),
63 CAT3_STEREO7(3, "STEREO7", "7 Channel Stereo", RotelCommand.STEREO7, "7_channel_stereo"),
64 CAT3_DSP1(3, "DSP1", "DSP 1", RotelCommand.DSP1, "dsp1"),
65 CAT3_DSP2(3, "DSP2", "DSP 2", RotelCommand.DSP2, "dsp2"),
66 CAT3_DSP3(3, "DSP3", "DSP 3", RotelCommand.DSP3, "dsp3"),
67 CAT3_DSP4(3, "DSP4", "DSP 4", RotelCommand.DSP4, "dsp4"),
68 CAT3_PROLOGIC(3, "PROLOGIC", "Dolby Pro Logic", RotelCommand.PROLOGIC, "dolby_prologic"),
69 CAT3_PLII_CINEMA(3, "PLIICINEMA", "Dolby PLII/PLIIx Cinema", RotelCommand.PLII_CINEMA, "dolby_plii_movie"),
70 CAT3_PLII_MUSIC(3, "PLIIMUSIC", "Dolby PLII/PLIIx Music", RotelCommand.PLII_MUSIC, "dolby_plii_music"),
71 CAT3_PLII_GAME(3, "PLIIGAME", "Dolby PLII/PLIIx Game", RotelCommand.PLII_GAME, "dolby_plii_game"),
72 CAT3_NEO6_CINEMA(3, "NEO6CINEMA", "dts Neo:6 Cinema", RotelCommand.NEO6_CINEMA, "dts_neo:6_cinema"),
73 CAT3_NEO6_MUSIC(3, "NEO6MUSIC", "dts Neo:6 Music", RotelCommand.NEO6_MUSIC, "dts_neo:6_music"),
75 CAT4_BYPASS(4, "BYPASS", "Analog Bypass", RotelCommand.BYPASS, "analog_bypass"),
76 CAT4_NONE(4, "NONE", "No DSP", RotelCommand.STEREO, "stereo"),
77 CAT4_STEREO3(4, "STEREO3", "Dolby 3 Stereo", RotelCommand.STEREO3, "dolby_3_stereo"),
78 CAT4_STEREO5(4, "STEREO5", "5 Channel Stereo", RotelCommand.STEREO5, "5_channel_stereo"),
79 CAT4_STEREO7(4, "STEREO7", "7 Channel Stereo", RotelCommand.STEREO7, "7_channel_stereo"),
80 CAT4_DSP1(4, "DSP1", "DSP 1", RotelCommand.DSP1, "dsp1"),
81 CAT4_DSP2(4, "DSP2", "DSP 2", RotelCommand.DSP2, "dsp2"),
82 CAT4_DSP3(4, "DSP3", "DSP 3", RotelCommand.DSP3, "dsp3"),
83 CAT4_DSP4(4, "DSP4", "DSP 4", RotelCommand.DSP4, "dsp4"),
84 CAT4_PROLOGIC(4, "PROLOGIC", "Dolby Pro Logic", RotelCommand.PROLOGIC, "dolby_prologic"),
85 CAT4_PLII_CINEMA(4, "PLIICINEMA", "Dolby PLII/PLIIx Cinema", RotelCommand.PLII_CINEMA, "dolby_plii_movie"),
86 CAT4_PLII_MUSIC(4, "PLIIMUSIC", "Dolby PLII/PLIIx Music", RotelCommand.PLII_MUSIC, "dolby_plii_music"),
87 CAT4_PLII_GAME(4, "PLIIGAME", "Dolby PLII/PLIIx Game", RotelCommand.PLII_GAME, "dolby_plii_game"),
88 CAT4_PLIIZ(4, "PLIIZ", "Dolby PLIIz", RotelCommand.PLIIZ, "dolby_pliiz"),
89 CAT4_NEO6_CINEMA(4, "NEO6CINEMA", "dts Neo:6 Cinema", RotelCommand.NEO6_CINEMA, "dts_neo:6_cinema"),
90 CAT4_NEO6_MUSIC(4, "NEO6MUSIC", "dts Neo:6 Music", RotelCommand.NEO6_MUSIC, "dts_neo:6_music"),
92 CAT5_BYPASS(5, "BYPASS", "Analog Bypass", RotelCommand.BYPASS, "analog_bypass"),
93 CAT5_NONE(5, "NONE", "No DSP", RotelCommand.STEREO, "stereo"),
94 CAT5_STEREO3(5, "STEREO3", "Dolby 3 Stereo", RotelCommand.STEREO3, "dolby_3_stereo"),
95 CAT5_STEREO5(5, "STEREO5", "5 Channel Stereo", RotelCommand.STEREO5, "5_channel_stereo"),
96 CAT5_STEREO7(5, "STEREO7", "7 Channel Stereo", RotelCommand.STEREO7, "7_channel_stereo"),
97 CAT5_STEREO9(5, "STEREO9", "9 Channel Stereo", RotelCommand.STEREO9, "9_channel_stereo"),
98 CAT5_STEREO11(5, "STEREO11", "11 Channel Stereo", RotelCommand.STEREO11, "11_channel_stereo"),
99 CAT5_ATMOS(5, "ATMOS", "Dolby Atmos", RotelCommand.ATMOS, "dolby atmos surround"),
100 CAT5_NEURAL_X(5, "NEURALX", "dts Neural:X", RotelCommand.NEURAL_X, "dts neural:x"),
102 CAT6_BYPASS(6, "BYPASS", "Analog Bypass", RotelCommand.BYPASS, "analog_bypass"),
103 CAT6_NONE(6, "NONE", "No DSP", RotelCommand.STEREO, "stereo"),
104 CAT6_STEREO3(6, "STEREO3", "Dolby 3 Stereo", RotelCommand.STEREO3, "dolby_3_stereo"),
105 CAT6_STEREO5(6, "STEREO5", "5 Channel Stereo", RotelCommand.STEREO5, "5_channel_stereo"),
106 CAT6_STEREO7(6, "STEREO7", "7 Channel Stereo", RotelCommand.STEREO7, "7_channel_stereo"),
107 CAT6_PLII_CINEMA(6, "PLIICINEMA", "Dolby PLII/PLIIx Cinema", RotelCommand.PLII_CINEMA, "dolby_plii_movie"),
108 CAT6_PLII_MUSIC(6, "PLIIMUSIC", "Dolby PLII/PLIIx Music", RotelCommand.PLII_MUSIC, "dolby_plii_music"),
109 CAT6_PLII_GAME(6, "PLIIGAME", "Dolby PLII/PLIIx Game", RotelCommand.PLII_GAME, "dolby_plii_game"),
110 CAT6_PLIIZ(6, "PLIIZ", "Dolby PLIIz", RotelCommand.PLIIZ, "dolby_pliiz"),
111 CAT6_NEO6_CINEMA(6, "NEO6CINEMA", "dts Neo:6 Cinema", RotelCommand.NEO6_CINEMA, "dts_neo:6_cinema"),
112 CAT6_NEO6_MUSIC(6, "NEO6MUSIC", "dts Neo:6 Music", RotelCommand.NEO6_MUSIC, "dts_neo:6_music");
114 private int category;
116 private String label;
117 private RotelCommand command;
118 private String feedback;
123 * @param category a category of models for which the DSP mode is available
124 * @param name the name of the DSP mode
125 * @param label the label of the DSP mode
126 * @param command the command to select the DSP mode
127 * @param feedback the feedback message identifying the DSP mode
129 private RotelDsp(int category, String name, String label, RotelCommand command, String feedback) {
130 this.category = category;
133 this.command = command;
134 this.feedback = feedback;
138 * Get the category of models for the current DSP mode
140 * @return the category of models
142 public int getCategory() {
147 * Get the name of the current DSP mode
151 public String getName() {
156 * Get the label of the current DSP mode
160 public String getLabel() {
165 * Get the command to select the current DSP mode
167 * @return the command
169 public RotelCommand getCommand() {
174 * Get the feedback message identifying the current DSP mode
176 * @return the feedback message
178 public String getFeedback() {
183 * Get the list of {@link StateOption} associated to the available DSP modes for a particular category of models
185 * @param category a category of models
187 * @return the list of {@link StateOption} associated to the available DSP modes for a provided category of models
189 public static List<StateOption> getStateOptions(int category) {
190 List<StateOption> options = new ArrayList<>();
191 for (RotelDsp value : RotelDsp.values()) {
192 if (value.getCategory() == category) {
193 options.add(new StateOption(value.getName(), value.getLabel()));
200 * Get the DSP mode associated to a name for a particular category of models
202 * @param category a category of models
203 * @param name the name used to identify the DSP mode
205 * @return the DSP mode associated to the searched name for the provided category of models
207 * @throws RotelException - If no DSP mode is associated to the searched name for the provided category
209 public static RotelDsp getFromName(int category, String name) throws RotelException {
210 for (RotelDsp value : RotelDsp.values()) {
211 if (value.getCategory() == category && value.getName().equals(name)) {
215 throw new RotelException("Invalid name for a DSP mode: " + name);
219 * Get the DSP mode identified by a feedback message for a particular category of models
221 * @param category a category of models
222 * @param feedback the feedback message used to identify the DSP mode
224 * @return the DSP mode associated to the searched feedback message for the provided category of models
226 * @throws RotelException - If no DSP mode is associated to the searched feedback message for the provided category
228 public static RotelDsp getFromFeedback(int category, String feedback) throws RotelException {
229 for (RotelDsp value : RotelDsp.values()) {
230 if (value.getCategory() == category && value.getFeedback().equals(feedback)) {
234 throw new RotelException("Invalid feedback for a DSP mode: " + feedback);
238 * Get the DSP mode associated to a command for a particular category of models
240 * @param category a category of models
241 * @param command the command used to identify the DSP mode
243 * @return the DSP mode associated to the searched command for the provided category of models
245 * @throws RotelException - If no DSP mode is associated to the searched command for the provided category
247 public static RotelDsp getFromCommand(int category, RotelCommand command) throws RotelException {
248 for (RotelDsp value : RotelDsp.values()) {
249 if (value.getCategory() == category && value.getCommand() == command) {
253 throw new RotelException("Invalid command for a DSP mode: " + command.getName());