2 * Copyright (c) 2010-2023 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.sonyprojector.internal;
15 import java.nio.charset.StandardCharsets;
16 import java.util.ArrayList;
17 import java.util.Arrays;
18 import java.util.List;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorAspect;
22 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorBlockNr;
23 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorCalibrationPreset;
24 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorColorSpace;
25 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorColorTemp;
26 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorContrastEnhancer;
27 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorFilmMode;
28 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorFilmProjection;
29 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorGammaCorrection;
30 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorInput;
31 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorIrisMode;
32 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorIrisSensitivity;
33 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorLampControl;
34 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorMosquitoNr;
35 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorMotionEnhancer;
36 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorMpegNr;
37 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorNr;
38 import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorPicturePosition;
39 import org.openhab.core.types.StateOption;
42 * Represents the different supported projector models
44 * @author Laurent Garnier - Initial contribution
47 public enum SonyProjectorModel {
51 HW10("VPL-HW10", false, 2, 2, 2, 1, true, 0, true, 2, 3, 3, true, true, 2, 2, true, true, 0, true, 3, 0, 0),
52 HW15("VPL-HW15", false, 2, 2, 2, 1, true, 0, true, 2, 3, 3, true, true, 3, 2, true, true, 0, true, 3, 0, 0),
53 HW20("VPL-HW20", false, 2, 2, 2, 1, true, 0, true, 2, 3, 3, true, true, 3, 2, true, true, 0, true, 3, 0, 0),
54 HW30ES("VPL-HW30ES", false, 4, 3, 3, 2, true, 0, true, 2, 4, 3, true, true, 4, 2, true, true, 0, true, 4, 0, 0),
55 HW35ES("VPL-HW35ES", false, 1, 3, 1, 2, true, 0, true, 5, 6, 0, false, false, 6, 2, false, false, 2, true, 6, 3, 2),
56 HW40ES("VPL-HW40ES", false, 1, 3, 1, 2, true, 0, true, 5, 6, 0, false, false, 6, 2, false, false, 2, true, 6, 3, 2),
57 HW45ES("VPL-HW45ES", false, 1, 1, 1, 1, true, 0, false, 6, 6, 0, false, false, 6, 2, false, false, 2, true, 6, 0,
59 HW50ES("VPL-HW50ES", false, 1, 3, 1, 2, true, 0, true, 5, 7, 5, true, false, 1, 2, false, false, 2, true, 6, 3, 2),
60 HW55ES("VPL-HW55ES", false, 1, 3, 1, 2, true, 0, true, 5, 7, 5, true, false, 1, 2, false, false, 2, true, 6, 3, 2),
61 HW58ES("VPL-HW58ES", false, 1, 3, 1, 2, true, 0, true, 5, 6, 0, false, false, 6, 2, false, false, 2, true, 6, 3, 2),
62 HW60("VPL-HW60", true, 1, 1, 1, 1, true, 0, false, 6, 1, 1, true, false, 1, 1, false, false, 1, true, 1, 0, 1),
63 HW65("VPL-HW65", true, 1, 1, 1, 1, true, 0, false, 6, 1, 1, true, false, 1, 1, false, false, 1, true, 1, 0, 1),
64 HW68("VPL-HW68", true, 1, 1, 1, 1, true, 0, false, 6, 1, 1, true, false, 1, 1, false, false, 1, true, 1, 0, 1),
68 // VW10HT("VPL-VW10HT", false, 2, 1, 1, 1, true, 0, true, 1, 1, 1, true, false, 2, 2, true, true, 0, true, 3, 0, 0),
69 // VW11HT("VPL-VW11HT", false, 2, 1, 1, 1, true, 0, true, 1, 1, 1, true, false, 2, 2, true, true, 0, true, 3, 0, 0),
70 // VW12HT("VPL-VW12HT", false, 2, 1, 1, 1, true, 0, true, 1, 1, 1, true, false, 2, 2, true, true, 0, true, 3, 0, 0),
72 VW40("VPL-VW40", false, 2, 2, 2, 0, true, 0, true, 2, 2, 2, true, true, 2, 2, false, false, 0, false, 3, 0, 0),
73 VW50("VPL-VW50", false, 2, 2, 2, 0, true, 0, true, 2, 2, 2, true, true, 2, 2, false, false, 0, false, 3, 0, 0),
74 VW60("VPL-VW60", false, 2, 2, 2, 0, true, 0, true, 3, 2, 2, true, true, 2, 2, false, false, 0, false, 3, 0, 0),
75 VW70("VPL-VW70", false, 2, 2, 2, 1, true, 0, true, 3, 3, 3, true, true, 3, 2, true, true, 0, true, 3, 0, 0),
76 VW80("VPL-VW80", false, 2, 2, 2, 2, true, 0, true, 3, 3, 3, true, true, 3, 2, true, true, 0, true, 3, 1, 2),
77 VW85("VPL-VW85", false, 3, 2, 3, 2, true, 0, true, 3, 4, 3, true, true, 5, 2, true, true, 0, true, 4, 1, 2),
78 VW90("VPL-VW90ES", false, 3, 5, 3, 2, true, 0, true, 3, 4, 3, true, true, 5, 2, true, true, 0, true, 4, 2, 2),
79 VW95("VPL-VW95ES", false, 4, 3, 3, 2, true, 2, true, 3, 4, 3, true, true, 5, 2, true, true, 0, true, 4, 2, 2),
81 VW100("VPL-VW100", false, 2, 4, 2, 3, false, 0, true, 4, 2, 4, false, false, 2, 2, false, false, 0, false, 3, 0, 0),
83 VW200("VPL-VW200", false, 2, 2, 2, 2, false, 0, true, 3, 2, 3, true, true, 2, 2, false, false, 0, true, 3, 1, 2),
84 VW260("VPL-VW260ES", true, 1, 1, 1, 1, true, 0, false, 1, 1, 0, false, false, 1, 1, false, false, 1, true, 2, 0, 1),
85 VW270("VPL-VW270ES", true, 1, 1, 1, 1, true, 0, false, 1, 1, 0, false, false, 1, 1, false, false, 1, true, 2, 0, 3),
86 VW285("VPL-VW285ES", true, 1, 1, 1, 1, true, 0, false, 1, 1, 0, false, false, 1, 1, false, false, 1, true, 2, 0, 1),
87 VW295("VPL-VW295ES", true, 1, 1, 1, 1, true, 0, false, 1, 1, 0, false, false, 1, 1, false, false, 1, true, 2, 0, 3),
89 VW300("VPL-VW300ES", true, 1, 1, 1, 1, true, 0, false, 1, 1, 0, false, false, 1, 1, false, false, 1, true, 1, 0, 1),
90 VW315("VPL-VW315", true, 1, 1, 1, 1, true, 0, false, 1, 1, 0, false, false, 1, 1, false, false, 1, true, 1, 0, 1),
91 VW320("VPL-VW320", true, 1, 1, 1, 1, true, 0, false, 1, 1, 0, false, false, 1, 1, false, false, 1, true, 1, 0, 1),
92 VW328("VPL-VW328", true, 1, 1, 1, 1, true, 0, false, 1, 1, 0, false, false, 1, 1, false, false, 1, true, 1, 0, 1),
93 VW350("VPL-VW350ES", true, 1, 1, 1, 1, true, 0, false, 1, 1, 0, false, false, 1, 1, false, false, 1, true, 1, 0, 1),
94 // VW360("VPL-VW360ES", false, 2, 4, 2, 3, true, 0, true, 1, 1, 1, true, false, 1, 2, false, false, 1, true, 1, 0,
96 VW365("VPL-VW365", true, 1, 1, 1, 1, true, 0, false, 1, 1, 0, false, false, 1, 1, false, false, 1, true, 1, 0, 1),
97 VW385("VPL-VW385ES", true, 1, 1, 1, 1, true, 1, false, 1, 1, 1, true, false, 1, 1, false, false, 1, true, 2, 0, 1),
99 VW500("VPL-VW500ES", true, 1, 1, 1, 1, true, 1, false, 1, 1, 1, true, false, 1, 1, false, false, 1, true, 1, 0, 1),
100 VW515("VPL-VW515", true, 1, 1, 1, 1, true, 1, false, 1, 1, 1, true, false, 1, 1, false, false, 1, true, 2, 0, 1),
101 VW520("VPL-VW520", true, 1, 1, 1, 1, true, 1, false, 1, 1, 1, true, false, 1, 1, false, false, 1, true, 2, 0, 1),
102 VW528("VPL-VW528", true, 1, 1, 1, 1, true, 1, false, 1, 1, 1, true, false, 1, 1, false, false, 1, true, 2, 0, 1),
103 VW550("VPL-VW550ES", true, 1, 1, 1, 1, true, 1, false, 1, 1, 1, true, false, 1, 1, false, false, 1, true, 1, 0, 1),
104 VW570("VPL-VW570ES", true, 1, 1, 1, 1, true, 1, false, 1, 1, 1, true, false, 1, 1, false, false, 1, true, 2, 0, 1),
106 VW600("VPL-VW600ES", true, 1, 1, 1, 1, true, 1, false, 1, 1, 1, true, false, 1, 1, false, false, 1, true, 1, 0, 1),
107 VW665("VPL-VW665", true, 1, 1, 1, 1, true, 1, false, 1, 1, 1, true, false, 1, 1, false, false, 1, true, 2, 0, 1),
108 VW675("VPL-VW675ES", true, 1, 1, 1, 1, true, 1, false, 1, 1, 1, true, false, 1, 1, false, false, 1, true, 2, 0, 1),
109 // VW685("VPL-VW685ES", true, 1, 1, 1, 1, true, 1, false, 1, 1, 1, true, false, 1, 1, false, false, 1, true, 2, 0,
111 VW695("VPL-VW695ES", true, 1, 1, 1, 1, true, 1, false, 1, 1, 1, true, false, 1, 1, false, false, 1, true, 2, 0, 1),
113 VW760("VPL-VW760ES", true, 1, 1, 1, 1, false, 1, false, 1, 1, 1, false, false, 1, 1, false, false, 1, true, 2, 0,
116 VW870("VPL-VW870ES", true, 1, 1, 1, 1, false, 1, false, 1, 1, 1, false, false, 1, 1, false, false, 1, true, 2, 0,
118 VW885("VPL-VW885ES", true, 1, 1, 1, 1, false, 1, false, 1, 1, 1, false, false, 1, 1, false, false, 1, true, 2, 0,
121 VW995("VPL-VW995ES", true, 1, 1, 1, 1, false, 1, false, 1, 1, 1, false, false, 1, 1, false, false, 1, true, 2, 0,
124 VW1000ES("VPL-VW1000ES", false, 5, 3, 1, 2, true, 1, true, 1, 5, 5, true, false, 1, 2, false, false, 2, true, 5, 3,
126 VW1100ES("VPL-VW1100ES", false, 5, 3, 1, 2, true, 1, true, 1, 5, 5, true, false, 1, 2, false, false, 2, true, 5, 3,
129 // VW5000ES("VPL-VW5000ES", false, 5, 3, 1, 2, true, 0, true, 1, 5, 5, true, false, 1, 2, false, false, 2, true, 5,
133 private boolean powerCmdAvailable;
134 private int calibrPresetsCategory;
135 private int inputCategory;
136 private int contrastEnhancerCategory;
137 private int filmModeCategory;
138 private boolean lampControlAvailable;
139 private int picturePositionCategory;
140 private boolean overscanAvailable;
141 private int aspectCategory;
142 private int colorTempCategory;
143 private int irisModeCategory;
144 private boolean irisManualAvailable;
145 private boolean irisSensitivityAvailable;
146 private int gammaCorrectionCategory;
147 private int nrCategory;
148 private boolean blockNrAvailable;
149 private boolean mosquitoNrAvailable;
150 private int mpegNrCategory;
151 private boolean xvColorAvailable;
152 private int colorSpaceCategory;
153 private int filmProjectionCategory;
154 private int motionEnhancerCategory;
159 * @param name the model name
160 * @param powerCmdAvailable true if the POWER command is available
161 * @param calibrPresetsCategory the category from {@link SonyProjectorCalibrationPreset}
162 * @param inputCategory the category from {@link SonyProjectorInput}
163 * @param contrastEnhancerCategory the category from {@link SonyProjectorContrastEnhancer}
164 * @param filmModeCategory the category from {@link SonyProjectorFilmMode}
165 * @param lampControlAvailable true if the lamp control setting is available
166 * @param picturePositionCategory the category from {@link SonyProjectorPicturePosition}
167 * @param overscanAvailable true if the overscan setting is available
168 * @param aspectCategory the category from {@link SonyProjectorAspect}
169 * @param colorTempCategory the category from {@link SonyProjectorColorTemp}
170 * @param irisModeCategory the category from {@link SonyProjectorIrisMode}
171 * @param irisManualAvailable true if the iris manual setting is available
172 * @param irisSensitivityAvailable true if the iris sensitivity setting is available
173 * @param gammaCorrectionCategory the category from {@link SonyProjectorGammaCorrection}
174 * @param nrCategory the category from {@link SonyProjectorNr}
175 * @param blockNrAvailable true if the block noise reduction setting is available
176 * @param mosquitoNrAvailable true if the mosquito noise reduction setting is available
177 * @param mpegNrCategory the category from {@link SonyProjectorMpegNr}
178 * @param xvColorAvailable true if the xvColor setting is available
179 * @param colorSpaceCategory the category from {@link SonyProjectorColorSpace}
180 * @param filmProjectionCategory the category from {@link SonyProjectorFilmProjection}
181 * @param motionEnhancerCategory the category from {@link SonyProjectorMotionEnhancer}
183 private SonyProjectorModel(String name, boolean powerCmdAvailable, int calibrPresetsCategory, int inputCategory,
184 int contrastEnhancerCategory, int filmModeCategory, boolean lampControlAvailable,
185 int picturePositionCategory, boolean overscanAvailable, int aspectCategory, int colorTempCategory,
186 int irisModeCategory, boolean irisManualAvailable, boolean irisSensitivityAvailable,
187 int gammaCorrectionCategory, int nrCategory, boolean blockNrAvailable, boolean mosquitoNrAvailable,
188 int mpegNrCategory, boolean xvColorAvailable, int colorSpaceCategory, int filmProjectionCategory,
189 int motionEnhancerCategory) {
191 this.powerCmdAvailable = powerCmdAvailable;
192 this.calibrPresetsCategory = calibrPresetsCategory;
193 this.inputCategory = inputCategory;
194 this.contrastEnhancerCategory = contrastEnhancerCategory;
195 this.filmModeCategory = filmModeCategory;
196 this.lampControlAvailable = lampControlAvailable;
197 this.picturePositionCategory = picturePositionCategory;
198 this.overscanAvailable = overscanAvailable;
199 this.aspectCategory = aspectCategory;
200 this.colorTempCategory = colorTempCategory;
201 this.irisModeCategory = irisModeCategory;
202 this.irisManualAvailable = irisManualAvailable;
203 this.irisSensitivityAvailable = irisSensitivityAvailable;
204 this.gammaCorrectionCategory = gammaCorrectionCategory;
205 this.nrCategory = nrCategory;
206 this.blockNrAvailable = blockNrAvailable;
207 this.mosquitoNrAvailable = mosquitoNrAvailable;
208 this.mpegNrCategory = mpegNrCategory;
209 this.xvColorAvailable = xvColorAvailable;
210 this.colorSpaceCategory = colorSpaceCategory;
211 this.filmProjectionCategory = filmProjectionCategory;
212 this.motionEnhancerCategory = motionEnhancerCategory;
218 * @return the model name
220 public String getName() {
225 * Inform whether the POWER command is available
227 * @return true if the POWER command is available
229 public boolean isPowerCmdAvailable() {
230 return powerCmdAvailable;
234 * Get the list of {@link StateOption} associated to the available calibration presets
236 * @return the list of {@link StateOption} associated to the available calibration presets
238 public List<StateOption> getCalibrPresetStateOptions() {
239 return SonyProjectorCalibrationPreset.getStateOptions(calibrPresetsCategory);
243 * Get the calibration preset associated to a name
245 * @param name the name used to identify the calibration preset
247 * @return the calibration preset associated to the searched name
249 * @throws SonyProjectorException - If no calibration preset is associated to the searched name
251 public byte[] getCalibrPresetDataCodeFromName(String name) throws SonyProjectorException {
252 return SonyProjectorCalibrationPreset.getFromName(calibrPresetsCategory, name).getDataCode();
256 * Get the calibration preset associated to a data code
258 * @param dataCode the data code used to identify the calibration preset
260 * @return the calibration preset associated to the searched data code
262 * @throws SonyProjectorException - If no calibration preset is associated to the searched data code
264 public String getCalibrPresetNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
265 return SonyProjectorCalibrationPreset.getFromDataCode(calibrPresetsCategory, dataCode).getName();
269 * Get the list of {@link StateOption} associated to the available video inputs
271 * @return the list of {@link StateOption} associated to the available video inputs
273 public List<StateOption> getInputStateOptions() {
274 return SonyProjectorInput.getStateOptions(inputCategory);
278 * Get the video input associated to a name
280 * @param name the name used to identify the video input
282 * @return the video input associated to the searched name
284 * @throws SonyProjectorException - If no video input is associated to the searched name
286 public byte[] getInputDataCodeFromName(String name) throws SonyProjectorException {
287 return SonyProjectorInput.getFromName(inputCategory, name).getDataCode();
291 * Get the video input associated to a data code
293 * @param dataCode the data code used to identify the video input
295 * @return the video input associated to the searched data code
297 * @throws SonyProjectorException - If no video input is associated to the searched data code
299 public String getInputNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
300 return SonyProjectorInput.getFromDataCode(inputCategory, dataCode).getName();
304 * Get the list of {@link StateOption} associated to the available contrast enhancer modes
306 * @return the list of {@link StateOption} associated to the available contrast enhancer modes
308 public List<StateOption> getContrastEnhancerStateOptions() {
309 return SonyProjectorContrastEnhancer.getStateOptions(contrastEnhancerCategory);
313 * Get the contrast enhancer mode associated to a name
315 * @param name the name used to identify the contrast enhancer mode
317 * @return the contrast enhancer mode associated to the searched name
319 * @throws SonyProjectorException - If no contrast enhancer mode is associated to the searched name
321 public byte[] getContrastEnhancerDataCodeFromName(String name) throws SonyProjectorException {
322 return SonyProjectorContrastEnhancer.getFromName(contrastEnhancerCategory, name).getDataCode();
326 * Get the contrast enhancer mode associated to a data code
328 * @param dataCode the data code used to identify the contrast enhancer mode
330 * @return the contrast enhancer mode associated to the searched data code
332 * @throws SonyProjectorException - If no contrast enhancer mode is associated to the searched data code
334 public String getContrastEnhancerNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
335 return SonyProjectorContrastEnhancer.getFromDataCode(contrastEnhancerCategory, dataCode).getName();
339 * Get the list of {@link StateOption} associated to the available film modes
341 * @return the list of {@link StateOption} associated to the available film modes
343 public List<StateOption> getFilmModeStateOptions() {
344 return SonyProjectorFilmMode.getStateOptions(filmModeCategory);
348 * Inform whether the film mode setting is available
350 * @return true if the film mode setting is available
352 public boolean isFilmModeAvailable() {
353 return filmModeCategory > 0;
357 * Get the film mode associated to a name
359 * @param name the name used to identify the film mode
361 * @return the film mode associated to the searched name
363 * @throws SonyProjectorException - If no film mode is associated to the searched name
365 public byte[] getFilmModeDataCodeFromName(String name) throws SonyProjectorException {
366 return SonyProjectorFilmMode.getFromName(filmModeCategory, name).getDataCode();
370 * Get the film mode associated to a data code
372 * @param dataCode the data code used to identify the film mode
374 * @return the film mode associated to the searched data code
376 * @throws SonyProjectorException - If no film mode is associated to the searched data code
378 public String getFilmModeNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
379 return SonyProjectorFilmMode.getFromDataCode(filmModeCategory, dataCode).getName();
383 * Get the list of {@link StateOption} associated to the available lamp control modes
385 * @return the list of {@link StateOption} associated to the available lamp control modes
387 public List<StateOption> getLampControlStateOptions() {
388 return lampControlAvailable ? SonyProjectorLampControl.getStateOptions() : new ArrayList<>();
392 * Inform whether the lamp control setting is available
394 * @return true if the lamp control setting is available
396 public boolean isLampControlAvailable() {
397 return lampControlAvailable;
401 * Get the list of {@link StateOption} associated to the available picture positions
403 * @return the list of {@link StateOption} associated to the available picture positions
405 public List<StateOption> getPicturePositionStateOptions() {
406 return SonyProjectorPicturePosition.getStateOptions(picturePositionCategory);
410 * Inform whether the picture position setting is available
412 * @return true if the picture position setting is available
414 public boolean isPicturePositionAvailable() {
415 return picturePositionCategory > 0;
419 * Get the picture position associated to a name
421 * @param name the name used to identify the picture position
423 * @return the picture position associated to the searched name
425 * @throws SonyProjectorException - If no picture position is associated to the searched name
427 public byte[] getPicturePositionCodeFromName(String name) throws SonyProjectorException {
428 return SonyProjectorPicturePosition.getFromName(picturePositionCategory, name).getDataCode();
432 * Get the picture position associated to a data code
434 * @param dataCode the data code used to identify the picture position
436 * @return the picture position associated to the searched data code
438 * @throws SonyProjectorException - If no picture position is associated to the searched data code
440 public String getPicturePositionNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
441 return SonyProjectorPicturePosition.getFromDataCode(picturePositionCategory, dataCode).getName();
445 * Get the list of {@link StateOption} associated to the available aspect modes
447 * @return the list of {@link StateOption} associated to the available aspect modes
449 public List<StateOption> getAspectStateOptions() {
450 return SonyProjectorAspect.getStateOptions(aspectCategory);
454 * Get the aspect mode associated to a name
456 * @param name the name used to identify the aspect mode
458 * @return the aspect mode associated to the searched name
460 * @throws SonyProjectorException - If no aspect mode is associated to the searched name
462 public byte[] getAspectCodeFromName(String name) throws SonyProjectorException {
463 return SonyProjectorAspect.getFromName(aspectCategory, name).getDataCode();
467 * Get the aspect mode associated to a data code
469 * @param dataCode the data code used to identify the aspect mode
471 * @return the aspect mode associated to the searched data code
473 * @throws SonyProjectorException - If no aspect mode is associated to the searched data code
475 public String getAspectNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
476 return SonyProjectorAspect.getFromDataCode(aspectCategory, dataCode).getName();
480 * Get the list of {@link StateOption} associated to the available color temperatures
482 * @return the list of {@link StateOption} associated to the available color temperatures
484 public List<StateOption> getColorTempStateOptions() {
485 return SonyProjectorColorTemp.getStateOptions(colorTempCategory);
489 * Get the color temperature associated to a name
491 * @param name the name used to identify the color temperature
493 * @return the color temperature associated to the searched name
495 * @throws SonyProjectorException - If no color temperature is associated to the searched name
497 public byte[] getColorTempCodeFromName(String name) throws SonyProjectorException {
498 return SonyProjectorColorTemp.getFromName(colorTempCategory, name).getDataCode();
502 * Get the color temperature associated to a data code
504 * @param dataCode the data code used to identify the color temperature
506 * @return the color temperature associated to the searched data code
508 * @throws SonyProjectorException - If no color temperature is associated to the searched data code
510 public String getColorTempNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
511 return SonyProjectorColorTemp.getFromDataCode(colorTempCategory, dataCode).getName();
515 * Get the list of {@link StateOption} associated to the available iris modes
517 * @return the list of {@link StateOption} associated to the available iris modes
519 public List<StateOption> getIrisModeStateOptions() {
520 return SonyProjectorIrisMode.getStateOptions(irisModeCategory);
524 * Inform whether the iris mode setting is available
526 * @return true if the iris mode setting is available
528 public boolean isIrisModeAvailable() {
529 return irisModeCategory > 0;
533 * Get the iris mode associated to a name
535 * @param name the name used to identify the iris mode
537 * @return the iris mode associated to the searched name
539 * @throws SonyProjectorException - If no iris mode is associated to the searched name
541 public byte[] getIrisModeCodeFromName(String name) throws SonyProjectorException {
542 return SonyProjectorIrisMode.getFromName(irisModeCategory, name).getDataCode();
546 * Get the iris mode associated to a data code
548 * @param dataCode the data code used to identify the iris mode
550 * @return the iris mode associated to the searched data code
552 * @throws SonyProjectorException - If no iris mode is associated to the searched data code
554 public String getIrisModeNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
555 return SonyProjectorIrisMode.getFromDataCode(irisModeCategory, dataCode).getName();
559 * Inform whether the overscan setting is available
561 * @return true if the overscan setting is available
563 public boolean isOverscanAvailable() {
564 return overscanAvailable;
568 * Inform whether the iris manual setting is available
570 * @return true if the iris manual setting is available
572 public boolean isIrisManualAvailable() {
573 return irisManualAvailable;
577 * Get the list of {@link StateOption} associated to the available iris sensitivities
579 * @return the list of {@link StateOption} associated to the available iris sensitivities
581 public List<StateOption> getIrisSensitivityStateOptions() {
582 return irisSensitivityAvailable ? SonyProjectorIrisSensitivity.getStateOptions() : new ArrayList<>();
586 * Inform whether the iris sensitivity setting is available
588 * @return true if the iris sensitivity setting is available
590 public boolean isIrisSensitivityAvailable() {
591 return irisSensitivityAvailable;
595 * Get the list of {@link StateOption} associated to the available gamma corrections
597 * @return the list of {@link StateOption} associated to the available gamma corrections
599 public List<StateOption> getGammaCorrectionStateOptions() {
600 return SonyProjectorGammaCorrection.getStateOptions(gammaCorrectionCategory);
604 * Get the gamma correction associated to a name
606 * @param name the name used to identify the gamma correction
608 * @return the gamma correction associated to the searched name
610 * @throws SonyProjectorException - If no gamma correction is associated to the searched name
612 public byte[] getGammaCorrectionCodeFromName(String name) throws SonyProjectorException {
613 return SonyProjectorGammaCorrection.getFromName(gammaCorrectionCategory, name).getDataCode();
617 * Get the gamma correction associated to a data code
619 * @param dataCode the data code used to identify the gamma correction
621 * @return the gamma correction associated to the searched data code
623 * @throws SonyProjectorException - If no gamma correction is associated to the searched data code
625 public String getGammaCorrectionNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
626 return SonyProjectorGammaCorrection.getFromDataCode(gammaCorrectionCategory, dataCode).getName();
630 * Get the list of {@link StateOption} associated to the available nose reduction modes
632 * @return the list of {@link StateOption} associated to the available nose reduction modes
634 public List<StateOption> getNrStateOptions() {
635 return SonyProjectorNr.getStateOptions(nrCategory);
639 * Get the noise reduction mode associated to a name
641 * @param name the name used to identify the noise reduction mode
643 * @return the noise reduction mode associated to the searched name
645 * @throws SonyProjectorException - If no noise reduction mode is associated to the searched name
647 public byte[] getNrCodeFromName(String name) throws SonyProjectorException {
648 return SonyProjectorNr.getFromName(nrCategory, name).getDataCode();
652 * Get the noise reduction mode associated to a data code
654 * @param dataCode the data code used to identify the noise reduction mode
656 * @return the noise reduction mode associated to the searched data code
658 * @throws SonyProjectorException - If no noise reduction mode is associated to the searched data code
660 public String getNrNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
661 return SonyProjectorNr.getFromDataCode(nrCategory, dataCode).getName();
665 * Get the list of {@link StateOption} associated to the available block nose reduction modes
667 * @return the list of {@link StateOption} associated to the available block nose reduction modes
669 public List<StateOption> getBlockNrStateOptions() {
670 return blockNrAvailable ? SonyProjectorBlockNr.getStateOptions() : new ArrayList<>();
674 * Inform whether the block noise reduction setting is available
676 * @return true if the block noise reduction setting is available
678 public boolean isBlockNrAvailable() {
679 return blockNrAvailable;
683 * Get the list of {@link StateOption} associated to the available mosquito nose reduction modes
685 * @return the list of {@link StateOption} associated to the available mosquito nose reduction modes
687 public List<StateOption> getMosquitoNrStateOptions() {
688 return mosquitoNrAvailable ? SonyProjectorMosquitoNr.getStateOptions() : new ArrayList<>();
692 * Inform whether the mosquito noise reduction setting is available
694 * @return true if the mosquito noise reduction setting is available
696 public boolean isMosquitoNrAvailable() {
697 return mosquitoNrAvailable;
701 * Get the list of {@link StateOption} associated to the available MPEG nose reduction modes
703 * @return the list of {@link StateOption} associated to the available MPEG nose reduction modes
705 public List<StateOption> getMpegNrStateOptions() {
706 return SonyProjectorMpegNr.getStateOptions(mpegNrCategory);
710 * Inform whether the MPEG noise reduction setting is available
712 * @return true if the MPEG noise reduction setting is available
714 public boolean isMpegNrAvailable() {
715 return mpegNrCategory > 0;
719 * Get the MPEG noise reduction mode associated to a name
721 * @param name the name used to identify the MPEG noise reduction mode
723 * @return the MPEG noise reduction mode associated to the searched name
725 * @throws SonyProjectorException - If no MPEG noise reduction mode is associated to the searched name
727 public byte[] getMpegNrCodeFromName(String name) throws SonyProjectorException {
728 return SonyProjectorMpegNr.getFromName(mpegNrCategory, name).getDataCode();
732 * Get the MPEG noise reduction mode associated to a data code
734 * @param dataCode the data code used to identify the MPEG noise reduction mode
736 * @return the MPEG noise reduction mode associated to the searched data code
738 * @throws SonyProjectorException - If no MPEG noise reduction mode is associated to the searched data code
740 public String getMpegNrNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
741 return SonyProjectorMpegNr.getFromDataCode(mpegNrCategory, dataCode).getName();
745 * Inform whether the xvColor setting is available
747 * @return true if the xvColor setting is available
749 public boolean isXvColorAvailable() {
750 return xvColorAvailable;
754 * Get the list of {@link StateOption} associated to the available color spaces
756 * @return the list of {@link StateOption} associated to the available color spaces
758 public List<StateOption> getColorSpaceStateOptions() {
759 return SonyProjectorColorSpace.getStateOptions(colorSpaceCategory);
763 * Get the color space associated to a name
765 * @param name the name used to identify the color space
767 * @return the color space associated to the searched name
769 * @throws SonyProjectorException - If no color space is associated to the searched name
771 public byte[] getColorSpaceCodeFromName(String name) throws SonyProjectorException {
772 return SonyProjectorColorSpace.getFromName(colorSpaceCategory, name).getDataCode();
776 * Get the color space associated to a data code
778 * @param dataCode the data code used to identify the color space
780 * @return the color space associated to the searched data code
782 * @throws SonyProjectorException - If no color space is associated to the searched data code
784 public String getColorSpaceNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
785 return SonyProjectorColorSpace.getFromDataCode(colorSpaceCategory, dataCode).getName();
789 * Get the list of {@link StateOption} associated to the available film projection modes
791 * @return the list of {@link StateOption} associated to the available film projection modes
793 public List<StateOption> getFilmProjectionStateOptions() {
794 return SonyProjectorFilmProjection.getStateOptions(filmProjectionCategory);
798 * Inform whether the film projection setting is available
800 * @return true if the film projection setting is available
802 public boolean isFilmProjectionAvailable() {
803 return filmProjectionCategory > 0;
807 * Get the film projection mode associated to a name
809 * @param name the name used to identify the film projection mode
811 * @return the film projection mode associated to the searched name
813 * @throws SonyProjectorException - If no film projection mode is associated to the searched name
815 public byte[] getFilmProjectionCodeFromName(String name) throws SonyProjectorException {
816 return SonyProjectorFilmProjection.getFromName(filmProjectionCategory, name).getDataCode();
820 * Get the film projection mode associated to a data code
822 * @param dataCode the data code used to identify the film projection mode
824 * @return the film projection mode associated to the searched data code
826 * @throws SonyProjectorException - If no film projection mode is associated to the searched data code
828 public String getFilmProjectionNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
829 return SonyProjectorFilmProjection.getFromDataCode(filmProjectionCategory, dataCode).getName();
833 * Get the list of {@link StateOption} associated to the available motion enhancer modes
835 * @return the list of {@link StateOption} associated to the available motion enhancer modes
837 public List<StateOption> getMotionEnhancerStateOptions() {
838 return SonyProjectorMotionEnhancer.getStateOptions(motionEnhancerCategory);
842 * Inform whether the motion enhancer setting is available
844 * @return true if the motion enhancer setting is available
846 public boolean isMotionEnhancerAvailable() {
847 return motionEnhancerCategory > 0;
851 * Get the motion enhancer mode associated to a name
853 * @param name the name used to identify the motion enhancer mode
855 * @return the motion enhancer mode associated to the searched name
857 * @throws SonyProjectorException - If no motion enhancer mode is associated to the searched name
859 public byte[] getMotionEnhancerCodeFromName(String name) throws SonyProjectorException {
860 return SonyProjectorMotionEnhancer.getFromName(motionEnhancerCategory, name).getDataCode();
864 * Get the motion enhancer mode associated to a data code
866 * @param dataCode the data code used to identify the motion enhancer mode
868 * @return the motion enhancer mode associated to the searched data code
870 * @throws SonyProjectorException - If no motion enhancer mode is associated to the searched data code
872 public String getMotionEnhancerNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
873 return SonyProjectorMotionEnhancer.getFromDataCode(motionEnhancerCategory, dataCode).getName();
877 * Get the projector model mode associated to a name
879 * @param name the name used to identify the projector model
880 * @param strict true for a strict matching with the searched name
882 * @return the projector model associated to the searched name
884 * @throws SonyProjectorException - If no projector model is associated to the searched name
886 public static SonyProjectorModel getFromName(String name, boolean strict) throws SonyProjectorException {
887 String otherName = lessStrictName(name);
888 for (SonyProjectorModel value : SonyProjectorModel.values()) {
889 if (strict && value.getName().equals(name)) {
891 } else if (!strict && lessStrictName(value.getName()).equals(otherName)) {
895 throw new SonyProjectorException("Invalid model name: " + name);
898 private static String lessStrictName(String name) {
899 // Ignore the ending letters
900 String newName = name;
901 byte[] data = name.getBytes();
902 // Search the first number, starting at right
903 int last = data.length - 1;
904 for (int i = last; i >= 0; i--) {
905 if (((char) data[i]) >= '0' && ((char) data[i]) <= '9') {
910 byte[] newData = Arrays.copyOf(data, last + 1);
911 newName = new String(newData, StandardCharsets.UTF_8);