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.CommandOption;
40 import org.openhab.core.types.StateOption;
43 * Represents the different supported projector models
45 * @author Laurent Garnier - Initial contribution
48 public enum SonyProjectorModel {
52 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),
53 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),
54 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),
55 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),
56 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),
57 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),
58 HW45ES("VPL-HW45ES", false, 1, 1, 1, 1, true, 0, false, 6, 6, 0, false, false, 6, 2, false, false, 2, true, 6, 0,
60 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),
61 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),
62 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),
63 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),
64 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),
65 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),
69 // 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),
70 // 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),
71 // 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),
73 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),
74 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),
75 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),
76 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),
77 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),
78 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),
79 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),
80 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),
82 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),
84 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),
85 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),
86 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),
87 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),
88 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),
90 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),
91 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),
92 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),
93 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),
94 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),
95 // VW360("VPL-VW360ES", false, 2, 4, 2, 3, true, 0, true, 1, 1, 1, true, false, 1, 2, false, false, 1, true, 1, 0,
97 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),
98 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),
100 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),
101 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),
102 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),
103 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),
104 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),
105 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),
107 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),
108 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),
109 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),
110 // VW685("VPL-VW685ES", true, 1, 1, 1, 1, true, 1, false, 1, 1, 1, true, false, 1, 1, false, false, 1, true, 2, 0,
112 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),
114 VW760("VPL-VW760ES", true, 1, 1, 1, 1, false, 1, false, 1, 1, 1, false, false, 1, 1, false, false, 1, true, 2, 0,
117 VW870("VPL-VW870ES", true, 1, 1, 1, 1, false, 1, false, 1, 1, 1, false, false, 1, 1, false, false, 1, true, 2, 0,
119 VW885("VPL-VW885ES", true, 1, 1, 1, 1, false, 1, false, 1, 1, 1, false, false, 1, 1, false, false, 1, true, 2, 0,
122 VW995("VPL-VW995ES", true, 1, 1, 1, 1, false, 1, false, 1, 1, 1, false, false, 1, 1, false, false, 1, true, 2, 0,
125 VW1000ES("VPL-VW1000ES", false, 5, 3, 1, 2, true, 1, true, 1, 5, 5, true, false, 1, 2, false, false, 2, true, 5, 3,
127 VW1100ES("VPL-VW1100ES", false, 5, 3, 1, 2, true, 1, true, 1, 5, 5, true, false, 1, 2, false, false, 2, true, 5, 3,
130 // VW5000ES("VPL-VW5000ES", false, 5, 3, 1, 2, true, 0, true, 1, 5, 5, true, false, 1, 2, false, false, 2, true, 5,
134 private boolean powerCmdAvailable;
135 private int calibrPresetsCategory;
136 private int inputCategory;
137 private int contrastEnhancerCategory;
138 private int filmModeCategory;
139 private boolean lampControlAvailable;
140 private int picturePositionCategory;
141 private boolean overscanAvailable;
142 private int aspectCategory;
143 private int colorTempCategory;
144 private int irisModeCategory;
145 private boolean irisManualAvailable;
146 private boolean irisSensitivityAvailable;
147 private int gammaCorrectionCategory;
148 private int nrCategory;
149 private boolean blockNrAvailable;
150 private boolean mosquitoNrAvailable;
151 private int mpegNrCategory;
152 private boolean xvColorAvailable;
153 private int colorSpaceCategory;
154 private int filmProjectionCategory;
155 private int motionEnhancerCategory;
160 * @param name the model name
161 * @param powerCmdAvailable true if the POWER command is available
162 * @param calibrPresetsCategory the category from {@link SonyProjectorCalibrationPreset}
163 * @param inputCategory the category from {@link SonyProjectorInput}
164 * @param contrastEnhancerCategory the category from {@link SonyProjectorContrastEnhancer}
165 * @param filmModeCategory the category from {@link SonyProjectorFilmMode}
166 * @param lampControlAvailable true if the lamp control setting is available
167 * @param picturePositionCategory the category from {@link SonyProjectorPicturePosition}
168 * @param overscanAvailable true if the overscan setting is available
169 * @param aspectCategory the category from {@link SonyProjectorAspect}
170 * @param colorTempCategory the category from {@link SonyProjectorColorTemp}
171 * @param irisModeCategory the category from {@link SonyProjectorIrisMode}
172 * @param irisManualAvailable true if the iris manual setting is available
173 * @param irisSensitivityAvailable true if the iris sensitivity setting is available
174 * @param gammaCorrectionCategory the category from {@link SonyProjectorGammaCorrection}
175 * @param nrCategory the category from {@link SonyProjectorNr}
176 * @param blockNrAvailable true if the block noise reduction setting is available
177 * @param mosquitoNrAvailable true if the mosquito noise reduction setting is available
178 * @param mpegNrCategory the category from {@link SonyProjectorMpegNr}
179 * @param xvColorAvailable true if the xvColor setting is available
180 * @param colorSpaceCategory the category from {@link SonyProjectorColorSpace}
181 * @param filmProjectionCategory the category from {@link SonyProjectorFilmProjection}
182 * @param motionEnhancerCategory the category from {@link SonyProjectorMotionEnhancer}
184 private SonyProjectorModel(String name, boolean powerCmdAvailable, int calibrPresetsCategory, int inputCategory,
185 int contrastEnhancerCategory, int filmModeCategory, boolean lampControlAvailable,
186 int picturePositionCategory, boolean overscanAvailable, int aspectCategory, int colorTempCategory,
187 int irisModeCategory, boolean irisManualAvailable, boolean irisSensitivityAvailable,
188 int gammaCorrectionCategory, int nrCategory, boolean blockNrAvailable, boolean mosquitoNrAvailable,
189 int mpegNrCategory, boolean xvColorAvailable, int colorSpaceCategory, int filmProjectionCategory,
190 int motionEnhancerCategory) {
192 this.powerCmdAvailable = powerCmdAvailable;
193 this.calibrPresetsCategory = calibrPresetsCategory;
194 this.inputCategory = inputCategory;
195 this.contrastEnhancerCategory = contrastEnhancerCategory;
196 this.filmModeCategory = filmModeCategory;
197 this.lampControlAvailable = lampControlAvailable;
198 this.picturePositionCategory = picturePositionCategory;
199 this.overscanAvailable = overscanAvailable;
200 this.aspectCategory = aspectCategory;
201 this.colorTempCategory = colorTempCategory;
202 this.irisModeCategory = irisModeCategory;
203 this.irisManualAvailable = irisManualAvailable;
204 this.irisSensitivityAvailable = irisSensitivityAvailable;
205 this.gammaCorrectionCategory = gammaCorrectionCategory;
206 this.nrCategory = nrCategory;
207 this.blockNrAvailable = blockNrAvailable;
208 this.mosquitoNrAvailable = mosquitoNrAvailable;
209 this.mpegNrCategory = mpegNrCategory;
210 this.xvColorAvailable = xvColorAvailable;
211 this.colorSpaceCategory = colorSpaceCategory;
212 this.filmProjectionCategory = filmProjectionCategory;
213 this.motionEnhancerCategory = motionEnhancerCategory;
219 * @return the model name
221 public String getName() {
226 * Inform whether the POWER command is available
228 * @return true if the POWER command is available
230 public boolean isPowerCmdAvailable() {
231 return powerCmdAvailable;
235 * Get the list of {@link StateOption} associated to the available calibration presets
237 * @return the list of {@link StateOption} associated to the available calibration presets
239 public List<StateOption> getCalibrPresetStateOptions() {
240 return SonyProjectorCalibrationPreset.getStateOptions(calibrPresetsCategory);
244 * Get the list of {@link CommandOption} associated to the available calibration presets
246 * @return the list of {@link CommandOption} associated to the available calibration presets
248 public List<CommandOption> getCalibrPresetCommandOptions() {
249 return SonyProjectorCalibrationPreset.getCommandOptions(calibrPresetsCategory);
253 * Get the calibration preset associated to a name
255 * @param name the name used to identify the calibration preset
257 * @return the calibration preset associated to the searched name
259 * @throws SonyProjectorException - If no calibration preset is associated to the searched name
261 public SonyProjectorCalibrationPreset getCalibrPresetFromName(String name) throws SonyProjectorException {
262 return SonyProjectorCalibrationPreset.getFromName(calibrPresetsCategory, name);
266 * Get the calibration preset associated to a data code
268 * @param dataCode the data code used to identify the calibration preset
270 * @return the calibration preset associated to the searched data code
272 * @throws SonyProjectorException - If no calibration preset is associated to the searched data code
274 public String getCalibrPresetNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
275 return SonyProjectorCalibrationPreset.getFromDataCode(calibrPresetsCategory, dataCode).getName();
279 * Get the list of {@link StateOption} associated to the available video inputs
281 * @return the list of {@link StateOption} associated to the available video inputs
283 public List<StateOption> getInputStateOptions() {
284 return SonyProjectorInput.getStateOptions(inputCategory);
288 * Get the list of {@link CommandOption} associated to the available video inputs
290 * @return the list of {@link CommandOption} associated to the available video inputs
292 public List<CommandOption> getInputCommandOptions() {
293 return SonyProjectorInput.getCommandOptions(inputCategory);
297 * Get the video input associated to a name
299 * @param name the name used to identify the video input
301 * @return the video input associated to the searched name
303 * @throws SonyProjectorException - If no video input is associated to the searched name
305 public SonyProjectorInput getInputFromName(String name) throws SonyProjectorException {
306 return SonyProjectorInput.getFromName(inputCategory, name);
310 * Get the video input associated to a data code
312 * @param dataCode the data code used to identify the video input
314 * @return the video input associated to the searched data code
316 * @throws SonyProjectorException - If no video input is associated to the searched data code
318 public String getInputNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
319 return SonyProjectorInput.getFromDataCode(inputCategory, dataCode).getName();
323 * Get the list of {@link StateOption} associated to the available contrast enhancer modes
325 * @return the list of {@link StateOption} associated to the available contrast enhancer modes
327 public List<StateOption> getContrastEnhancerStateOptions() {
328 return SonyProjectorContrastEnhancer.getStateOptions(contrastEnhancerCategory);
332 * Get the contrast enhancer mode associated to a name
334 * @param name the name used to identify the contrast enhancer mode
336 * @return the contrast enhancer mode associated to the searched name
338 * @throws SonyProjectorException - If no contrast enhancer mode is associated to the searched name
340 public byte[] getContrastEnhancerDataCodeFromName(String name) throws SonyProjectorException {
341 return SonyProjectorContrastEnhancer.getFromName(contrastEnhancerCategory, name).getDataCode();
345 * Get the contrast enhancer mode associated to a data code
347 * @param dataCode the data code used to identify the contrast enhancer mode
349 * @return the contrast enhancer mode associated to the searched data code
351 * @throws SonyProjectorException - If no contrast enhancer mode is associated to the searched data code
353 public String getContrastEnhancerNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
354 return SonyProjectorContrastEnhancer.getFromDataCode(contrastEnhancerCategory, dataCode).getName();
358 * Get the list of {@link StateOption} associated to the available film modes
360 * @return the list of {@link StateOption} associated to the available film modes
362 public List<StateOption> getFilmModeStateOptions() {
363 return SonyProjectorFilmMode.getStateOptions(filmModeCategory);
367 * Inform whether the film mode setting is available
369 * @return true if the film mode setting is available
371 public boolean isFilmModeAvailable() {
372 return filmModeCategory > 0;
376 * Get the film mode associated to a name
378 * @param name the name used to identify the film mode
380 * @return the film mode associated to the searched name
382 * @throws SonyProjectorException - If no film mode is associated to the searched name
384 public byte[] getFilmModeDataCodeFromName(String name) throws SonyProjectorException {
385 return SonyProjectorFilmMode.getFromName(filmModeCategory, name).getDataCode();
389 * Get the film mode associated to a data code
391 * @param dataCode the data code used to identify the film mode
393 * @return the film mode associated to the searched data code
395 * @throws SonyProjectorException - If no film mode is associated to the searched data code
397 public String getFilmModeNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
398 return SonyProjectorFilmMode.getFromDataCode(filmModeCategory, dataCode).getName();
402 * Get the list of {@link StateOption} associated to the available lamp control modes
404 * @return the list of {@link StateOption} associated to the available lamp control modes
406 public List<StateOption> getLampControlStateOptions() {
407 return lampControlAvailable ? SonyProjectorLampControl.getStateOptions() : new ArrayList<>();
411 * Inform whether the lamp control setting is available
413 * @return true if the lamp control setting is available
415 public boolean isLampControlAvailable() {
416 return lampControlAvailable;
420 * Get the list of {@link StateOption} associated to the available picture positions
422 * @return the list of {@link StateOption} associated to the available picture positions
424 public List<StateOption> getPicturePositionStateOptions() {
425 return SonyProjectorPicturePosition.getStateOptions(picturePositionCategory);
429 * Inform whether the picture position setting is available
431 * @return true if the picture position setting is available
433 public boolean isPicturePositionAvailable() {
434 return picturePositionCategory > 0;
438 * Get the picture position associated to a name
440 * @param name the name used to identify the picture position
442 * @return the picture position associated to the searched name
444 * @throws SonyProjectorException - If no picture position is associated to the searched name
446 public byte[] getPicturePositionCodeFromName(String name) throws SonyProjectorException {
447 return SonyProjectorPicturePosition.getFromName(picturePositionCategory, name).getDataCode();
451 * Get the picture position associated to a data code
453 * @param dataCode the data code used to identify the picture position
455 * @return the picture position associated to the searched data code
457 * @throws SonyProjectorException - If no picture position is associated to the searched data code
459 public String getPicturePositionNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
460 return SonyProjectorPicturePosition.getFromDataCode(picturePositionCategory, dataCode).getName();
464 * Get the list of {@link StateOption} associated to the available aspect modes
466 * @return the list of {@link StateOption} associated to the available aspect modes
468 public List<StateOption> getAspectStateOptions() {
469 return SonyProjectorAspect.getStateOptions(aspectCategory);
473 * Get the list of {@link CommandOption} associated to the available aspect modes
475 * @return the list of {@link CommandOption} associated to the available aspect modes
477 public List<CommandOption> getAspectCommandOptions() {
478 return SonyProjectorAspect.getCommandOptions(aspectCategory);
482 * Get the aspect mode associated to a name
484 * @param name the name used to identify the aspect mode
486 * @return the aspect mode associated to the searched name
488 * @throws SonyProjectorException - If no aspect mode is associated to the searched name
490 public SonyProjectorAspect getAspectFromName(String name) throws SonyProjectorException {
491 return SonyProjectorAspect.getFromName(aspectCategory, name);
495 * Get the aspect mode associated to a data code
497 * @param dataCode the data code used to identify the aspect mode
499 * @return the aspect mode associated to the searched data code
501 * @throws SonyProjectorException - If no aspect mode is associated to the searched data code
503 public String getAspectNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
504 return SonyProjectorAspect.getFromDataCode(aspectCategory, dataCode).getName();
508 * Get the list of {@link StateOption} associated to the available color temperatures
510 * @return the list of {@link StateOption} associated to the available color temperatures
512 public List<StateOption> getColorTempStateOptions() {
513 return SonyProjectorColorTemp.getStateOptions(colorTempCategory);
517 * Get the color temperature associated to a name
519 * @param name the name used to identify the color temperature
521 * @return the color temperature associated to the searched name
523 * @throws SonyProjectorException - If no color temperature is associated to the searched name
525 public byte[] getColorTempCodeFromName(String name) throws SonyProjectorException {
526 return SonyProjectorColorTemp.getFromName(colorTempCategory, name).getDataCode();
530 * Get the color temperature associated to a data code
532 * @param dataCode the data code used to identify the color temperature
534 * @return the color temperature associated to the searched data code
536 * @throws SonyProjectorException - If no color temperature is associated to the searched data code
538 public String getColorTempNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
539 return SonyProjectorColorTemp.getFromDataCode(colorTempCategory, dataCode).getName();
543 * Get the list of {@link StateOption} associated to the available iris modes
545 * @return the list of {@link StateOption} associated to the available iris modes
547 public List<StateOption> getIrisModeStateOptions() {
548 return SonyProjectorIrisMode.getStateOptions(irisModeCategory);
552 * Inform whether the iris mode setting is available
554 * @return true if the iris mode setting is available
556 public boolean isIrisModeAvailable() {
557 return irisModeCategory > 0;
561 * Get the iris mode associated to a name
563 * @param name the name used to identify the iris mode
565 * @return the iris mode associated to the searched name
567 * @throws SonyProjectorException - If no iris mode is associated to the searched name
569 public byte[] getIrisModeCodeFromName(String name) throws SonyProjectorException {
570 return SonyProjectorIrisMode.getFromName(irisModeCategory, name).getDataCode();
574 * Get the iris mode associated to a data code
576 * @param dataCode the data code used to identify the iris mode
578 * @return the iris mode associated to the searched data code
580 * @throws SonyProjectorException - If no iris mode is associated to the searched data code
582 public String getIrisModeNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
583 return SonyProjectorIrisMode.getFromDataCode(irisModeCategory, dataCode).getName();
587 * Inform whether the overscan setting is available
589 * @return true if the overscan setting is available
591 public boolean isOverscanAvailable() {
592 return overscanAvailable;
596 * Inform whether the iris manual setting is available
598 * @return true if the iris manual setting is available
600 public boolean isIrisManualAvailable() {
601 return irisManualAvailable;
605 * Get the list of {@link StateOption} associated to the available iris sensitivities
607 * @return the list of {@link StateOption} associated to the available iris sensitivities
609 public List<StateOption> getIrisSensitivityStateOptions() {
610 return irisSensitivityAvailable ? SonyProjectorIrisSensitivity.getStateOptions() : new ArrayList<>();
614 * Inform whether the iris sensitivity setting is available
616 * @return true if the iris sensitivity setting is available
618 public boolean isIrisSensitivityAvailable() {
619 return irisSensitivityAvailable;
623 * Get the list of {@link StateOption} associated to the available gamma corrections
625 * @return the list of {@link StateOption} associated to the available gamma corrections
627 public List<StateOption> getGammaCorrectionStateOptions() {
628 return SonyProjectorGammaCorrection.getStateOptions(gammaCorrectionCategory);
632 * Get the gamma correction associated to a name
634 * @param name the name used to identify the gamma correction
636 * @return the gamma correction associated to the searched name
638 * @throws SonyProjectorException - If no gamma correction is associated to the searched name
640 public byte[] getGammaCorrectionCodeFromName(String name) throws SonyProjectorException {
641 return SonyProjectorGammaCorrection.getFromName(gammaCorrectionCategory, name).getDataCode();
645 * Get the gamma correction associated to a data code
647 * @param dataCode the data code used to identify the gamma correction
649 * @return the gamma correction associated to the searched data code
651 * @throws SonyProjectorException - If no gamma correction is associated to the searched data code
653 public String getGammaCorrectionNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
654 return SonyProjectorGammaCorrection.getFromDataCode(gammaCorrectionCategory, dataCode).getName();
658 * Get the list of {@link StateOption} associated to the available nose reduction modes
660 * @return the list of {@link StateOption} associated to the available nose reduction modes
662 public List<StateOption> getNrStateOptions() {
663 return SonyProjectorNr.getStateOptions(nrCategory);
667 * Get the noise reduction mode associated to a name
669 * @param name the name used to identify the noise reduction mode
671 * @return the noise reduction mode associated to the searched name
673 * @throws SonyProjectorException - If no noise reduction mode is associated to the searched name
675 public byte[] getNrCodeFromName(String name) throws SonyProjectorException {
676 return SonyProjectorNr.getFromName(nrCategory, name).getDataCode();
680 * Get the noise reduction mode associated to a data code
682 * @param dataCode the data code used to identify the noise reduction mode
684 * @return the noise reduction mode associated to the searched data code
686 * @throws SonyProjectorException - If no noise reduction mode is associated to the searched data code
688 public String getNrNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
689 return SonyProjectorNr.getFromDataCode(nrCategory, dataCode).getName();
693 * Get the list of {@link StateOption} associated to the available block nose reduction modes
695 * @return the list of {@link StateOption} associated to the available block nose reduction modes
697 public List<StateOption> getBlockNrStateOptions() {
698 return blockNrAvailable ? SonyProjectorBlockNr.getStateOptions() : new ArrayList<>();
702 * Inform whether the block noise reduction setting is available
704 * @return true if the block noise reduction setting is available
706 public boolean isBlockNrAvailable() {
707 return blockNrAvailable;
711 * Get the list of {@link StateOption} associated to the available mosquito nose reduction modes
713 * @return the list of {@link StateOption} associated to the available mosquito nose reduction modes
715 public List<StateOption> getMosquitoNrStateOptions() {
716 return mosquitoNrAvailable ? SonyProjectorMosquitoNr.getStateOptions() : new ArrayList<>();
720 * Inform whether the mosquito noise reduction setting is available
722 * @return true if the mosquito noise reduction setting is available
724 public boolean isMosquitoNrAvailable() {
725 return mosquitoNrAvailable;
729 * Get the list of {@link StateOption} associated to the available MPEG nose reduction modes
731 * @return the list of {@link StateOption} associated to the available MPEG nose reduction modes
733 public List<StateOption> getMpegNrStateOptions() {
734 return SonyProjectorMpegNr.getStateOptions(mpegNrCategory);
738 * Inform whether the MPEG noise reduction setting is available
740 * @return true if the MPEG noise reduction setting is available
742 public boolean isMpegNrAvailable() {
743 return mpegNrCategory > 0;
747 * Get the MPEG noise reduction mode associated to a name
749 * @param name the name used to identify the MPEG noise reduction mode
751 * @return the MPEG noise reduction mode associated to the searched name
753 * @throws SonyProjectorException - If no MPEG noise reduction mode is associated to the searched name
755 public byte[] getMpegNrCodeFromName(String name) throws SonyProjectorException {
756 return SonyProjectorMpegNr.getFromName(mpegNrCategory, name).getDataCode();
760 * Get the MPEG noise reduction mode associated to a data code
762 * @param dataCode the data code used to identify the MPEG noise reduction mode
764 * @return the MPEG noise reduction mode associated to the searched data code
766 * @throws SonyProjectorException - If no MPEG noise reduction mode is associated to the searched data code
768 public String getMpegNrNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
769 return SonyProjectorMpegNr.getFromDataCode(mpegNrCategory, dataCode).getName();
773 * Inform whether the xvColor setting is available
775 * @return true if the xvColor setting is available
777 public boolean isXvColorAvailable() {
778 return xvColorAvailable;
782 * Get the list of {@link StateOption} associated to the available color spaces
784 * @return the list of {@link StateOption} associated to the available color spaces
786 public List<StateOption> getColorSpaceStateOptions() {
787 return SonyProjectorColorSpace.getStateOptions(colorSpaceCategory);
791 * Get the color space associated to a name
793 * @param name the name used to identify the color space
795 * @return the color space associated to the searched name
797 * @throws SonyProjectorException - If no color space is associated to the searched name
799 public byte[] getColorSpaceCodeFromName(String name) throws SonyProjectorException {
800 return SonyProjectorColorSpace.getFromName(colorSpaceCategory, name).getDataCode();
804 * Get the color space associated to a data code
806 * @param dataCode the data code used to identify the color space
808 * @return the color space associated to the searched data code
810 * @throws SonyProjectorException - If no color space is associated to the searched data code
812 public String getColorSpaceNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
813 return SonyProjectorColorSpace.getFromDataCode(colorSpaceCategory, dataCode).getName();
817 * Get the list of {@link StateOption} associated to the available film projection modes
819 * @return the list of {@link StateOption} associated to the available film projection modes
821 public List<StateOption> getFilmProjectionStateOptions() {
822 return SonyProjectorFilmProjection.getStateOptions(filmProjectionCategory);
826 * Inform whether the film projection setting is available
828 * @return true if the film projection setting is available
830 public boolean isFilmProjectionAvailable() {
831 return filmProjectionCategory > 0;
835 * Get the film projection mode associated to a name
837 * @param name the name used to identify the film projection mode
839 * @return the film projection mode associated to the searched name
841 * @throws SonyProjectorException - If no film projection mode is associated to the searched name
843 public byte[] getFilmProjectionCodeFromName(String name) throws SonyProjectorException {
844 return SonyProjectorFilmProjection.getFromName(filmProjectionCategory, name).getDataCode();
848 * Get the film projection mode associated to a data code
850 * @param dataCode the data code used to identify the film projection mode
852 * @return the film projection mode associated to the searched data code
854 * @throws SonyProjectorException - If no film projection mode is associated to the searched data code
856 public String getFilmProjectionNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
857 return SonyProjectorFilmProjection.getFromDataCode(filmProjectionCategory, dataCode).getName();
861 * Get the list of {@link StateOption} associated to the available motion enhancer modes
863 * @return the list of {@link StateOption} associated to the available motion enhancer modes
865 public List<StateOption> getMotionEnhancerStateOptions() {
866 return SonyProjectorMotionEnhancer.getStateOptions(motionEnhancerCategory);
870 * Inform whether the motion enhancer setting is available
872 * @return true if the motion enhancer setting is available
874 public boolean isMotionEnhancerAvailable() {
875 return motionEnhancerCategory > 0;
879 * Get the motion enhancer mode associated to a name
881 * @param name the name used to identify the motion enhancer mode
883 * @return the motion enhancer mode associated to the searched name
885 * @throws SonyProjectorException - If no motion enhancer mode is associated to the searched name
887 public byte[] getMotionEnhancerCodeFromName(String name) throws SonyProjectorException {
888 return SonyProjectorMotionEnhancer.getFromName(motionEnhancerCategory, name).getDataCode();
892 * Get the motion enhancer mode associated to a data code
894 * @param dataCode the data code used to identify the motion enhancer mode
896 * @return the motion enhancer mode associated to the searched data code
898 * @throws SonyProjectorException - If no motion enhancer mode is associated to the searched data code
900 public String getMotionEnhancerNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
901 return SonyProjectorMotionEnhancer.getFromDataCode(motionEnhancerCategory, dataCode).getName();
905 * Get the projector model mode associated to a name
907 * @param name the name used to identify the projector model
908 * @param strict true for a strict matching with the searched name
910 * @return the projector model associated to the searched name
912 * @throws SonyProjectorException - If no projector model is associated to the searched name
914 public static SonyProjectorModel getFromName(String name, boolean strict) throws SonyProjectorException {
915 String otherName = lessStrictName(name);
916 for (SonyProjectorModel value : SonyProjectorModel.values()) {
917 if (strict && value.getName().equals(name)) {
919 } else if (!strict && lessStrictName(value.getName()).equals(otherName)) {
923 throw new SonyProjectorException("Invalid model name: " + name);
926 private static String lessStrictName(String name) {
927 // Ignore the ending letters
928 String newName = name;
929 byte[] data = name.getBytes();
930 // Search the first number, starting at right
931 int last = data.length - 1;
932 for (int i = last; i >= 0; i--) {
933 if (((char) data[i]) >= '0' && ((char) data[i]) <= '9') {
938 byte[] newData = Arrays.copyOf(data, last + 1);
939 newName = new String(newData, StandardCharsets.UTF_8);