]> git.basschouten.com Git - openhab-addons.git/blob
bfbefd1abd22b4bb20ee6080f9e32396e0ec32e2
[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.rotel.internal.communication;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.rotel.internal.RotelException;
18
19 /**
20  * Represents the different kinds of commands
21  *
22  * @author Laurent Garnier - Initial contribution
23  */
24 @NonNullByDefault
25 public enum RotelCommand {
26
27     POWER_TOGGLE("Power Toggle", RotelConnector.PRIMARY_CMD, (byte) 0x0A, "power_toggle", "power_toggle"),
28     POWER_OFF("Power Off", RotelConnector.PRIMARY_CMD, (byte) 0x4A, "power_off", "power_off"),
29     POWER_ON("Power On", RotelConnector.PRIMARY_CMD, (byte) 0x4B, "power_on", "power_on"),
30     POWER("Request current power status", "get_current_power", "power?"),
31     ZONE_SELECT("Zone Select", RotelConnector.PRIMARY_CMD, (byte) 0x23),
32     MAIN_ZONE_POWER_TOGGLE("Main Zone Power Toggle", RotelConnector.MAIN_ZONE_CMD, (byte) 0x0A),
33     MAIN_ZONE_POWER_OFF("Main Zone Power Off", RotelConnector.MAIN_ZONE_CMD, (byte) 0x4A),
34     MAIN_ZONE_POWER_ON("Main Zone Power On", RotelConnector.MAIN_ZONE_CMD, (byte) 0x4B),
35     ZONE2_POWER_TOGGLE("Zone 2 Power Toggle", RotelConnector.ZONE2_CMD, (byte) 0x0A),
36     ZONE2_POWER_OFF("Zone 2 Power Off", RotelConnector.ZONE2_CMD, (byte) 0x4A),
37     ZONE2_POWER_ON("Zone 2 Power On", RotelConnector.ZONE2_CMD, (byte) 0x4B),
38     ZONE3_POWER_TOGGLE("Zone 3 Power Toggle", RotelConnector.ZONE3_CMD, (byte) 0x0A),
39     ZONE3_POWER_OFF("Zone 3 Power Off", RotelConnector.ZONE3_CMD, (byte) 0x4A),
40     ZONE3_POWER_ON("Zone 3 Power On", RotelConnector.ZONE3_CMD, (byte) 0x4B),
41     ZONE4_POWER_TOGGLE("Zone 4 Power Toggle", RotelConnector.ZONE4_CMD, (byte) 0x0A),
42     ZONE4_POWER_OFF("Zone 4 Power Off", RotelConnector.ZONE4_CMD, (byte) 0x4A),
43     ZONE4_POWER_ON("Zone 4 Power On", RotelConnector.ZONE4_CMD, (byte) 0x4B),
44     VOLUME_UP("Volume Up", RotelConnector.PRIMARY_CMD, (byte) 0x0B, "volume_up", "vol_up"),
45     VOLUME_DOWN("Volume Down", RotelConnector.PRIMARY_CMD, (byte) 0x0C, "volume_down", "vol_dwn"),
46     VOLUME_SET("Set Volume to level", RotelConnector.VOLUME_CMD, (byte) 0, "volume_", "vol_"),
47     VOLUME_GET("Request current volume level", "get_volume", "volume?"),
48     VOLUME_GET_MIN("Request Min volume level", "get_volume_min", null),
49     VOLUME_GET_MAX("Request Max volume level", "get_volume_max", null),
50     MUTE_TOGGLE("Mute Toggle", RotelConnector.PRIMARY_CMD, (byte) 0x1E, "mute", "mute"),
51     MUTE_ON("Mute On", "mute_on", "mute_on"),
52     MUTE_OFF("Mute Off", "mute_off", "mute_off"),
53     MUTE("Request current mute status", "get_mute_status", "mute?"),
54     MAIN_ZONE_VOLUME_UP("Main Zone Volume Up", RotelConnector.MAIN_ZONE_CMD, (byte) 0),
55     MAIN_ZONE_VOLUME_DOWN("Main Zone Volume Down", RotelConnector.MAIN_ZONE_CMD, (byte) 1),
56     MAIN_ZONE_MUTE_TOGGLE("Main Zone Mute Toggle", RotelConnector.MAIN_ZONE_CMD, (byte) 0x1E),
57     MAIN_ZONE_MUTE_ON("Main Zone Mute On", RotelConnector.MAIN_ZONE_CMD, (byte) 0x6C),
58     MAIN_ZONE_MUTE_OFF("Main Zone Mute Off", RotelConnector.MAIN_ZONE_CMD, (byte) 0x6D),
59     ZONE2_VOLUME_UP("Zone 2 Volume Up", RotelConnector.ZONE2_CMD, (byte) 0),
60     ZONE2_VOLUME_DOWN("Zone 2 Volume Down", RotelConnector.ZONE2_CMD, (byte) 1),
61     ZONE2_VOLUME_SET("Set Zone 2 Volume to level", RotelConnector.ZONE2_VOLUME_CMD, (byte) 0),
62     ZONE2_MUTE_TOGGLE("Zone 2 Mute Toggle", RotelConnector.ZONE2_CMD, (byte) 0x1E),
63     ZONE2_MUTE_ON("Zone 2 Mute On", RotelConnector.ZONE2_CMD, (byte) 0x6C),
64     ZONE2_MUTE_OFF("Zone 2 Mute Off", RotelConnector.ZONE2_CMD, (byte) 0x6D),
65     ZONE3_VOLUME_UP("Zone 3 Volume Up", RotelConnector.ZONE3_CMD, (byte) 0),
66     ZONE3_VOLUME_DOWN("Zone 3 Volume Down", RotelConnector.ZONE3_CMD, (byte) 1),
67     ZONE3_VOLUME_SET("Set Zone 3 Volume to level", RotelConnector.ZONE3_VOLUME_CMD, (byte) 0),
68     ZONE3_MUTE_TOGGLE("Zone 3 Mute Toggle", RotelConnector.ZONE3_CMD, (byte) 0x1E),
69     ZONE3_MUTE_ON("Zone 3 Mute On", RotelConnector.ZONE3_CMD, (byte) 0x6C),
70     ZONE3_MUTE_OFF("Zone 3 Mute Off", RotelConnector.ZONE3_CMD, (byte) 0x6D),
71     ZONE4_VOLUME_UP("Zone 4 Volume Up", RotelConnector.ZONE4_CMD, (byte) 0),
72     ZONE4_VOLUME_DOWN("Zone 4 Volume Down", RotelConnector.ZONE4_CMD, (byte) 1),
73     ZONE4_VOLUME_SET("Set Zone 4 Volume to level", RotelConnector.ZONE4_VOLUME_CMD, (byte) 0),
74     ZONE4_MUTE_TOGGLE("Zone 4 Mute Toggle", RotelConnector.ZONE4_CMD, (byte) 0x1E),
75     ZONE4_MUTE_ON("Zone 4 Mute On", RotelConnector.ZONE4_CMD, (byte) 0x6C),
76     ZONE4_MUTE_OFF("Zone 4 Mute Off", RotelConnector.ZONE4_CMD, (byte) 0x6D),
77     SOURCE_CD("Source CD", RotelConnector.PRIMARY_CMD, (byte) 0x02, "cd", "cd"),
78     SOURCE_TUNER("Source Tuner", RotelConnector.PRIMARY_CMD, (byte) 0x03, "tuner", "tuner"),
79     SOURCE_TAPE("Source Tape", RotelConnector.PRIMARY_CMD, (byte) 0x04, "tape", "tape"),
80     SOURCE_VIDEO1("Source Video 1", RotelConnector.PRIMARY_CMD, (byte) 0x05, "video1", "video1"),
81     SOURCE_VIDEO2("Source Video 2", RotelConnector.PRIMARY_CMD, (byte) 0x06, "video2", "video2"),
82     SOURCE_VIDEO3("Source Video 3", RotelConnector.PRIMARY_CMD, (byte) 0x07, "video3", "video3"),
83     SOURCE_VIDEO4("Source Video 4", RotelConnector.PRIMARY_CMD, (byte) 0x08, "video4", "video4"),
84     SOURCE_VIDEO5("Source Video 5", RotelConnector.PRIMARY_CMD, (byte) 0x09, "video5", "video5"),
85     SOURCE_VIDEO6("Source Video 6", RotelConnector.PRIMARY_CMD, (byte) 0x94, "video6", "video6"),
86     SOURCE_VIDEO7("Source Video 7", "video7", "video7"),
87     SOURCE_VIDEO8("Source Video 8", "video8", "video8"),
88     SOURCE_PHONO("Source Phono", RotelConnector.PRIMARY_CMD, (byte) 0x35, "phono", "phono"),
89     SOURCE_USB("Source Front USB", RotelConnector.PRIMARY_CMD, (byte) 0x8E, "usb", "usb"),
90     SOURCE_PCUSB("Source PC USB", "pc_usb", "pcusb"),
91     SOURCE_MULTI_INPUT("Source Multi Input", RotelConnector.PRIMARY_CMD, (byte) 0x15, "multi_input", "multi_input"),
92     SOURCE_AUX("Source Aux", "aux", "aux"),
93     SOURCE_AUX1("Source Aux 1", "aux1", "aux1"),
94     SOURCE_AUX2("Source Aux 2", "aux2", "aux2"),
95     SOURCE_AUX1_COAX("Source Aux 1 Coax", "aux1_coax", "aux1_coax"),
96     SOURCE_AUX1_OPT("Source Aux 1 Optical", "aux1_opt", "aux1_opt"),
97     SOURCE_COAX1("Source Coax 1", "coax1", "coax1"),
98     SOURCE_COAX2("Source Coax 2", "coax2", "coax2"),
99     SOURCE_COAX3("Source Coax 3", "coax3", "coax3"),
100     SOURCE_OPT1("Source Optical 1", "opt1", "opt1"),
101     SOURCE_OPT2("Source Optical 2", "opt2", "opt2"),
102     SOURCE_OPT3("Source Optical 3", "opt3", "opt3"),
103     SOURCE_BLUETOOTH("Source Bluetooth", "bluetooth", "bluetooth"),
104     SOURCE_ROTEL_CD("Source Rotel CD", "rcd", null),
105     SOURCE_XLR("Source XLR", "bal_xlr", "bal_xlr"),
106     SOURCE_FM("Source FM", "fm", "fm"),
107     SOURCE_DAB("Source DAB", "dab", "dab"),
108     SOURCE_PLAYFI("Source PlayFi", "playfi", "playfi"),
109     SOURCE_IRADIO("Source iRadio", "iradio", "iradio"),
110     SOURCE_NETWORK("Source Network", "network", "network"),
111     SOURCE("Request current source", "get_current_source", "source?"),
112     MAIN_ZONE_SOURCE_CD("Main Zone Source CD", RotelConnector.MAIN_ZONE_CMD, (byte) 0x02, "main_zone_cd",
113             "main_zone_cd"),
114     MAIN_ZONE_SOURCE_TUNER("Main Zone Source Tuner", RotelConnector.MAIN_ZONE_CMD, (byte) 0x03, "main_zone_tuner",
115             "main_zone_tuner"),
116     MAIN_ZONE_SOURCE_TAPE("Main Zone Source Tape", RotelConnector.MAIN_ZONE_CMD, (byte) 0x04, "main_zone_tape",
117             "main_zone_tape"),
118     MAIN_ZONE_SOURCE_VIDEO1("Main Zone Source Video 1", RotelConnector.MAIN_ZONE_CMD, (byte) 0x05, "main_zone_video1",
119             "main_zone_video1"),
120     MAIN_ZONE_SOURCE_VIDEO2("Main Zone Source Video 2", RotelConnector.MAIN_ZONE_CMD, (byte) 0x06, "main_zone_video2",
121             "main_zone_video2"),
122     MAIN_ZONE_SOURCE_VIDEO3("Main Zone Source Video 3", RotelConnector.MAIN_ZONE_CMD, (byte) 0x07, "main_zone_video3",
123             "main_zone_video3"),
124     MAIN_ZONE_SOURCE_VIDEO4("Main Zone Source Video 4", RotelConnector.MAIN_ZONE_CMD, (byte) 0x08, "main_zone_video4",
125             "main_zone_video4"),
126     MAIN_ZONE_SOURCE_VIDEO5("Main Zone Source Video 5", RotelConnector.MAIN_ZONE_CMD, (byte) 0x09, "main_zone_video5",
127             "main_zone_video5"),
128     MAIN_ZONE_SOURCE_VIDEO6("Main Zone Source Video 6", RotelConnector.MAIN_ZONE_CMD, (byte) 0x94, "main_zone_video6",
129             "main_zone_video6"),
130     MAIN_ZONE_SOURCE_USB("Main Zone Source Front USB", RotelConnector.MAIN_ZONE_CMD, (byte) 0x8E, "main_zone_usb",
131             "main_zone_usb"),
132     MAIN_ZONE_SOURCE_MULTI_INPUT("Main Zone Source Multi Input", RotelConnector.MAIN_ZONE_CMD, (byte) 0x15,
133             "main_zone_multi_input", "main_zone_multi_input"),
134     RECORD_SOURCE_CD("Record Source CD", RotelConnector.RECORD_SRC_CMD, (byte) 0x02, "record_cd", "record_cd"),
135     RECORD_SOURCE_TUNER("Record Source Tuner", RotelConnector.RECORD_SRC_CMD, (byte) 0x03, "record_tuner",
136             "record_tuner"),
137     RECORD_SOURCE_TAPE("Record Source Tape", RotelConnector.RECORD_SRC_CMD, (byte) 0x04, "record_tape", "record_tape"),
138     RECORD_SOURCE_VIDEO1("Record Source Video 1", RotelConnector.RECORD_SRC_CMD, (byte) 0x05, "record_video1",
139             "record_video1"),
140     RECORD_SOURCE_VIDEO2("Record Source Video 2", RotelConnector.RECORD_SRC_CMD, (byte) 0x06, "record_video2",
141             "record_video2"),
142     RECORD_SOURCE_VIDEO3("Record Source Video 3", RotelConnector.RECORD_SRC_CMD, (byte) 0x07, "record_video3",
143             "record_video3"),
144     RECORD_SOURCE_VIDEO4("Record Source Video 4", RotelConnector.RECORD_SRC_CMD, (byte) 0x08, "record_video4",
145             "record_video4"),
146     RECORD_SOURCE_VIDEO5("Record Source Video 5", RotelConnector.RECORD_SRC_CMD, (byte) 0x09, "record_video5",
147             "record_video5"),
148     RECORD_SOURCE_VIDEO6("Record Source Video 6", RotelConnector.RECORD_SRC_CMD, (byte) 0x94, "record_video6",
149             "record_video6"),
150     RECORD_SOURCE_USB("Record Source Front USB", RotelConnector.RECORD_SRC_CMD, (byte) 0x8E, "record_usb",
151             "record_usb"),
152     RECORD_SOURCE_MAIN("Record Follow Main Zone Source", RotelConnector.RECORD_SRC_CMD, (byte) 0x6B,
153             "record_follow_main", "record_follow_main"),
154     ZONE2_SOURCE_CD("Zone 2 Source CD", RotelConnector.ZONE2_CMD, (byte) 0x02, "zone2_cd", "zone2_cd"),
155     ZONE2_SOURCE_TUNER("Zone 2 Source Tuner", RotelConnector.ZONE2_CMD, (byte) 0x03, "zone2_tuner", "zone2_tuner"),
156     ZONE2_SOURCE_TAPE("Zone 2 Source Tape", RotelConnector.ZONE2_CMD, (byte) 0x04, "zone2_tape", "zone2_tape"),
157     ZONE2_SOURCE_VIDEO1("Zone 2 Source Video 1", RotelConnector.ZONE2_CMD, (byte) 0x05, "zone2_video1", "zone2_video1"),
158     ZONE2_SOURCE_VIDEO2("Zone 2 Source Video 2", RotelConnector.ZONE2_CMD, (byte) 0x06, "zone2_video2", "zone2_video2"),
159     ZONE2_SOURCE_VIDEO3("Zone 2 Source Video 3", RotelConnector.ZONE2_CMD, (byte) 0x07, "zone2_video3", "zone2_video3"),
160     ZONE2_SOURCE_VIDEO4("Zone 2 Source Video 4", RotelConnector.ZONE2_CMD, (byte) 0x08, "zone2_video4", "zone2_video4"),
161     ZONE2_SOURCE_VIDEO5("Zone 2 Source Video 5", RotelConnector.ZONE2_CMD, (byte) 0x09, "zone2_video5", "zone2_video5"),
162     ZONE2_SOURCE_VIDEO6("Zone 2 Source Video 6", RotelConnector.ZONE2_CMD, (byte) 0x94, "zone2_video6", "zone2_video6"),
163     ZONE2_SOURCE_USB("Zone 2 Source Front USB", RotelConnector.ZONE2_CMD, (byte) 0x8E, "zone2_usb", "zone2_usb"),
164     ZONE2_SOURCE_MAIN("Zone 2 Follow Main Zone Source", RotelConnector.ZONE2_CMD, (byte) 0x6B, "zone2_follow_main",
165             "zone2_follow_main"),
166     ZONE3_SOURCE_CD("Zone 3 Source CD", RotelConnector.ZONE3_CMD, (byte) 0x02, "zone3_cd", "zone3_cd"),
167     ZONE3_SOURCE_TUNER("Zone 3 Source Tuner", RotelConnector.ZONE3_CMD, (byte) 0x03, "zone3_tuner", "zone3_tuner"),
168     ZONE3_SOURCE_TAPE("Zone 3 Source Tape", RotelConnector.ZONE3_CMD, (byte) 0x04, "zone3_tape", "zone3_tape"),
169     ZONE3_SOURCE_VIDEO1("Zone 3 Source Video 1", RotelConnector.ZONE3_CMD, (byte) 0x05, "zone3_video1", "zone3_video1"),
170     ZONE3_SOURCE_VIDEO2("Zone 3 Source Video 2", RotelConnector.ZONE3_CMD, (byte) 0x06, "zone3_video2", "zone3_video2"),
171     ZONE3_SOURCE_VIDEO3("Zone 3 Source Video 3", RotelConnector.ZONE3_CMD, (byte) 0x07, "zone3_video3", "zone3_video3"),
172     ZONE3_SOURCE_VIDEO4("Zone 3 Source Video 4", RotelConnector.ZONE3_CMD, (byte) 0x08, "zone3_video4", "zone3_video4"),
173     ZONE3_SOURCE_VIDEO5("Zone 3 Source Video 5", RotelConnector.ZONE3_CMD, (byte) 0x09, "zone3_video5", "zone3_video5"),
174     ZONE3_SOURCE_VIDEO6("Zone 3 Source Video 6", RotelConnector.ZONE3_CMD, (byte) 0x94, "zone3_video6", "zone3_video6"),
175     ZONE3_SOURCE_USB("Zone 3 Source Front USB", RotelConnector.ZONE3_CMD, (byte) 0x8E, "zone3_usb", "zone3_usb"),
176     ZONE3_SOURCE_MAIN("Zone 3 Follow Main Zone Source", RotelConnector.ZONE3_CMD, (byte) 0x6B, "zone3_follow_main",
177             "zone3_follow_main"),
178     ZONE4_SOURCE_CD("Zone 4 Source CD", RotelConnector.ZONE4_CMD, (byte) 0x02, "zone4_cd", "zone4_cd"),
179     ZONE4_SOURCE_TUNER("Zone 4 Source Tuner", RotelConnector.ZONE4_CMD, (byte) 0x03, "zone4_tuner", "zone4_tuner"),
180     ZONE4_SOURCE_TAPE("Zone 4 Source Tape", RotelConnector.ZONE4_CMD, (byte) 0x04, "zone4_tape", "zone4_tape"),
181     ZONE4_SOURCE_VIDEO1("Zone 4 Source Video 1", RotelConnector.ZONE4_CMD, (byte) 0x05, "zone4_video1", "zone4_video1"),
182     ZONE4_SOURCE_VIDEO2("Zone 4 Source Video 2", RotelConnector.ZONE4_CMD, (byte) 0x06, "zone4_video2", "zone4_video2"),
183     ZONE4_SOURCE_VIDEO3("Zone 4 Source Video 3", RotelConnector.ZONE4_CMD, (byte) 0x07, "zone4_video3", "zone4_video3"),
184     ZONE4_SOURCE_VIDEO4("Zone 4 Source Video 4", RotelConnector.ZONE4_CMD, (byte) 0x08, "zone4_video4", "zone4_video4"),
185     ZONE4_SOURCE_VIDEO5("Zone 4 Source Video 5", RotelConnector.ZONE4_CMD, (byte) 0x09, "zone4_video5", "zone4_video5"),
186     ZONE4_SOURCE_VIDEO6("Zone 4 Source Video 6", RotelConnector.ZONE4_CMD, (byte) 0x94, "zone4_video6", "zone4_video6"),
187     ZONE4_SOURCE_USB("Zone 4 Source Front USB", RotelConnector.ZONE4_CMD, (byte) 0x8E, "zone4_usb", "zone4_usb"),
188     ZONE4_SOURCE_MAIN("Zone 4 Follow Main Zone Source", RotelConnector.ZONE4_CMD, (byte) 0x6B, "zone4_follow_main",
189             "zone4_follow_main"),
190     STEREO("Stereo", RotelConnector.PRIMARY_CMD, (byte) 0x11, "2channel", "2channel"),
191     STEREO3("Dolby 3 Stereo ", RotelConnector.PRIMARY_CMD, (byte) 0x12, "3channel", "3channel"),
192     STEREO5("5 Channel Stereo", RotelConnector.PRIMARY_CMD, (byte) 0x5B, "5channel", "5channel"),
193     STEREO7("7 Channel Stereo", RotelConnector.PRIMARY_CMD, (byte) 0x5C, "7channel", "7channel"),
194     STEREO9("9 Channel Stereo", "9channel", "9channel"),
195     STEREO11("11 Channel Stereo", "11channel", "11channel"),
196     DSP1("DSP 1", RotelConnector.PRIMARY_CMD, (byte) 0x57),
197     DSP2("DSP 2", RotelConnector.PRIMARY_CMD, (byte) 0x58),
198     DSP3("DSP 3", RotelConnector.PRIMARY_CMD, (byte) 0x59),
199     DSP4("DSP 4", RotelConnector.PRIMARY_CMD, (byte) 0x5A),
200     PROLOGIC("Dolby Pro Logic", RotelConnector.PRIMARY_CMD, (byte) 0x5F),
201     PLII_CINEMA("Dolby PLII Cinema", RotelConnector.PRIMARY_CMD, (byte) 0x5D, "prologic_movie", "prologic_movie"),
202     PLII_MUSIC("Dolby PLII Music", RotelConnector.PRIMARY_CMD, (byte) 0x5E, "prologic_music", "prologic_music"),
203     PLII_GAME("Dolby PLII Game", RotelConnector.PRIMARY_CMD, (byte) 0x74, "prologic_game", "prologic_game"),
204     PLIIZ("Dolby PLIIz", RotelConnector.PRIMARY_CMD, (byte) 0x92, "prologic_iiz", "prologic_iiz"),
205     NEO6_MUSIC("dts Neo:6 Music", RotelConnector.PRIMARY_CMD, (byte) 0x60, "neo6_music", "neo6_music"),
206     NEO6_CINEMA("dts Neo:6 Cinema", RotelConnector.PRIMARY_CMD, (byte) 0x61, "neo6_cinema", "neo6_cinema"),
207     ATMOS("Dolby Atmos", "dolby_atmos", "dolby_atmos"),
208     NEURAL_X("dts Neural:X", "dts_neural", "dts_neural"),
209     BYPASS("Analog Bypass", RotelConnector.PRIMARY_CMD, (byte) 0x11, "bypass", "bypass"),
210     DSP_MODE("Request current DSP mode", "get_dsp_mode", "dsp_mode"),
211     TONE_MAX("Request Max tone level", "get_tone_max", null),
212     TONE_CONTROL_SELECT("Tone Control Select", RotelConnector.PRIMARY_CMD, (byte) 0x67),
213     TREBLE_UP("Treble Up", RotelConnector.PRIMARY_CMD, (byte) 0x0D, "treble_up", "treble_up"),
214     TREBLE_DOWN("Treble Down", RotelConnector.PRIMARY_CMD, (byte) 0x0E, "treble_down", "treble_down"),
215     TREBLE_SET("Set Treble to level", "treble_", "treble_"),
216     TREBLE("Request current treble level", "get_treble", "treble?"),
217     BASS_UP("Bass Up", RotelConnector.PRIMARY_CMD, (byte) 0x0F, "bass_up", "bass_up"),
218     BASS_DOWN("Bass Down", RotelConnector.PRIMARY_CMD, (byte) 0x10, "bass_down", "bass_down"),
219     BASS_SET("Set Bass to level", "bass_", "bass_"),
220     BASS("Request current bass level", "get_bass", "bass?"),
221     RECORD_FONCTION_SELECT("Record Function Select", RotelConnector.PRIMARY_CMD, (byte) 0x17),
222     PLAY("Play Source", RotelConnector.PRIMARY_CMD, (byte) 0x04, "play", "play"),
223     STOP("Stop Source", RotelConnector.PRIMARY_CMD, (byte) 0x06, "stop", "stop"),
224     PAUSE("Pause Source", RotelConnector.PRIMARY_CMD, (byte) 0x05, "pause", "pause"),
225     CD_PLAY_STATUS("Request CD play status", "get_cd_play_status", null),
226     PLAY_STATUS("Request source play status", "get_play_status", "status"),
227     TRACK_FORWARD("Track Forward", RotelConnector.PRIMARY_CMD, (byte) 0x09, "track_fwd", "trkf"),
228     TRACK_BACKWORD("Track Backward", RotelConnector.PRIMARY_CMD, (byte) 0x08, "track_back", "trkb"),
229     TRACK("Request current CD track number", null, "track"),
230     FREQUENCY("Request current frequency for digital source input", "get_current_freq", "freq?"),
231     DISPLAY_REFRESH("Display Refresh", RotelConnector.PRIMARY_CMD, (byte) 0xFF),
232     DIMMER_LEVEL_GET("Request current front display dimmer level", "get_current_dimmer", "dimmer?"),
233     DIMMER_LEVEL_SET("Set front display dimmer to level", "dimmer_", "dimmer_"),
234     UPDATE_AUTO("Set Update to Auto", "display_update_auto", "rs232_update_on"),
235     UPDATE_MANUAL("Set Update to Manual", "display_update_manual", "rs232_update_off"),
236     TONE_CONTROLS_ON("Tone Controls On", "tone_on", null),
237     TONE_CONTROLS_OFF("Tone Controls Off", "tone_off", null),
238     TONE_CONTROLS("Request current tone control state", "get_tone", null),
239     TCBYPASS_ON("Bypass On", null, "bypass_on"),
240     TCBYPASS_OFF("Bypass Off", null, "bypass_off"),
241     TCBYPASS("Request current tone bypass state", null, "bypass?"),
242     BALANCE_RIGHT("Balance Right", "balance_right", "balance_r"),
243     BALANCE_LEFT("Balance Left", "balance_left", "balance_l"),
244     BALANCE_SET("Set Balance to level", "balance_", "balance_"),
245     BALANCE_SET_FIX("Set Balance to level", "balance_", "balance_"),
246     BALANCE("Request current balance setting", "get_balance", "balance?"),
247     SPEAKER_A_TOGGLE("Toggle Speaker A Output", RotelConnector.PRIMARY_CMD, (byte) 0x50, "speaker_a", "speaker_a"),
248     SPEAKER_A_ON("Set Speaker A Output", "speaker_a_on", "speaker_a_on"),
249     SPEAKER_A_OFF("Unset Speaker A Output", "speaker_a_off", "speaker_a_off"),
250     SPEAKER_B_TOGGLE("Toggle Speaker B Output", RotelConnector.PRIMARY_CMD, (byte) 0x51, "speaker_b", "speaker_b"),
251     SPEAKER_B_ON("Set Speaker B Output", "speaker_b_on", "speaker_b_on"),
252     SPEAKER_B_OFF("Unset Speaker B Output", "speaker_b_off", "speaker_b_off"),
253     SPEAKER("Request current active speaker outputs", "get_current_speaker", "speaker?");
254
255     public static final byte PRIMARY_COMMAND = (byte) 0x10;
256
257     private String name;
258     private byte hexType;
259     private byte hexKey;
260     private @Nullable String asciiCommandV1;
261     private @Nullable String asciiCommandV2;
262
263     /**
264      * Constructor when the textual commands are undefined
265      *
266      * @param name the command name
267      * @param hexType the the command type (HEX protocol)
268      * @param hexKey the the command key (HEX protocol)
269      */
270     private RotelCommand(String name, byte hexType, byte hexKey) {
271         this(name, hexType, hexKey, null, null);
272     }
273
274     /**
275      * Constructor when the HEX command is undefined
276      *
277      * @param name the command name
278      * @param asciiCommandV1 the textual command (ASCII protocol V1)
279      * @param asciiCommandV2 the textual command (ASCII protocol V2)
280      */
281     private RotelCommand(String name, @Nullable String asciiCommandV1, @Nullable String asciiCommandV2) {
282         this(name, (byte) 0, (byte) 0, asciiCommandV1, asciiCommandV2);
283     }
284
285     /**
286      * Constructor
287      *
288      * @param name the command name
289      * @param hexType the the command type (HEX protocol)
290      * @param hexKey the the command key (HEX protocol)
291      * @param asciiCommandV1 the textual command (ASCII protocol V1)
292      * @param asciiCommandV2 the textual command (ASCII protocol V2)
293      */
294     private RotelCommand(String name, byte hexType, byte hexKey, @Nullable String asciiCommandV1,
295             @Nullable String asciiCommandV2) {
296         this.name = name;
297         this.hexType = hexType;
298         this.hexKey = hexKey;
299         this.asciiCommandV1 = asciiCommandV1;
300         this.asciiCommandV2 = asciiCommandV2;
301     }
302
303     /**
304      * Get the command name
305      *
306      * @return the command name
307      */
308     public String getName() {
309         return name;
310     }
311
312     /**
313      * Get the command type (HEX protocol)
314      *
315      * @return the command type
316      */
317     public byte getHexType() {
318         return hexType;
319     }
320
321     /**
322      * Get the command key (HEX protocol)
323      *
324      * @return the command key
325      */
326     public byte getHexKey() {
327         return hexKey;
328     }
329
330     /**
331      * Get the textual command (ASCII protocol V1)
332      *
333      * @return the textual command
334      */
335     public @Nullable String getAsciiCommandV1() {
336         return asciiCommandV1;
337     }
338
339     /**
340      * Get the textual command (ASCII protocol V2)
341      *
342      * @return the textual command
343      */
344     public @Nullable String getAsciiCommandV2() {
345         return asciiCommandV2;
346     }
347
348     /**
349      * Get the command associated to a textual command
350      *
351      * @param text the textual command used to identify the command
352      *
353      * @return the command associated to the searched textual command
354      *
355      * @throws RotelException - If no command is associated to the searched textual command
356      */
357     public static RotelCommand getFromAsciiCommand(String text) throws RotelException {
358         for (RotelCommand value : RotelCommand.values()) {
359             if (text.equals(value.getAsciiCommandV1()) || text.equals(value.getAsciiCommandV2())) {
360                 return value;
361             }
362         }
363         throw new RotelException("Invalid textual command: " + text);
364     }
365 }