added migrated 2.x add-ons
Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<features name="org.openhab.binding.powermax-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
|
||||
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>
|
||||
|
||||
<feature name="openhab-binding-sonyprojector" description="Sony Projector Binding" version="${project.version}">
|
||||
<feature>openhab-runtime-base</feature>
|
||||
<feature>openhab-transport-serial</feature>
|
||||
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.sonyprojector/${project.version}</bundle>
|
||||
</feature>
|
||||
</features>
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.core.thing.ThingTypeUID;
|
||||
|
||||
/**
|
||||
* The {@link SonyProjectorBindingConstants} class defines common constants, which are
|
||||
* used across the whole binding.
|
||||
*
|
||||
* @author Markus Wehrle - Initial contribution
|
||||
* @author Laurent Garnier - Added channels and a new thing type
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class SonyProjectorBindingConstants {
|
||||
|
||||
private static final String BINDING_ID = "sonyprojector";
|
||||
|
||||
// List of all Thing Type UIDs
|
||||
public static final ThingTypeUID THING_TYPE_ETHERNET = new ThingTypeUID(BINDING_ID, "ethernetconnection");
|
||||
public static final ThingTypeUID THING_TYPE_SERIAL = new ThingTypeUID(BINDING_ID, "serialconnection");
|
||||
public static final ThingTypeUID THING_TYPE_SERIAL_OVER_IP = new ThingTypeUID(BINDING_ID, "serialoveripconnection");
|
||||
|
||||
// List of all Channel ids
|
||||
public static final String CHANNEL_POWER = "power";
|
||||
public static final String CHANNEL_POWERSTATE = "powerstate";
|
||||
public static final String CHANNEL_INPUT = "input";
|
||||
public static final String CHANNEL_CALIBRATION_PRESET = "calibrationpreset";
|
||||
public static final String CHANNEL_CONTRAST = "contrast";
|
||||
public static final String CHANNEL_BRIGHTNESS = "brightness";
|
||||
public static final String CHANNEL_COLOR = "color";
|
||||
public static final String CHANNEL_HUE = "hue";
|
||||
public static final String CHANNEL_SHARPNESS = "sharpness";
|
||||
public static final String CHANNEL_COLOR_TEMP = "colortemperature";
|
||||
public static final String CHANNEL_IRIS_MODE = "irismode";
|
||||
public static final String CHANNEL_IRIS_MANUAL = "irismanual";
|
||||
public static final String CHANNEL_IRIS_SENSITIVITY = "irissensitivity";
|
||||
public static final String CHANNEL_LAMP_CONTROL = "lampcontrol";
|
||||
public static final String CHANNEL_FILM_PROJECTION = "filmprojection";
|
||||
public static final String CHANNEL_MOTION_ENHANCER = "motionenhancer";
|
||||
public static final String CHANNEL_CONTRAST_ENHANCER = "contrastenhancer";
|
||||
public static final String CHANNEL_FILM_MODE = "filmmode";
|
||||
public static final String CHANNEL_GAMMA_CORRECTION = "gammacorrection";
|
||||
public static final String CHANNEL_COLOR_SPACE = "colorspace";
|
||||
public static final String CHANNEL_NR = "nr";
|
||||
public static final String CHANNEL_BLOCK_NR = "blocknr";
|
||||
public static final String CHANNEL_MOSQUITO_NR = "mosquitonr";
|
||||
public static final String CHANNEL_MPEG_NR = "mpegnr";
|
||||
public static final String CHANNEL_XVCOLOR = "xvcolor";
|
||||
public static final String CHANNEL_PICTURE_MUTING = "picturemuting";
|
||||
public static final String CHANNEL_ASPECT = "aspect";
|
||||
public static final String CHANNEL_OVERSCAN = "overscan";
|
||||
public static final String CHANNEL_PICTURE_POSITION = "pictureposition";
|
||||
public static final String CHANNEL_LAMP_USE_TIME = "lampusetime";
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
||||
/**
|
||||
* The {@link SonyProjectorException} class is used for any exception thrown by the binding
|
||||
*
|
||||
* @author Markus Wehrle - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class SonyProjectorException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// Parameterless Constructor
|
||||
public SonyProjectorException() {
|
||||
}
|
||||
|
||||
// Constructor that accepts a message
|
||||
public SonyProjectorException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal;
|
||||
|
||||
import static org.openhab.binding.sonyprojector.internal.SonyProjectorBindingConstants.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.handler.SonyProjectorHandler;
|
||||
import org.openhab.core.io.transport.serial.SerialPortManager;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingTypeUID;
|
||||
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
|
||||
import org.openhab.core.thing.binding.ThingHandler;
|
||||
import org.openhab.core.thing.binding.ThingHandlerFactory;
|
||||
import org.osgi.service.component.annotations.Activate;
|
||||
import org.osgi.service.component.annotations.Component;
|
||||
import org.osgi.service.component.annotations.Reference;
|
||||
|
||||
/**
|
||||
* The {@link SonyProjectorHandlerFactory} is responsible for creating things and thing
|
||||
* handlers.
|
||||
*
|
||||
* @author Markus Wehrle - Initial contribution
|
||||
* @author Laurent Garnier - Support for serialconnection thing type + new StateDescriptionOptionProvider
|
||||
*/
|
||||
@NonNullByDefault
|
||||
@Component(configurationPid = "binding.sonyprojector", service = ThingHandlerFactory.class)
|
||||
public class SonyProjectorHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.unmodifiableSet(
|
||||
Stream.of(THING_TYPE_ETHERNET, THING_TYPE_SERIAL, THING_TYPE_SERIAL_OVER_IP).collect(Collectors.toSet()));
|
||||
|
||||
private final SerialPortManager serialPortManager;
|
||||
|
||||
private final SonyProjectorStateDescriptionOptionProvider stateDescriptionProvider;
|
||||
|
||||
@Activate
|
||||
public SonyProjectorHandlerFactory(final @Reference SerialPortManager serialPortManager,
|
||||
final @Reference SonyProjectorStateDescriptionOptionProvider stateDescriptionProvider) {
|
||||
this.serialPortManager = serialPortManager;
|
||||
this.stateDescriptionProvider = stateDescriptionProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
|
||||
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable ThingHandler createHandler(Thing thing) {
|
||||
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
|
||||
|
||||
if (SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID)) {
|
||||
return new SonyProjectorHandler(thing, stateDescriptionProvider, serialPortManager);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,914 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorAspect;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorBlockNr;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorCalibrationPreset;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorColorSpace;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorColorTemp;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorContrastEnhancer;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorFilmMode;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorFilmProjection;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorGammaCorrection;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorInput;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorIrisMode;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorIrisSensitivity;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorLampControl;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorMosquitoNr;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorMotionEnhancer;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorMpegNr;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorNr;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorPicturePosition;
|
||||
import org.openhab.core.types.StateOption;
|
||||
|
||||
/**
|
||||
* Represents the different supported projector models
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorModel {
|
||||
|
||||
// HW models
|
||||
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
HW45ES("VPL-HW45ES", false, 1, 1, 1, 1, true, 0, false, 6, 6, 0, false, false, 6, 2, false, false, 2, true, 6, 0,
|
||||
1),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
|
||||
// VW models
|
||||
|
||||
// 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),
|
||||
// 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),
|
||||
// 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),
|
||||
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
|
||||
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),
|
||||
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
// VW360("VPL-VW360ES", false, 2, 4, 2, 3, true, 0, true, 1, 1, 1, true, false, 1, 2, false, false, 1, true, 1, 0,
|
||||
// 1),
|
||||
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),
|
||||
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),
|
||||
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
// VW685("VPL-VW685ES", true, 1, 1, 1, 1, true, 1, false, 1, 1, 1, true, false, 1, 1, false, false, 1, true, 2, 0,
|
||||
// 1),
|
||||
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),
|
||||
|
||||
VW760("VPL-VW760ES", true, 1, 1, 1, 1, false, 1, false, 1, 1, 1, false, false, 1, 1, false, false, 1, true, 2, 0,
|
||||
1),
|
||||
|
||||
VW870("VPL-VW870ES", true, 1, 1, 1, 1, false, 1, false, 1, 1, 1, false, false, 1, 1, false, false, 1, true, 2, 0,
|
||||
1),
|
||||
VW885("VPL-VW885ES", true, 1, 1, 1, 1, false, 1, false, 1, 1, 1, false, false, 1, 1, false, false, 1, true, 2, 0,
|
||||
1),
|
||||
|
||||
VW995("VPL-VW995ES", true, 1, 1, 1, 1, false, 1, false, 1, 1, 1, false, false, 1, 1, false, false, 1, true, 2, 0,
|
||||
1),
|
||||
|
||||
VW1000ES("VPL-VW1000ES", false, 5, 3, 1, 2, true, 1, true, 1, 5, 5, true, false, 1, 2, false, false, 2, true, 5, 3,
|
||||
2),
|
||||
VW1100ES("VPL-VW1100ES", false, 5, 3, 1, 2, true, 1, true, 1, 5, 5, true, false, 1, 2, false, false, 2, true, 5, 3,
|
||||
2);
|
||||
|
||||
// VW5000ES("VPL-VW5000ES", false, 5, 3, 1, 2, true, 0, true, 1, 5, 5, true, false, 1, 2, false, false, 2, true, 5,
|
||||
// 3, 2);
|
||||
|
||||
private String name;
|
||||
private boolean powerCmdAvailable;
|
||||
private int calibrPresetsCategory;
|
||||
private int inputCategory;
|
||||
private int contrastEnhancerCategory;
|
||||
private int filmModeCategory;
|
||||
private boolean lampControlAvailable;
|
||||
private int picturePositionCategory;
|
||||
private boolean overscanAvailable;
|
||||
private int aspectCategory;
|
||||
private int colorTempCategory;
|
||||
private int irisModeCategory;
|
||||
private boolean irisManualAvailable;
|
||||
private boolean irisSensitivityAvailable;
|
||||
private int gammaCorrectionCategory;
|
||||
private int nrCategory;
|
||||
private boolean blockNrAvailable;
|
||||
private boolean mosquitoNrAvailable;
|
||||
private int mpegNrCategory;
|
||||
private boolean xvColorAvailable;
|
||||
private int colorSpaceCategory;
|
||||
private int filmProjectionCategory;
|
||||
private int motionEnhancerCategory;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param name the model name
|
||||
* @param powerCmdAvailable true if the POWER command is available
|
||||
* @param calibrPresetsCategory the category from {@link SonyProjectorCalibrationPreset}
|
||||
* @param inputCategory the category from {@link SonyProjectorInput}
|
||||
* @param contrastEnhancerCategory the category from {@link SonyProjectorContrastEnhancer}
|
||||
* @param filmModeCategory the category from {@link SonyProjectorFilmMode}
|
||||
* @param lampControlAvailable true if the lamp control setting is available
|
||||
* @param picturePositionCategory the category from {@link SonyProjectorPicturePosition}
|
||||
* @param overscanAvailable true if the overscan setting is available
|
||||
* @param aspectCategory the category from {@link SonyProjectorAspect}
|
||||
* @param colorTempCategory the category from {@link SonyProjectorColorTemp}
|
||||
* @param irisModeCategory the category from {@link SonyProjectorIrisMode}
|
||||
* @param irisManualAvailable true if the iris manual setting is available
|
||||
* @param irisSensitivityAvailable true if the iris sensitivity setting is available
|
||||
* @param gammaCorrectionCategory the category from {@link SonyProjectorGammaCorrection}
|
||||
* @param nrCategory the category from {@link SonyProjectorNr}
|
||||
* @param blockNrAvailable true if the block noise reduction setting is available
|
||||
* @param mosquitoNrAvailable true if the mosquito noise reduction setting is available
|
||||
* @param mpegNrCategory the category from {@link SonyProjectorMpegNr}
|
||||
* @param xvColorAvailable true if the xvColor setting is available
|
||||
* @param colorSpaceCategory the category from {@link SonyProjectorColorSpace}
|
||||
* @param filmProjectionCategory the category from {@link SonyProjectorFilmProjection}
|
||||
* @param motionEnhancerCategory the category from {@link SonyProjectorMotionEnhancer}
|
||||
*/
|
||||
private SonyProjectorModel(String name, boolean powerCmdAvailable, int calibrPresetsCategory, int inputCategory,
|
||||
int contrastEnhancerCategory, int filmModeCategory, boolean lampControlAvailable,
|
||||
int picturePositionCategory, boolean overscanAvailable, int aspectCategory, int colorTempCategory,
|
||||
int irisModeCategory, boolean irisManualAvailable, boolean irisSensitivityAvailable,
|
||||
int gammaCorrectionCategory, int nrCategory, boolean blockNrAvailable, boolean mosquitoNrAvailable,
|
||||
int mpegNrCategory, boolean xvColorAvailable, int colorSpaceCategory, int filmProjectionCategory,
|
||||
int motionEnhancerCategory) {
|
||||
this.name = name;
|
||||
this.powerCmdAvailable = powerCmdAvailable;
|
||||
this.calibrPresetsCategory = calibrPresetsCategory;
|
||||
this.inputCategory = inputCategory;
|
||||
this.contrastEnhancerCategory = contrastEnhancerCategory;
|
||||
this.filmModeCategory = filmModeCategory;
|
||||
this.lampControlAvailable = lampControlAvailable;
|
||||
this.picturePositionCategory = picturePositionCategory;
|
||||
this.overscanAvailable = overscanAvailable;
|
||||
this.aspectCategory = aspectCategory;
|
||||
this.colorTempCategory = colorTempCategory;
|
||||
this.irisModeCategory = irisModeCategory;
|
||||
this.irisManualAvailable = irisManualAvailable;
|
||||
this.irisSensitivityAvailable = irisSensitivityAvailable;
|
||||
this.gammaCorrectionCategory = gammaCorrectionCategory;
|
||||
this.nrCategory = nrCategory;
|
||||
this.blockNrAvailable = blockNrAvailable;
|
||||
this.mosquitoNrAvailable = mosquitoNrAvailable;
|
||||
this.mpegNrCategory = mpegNrCategory;
|
||||
this.xvColorAvailable = xvColorAvailable;
|
||||
this.colorSpaceCategory = colorSpaceCategory;
|
||||
this.filmProjectionCategory = filmProjectionCategory;
|
||||
this.motionEnhancerCategory = motionEnhancerCategory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the model name
|
||||
*
|
||||
* @return the model name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform whether the POWER command is available
|
||||
*
|
||||
* @return true if the POWER command is available
|
||||
*/
|
||||
public boolean isPowerCmdAvailable() {
|
||||
return powerCmdAvailable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available calibration presets
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available calibration presets
|
||||
*/
|
||||
public List<StateOption> getCalibrPresetStateOptions() {
|
||||
return SonyProjectorCalibrationPreset.getStateOptions(calibrPresetsCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the calibration preset associated to a name
|
||||
*
|
||||
* @param name the name used to identify the calibration preset
|
||||
*
|
||||
* @return the calibration preset associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no calibration preset is associated to the searched name
|
||||
*/
|
||||
public byte[] getCalibrPresetDataCodeFromName(String name) throws SonyProjectorException {
|
||||
return SonyProjectorCalibrationPreset.getFromName(calibrPresetsCategory, name).getDataCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the calibration preset associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the calibration preset
|
||||
*
|
||||
* @return the calibration preset associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no calibration preset is associated to the searched data code
|
||||
*/
|
||||
public String getCalibrPresetNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
return SonyProjectorCalibrationPreset.getFromDataCode(calibrPresetsCategory, dataCode).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available video inputs
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available video inputs
|
||||
*/
|
||||
public List<StateOption> getInputStateOptions() {
|
||||
return SonyProjectorInput.getStateOptions(inputCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the video input associated to a name
|
||||
*
|
||||
* @param name the name used to identify the video input
|
||||
*
|
||||
* @return the video input associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no video input is associated to the searched name
|
||||
*/
|
||||
public byte[] getInputDataCodeFromName(String name) throws SonyProjectorException {
|
||||
return SonyProjectorInput.getFromName(inputCategory, name).getDataCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the video input associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the video input
|
||||
*
|
||||
* @return the video input associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no video input is associated to the searched data code
|
||||
*/
|
||||
public String getInputNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
return SonyProjectorInput.getFromDataCode(inputCategory, dataCode).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available contrast enhancer modes
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available contrast enhancer modes
|
||||
*/
|
||||
public List<StateOption> getContrastEnhancerStateOptions() {
|
||||
return SonyProjectorContrastEnhancer.getStateOptions(contrastEnhancerCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the contrast enhancer mode associated to a name
|
||||
*
|
||||
* @param name the name used to identify the contrast enhancer mode
|
||||
*
|
||||
* @return the contrast enhancer mode associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no contrast enhancer mode is associated to the searched name
|
||||
*/
|
||||
public byte[] getContrastEnhancerDataCodeFromName(String name) throws SonyProjectorException {
|
||||
return SonyProjectorContrastEnhancer.getFromName(contrastEnhancerCategory, name).getDataCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the contrast enhancer mode associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the contrast enhancer mode
|
||||
*
|
||||
* @return the contrast enhancer mode associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no contrast enhancer mode is associated to the searched data code
|
||||
*/
|
||||
public String getContrastEnhancerNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
return SonyProjectorContrastEnhancer.getFromDataCode(contrastEnhancerCategory, dataCode).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available film modes
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available film modes
|
||||
*/
|
||||
public List<StateOption> getFilmModeStateOptions() {
|
||||
return SonyProjectorFilmMode.getStateOptions(filmModeCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform whether the film mode setting is available
|
||||
*
|
||||
* @return true if the film mode setting is available
|
||||
*/
|
||||
public boolean isFilmModeAvailable() {
|
||||
return filmModeCategory > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the film mode associated to a name
|
||||
*
|
||||
* @param name the name used to identify the film mode
|
||||
*
|
||||
* @return the film mode associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no film mode is associated to the searched name
|
||||
*/
|
||||
public byte[] getFilmModeDataCodeFromName(String name) throws SonyProjectorException {
|
||||
return SonyProjectorFilmMode.getFromName(filmModeCategory, name).getDataCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the film mode associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the film mode
|
||||
*
|
||||
* @return the film mode associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no film mode is associated to the searched data code
|
||||
*/
|
||||
public String getFilmModeNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
return SonyProjectorFilmMode.getFromDataCode(filmModeCategory, dataCode).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available lamp control modes
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available lamp control modes
|
||||
*/
|
||||
public List<StateOption> getLampControlStateOptions() {
|
||||
return lampControlAvailable ? SonyProjectorLampControl.getStateOptions() : new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform whether the lamp control setting is available
|
||||
*
|
||||
* @return true if the lamp control setting is available
|
||||
*/
|
||||
public boolean isLampControlAvailable() {
|
||||
return lampControlAvailable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available picture positions
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available picture positions
|
||||
*/
|
||||
public List<StateOption> getPicturePositionStateOptions() {
|
||||
return SonyProjectorPicturePosition.getStateOptions(picturePositionCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform whether the picture position setting is available
|
||||
*
|
||||
* @return true if the picture position setting is available
|
||||
*/
|
||||
public boolean isPicturePositionAvailable() {
|
||||
return picturePositionCategory > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the picture position associated to a name
|
||||
*
|
||||
* @param name the name used to identify the picture position
|
||||
*
|
||||
* @return the picture position associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no picture position is associated to the searched name
|
||||
*/
|
||||
public byte[] getPicturePositionCodeFromName(String name) throws SonyProjectorException {
|
||||
return SonyProjectorPicturePosition.getFromName(picturePositionCategory, name).getDataCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the picture position associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the picture position
|
||||
*
|
||||
* @return the picture position associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no picture position is associated to the searched data code
|
||||
*/
|
||||
public String getPicturePositionNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
return SonyProjectorPicturePosition.getFromDataCode(picturePositionCategory, dataCode).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available aspect modes
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available aspect modes
|
||||
*/
|
||||
public List<StateOption> getAspectStateOptions() {
|
||||
return SonyProjectorAspect.getStateOptions(aspectCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the aspect mode associated to a name
|
||||
*
|
||||
* @param name the name used to identify the aspect mode
|
||||
*
|
||||
* @return the aspect mode associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no aspect mode is associated to the searched name
|
||||
*/
|
||||
public byte[] getAspectCodeFromName(String name) throws SonyProjectorException {
|
||||
return SonyProjectorAspect.getFromName(aspectCategory, name).getDataCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the aspect mode associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the aspect mode
|
||||
*
|
||||
* @return the aspect mode associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no aspect mode is associated to the searched data code
|
||||
*/
|
||||
public String getAspectNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
return SonyProjectorAspect.getFromDataCode(aspectCategory, dataCode).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available color temperatures
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available color temperatures
|
||||
*/
|
||||
public List<StateOption> getColorTempStateOptions() {
|
||||
return SonyProjectorColorTemp.getStateOptions(colorTempCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color temperature associated to a name
|
||||
*
|
||||
* @param name the name used to identify the color temperature
|
||||
*
|
||||
* @return the color temperature associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no color temperature is associated to the searched name
|
||||
*/
|
||||
public byte[] getColorTempCodeFromName(String name) throws SonyProjectorException {
|
||||
return SonyProjectorColorTemp.getFromName(colorTempCategory, name).getDataCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color temperature associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the color temperature
|
||||
*
|
||||
* @return the color temperature associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no color temperature is associated to the searched data code
|
||||
*/
|
||||
public String getColorTempNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
return SonyProjectorColorTemp.getFromDataCode(colorTempCategory, dataCode).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available iris modes
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available iris modes
|
||||
*/
|
||||
public List<StateOption> getIrisModeStateOptions() {
|
||||
return SonyProjectorIrisMode.getStateOptions(irisModeCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform whether the iris mode setting is available
|
||||
*
|
||||
* @return true if the iris mode setting is available
|
||||
*/
|
||||
public boolean isIrisModeAvailable() {
|
||||
return irisModeCategory > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the iris mode associated to a name
|
||||
*
|
||||
* @param name the name used to identify the iris mode
|
||||
*
|
||||
* @return the iris mode associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no iris mode is associated to the searched name
|
||||
*/
|
||||
public byte[] getIrisModeCodeFromName(String name) throws SonyProjectorException {
|
||||
return SonyProjectorIrisMode.getFromName(irisModeCategory, name).getDataCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the iris mode associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the iris mode
|
||||
*
|
||||
* @return the iris mode associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no iris mode is associated to the searched data code
|
||||
*/
|
||||
public String getIrisModeNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
return SonyProjectorIrisMode.getFromDataCode(irisModeCategory, dataCode).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform whether the overscan setting is available
|
||||
*
|
||||
* @return true if the overscan setting is available
|
||||
*/
|
||||
public boolean isOverscanAvailable() {
|
||||
return overscanAvailable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform whether the iris manual setting is available
|
||||
*
|
||||
* @return true if the iris manual setting is available
|
||||
*/
|
||||
public boolean isIrisManualAvailable() {
|
||||
return irisManualAvailable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available iris sensitivities
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available iris sensitivities
|
||||
*/
|
||||
public List<StateOption> getIrisSensitivityStateOptions() {
|
||||
return irisSensitivityAvailable ? SonyProjectorIrisSensitivity.getStateOptions() : new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform whether the iris sensitivity setting is available
|
||||
*
|
||||
* @return true if the iris sensitivity setting is available
|
||||
*/
|
||||
public boolean isIrisSensitivityAvailable() {
|
||||
return irisSensitivityAvailable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available gamma corrections
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available gamma corrections
|
||||
*/
|
||||
public List<StateOption> getGammaCorrectionStateOptions() {
|
||||
return SonyProjectorGammaCorrection.getStateOptions(gammaCorrectionCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the gamma correction associated to a name
|
||||
*
|
||||
* @param name the name used to identify the gamma correction
|
||||
*
|
||||
* @return the gamma correction associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no gamma correction is associated to the searched name
|
||||
*/
|
||||
public byte[] getGammaCorrectionCodeFromName(String name) throws SonyProjectorException {
|
||||
return SonyProjectorGammaCorrection.getFromName(gammaCorrectionCategory, name).getDataCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the gamma correction associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the gamma correction
|
||||
*
|
||||
* @return the gamma correction associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no gamma correction is associated to the searched data code
|
||||
*/
|
||||
public String getGammaCorrectionNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
return SonyProjectorGammaCorrection.getFromDataCode(gammaCorrectionCategory, dataCode).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available nose reduction modes
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available nose reduction modes
|
||||
*/
|
||||
public List<StateOption> getNrStateOptions() {
|
||||
return SonyProjectorNr.getStateOptions(nrCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the noise reduction mode associated to a name
|
||||
*
|
||||
* @param name the name used to identify the noise reduction mode
|
||||
*
|
||||
* @return the noise reduction mode associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no noise reduction mode is associated to the searched name
|
||||
*/
|
||||
public byte[] getNrCodeFromName(String name) throws SonyProjectorException {
|
||||
return SonyProjectorNr.getFromName(nrCategory, name).getDataCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the noise reduction mode associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the noise reduction mode
|
||||
*
|
||||
* @return the noise reduction mode associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no noise reduction mode is associated to the searched data code
|
||||
*/
|
||||
public String getNrNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
return SonyProjectorNr.getFromDataCode(nrCategory, dataCode).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available block nose reduction modes
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available block nose reduction modes
|
||||
*/
|
||||
public List<StateOption> getBlockNrStateOptions() {
|
||||
return blockNrAvailable ? SonyProjectorBlockNr.getStateOptions() : new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform whether the block noise reduction setting is available
|
||||
*
|
||||
* @return true if the block noise reduction setting is available
|
||||
*/
|
||||
public boolean isBlockNrAvailable() {
|
||||
return blockNrAvailable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available mosquito nose reduction modes
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available mosquito nose reduction modes
|
||||
*/
|
||||
public List<StateOption> getMosquitoNrStateOptions() {
|
||||
return mosquitoNrAvailable ? SonyProjectorMosquitoNr.getStateOptions() : new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform whether the mosquito noise reduction setting is available
|
||||
*
|
||||
* @return true if the mosquito noise reduction setting is available
|
||||
*/
|
||||
public boolean isMosquitoNrAvailable() {
|
||||
return mosquitoNrAvailable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available MPEG nose reduction modes
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available MPEG nose reduction modes
|
||||
*/
|
||||
public List<StateOption> getMpegNrStateOptions() {
|
||||
return SonyProjectorMpegNr.getStateOptions(mpegNrCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform whether the MPEG noise reduction setting is available
|
||||
*
|
||||
* @return true if the MPEG noise reduction setting is available
|
||||
*/
|
||||
public boolean isMpegNrAvailable() {
|
||||
return mpegNrCategory > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MPEG noise reduction mode associated to a name
|
||||
*
|
||||
* @param name the name used to identify the MPEG noise reduction mode
|
||||
*
|
||||
* @return the MPEG noise reduction mode associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no MPEG noise reduction mode is associated to the searched name
|
||||
*/
|
||||
public byte[] getMpegNrCodeFromName(String name) throws SonyProjectorException {
|
||||
return SonyProjectorMpegNr.getFromName(mpegNrCategory, name).getDataCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MPEG noise reduction mode associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the MPEG noise reduction mode
|
||||
*
|
||||
* @return the MPEG noise reduction mode associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no MPEG noise reduction mode is associated to the searched data code
|
||||
*/
|
||||
public String getMpegNrNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
return SonyProjectorMpegNr.getFromDataCode(mpegNrCategory, dataCode).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform whether the xvColor setting is available
|
||||
*
|
||||
* @return true if the xvColor setting is available
|
||||
*/
|
||||
public boolean isXvColorAvailable() {
|
||||
return xvColorAvailable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available color spaces
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available color spaces
|
||||
*/
|
||||
public List<StateOption> getColorSpaceStateOptions() {
|
||||
return SonyProjectorColorSpace.getStateOptions(colorSpaceCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color space associated to a name
|
||||
*
|
||||
* @param name the name used to identify the color space
|
||||
*
|
||||
* @return the color space associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no color space is associated to the searched name
|
||||
*/
|
||||
public byte[] getColorSpaceCodeFromName(String name) throws SonyProjectorException {
|
||||
return SonyProjectorColorSpace.getFromName(colorSpaceCategory, name).getDataCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color space associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the color space
|
||||
*
|
||||
* @return the color space associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no color space is associated to the searched data code
|
||||
*/
|
||||
public String getColorSpaceNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
return SonyProjectorColorSpace.getFromDataCode(colorSpaceCategory, dataCode).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available film projection modes
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available film projection modes
|
||||
*/
|
||||
public List<StateOption> getFilmProjectionStateOptions() {
|
||||
return SonyProjectorFilmProjection.getStateOptions(filmProjectionCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform whether the film projection setting is available
|
||||
*
|
||||
* @return true if the film projection setting is available
|
||||
*/
|
||||
public boolean isFilmProjectionAvailable() {
|
||||
return filmProjectionCategory > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the film projection mode associated to a name
|
||||
*
|
||||
* @param name the name used to identify the film projection mode
|
||||
*
|
||||
* @return the film projection mode associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no film projection mode is associated to the searched name
|
||||
*/
|
||||
public byte[] getFilmProjectionCodeFromName(String name) throws SonyProjectorException {
|
||||
return SonyProjectorFilmProjection.getFromName(filmProjectionCategory, name).getDataCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the film projection mode associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the film projection mode
|
||||
*
|
||||
* @return the film projection mode associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no film projection mode is associated to the searched data code
|
||||
*/
|
||||
public String getFilmProjectionNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
return SonyProjectorFilmProjection.getFromDataCode(filmProjectionCategory, dataCode).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available motion enhancer modes
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available motion enhancer modes
|
||||
*/
|
||||
public List<StateOption> getMotionEnhancerStateOptions() {
|
||||
return SonyProjectorMotionEnhancer.getStateOptions(motionEnhancerCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform whether the motion enhancer setting is available
|
||||
*
|
||||
* @return true if the motion enhancer setting is available
|
||||
*/
|
||||
public boolean isMotionEnhancerAvailable() {
|
||||
return motionEnhancerCategory > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the motion enhancer mode associated to a name
|
||||
*
|
||||
* @param name the name used to identify the motion enhancer mode
|
||||
*
|
||||
* @return the motion enhancer mode associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no motion enhancer mode is associated to the searched name
|
||||
*/
|
||||
public byte[] getMotionEnhancerCodeFromName(String name) throws SonyProjectorException {
|
||||
return SonyProjectorMotionEnhancer.getFromName(motionEnhancerCategory, name).getDataCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the motion enhancer mode associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the motion enhancer mode
|
||||
*
|
||||
* @return the motion enhancer mode associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no motion enhancer mode is associated to the searched data code
|
||||
*/
|
||||
public String getMotionEnhancerNameFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
return SonyProjectorMotionEnhancer.getFromDataCode(motionEnhancerCategory, dataCode).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the projector model mode associated to a name
|
||||
*
|
||||
* @param name the name used to identify the projector model
|
||||
* @param strict true for a strict matching with the searched name
|
||||
*
|
||||
* @return the projector model associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no projector model is associated to the searched name
|
||||
*/
|
||||
public static SonyProjectorModel getFromName(String name, boolean strict) throws SonyProjectorException {
|
||||
String otherName = lessStrictName(name);
|
||||
for (SonyProjectorModel value : SonyProjectorModel.values()) {
|
||||
if (strict && value.getName().equals(name)) {
|
||||
return value;
|
||||
} else if (!strict && lessStrictName(value.getName()).equals(otherName)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid model name: " + name);
|
||||
}
|
||||
|
||||
private static String lessStrictName(String name) {
|
||||
// Ignore the ending letters
|
||||
String newName = name;
|
||||
byte[] data = name.getBytes();
|
||||
// Search the first number, starting at right
|
||||
int last = data.length - 1;
|
||||
for (int i = last; i >= 0; i--) {
|
||||
if (((char) data[i]) >= '0' && ((char) data[i]) <= '9') {
|
||||
last = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
byte[] newData = Arrays.copyOf(data, last + 1);
|
||||
newName = new String(newData, StandardCharsets.UTF_8);
|
||||
return newName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.core.thing.binding.BaseDynamicStateDescriptionProvider;
|
||||
import org.openhab.core.thing.i18n.ChannelTypeI18nLocalizationService;
|
||||
import org.openhab.core.thing.type.DynamicStateDescriptionProvider;
|
||||
import org.osgi.service.component.annotations.Component;
|
||||
import org.osgi.service.component.annotations.Reference;
|
||||
|
||||
/**
|
||||
* Dynamic provider of state options while leaving other state description fields as original.
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@Component(service = { DynamicStateDescriptionProvider.class, SonyProjectorStateDescriptionOptionProvider.class })
|
||||
@NonNullByDefault
|
||||
public class SonyProjectorStateDescriptionOptionProvider extends BaseDynamicStateDescriptionProvider {
|
||||
|
||||
@Reference
|
||||
protected void setChannelTypeI18nLocalizationService(
|
||||
final ChannelTypeI18nLocalizationService channelTypeI18nLocalizationService) {
|
||||
this.channelTypeI18nLocalizationService = channelTypeI18nLocalizationService;
|
||||
}
|
||||
|
||||
protected void unsetChannelTypeI18nLocalizationService(
|
||||
final ChannelTypeI18nLocalizationService channelTypeI18nLocalizationService) {
|
||||
this.channelTypeI18nLocalizationService = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different aspect modes available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorAspect {
|
||||
|
||||
// Category 1: VW260, VW270, VW285, VW295, VW300, VW315, VW320, VW328, VW350, VW365, VW385, VW500, VW515, VW520,
|
||||
// VW528, VW550, VW570, VW600, VW665, VW675, VW695, VW760, VW885
|
||||
CAT1_NORMAL(1, "Normal", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT1_V_STRETCH(1, "VStretch", "V Stretch", new byte[] { 0x00, 0x0B }),
|
||||
CAT1_185(1, "185", "1.85:1 Zoom", new byte[] { 0x00, 0x0C }),
|
||||
CAT1_235(1, "235", "2.35:1 Zoom", new byte[] { 0x00, 0x0D }),
|
||||
CAT1_STRETCH(1, "Stretch", null, new byte[] { 0x00, 0x0E }),
|
||||
CAT1_SQUEEZE(1, "Squeeze", null, new byte[] { 0x00, 0x0F }),
|
||||
|
||||
// Category 2: VW40, VW50, HW10, HW15, HW20, HW30
|
||||
CAT2_FULL(2, "Full", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT2_NORMAL(2, "Normal", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT2_WIDE(2, "WideZoom", "Wide Zoom", new byte[] { 0x00, 0x02 }),
|
||||
CAT2_ZOOM(2, "Zoom", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT2_FULL1(2, "Full1", "Full 1", new byte[] { 0x00, 0x07 }),
|
||||
CAT2_FULL2(2, "Full2", "Full 2", new byte[] { 0x00, 0x08 }),
|
||||
|
||||
// Category 3: VW60, VW70, VW80, VW85, VW90, VW95, VW200
|
||||
CAT3_FULL(3, "Full", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT3_NORMAL(3, "Normal", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT3_WIDE(3, "WideZoom", "Wide Zoom", new byte[] { 0x00, 0x02 }),
|
||||
CAT3_ZOOM(3, "Zoom", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT3_FULL1(3, "Full1", "Full 1", new byte[] { 0x00, 0x07 }),
|
||||
CAT3_FULL2(3, "Full2", "Full 2", new byte[] { 0x00, 0x08 }),
|
||||
CAT3_ANAMORPHIC(3, "Anamorphic", null, new byte[] { 0x00, 0x0B }),
|
||||
|
||||
// Category 4: VW100
|
||||
CAT4_FULL(4, "Full", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT4_NORMAL(4, "Normal", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT4_WIDE(4, "WideZoom", "Wide Zoom", new byte[] { 0x00, 0x02 }),
|
||||
CAT4_ZOOM(4, "Zoom", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT3_SUBTITLE(4, "Subtitle", null, new byte[] { 0x00, 0x04 }),
|
||||
|
||||
// Category 5: HW40ES, HW50ES, HW55ES, HW58ES
|
||||
CAT5_FULL(5, "Full", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT5_NORMAL(5, "Normal", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT5_WIDE(5, "WideZoom", "Wide Zoom", new byte[] { 0x00, 0x02 }),
|
||||
CAT5_ZOOM(5, "Zoom", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT5_V_STRETCH(5, "VStretch", "V Stretch", new byte[] { 0x00, 0x0B }),
|
||||
CAT5_STRETCH(5, "Stretch", null, new byte[] { 0x00, 0x0E }),
|
||||
CAT5_SQUEEZE(5, "Squeeze", null, new byte[] { 0x00, 0x0F }),
|
||||
|
||||
// Category 6: HW45ES, HW60, HW65, HW68
|
||||
CAT6_NORMAL(6, "Normal", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT6_V_STRETCH(6, "VStretch", "V Stretch", new byte[] { 0x00, 0x0B }),
|
||||
CAT6_STRETCH(6, "Stretch", null, new byte[] { 0x00, 0x0E }),
|
||||
CAT6_SQUEEZE(6, "Squeeze", null, new byte[] { 0x00, 0x0F });
|
||||
|
||||
private int category;
|
||||
private String name;
|
||||
private @Nullable String label;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param category a category of projector models for which the aspect mode is available
|
||||
* @param name the name of the aspect mode
|
||||
* @param label the label of the aspect mode; can be null when the label is identical to the name
|
||||
* @param dataCode the data code identifying the aspect mode
|
||||
*/
|
||||
private SonyProjectorAspect(int category, String name, @Nullable String label, byte[] dataCode) {
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of projector models for the current aspect mode
|
||||
*
|
||||
* @return the category of projector models
|
||||
*/
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current aspect mode
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label of the current aspect mode
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public @Nullable String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current aspect mode
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available aspect modes for a particular category of
|
||||
* projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available aspect modes for a provided category of
|
||||
* projector models
|
||||
*/
|
||||
public static List<StateOption> getStateOptions(int category) {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorAspect value : SonyProjectorAspect.values()) {
|
||||
if (value.getCategory() == category) {
|
||||
options.add(new StateOption(value.getName(),
|
||||
value.getLabel() != null ? value.getLabel() : value.getName()));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the aspect mode associated to a name for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param name the name used to identify the aspect mode
|
||||
*
|
||||
* @return the aspect mode associated to the searched name for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no aspect mode is associated to the searched name for the provided category
|
||||
*/
|
||||
public static SonyProjectorAspect getFromName(int category, String name) throws SonyProjectorException {
|
||||
for (SonyProjectorAspect value : SonyProjectorAspect.values()) {
|
||||
if (value.getCategory() == category && value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for an aspect mode: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the aspect mode associated to a data code for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param dataCode the data code used to identify the aspect mode
|
||||
*
|
||||
* @return the aspect mode associated to the searched data code for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no aspect mode is associated to the searched data code for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorAspect getFromDataCode(int category, byte[] dataCode) throws SonyProjectorException {
|
||||
for (SonyProjectorAspect value : SonyProjectorAspect.values()) {
|
||||
if (value.getCategory() == category && Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid data code for an aspect mode: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different block noise reduction modes available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorBlockNr {
|
||||
|
||||
HIGH("High", new byte[] { 0x00, 0x03 }),
|
||||
MIDDLE("Middle", new byte[] { 0x00, 0x02 }),
|
||||
LOW("Low", new byte[] { 0x00, 0x01 }),
|
||||
OFF("Off", new byte[] { 0x00, 0x00 });
|
||||
|
||||
private String name;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param name the name of the block noise reduction mode
|
||||
* @param dataCode the data code identifying the block noise reduction mode
|
||||
*/
|
||||
private SonyProjectorBlockNr(String name, byte[] dataCode) {
|
||||
this.name = name;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current block noise reduction mode
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current block noise reduction mode
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available block noise reduction modes
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available block noise reduction modes
|
||||
*/
|
||||
public static List<StateOption> getStateOptions() {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorBlockNr value : SonyProjectorBlockNr.values()) {
|
||||
options.add(new StateOption(value.getName(), value.getName()));
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the block noise reduction mode associated to a name
|
||||
*
|
||||
* @param name the name used to identify the block noise reduction mode
|
||||
*
|
||||
* @return the block noise reduction mode associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no block noise reduction mode is associated to the searched name
|
||||
*/
|
||||
public static SonyProjectorBlockNr getFromName(String name) throws SonyProjectorException {
|
||||
for (SonyProjectorBlockNr value : SonyProjectorBlockNr.values()) {
|
||||
if (value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for a block noise reduction mode: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the block noise reduction mode associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the block noise reduction mode
|
||||
*
|
||||
* @return the block noise reduction mode associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no block noise reduction mode is associated to the searched data code
|
||||
*/
|
||||
public static SonyProjectorBlockNr getFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
for (SonyProjectorBlockNr value : SonyProjectorBlockNr.values()) {
|
||||
if (Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException(
|
||||
"Invalid data code for a block noise reduction mode: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different calibration presets available for the projector
|
||||
*
|
||||
* @author Markus Wehrle - Initial contribution
|
||||
* @author Laurent Garnier - Transform into an enum and consider differences between models
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorCalibrationPreset {
|
||||
|
||||
// Category 1: VW260, VW270, VW285, VW295, VW300, VW315, VW320, VW328, VW350, VW365, VW385, VW500, VW515, VW520,
|
||||
// VW528, VW550, VW570, VW600, VW665, VW675, VW695, VW760, VW870, VW885, VW995, HW40ES, HW45ES, HW50ES, HW55ES,
|
||||
// HW58ES, HW60, HW65, HW68
|
||||
CAT1_CINEMA_FILM1(1, "Film1", "Cinema Film 1", new byte[] { 0x00, 0x00 }),
|
||||
CAT1_CINEMA_FILM2(1, "Film2", "Cinema Film 2", new byte[] { 0x00, 0x01 }),
|
||||
CAT1_REFERENCE(1, "Reference", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT1_TV(1, "TV", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT1_PHOTO(1, "Photo", null, new byte[] { 0x00, 0x04 }),
|
||||
CAT1_GAME(1, "Game", null, new byte[] { 0x00, 0x05 }),
|
||||
CAT1_BRT_CINE(1, "BRTCINE", "Bright Cinema", new byte[] { 0x00, 0x06 }),
|
||||
CAT1_BRT_TV(1, "BRTTV", "Bright TV", new byte[] { 0x00, 0x07 }),
|
||||
CAT1_USER(1, "User", null, new byte[] { 0x00, 0x08 }),
|
||||
|
||||
// Category 2: VW40, VW50, VW60, VW70, VW80, VW100, VW200, HW10, HW15, HW20
|
||||
CAT2_DYNAMIC(2, "Dynamic", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT2_STANDARD(2, "Standard", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT2_CINEMA(2, "Cinema", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT2_USER1(2, "User1", "User 1", new byte[] { 0x00, 0x03 }),
|
||||
CAT2_USER2(2, "User2", "User 2", new byte[] { 0x00, 0x04 }),
|
||||
CAT2_USER3(2, "User3", "User 3", new byte[] { 0x00, 0x05 }),
|
||||
|
||||
// Category 3: VW85, VW90
|
||||
CAT3_DYNAMIC(3, "Dynamic", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT3_STANDARD(3, "Standard", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT3_CINEMA1(3, "Cinema1", "Cinema 1", new byte[] { 0x00, 0x02 }),
|
||||
CAT3_CINEMA2(3, "Cinema2", "Cinema 2", new byte[] { 0x00, 0x03 }),
|
||||
CAT3_CINEMA3(3, "Cinema3", "Cinema 3", new byte[] { 0x00, 0x04 }),
|
||||
CAT3_USER(3, "User", null, new byte[] { 0x00, 0x05 }),
|
||||
|
||||
// Category 4: VW95, HW30ES
|
||||
CAT4_DYNAMIC(4, "Dynamic", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT4_STANDARD(4, "Standard", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT4_CINEMA1(4, "Cinema1", "Cinema 1", new byte[] { 0x00, 0x02 }),
|
||||
CAT4_CINEMA2(4, "Cinema2", "Cinema 2", new byte[] { 0x00, 0x03 }),
|
||||
CAT4_CINEMA3(4, "Cinema3", "Cinema 3", new byte[] { 0x00, 0x04 }),
|
||||
CAT4_GAME(4, "Game", null, new byte[] { 0x00, 0x05 }),
|
||||
CAT4_PHOTO(4, "Photo", null, new byte[] { 0x00, 0x06 }),
|
||||
CAT4_USER1(4, "User1", "User 1", new byte[] { 0x00, 0x07 }),
|
||||
CAT4_USER2(4, "User2", "User 2", new byte[] { 0x00, 0x08 }),
|
||||
|
||||
// Category 5: VW1000ES, VW1100ES
|
||||
CAT5_CINEMA_FILM1(5, "Film1", "Cinema Film 1", new byte[] { 0x00, 0x00 }),
|
||||
CAT5_CINEMA_FILM2(5, "Film2", "Cinema Film 2", new byte[] { 0x00, 0x01 }),
|
||||
CAT5_CINEMA_DIGITAL(5, "Digital", "Cinema Digital", new byte[] { 0x00, 0x02 }),
|
||||
CAT5_REFERENCE(5, "Reference", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT5_TV(5, "TV", null, new byte[] { 0x00, 0x04 }),
|
||||
CAT5_PHOTO(5, "Photo", null, new byte[] { 0x00, 0x05 }),
|
||||
CAT5_GAME(5, "Game", null, new byte[] { 0x00, 0x06 }),
|
||||
CAT5_BRT_CINE(5, "BRTCINE", "Bright Cinema", new byte[] { 0x00, 0x07 }),
|
||||
CAT5_BRT_TV(5, "BRTTV", "Bright TV", new byte[] { 0x00, 0x08 });
|
||||
|
||||
private int category;
|
||||
private String name;
|
||||
private @Nullable String label;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param category a category of projector models for which the calibration preset is available
|
||||
* @param name the name of the calibration preset
|
||||
* @param label the label of the calibration preset; can be null when the label is identical to the name
|
||||
* @param dataCode the data code identifying the calibration preset
|
||||
*/
|
||||
private SonyProjectorCalibrationPreset(int category, String name, @Nullable String label, byte[] dataCode) {
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of projector models for the current calibration preset
|
||||
*
|
||||
* @return the category of projector models
|
||||
*/
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current calibration preset
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label of the current calibration preset
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public @Nullable String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current calibration preset
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available calibration presets for a particular category of
|
||||
* projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available calibration presets for a provided category
|
||||
* of projector models
|
||||
*/
|
||||
public static List<StateOption> getStateOptions(int category) {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorCalibrationPreset value : SonyProjectorCalibrationPreset.values()) {
|
||||
if (value.getCategory() == category) {
|
||||
options.add(new StateOption(value.getName(),
|
||||
value.getLabel() != null ? value.getLabel() : value.getName()));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the calibration preset associated to a name for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param name the name used to identify the calibration preset
|
||||
*
|
||||
* @return the calibration preset associated to the searched name for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no calibration preset is associated to the searched name for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorCalibrationPreset getFromName(int category, String name) throws SonyProjectorException {
|
||||
for (SonyProjectorCalibrationPreset value : SonyProjectorCalibrationPreset.values()) {
|
||||
if (value.getCategory() == category && value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for a calibration preset: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the calibration preset associated to a data code for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param dataCode the data code used to identify the calibration preset
|
||||
*
|
||||
* @return the calibration preset associated to the searched data code for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no calibration preset is associated to the searched data code for the
|
||||
* provided category
|
||||
*/
|
||||
public static SonyProjectorCalibrationPreset getFromDataCode(int category, byte[] dataCode)
|
||||
throws SonyProjectorException {
|
||||
for (SonyProjectorCalibrationPreset value : SonyProjectorCalibrationPreset.values()) {
|
||||
if (value.getCategory() == category && Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException(
|
||||
"Invalid data code for a calibration preset: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different color spaces available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorColorSpace {
|
||||
|
||||
// Category 1: VW300, VW315, VW320, VW328, VW350, VW365, VW500, VW600, HW60, HW65, HW68
|
||||
CAT1_BT709(1, "BT709", "BT.709", new byte[] { 0x00, 0x00 }),
|
||||
CAT1_SPACE1(1, "ColorSpace1", "Color Space 1", new byte[] { 0x00, 0x03 }),
|
||||
CAT1_SPACE2(1, "ColorSpace2", "Color Space 2", new byte[] { 0x00, 0x04 }),
|
||||
CAT1_SPACE3(1, "ColorSpace3", "Color Space 3", new byte[] { 0x00, 0x05 }),
|
||||
CAT1_CUSTOM(1, "Custom", null, new byte[] { 0x00, 0x06 }),
|
||||
|
||||
// Category 2: VW260, VW270, VW285, VW295, VW385, VW515, VW520, VW528, VW550, VW570, VW665, VW675, VW695, VW760,
|
||||
// VW870, VW885, VW995
|
||||
CAT2_BT709(2, "BT709", "BT.709", new byte[] { 0x00, 0x00 }),
|
||||
CAT2_BT2020(2, "BT2020", "BT.2020", new byte[] { 0x00, 0x08 }),
|
||||
CAT2_SPACE1(2, "ColorSpace1", "Color Space 1", new byte[] { 0x00, 0x03 }),
|
||||
CAT2_SPACE2(2, "ColorSpace2", "Color Space 2", new byte[] { 0x00, 0x04 }),
|
||||
CAT2_SPACE3(2, "ColorSpace3", "Color Space 3", new byte[] { 0x00, 0x05 }),
|
||||
CAT2_CUSTOM(2, "Custom", null, new byte[] { 0x00, 0x06 }),
|
||||
|
||||
// Category 3: VW40, VW50, VW60, VW70, VW80, VW100, VW200, HW10, HW15, HW20
|
||||
CAT3_NORMAL(3, "Normal", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT3_WIDE(3, "Wide", null, new byte[] { 0x00, 0x01 }),
|
||||
|
||||
// Category 4: VW85, VW90, VW95, HW30ES
|
||||
CAT4_NORMAL(4, "Normal", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT4_WIDE1(4, "Wide1", "Wide 1", new byte[] { 0x00, 0x01 }),
|
||||
CAT4_WIDE2(4, "Wide2", "Wide 2", new byte[] { 0x00, 0x02 }),
|
||||
CAT4_WIDE3(4, "Wide3", "Wide 3", new byte[] { 0x00, 0x03 }),
|
||||
|
||||
// Category 5: VW1000ES, VW1100ES
|
||||
CAT5_BT709(5, "BT709", "BT.709", new byte[] { 0x00, 0x00 }),
|
||||
CAT5_DCI(5, "DCI", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT5_ADOBE_RGB(5, "AdobeRGB", "Adobe RGB", new byte[] { 0x00, 0x02 }),
|
||||
CAT5_SPACE1(5, "ColorSpace1", "Color Space 1", new byte[] { 0x00, 0x03 }),
|
||||
CAT5_SPACE2(5, "ColorSpace2", "Color Space 2", new byte[] { 0x00, 0x04 }),
|
||||
CAT5_SPACE3(5, "ColorSpace3", "Color Space 3", new byte[] { 0x00, 0x05 }),
|
||||
|
||||
// Category 6: HW35ES, HW40ES, HW45ES, HW50ES, HW55ES, HW58ES
|
||||
CAT6_BT709(6, "BT709", "BT.709", new byte[] { 0x00, 0x00 }),
|
||||
CAT6_SPACE1(6, "ColorSpace1", "Color Space 1", new byte[] { 0x00, 0x01 }),
|
||||
CAT6_SPACE2(6, "ColorSpace2", "Color Space 2", new byte[] { 0x00, 0x02 }),
|
||||
CAT6_SPACE3(6, "ColorSpace3", "Color Space 3", new byte[] { 0x00, 0x03 });
|
||||
|
||||
private int category;
|
||||
private String name;
|
||||
private @Nullable String label;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param category a category of projector models for which the color space is available
|
||||
* @param name the name of the color space
|
||||
* @param label the label of the color space; can be null when the label is identical to the name
|
||||
* @param dataCode the data code identifying the color space
|
||||
*/
|
||||
private SonyProjectorColorSpace(int category, String name, @Nullable String label, byte[] dataCode) {
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of projector models for the current color space
|
||||
*
|
||||
* @return the category of projector models
|
||||
*/
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current color space
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label of the current color space
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public @Nullable String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current color space
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available color spaces for a particular category of
|
||||
* projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available color spaces for a provided category of
|
||||
* projector models
|
||||
*/
|
||||
public static List<StateOption> getStateOptions(int category) {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorColorSpace value : SonyProjectorColorSpace.values()) {
|
||||
if (value.getCategory() == category) {
|
||||
options.add(new StateOption(value.getName(),
|
||||
value.getLabel() != null ? value.getLabel() : value.getName()));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color space associated to a name for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param name the name used to identify the color space
|
||||
*
|
||||
* @return the color space associated to the searched name for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no color space is associated to the searched name for the provided category
|
||||
*/
|
||||
public static SonyProjectorColorSpace getFromName(int category, String name) throws SonyProjectorException {
|
||||
for (SonyProjectorColorSpace value : SonyProjectorColorSpace.values()) {
|
||||
if (value.getCategory() == category && value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for a color space: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color space associated to a data code for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param dataCode the data code used to identify the color space
|
||||
*
|
||||
* @return the color space associated to the searched data code for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no color space is associated to the searched data code for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorColorSpace getFromDataCode(int category, byte[] dataCode) throws SonyProjectorException {
|
||||
for (SonyProjectorColorSpace value : SonyProjectorColorSpace.values()) {
|
||||
if (value.getCategory() == category && Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid data code for a color space: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different color temperatures available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorColorTemp {
|
||||
|
||||
// Category 1: VW260, VW270, VW285, VW295, VW300, VW315, VW320, VW328, VW350, VW365, VW385, VW500, VW515, VW520,
|
||||
// VW528, VW550, VW570, VW600, VW665, VW675, VW695, VW760, VW870, VW885, VW995, HW60, HW65, HW68
|
||||
CAT1_D93(1, "D93", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT1_D75(1, "D75", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT1_D65(1, "D65", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT1_D55(1, "D55", null, new byte[] { 0x00, 0x09 }),
|
||||
CAT1_CUSTOM1(1, "Custom1", "Custom 1", new byte[] { 0x00, 0x03 }),
|
||||
CAT1_CUSTOM2(1, "Custom2", "Custom 2", new byte[] { 0x00, 0x04 }),
|
||||
CAT1_CUSTOM3(1, "Custom3", "Custom 3", new byte[] { 0x00, 0x05 }),
|
||||
CAT1_CUSTOM4(1, "Custom4", "Custom 4", new byte[] { 0x00, 0x06 }),
|
||||
CAT1_CUSTOM5(1, "Custom5", "Custom 5", new byte[] { 0x00, 0x08 }),
|
||||
|
||||
// Category 2: VW40, VW50, VW60, VW100, VW200
|
||||
CAT2_HIGH(2, "High", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT2_MIDDLE(2, "Middle", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT2_LOW(2, "Low", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT2_CUSTOM1(2, "Custom1", "Custom 1", new byte[] { 0x00, 0x03 }),
|
||||
CAT2_CUSTOM2(2, "Custom2", "Custom 2", new byte[] { 0x00, 0x04 }),
|
||||
CAT2_CUSTOM3(2, "Custom3", "Custom 3", new byte[] { 0x00, 0x05 }),
|
||||
|
||||
// Category 3: VW70, VW80, HW10, HW15, HW20
|
||||
CAT3_HIGH(3, "High", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT3_MIDDLE(3, "Middle", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT3_LOW(3, "Low", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT3_CUSTOM1(3, "Custom1", "Custom 1", new byte[] { 0x00, 0x03 }),
|
||||
CAT3_CUSTOM2(3, "Custom2", "Custom 2", new byte[] { 0x00, 0x04 }),
|
||||
CAT3_CUSTOM3(3, "Custom3", "Custom 3", new byte[] { 0x00, 0x05 }),
|
||||
CAT3_CUSTOM4(3, "Custom4", "Custom 4", new byte[] { 0x00, 0x06 }),
|
||||
|
||||
// Category 4: VW85, VW90, VW95, HW30
|
||||
CAT4_HIGH(4, "High", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT4_MIDDLE(4, "Middle", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT4_LOW1(4, "Low1", "Low 1", new byte[] { 0x00, 0x02 }),
|
||||
CAT4_LOW2(4, "Low2", "Low 2", new byte[] { 0x00, 0x07 }),
|
||||
CAT4_CUSTOM1(4, "Custom1", "Custom 1", new byte[] { 0x00, 0x03 }),
|
||||
CAT4_CUSTOM2(4, "Custom2", "Custom 2", new byte[] { 0x00, 0x04 }),
|
||||
CAT4_CUSTOM3(4, "Custom3", "Custom 3", new byte[] { 0x00, 0x05 }),
|
||||
CAT4_CUSTOM4(4, "Custom4", "Custom 4", new byte[] { 0x00, 0x06 }),
|
||||
CAT4_CUSTOM5(4, "Custom5", "Custom 5", new byte[] { 0x00, 0x08 }),
|
||||
|
||||
// Category 5: VW1000ES, VW1100ES
|
||||
CAT5_D93(5, "D93", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT5_D75(5, "D75", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT5_D65(5, "D65", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT5_D55(5, "D55", null, new byte[] { 0x00, 0x09 }),
|
||||
CAT5_DCI(5, "DCI", null, new byte[] { 0x00, 0x07 }),
|
||||
CAT5_CUSTOM1(5, "Custom1", "Custom 1", new byte[] { 0x00, 0x03 }),
|
||||
CAT5_CUSTOM2(5, "Custom2", "Custom 2", new byte[] { 0x00, 0x04 }),
|
||||
CAT5_CUSTOM3(5, "Custom3", "Custom 3", new byte[] { 0x00, 0x05 }),
|
||||
CAT5_CUSTOM4(5, "Custom4", "Custom 4", new byte[] { 0x00, 0x06 }),
|
||||
CAT5_CUSTOM5(5, "Custom5", "Custom 5", new byte[] { 0x00, 0x08 }),
|
||||
|
||||
// Category 6: HW35ES, HW40ES, HW45ES, HW58ES
|
||||
CAT6_D93(6, "D93", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT6_D75(6, "D75", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT6_D65(6, "D65", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT6_D55(6, "D55", null, new byte[] { 0x00, 0x07 }),
|
||||
CAT6_CUSTOM(6, "Custom", null, new byte[] { 0x00, 0x08 }),
|
||||
|
||||
// Category 7: HW50ES, HW55ES
|
||||
CAT7_D93(7, "D93", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT7_D75(7, "D75", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT7_D65(7, "D65", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT7_D55(7, "D55", null, new byte[] { 0x00, 0x07 }),
|
||||
CAT7_CUSTOM1(7, "Custom1", "Custom 1", new byte[] { 0x00, 0x03 }),
|
||||
CAT7_CUSTOM2(7, "Custom2", "Custom 2", new byte[] { 0x00, 0x04 }),
|
||||
CAT7_CUSTOM3(7, "Custom3", "Custom 3", new byte[] { 0x00, 0x05 }),
|
||||
CAT7_CUSTOM4(7, "Custom4", "Custom 4", new byte[] { 0x00, 0x06 }),
|
||||
CAT7_CUSTOM5(7, "Custom5", "Custom 5", new byte[] { 0x00, 0x08 });
|
||||
|
||||
private int category;
|
||||
private String name;
|
||||
private @Nullable String label;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param category a category of projector models for which the color temperature is available
|
||||
* @param name the name of the color temperature
|
||||
* @param label the label of the color temperature; can be null when the label is identical to the name
|
||||
* @param dataCode the data code identifying the color temperature
|
||||
*/
|
||||
private SonyProjectorColorTemp(int category, String name, @Nullable String label, byte[] dataCode) {
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of projector models for the current color temperature
|
||||
*
|
||||
* @return the category of projector models
|
||||
*/
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current color temperature
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label of the current color temperature
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public @Nullable String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current color temperature
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available color temperatures for a particular category of
|
||||
* projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available color temperatures for a provided category of
|
||||
* projector models
|
||||
*/
|
||||
public static List<StateOption> getStateOptions(int category) {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorColorTemp value : SonyProjectorColorTemp.values()) {
|
||||
if (value.getCategory() == category) {
|
||||
options.add(new StateOption(value.getName(),
|
||||
value.getLabel() != null ? value.getLabel() : value.getName()));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color temperature associated to a name for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param name the name used to identify the color temperature
|
||||
*
|
||||
* @return the color temperature associated to the searched name for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no color temperature is associated to the searched name for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorColorTemp getFromName(int category, String name) throws SonyProjectorException {
|
||||
for (SonyProjectorColorTemp value : SonyProjectorColorTemp.values()) {
|
||||
if (value.getCategory() == category && value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for a color temperature: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color temperature associated to a data code for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param dataCode the data code used to identify the color temperature
|
||||
*
|
||||
* @return the color temperature associated to the searched data code for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no color temperature is associated to the searched data code for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorColorTemp getFromDataCode(int category, byte[] dataCode) throws SonyProjectorException {
|
||||
for (SonyProjectorColorTemp value : SonyProjectorColorTemp.values()) {
|
||||
if (value.getCategory() == category && Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid data code for a color temperature: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,173 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different contrast enhancer modes available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorContrastEnhancer {
|
||||
|
||||
// Category 1: VW260, VW270, VW285, VW295, VW300, VW315, VW320, VW328, VW350, VW365, VW385, VW500, VW515, VW520,
|
||||
// VW528, VW550, VW570, VW600, VW665, VW675, VW695, VW760, VW870, VW885, VW995, VW1000ES, VW1100ES, HW40ES, HW45ES,
|
||||
// HW50ES, HW55ES, HW58ES, HW60, HW65, HW68
|
||||
CAT1_HIGH(1, "High", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT1_MIDDLE(1, "Middle", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT1_LOW(1, "Low", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT1_OFF(1, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 2: VW40, VW50, VW60, VW70, VW80, VW100, VW200, HW10, HW15, HW20
|
||||
CAT2_HIGH(2, "High", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT2_LOW(2, "Low", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT2_OFF(2, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 3: VW85, VW90, VW95, HW30ES
|
||||
CAT3_LEVEL_MINUS_3(3, "-3", null, new byte[] { (byte) 0xFF, (byte) 0xFD }),
|
||||
CAT3_LEVEL_MINUS_2(3, "-2", null, new byte[] { (byte) 0xFF, (byte) 0xFE }),
|
||||
CAT3_LEVEL_MINUS_1(3, "-1", null, new byte[] { (byte) 0xFF, (byte) 0xFF }),
|
||||
CAT3_LEVEL_0(3, "0", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT3_LEVEL_PLUS_1(3, "1", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT3_LEVEL_PLUS_2(3, "2", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT3_LEVEL_PLUS_3(3, "3", null, new byte[] { 0x00, 0x03 });
|
||||
|
||||
private int category;
|
||||
private String name;
|
||||
private @Nullable String label;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param category a category of projector models for which the contrast enhancer mode is available
|
||||
* @param name the name of the contrast enhancer mode
|
||||
* @param label the label of the contrast enhancer mode; can be null when the label is identical to the name
|
||||
* @param dataCode the data code identifying the contrast enhancer mode
|
||||
*/
|
||||
private SonyProjectorContrastEnhancer(int category, String name, @Nullable String label, byte[] dataCode) {
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of projector models for the current contrast enhancer mode
|
||||
*
|
||||
* @return the category of projector models
|
||||
*/
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current contrast enhancer mode
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label of the current contrast enhancer mode
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public @Nullable String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current contrast enhancer mode
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available contrast enhancer modes for a particular category
|
||||
* of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available contrast enhancer modes for a provided
|
||||
* category of projector models
|
||||
*/
|
||||
public static List<StateOption> getStateOptions(int category) {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorContrastEnhancer value : SonyProjectorContrastEnhancer.values()) {
|
||||
if (value.getCategory() == category) {
|
||||
options.add(new StateOption(value.getName(),
|
||||
value.getLabel() != null ? value.getLabel() : value.getName()));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the contrast enhancer mode associated to a name for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param name the name used to identify the contrast enhancer mode
|
||||
*
|
||||
* @return the contrast enhancer mode associated to the searched name for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no contrast enhancer mode is associated to the searched name for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorContrastEnhancer getFromName(int category, String name) throws SonyProjectorException {
|
||||
for (SonyProjectorContrastEnhancer value : SonyProjectorContrastEnhancer.values()) {
|
||||
if (value.getCategory() == category && value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for a contrast enhancer mode: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the contrast enhancer mode associated to a data code for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param dataCode the data code used to identify the contrast enhancer mode
|
||||
*
|
||||
* @return the contrast enhancer mode associated to the searched data code for the provided category of projector
|
||||
* models
|
||||
*
|
||||
* @throws SonyProjectorException - If no contrast enhancer mode is associated to the searched data code for the
|
||||
* provided category
|
||||
*/
|
||||
public static SonyProjectorContrastEnhancer getFromDataCode(int category, byte[] dataCode)
|
||||
throws SonyProjectorException {
|
||||
for (SonyProjectorContrastEnhancer value : SonyProjectorContrastEnhancer.values()) {
|
||||
if (value.getCategory() == category && Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException(
|
||||
"Invalid data code for a contrast enhancer mode: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different film modes available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorFilmMode {
|
||||
|
||||
// Category 1: VW70, VW260, VW270, VW285, VW295, VW300, VW315, VW320, VW328, VW350, VW365, VW385, VW500, VW515,
|
||||
// VW520, VW528, VW550, VW570, VW600, VW665, VW675, VW695, VW760, VW870, VW885, VW995, HW10, HW15, HW20, HW45ES,
|
||||
// HW60, HW65, HW68
|
||||
CAT1_AUTO(1, "Auto", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT1_OFF(1, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 2: VW80, VW85, VW90, VW95, VW200, VW1000ES, VW1100ES, HW30ES, HW40ES, HW50ES, HW55ES, HW58ES
|
||||
CAT2_AUTO1(2, "Auto1", "Auto 1", new byte[] { 0x00, 0x01 }),
|
||||
CAT2_AUTO2(2, "Auto2", "Auto 2", new byte[] { 0x00, 0x02 }),
|
||||
CAT2_OFF(2, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 3: VW100
|
||||
CAT3_AUTO(3, "Auto", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT3_OFF(3, "Off", null, new byte[] { 0x00, 0x01 });
|
||||
|
||||
private int category;
|
||||
private String name;
|
||||
private @Nullable String label;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param category a category of projector models for which the film mode is available
|
||||
* @param name the name of the film mode
|
||||
* @param label the label of the film mode; can be null when the label is identical to the name
|
||||
* @param dataCode the data code identifying the film mode
|
||||
*/
|
||||
private SonyProjectorFilmMode(int category, String name, @Nullable String label, byte[] dataCode) {
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of projector models for the current film mode
|
||||
*
|
||||
* @return the category of projector models
|
||||
*/
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current film mode
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label of the current film mode
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public @Nullable String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current film mode
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available film modes for a particular category of projector
|
||||
* models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available film modes for a provided category of
|
||||
* projector models
|
||||
*/
|
||||
public static List<StateOption> getStateOptions(int category) {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorFilmMode value : SonyProjectorFilmMode.values()) {
|
||||
if (value.getCategory() == category) {
|
||||
options.add(new StateOption(value.getName(),
|
||||
value.getLabel() != null ? value.getLabel() : value.getName()));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the film mode associated to a name for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param name the name used to identify the film mode
|
||||
*
|
||||
* @return the film mode associated to the searched name for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no film mode is associated to the searched name for the provided category
|
||||
*/
|
||||
public static SonyProjectorFilmMode getFromName(int category, String name) throws SonyProjectorException {
|
||||
for (SonyProjectorFilmMode value : SonyProjectorFilmMode.values()) {
|
||||
if (value.getCategory() == category && value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for a film mode: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the film mode associated to a data code for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param dataCode the data code used to identify the film mode
|
||||
*
|
||||
* @return the film mode associated to the searched data code for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no film mode is associated to the searched data code for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorFilmMode getFromDataCode(int category, byte[] dataCode) throws SonyProjectorException {
|
||||
for (SonyProjectorFilmMode value : SonyProjectorFilmMode.values()) {
|
||||
if (value.getCategory() == category && Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid data code for a film mode: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different film projection modes available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorFilmProjection {
|
||||
|
||||
// Category 1: VW80, VW85, VW200
|
||||
CAT1_MODE1(1, "Mode1", "Mode 1", new byte[] { 0x00, 0x01 }),
|
||||
CAT1_MODE2(1, "Mode2", "Mode 2", new byte[] { 0x00, 0x02 }),
|
||||
CAT1_MODE3(1, "Mode3", "Mode 3", new byte[] { 0x00, 0x03 }),
|
||||
CAT1_OFF(1, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 2: VW90, VW95
|
||||
CAT2_MODE1(2, "Mode1", "Mode 1", new byte[] { 0x00, 0x01 }),
|
||||
CAT2_MODE2(2, "Mode2", "Mode 2", new byte[] { 0x00, 0x02 }),
|
||||
CAT2_OFF(2, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 3: VW1000ES, VW1100ES, HW35ES, HW40ES, HW50ES, HW55ES, HW58ES
|
||||
CAT3_ON(3, "On", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT3_OFF(3, "Off", null, new byte[] { 0x00, 0x00 });
|
||||
|
||||
private int category;
|
||||
private String name;
|
||||
private @Nullable String label;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param category a category of projector models for which the film projection mode is available
|
||||
* @param name the name of the film projection mode
|
||||
* @param label the label of the film projection mode; can be null when the label is identical to the name
|
||||
* @param dataCode the data code identifying the film projection mode
|
||||
*/
|
||||
private SonyProjectorFilmProjection(int category, String name, @Nullable String label, byte[] dataCode) {
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of projector models for the current film projection mode
|
||||
*
|
||||
* @return the category of projector models
|
||||
*/
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current film projection mode
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label of the current film projection mode
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public @Nullable String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current film projection mode
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available film projection modes for a particular category
|
||||
* of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available film projection modes for a provided category
|
||||
* of projector models
|
||||
*/
|
||||
public static List<StateOption> getStateOptions(int category) {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorFilmProjection value : SonyProjectorFilmProjection.values()) {
|
||||
if (value.getCategory() == category) {
|
||||
options.add(new StateOption(value.getName(),
|
||||
value.getLabel() != null ? value.getLabel() : value.getName()));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the film projection mode associated to a name for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param name the name used to identify the film projection mode
|
||||
*
|
||||
* @return the film projection mode associated to the searched name for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no film projection mode is associated to the searched name for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorFilmProjection getFromName(int category, String name) throws SonyProjectorException {
|
||||
for (SonyProjectorFilmProjection value : SonyProjectorFilmProjection.values()) {
|
||||
if (value.getCategory() == category && value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for a film projection mode: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the film projection mode associated to a data code for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param dataCode the data code used to identify the film projection mode
|
||||
*
|
||||
* @return the film projection mode associated to the searched data code for the provided category of projector
|
||||
* models
|
||||
*
|
||||
* @throws SonyProjectorException - If no film projection mode is associated to the searched data code for the
|
||||
* provided category
|
||||
*/
|
||||
public static SonyProjectorFilmProjection getFromDataCode(int category, byte[] dataCode)
|
||||
throws SonyProjectorException {
|
||||
for (SonyProjectorFilmProjection value : SonyProjectorFilmProjection.values()) {
|
||||
if (value.getCategory() == category && Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException(
|
||||
"Invalid data code for a film projection mode: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different gamma corrections available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorGammaCorrection {
|
||||
|
||||
// Category 1: VW260, VW270, VW285, VW295, VW300, VW315, VW320, VW328, VW350, VW365, VW385, VW500, VW515, VW520,
|
||||
// VW528, VW550, VW570, VW600, VW665, VW675, VW695, VW760, VW870, VW885, VW995, VW1000ES, VW1100ES, HW50ES, HW55ES,
|
||||
// HW60, HW65, HW68
|
||||
CAT1_18(1, "1.8", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT1_20(1, "2.0", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT1_21(1, "2.1", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT1_22(1, "2.2", null, new byte[] { 0x00, 0x04 }),
|
||||
CAT1_24(1, "2.4", null, new byte[] { 0x00, 0x05 }),
|
||||
CAT1_26(1, "2.6", null, new byte[] { 0x00, 0x06 }),
|
||||
CAT1_GAMMA7(1, "Gamma7", "Gamma 7", new byte[] { 0x00, 0x07 }),
|
||||
CAT1_GAMMA8(1, "Gamma8", "Gamma 8", new byte[] { 0x00, 0x08 }),
|
||||
CAT1_GAMMA9(1, "Gamma9", "Gamma 9", new byte[] { 0x00, 0x09 }),
|
||||
CAT1_GAMMA10(1, "Gamma10", "Gamma 10", new byte[] { 0x00, 0x0A }),
|
||||
CAT1_OFF(1, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 2: VW40, VW50, VW60, VW100, VW200, HW10
|
||||
CAT2_GAMMA1(2, "Gamma1", "Gamma 1", new byte[] { 0x00, 0x01 }),
|
||||
CAT2_GAMMA2(2, "Gamma2", "Gamma 2", new byte[] { 0x00, 0x02 }),
|
||||
CAT2_GAMMA3(2, "Gamma3", "Gamma 3", new byte[] { 0x00, 0x03 }),
|
||||
CAT2_OFF(2, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 3: VW70, VW80, HW15, HW20
|
||||
CAT3_GAMMA1(3, "Gamma1", "Gamma 1", new byte[] { 0x00, 0x01 }),
|
||||
CAT3_GAMMA2(3, "Gamma2", "Gamma 2", new byte[] { 0x00, 0x02 }),
|
||||
CAT3_GAMMA3(3, "Gamma3", "Gamma 3", new byte[] { 0x00, 0x03 }),
|
||||
CAT3_GAMMA4(3, "Gamma4", "Gamma 4", new byte[] { 0x00, 0x04 }),
|
||||
CAT3_GAMMA5(3, "Gamma5", "Gamma 5", new byte[] { 0x00, 0x05 }),
|
||||
CAT3_GAMMA6(3, "Gamma6", "Gamma 6", new byte[] { 0x00, 0x06 }),
|
||||
CAT3_OFF(3, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 4: HW30ES
|
||||
CAT4_GAMMA1(4, "Gamma1", "Gamma 1", new byte[] { 0x00, 0x01 }),
|
||||
CAT4_GAMMA2(4, "Gamma2", "Gamma 2", new byte[] { 0x00, 0x02 }),
|
||||
CAT4_GAMMA3(4, "Gamma3", "Gamma 3", new byte[] { 0x00, 0x03 }),
|
||||
CAT4_GAMMA4(4, "Gamma4", "Gamma 4", new byte[] { 0x00, 0x04 }),
|
||||
CAT4_GAMMA5(4, "Gamma5", "Gamma 5", new byte[] { 0x00, 0x05 }),
|
||||
CAT4_GAMMA6(4, "Gamma6", "Gamma 6", new byte[] { 0x00, 0x06 }),
|
||||
CAT4_GAMMA7(4, "Gamma7", "Gamma 7", new byte[] { 0x00, 0x07 }),
|
||||
CAT4_GAMMA8(4, "Gamma8", "Gamma 8", new byte[] { 0x00, 0x08 }),
|
||||
CAT4_OFF(4, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 5: VW85, VW90, VW95
|
||||
CAT5_GAMMA1(5, "Gamma1", "Gamma 1", new byte[] { 0x00, 0x01 }),
|
||||
CAT5_GAMMA2(5, "Gamma2", "Gamma 2", new byte[] { 0x00, 0x02 }),
|
||||
CAT5_GAMMA3(5, "Gamma3", "Gamma 3", new byte[] { 0x00, 0x03 }),
|
||||
CAT5_GAMMA4(5, "Gamma4", "Gamma 4", new byte[] { 0x00, 0x04 }),
|
||||
CAT5_GAMMA5(5, "Gamma5", "Gamma 5", new byte[] { 0x00, 0x05 }),
|
||||
CAT5_GAMMA6(5, "Gamma6", "Gamma 6", new byte[] { 0x00, 0x06 }),
|
||||
CAT5_GAMMA7(5, "Gamma7", "Gamma 7", new byte[] { 0x00, 0x07 }),
|
||||
CAT5_GAMMA8(5, "Gamma8", "Gamma 8", new byte[] { 0x00, 0x08 }),
|
||||
CAT5_GAMMA9(5, "Gamma9", "Gamma 9", new byte[] { 0x00, 0x09 }),
|
||||
CAT5_GAMMA10(5, "Gamma10", "Gamma 10", new byte[] { 0x00, 0x0A }),
|
||||
CAT5_OFF(5, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 6: HW35ES, HW40ES, HW45ES, HW58ES
|
||||
CAT6_20(6, "2.0", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT6_22(6, "2.2", null, new byte[] { 0x00, 0x04 }),
|
||||
CAT6_24(6, "2.4", null, new byte[] { 0x00, 0x05 }),
|
||||
CAT6_GAMMA4(6, "Gamma4", "Gamma 4", new byte[] { 0x00, 0x08 }),
|
||||
CAT6_GAMMA5(6, "Gamma5", "Gamma 5", new byte[] { 0x00, 0x09 }),
|
||||
CAT6_GAMMA6(6, "Gamma6", "Gamma 6", new byte[] { 0x00, 0x0A }),
|
||||
CAT6_OFF(6, "Off", null, new byte[] { 0x00, 0x00 });
|
||||
|
||||
private int category;
|
||||
private String name;
|
||||
private @Nullable String label;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param category a category of projector models for which the gamma correction is available
|
||||
* @param name the name of the gamma correction
|
||||
* @param label the label of the gamma correction; can be null when the label is identical to the name
|
||||
* @param dataCode the data code identifying the gamma correction
|
||||
*/
|
||||
private SonyProjectorGammaCorrection(int category, String name, @Nullable String label, byte[] dataCode) {
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of projector models for the current gamma correction
|
||||
*
|
||||
* @return the category of projector models
|
||||
*/
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current gamma correction
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label of the current gamma correction
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public @Nullable String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current gamma correction
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available gamma corrections for a particular category of
|
||||
* projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available gamma corrections for a provided category of
|
||||
* projector models
|
||||
*/
|
||||
public static List<StateOption> getStateOptions(int category) {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorGammaCorrection value : SonyProjectorGammaCorrection.values()) {
|
||||
if (value.getCategory() == category) {
|
||||
options.add(new StateOption(value.getName(),
|
||||
value.getLabel() != null ? value.getLabel() : value.getName()));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the gamma correction associated to a name for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param name the name used to identify the gamma correction
|
||||
*
|
||||
* @return the gamma correction associated to the searched name for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no gamma correction is associated to the searched name for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorGammaCorrection getFromName(int category, String name) throws SonyProjectorException {
|
||||
for (SonyProjectorGammaCorrection value : SonyProjectorGammaCorrection.values()) {
|
||||
if (value.getCategory() == category && value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid nam for a gamma correctione: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the gamma correction associated to a data code for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param dataCode the data code used to identify the gamma correction
|
||||
*
|
||||
* @return the gamma correction associated to the searched data code for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no gamma correction is associated to the searched data code for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorGammaCorrection getFromDataCode(int category, byte[] dataCode)
|
||||
throws SonyProjectorException {
|
||||
for (SonyProjectorGammaCorrection value : SonyProjectorGammaCorrection.values()) {
|
||||
if (value.getCategory() == category && Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid data code for a gamma correctione: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different video inputs available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorInput {
|
||||
|
||||
// Category 1: VW260, VW270, VW285, VW295, VW300, VW315, VW320, VW328, VW350, VW365, VW385, VW500, VW515, VW520,
|
||||
// VW528, VW550, VW570, VW600, VW665, VW675, VW695, VW760, VW870, VW885, VW995, HW45ES, HW60, HW65, HW68
|
||||
CAT1_HDMI1(1, "HDMI1", "HDMI 1", new byte[] { 0x00, 0x02 }),
|
||||
CAT1_HDMI2(1, "HDMI2", "HDMI 2", new byte[] { 0x00, 0x03 }),
|
||||
|
||||
// Category 2: VW40, VW50, VW60, VW70, VW80, VW85, VW200, HW10, HW15, HW20
|
||||
CAT2_VIDEO(2, "Video", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT2_SVIDEO(2, "SVideo", "S-Video", new byte[] { 0x00, 0x01 }),
|
||||
CAT2_INPUT_A(2, "InputA", "Input A", new byte[] { 0x00, 0x02 }),
|
||||
CAT2_COMPONENT(2, "Component", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT2_HDMI1(2, "HDMI1", "HDMI 1", new byte[] { 0x00, 0x04 }),
|
||||
CAT2_HDMI2(2, "HDMI2", "HDMI 2", new byte[] { 0x00, 0x05 }),
|
||||
|
||||
// Category 3: VW95, VW1000ES, VW1100ES, HW30ES, HW40ES, HW50ES, HW55ES, HW58ES
|
||||
CAT3_INPUT_A(3, "InputA", "Input A", new byte[] { 0x00, 0x02 }),
|
||||
CAT3_COMPONENT(3, "Component", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT3_HDMI1(3, "HDMI1", "HDMI 1", new byte[] { 0x00, 0x04 }),
|
||||
CAT3_HDMI2(3, "HDMI2", "HDMI 2", new byte[] { 0x00, 0x05 }),
|
||||
|
||||
// Category 4: VW100
|
||||
CAT4_VIDEO(4, "Video", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT4_SVIDEO(4, "SVideo", "S-Video", new byte[] { 0x00, 0x01 }),
|
||||
CAT4_INPUT_A(4, "InputA", "Input A", new byte[] { 0x00, 0x02 }),
|
||||
CAT4_COMPONENT(4, "Component", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT4_HDMI(4, "HDMI", null, new byte[] { 0x00, 0x04 }),
|
||||
CAT4_DVI(4, "DVI", null, new byte[] { 0x00, 0x05 }),
|
||||
|
||||
// Category 5: VW90
|
||||
CAT5_VIDEO(5, "Video", null, new byte[] { 0x00, 0x00 }),
|
||||
CAT5_INPUT_A(5, "InputA", "Input A", new byte[] { 0x00, 0x02 }),
|
||||
CAT5_COMPONENT(5, "Component", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT5_HDMI1(5, "HDMI1", "HDMI 1", new byte[] { 0x00, 0x04 }),
|
||||
CAT5_HDMI2(5, "HDMI2", "HDMI 2", new byte[] { 0x00, 0x05 });
|
||||
|
||||
private int category;
|
||||
private String name;
|
||||
private @Nullable String label;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param category a category of projector models for which the video input is available
|
||||
* @param name the name of the video input
|
||||
* @param label the label of the video input; can be null when the label is identical to the name
|
||||
* @param dataCode the data code identifying the video input
|
||||
*/
|
||||
private SonyProjectorInput(int category, String name, @Nullable String label, byte[] dataCode) {
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of projector models for the current video input
|
||||
*
|
||||
* @return the category of projector models
|
||||
*/
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current video input
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label of the current video input
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public @Nullable String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current video input
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available video inputs for a particular category of
|
||||
* projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available video inputs for a provided category of
|
||||
* projector models
|
||||
*/
|
||||
public static List<StateOption> getStateOptions(int category) {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorInput value : SonyProjectorInput.values()) {
|
||||
if (value.getCategory() == category) {
|
||||
options.add(new StateOption(value.getName(),
|
||||
value.getLabel() != null ? value.getLabel() : value.getName()));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the video input associated to a name for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param name the name used to identify the video input
|
||||
*
|
||||
* @return the video input associated to the searched name for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no video input is associated to the searched name for the provided category
|
||||
*/
|
||||
public static SonyProjectorInput getFromName(int category, String name) throws SonyProjectorException {
|
||||
for (SonyProjectorInput value : SonyProjectorInput.values()) {
|
||||
if (value.getCategory() == category && value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for a video input: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the video input associated to a data code for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param dataCode the data code used to identify the video input
|
||||
*
|
||||
* @return the video input associated to the searched data code for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no video input is associated to the searched data code for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorInput getFromDataCode(int category, byte[] dataCode) throws SonyProjectorException {
|
||||
for (SonyProjectorInput value : SonyProjectorInput.values()) {
|
||||
if (value.getCategory() == category && Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid data code for a video input: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different iris modes available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorIrisMode {
|
||||
|
||||
// Category 1: VW385, VW500, VW515, VW520, VW528, VW550, VW570, VW600, VW665, VW675, VW695, VW760, VW870, VW885,
|
||||
// VW995, HW60, HW65, HW68
|
||||
CAT1_FULL(1, "Full", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT1_LIMITED(1, "Limited", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT1_OFF(1, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 2: VW40, VW50, VW60
|
||||
CAT2_ON(2, "On", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT2_AUTO1(2, "Auto1", "Auto 1", new byte[] { 0x00, 0x02 }),
|
||||
CAT2_AUTO2(2, "Auto2", "Auto 2", new byte[] { 0x00, 0x03 }),
|
||||
CAT2_OFF(2, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 3: VW70, VW80, VW85, VW90, VW95, VW200, HW10, HW15, HW20, HW30ES
|
||||
CAT3_AUTO1(3, "Auto1", "Auto 1", new byte[] { 0x00, 0x02 }),
|
||||
CAT3_AUTO2(3, "Auto2", "Auto 2", new byte[] { 0x00, 0x03 }),
|
||||
CAT3_MANUAL(3, "Manual", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT3_OFF(3, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 4: VW100
|
||||
CAT4_ON(4, "On", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT4_AUTO(4, "Auto", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT4_OFF(4, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 5: VW1000ES, VW1100ES, HW50ES, HW55ES
|
||||
CAT5_AUTO_FULL(5, "AutoFull", "Auto Full", new byte[] { 0x00, 0x02 }),
|
||||
CAT5_AUTO_LIMITED(5, "AutoLimited", "Auto Limited", new byte[] { 0x00, 0x03 }),
|
||||
CAT5_MANUAL(5, "Manual", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT5_OFF(5, "Off", null, new byte[] { 0x00, 0x00 });
|
||||
|
||||
private int category;
|
||||
private String name;
|
||||
private @Nullable String label;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param category a category of projector models for which the iris mode is available
|
||||
* @param name the name of the iris mode
|
||||
* @param label the label of the iris mode; can be null when the label is identical to the name
|
||||
* @param dataCode the data code identifying the iris mode
|
||||
*/
|
||||
private SonyProjectorIrisMode(int category, String name, @Nullable String label, byte[] dataCode) {
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of projector models for the current iris mode
|
||||
*
|
||||
* @return the category of projector models
|
||||
*/
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current iris mode
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label of the current iris mode
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public @Nullable String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current iris mode
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available iris modes for a particular category of projector
|
||||
* models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available iris modes for a provided category of
|
||||
* projector models
|
||||
*/
|
||||
public static List<StateOption> getStateOptions(int category) {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorIrisMode value : SonyProjectorIrisMode.values()) {
|
||||
if (value.getCategory() == category) {
|
||||
options.add(new StateOption(value.getName(),
|
||||
value.getLabel() != null ? value.getLabel() : value.getName()));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the iris mode associated to a name for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param name the name used to identify the iris mode
|
||||
*
|
||||
* @return the iris mode associated to the searched name for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no iris mode is associated to the searched name for the provided category
|
||||
*/
|
||||
public static SonyProjectorIrisMode getFromName(int category, String name) throws SonyProjectorException {
|
||||
for (SonyProjectorIrisMode value : SonyProjectorIrisMode.values()) {
|
||||
if (value.getCategory() == category && value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for an iris mode: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the iris mode associated to a data code for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param dataCode the data code used to identify the iris mode
|
||||
*
|
||||
* @return the iris mode associated to the searched data code for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no iris mode is associated to the searched data code for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorIrisMode getFromDataCode(int category, byte[] dataCode) throws SonyProjectorException {
|
||||
for (SonyProjectorIrisMode value : SonyProjectorIrisMode.values()) {
|
||||
if (value.getCategory() == category && Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid data code for an iris mode: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different iris sensitivities available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorIrisSensitivity {
|
||||
|
||||
RECOMMEND("Recommend", new byte[] { 0x00, 0x00 }),
|
||||
FAST("Fast", new byte[] { 0x00, 0x01 }),
|
||||
SLOW("Slow", new byte[] { 0x00, 0x02 });
|
||||
|
||||
private String name;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param name the name of the iris sensitivity
|
||||
* @param dataCode the data code identifying the iris sensitivity
|
||||
*/
|
||||
private SonyProjectorIrisSensitivity(String name, byte[] dataCode) {
|
||||
this.name = name;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current iris sensitivity
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current iris sensitivity
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available iris sensitivities
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available iris sensitivities
|
||||
*/
|
||||
public static List<StateOption> getStateOptions() {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorIrisSensitivity value : SonyProjectorIrisSensitivity.values()) {
|
||||
options.add(new StateOption(value.getName(), value.getName()));
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the iris sensitivity associated to a name
|
||||
*
|
||||
* @param name the name used to identify the iris sensitivity
|
||||
*
|
||||
* @return the iris sensitivity associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no iris sensitivity is associated to the searched name
|
||||
*/
|
||||
public static SonyProjectorIrisSensitivity getFromName(String name) throws SonyProjectorException {
|
||||
for (SonyProjectorIrisSensitivity value : SonyProjectorIrisSensitivity.values()) {
|
||||
if (value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for an iris sensitivity: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the iris sensitivity associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the iris sensitivity
|
||||
*
|
||||
* @return the iris sensitivity associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no iris sensitivity is associated to the searched data code
|
||||
*/
|
||||
public static SonyProjectorIrisSensitivity getFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
for (SonyProjectorIrisSensitivity value : SonyProjectorIrisSensitivity.values()) {
|
||||
if (Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid data code for an iris sensitivity: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
||||
/**
|
||||
* Represents the different kinds of commands
|
||||
*
|
||||
* @author Markus Wehrle - Initial contribution
|
||||
* @author Laurent Garnier - Transform into an enum and rename it
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorItem {
|
||||
|
||||
// Not available for VW40, VW50, VW60, VW70, VW80, VW85, VW90, VW95, VW100, VW200, VW1000ES, VW1100ES,
|
||||
// HW10, HW15, HW20, HW30ES, HW35ES, HW40ES, HW50ES, HW55ES, HW58ES
|
||||
POWER("Power", new byte[] { 0x01, 0x30 }),
|
||||
|
||||
INPUT("Input", new byte[] { 0x00, 0x01 }),
|
||||
CALIBRATION_PRESET("Calibration Preset", new byte[] { 0x00, 0x02 }),
|
||||
CONTRAST("Contrast", new byte[] { 0x00, 0x10 }),
|
||||
BRIGHTNESS("Brigtness", new byte[] { 0x00, 0x11 }),
|
||||
COLOR("Color", new byte[] { 0x00, 0x12 }),
|
||||
HUE("Hue", new byte[] { 0x00, 0x13 }),
|
||||
SHARPNESS("Sharpness", new byte[] { 0x00, 0x14 }),
|
||||
COLOR_TEMP("Color Temperature", new byte[] { 0x00, 0x17 }),
|
||||
|
||||
// Not available for VW100, VW200
|
||||
LAMP_CONTROL("Lamp Control", new byte[] { 0x00, 0x1A }),
|
||||
|
||||
CONTRAST_ENHANCER("Contrast Enhancer", new byte[] { 0x00, 0x1C }),
|
||||
|
||||
// Not available for VW260, VW270, VW285, VW295, VW300, VW315, VW320, VW328, VW350, VW365, HW35ES, HW40ES, HW45ES,
|
||||
// HW58ES
|
||||
IRIS_MODE("Iris Mode", new byte[] { 0x00, 0x1D }),
|
||||
|
||||
// Not available for VW315, VW320, VW328, VW365, VW515, VW520, VW528, VW665, HW60, HW65, HW68
|
||||
REAL_COLOR("Real Color Processing", new byte[] { 0x00, 0x1E }),
|
||||
|
||||
// Not available for VW40, VW50, VW60
|
||||
FILM_MODE("Film Mode", new byte[] { 0x00, 0x1F }),
|
||||
|
||||
ASPECT("Aspect", new byte[] { 0x00, 0x20 }),
|
||||
GAMMA_CORRECTION("Gamma Correction", new byte[] { 0x00, 0x22 }),
|
||||
COLOR_SPACE("Color Space", new byte[] { 0x00, 0x3B }),
|
||||
PICTURE_MUTING("Picture Muting", new byte[] { 0x00, 0x30 }),
|
||||
NR("NR", new byte[] { 0x00, 0x25 }),
|
||||
|
||||
// Not available for VW40, VW50, VW60, VW100, VW200, VW260, VW270, VW285, VW295, VW300, VW315, VW320, VW328, VW350,
|
||||
// VW365, VW385, VW500, VW515, VW520, VW528, VW550, VW570, VW600, VW665, VW675, VW760, VW870, VW885, VW995,
|
||||
// VW1000ES, VW1100ES, HW35ES, HW40ES, HW45ES, HW50ES, HW55ES, HW58ES, HW60, HW65, HW68
|
||||
BLOCK_NR("Block NR", new byte[] { 0x00, 0x26 }),
|
||||
MOSQUITO_NR("Mosquito NR", new byte[] { 0x00, 0x27 }),
|
||||
|
||||
// Not available for VW40, VW50, VW60, VW70, VW80, VW85, VW90, VW95, VW100, VW200, HW10, HW15, HW20, HW30ES
|
||||
MPEG_NR("MPEG NR", new byte[] { 0x00, 0x6C }),
|
||||
|
||||
// Not available for VW260, VW270, VW285, VW295, VW300, VW315, VW320, VW328, VW350, VW365, VW385, VW500, VW515,
|
||||
// VW520, VW528, VW550, VW570, VW600, VW665, VW675, VW760, VW870, VW885, VW995, HW45ES, HW60, HW65, HW68
|
||||
OVERSCAN("Overscan", new byte[] { 0x00, 0x23 }),
|
||||
|
||||
// Not available for VW100, VW260, VW270, VW285, VW295, VW300, VW315, VW320, VW328, VW350, VW365, VW385, VW500,
|
||||
// VW515, VW520, VW528, VW550, VW570, VW600, VW665, VW675, VW760, VW870, VW885, VW995, VW1000ES, VW1100ES, HW35ES,
|
||||
// HW40ES, HW45ES, HW50ES, HW55ES, HW58ES, HW60, HW65, HW68
|
||||
IRIS_SENSITIVITY("Iris Sensitivity", new byte[] { 0x00, 0x56 }),
|
||||
|
||||
// Not available for VW100, VW260, VW270, VW285, VW295, VW300, VW315, VW320, VW328, VW350, VW365, VW760, VW870,
|
||||
// VW885, VW995, HW35ES, HW40ES, HW45ES, HW58ES
|
||||
IRIS_MANUAL("Iris Manual", new byte[] { 0x00, 0x57 }),
|
||||
|
||||
// Not available for VW40, VW50, VW60, VW70, VW100, VW260, VW270, VW285, VW295, VW300, VW315, VW320, VW328, VW350,
|
||||
// VW365, VW385, VW500, VW515, VW520, VW528, VW570, VW600, VW665, VW675, VW695, VW760, VW870, VW885, VW995, HW10,
|
||||
// HW15, HW20, HW30ES, HW45ES, HW60, HW65, HW68
|
||||
FILM_PROJECTION("Film Projection", new byte[] { 0x00, 0x58 }),
|
||||
|
||||
// Not available for VW40, VW50, VW60, VW70, VW100, HW10, HW15, HW20, HW30ES
|
||||
MOTION_ENHANCER("Motion Enhancer", new byte[] { 0x00, 0x59 }),
|
||||
|
||||
// Not available for VW40, VW50, VW60, VW100
|
||||
XVCOLOR("xvColor", new byte[] { 0x00, 0x5A }),
|
||||
|
||||
// Not available for VW40, VW50, VW60, VW70, VW80, VW85, VW90, VW100, VW200, VW260, VW270, VW285, VW295, VW300,
|
||||
// VW315, VW320, VW328, VW350, VW365, HW10, HW15, HW20, HW30ES, HW35ES, HW40ES, HW45ES, HW50ES, HW55ES, HW58ES,
|
||||
// HW60, HW65, HW68
|
||||
PICTURE_POSITION("Picture Position", new byte[] { 0x00, 0x66 }),
|
||||
|
||||
// Not available for VW40, VW50, VW60, VW70, VW85, VW95, VW100, HW15, HW20, HW30ES
|
||||
REALITY_CREATION("Reality Creation", new byte[] { 0x00, 0x67 }),
|
||||
|
||||
// Not available for VW40, VW50, VW60, VW70, VW85, VW95, VW100, VW315, VW320, VW328, VW365, VW1000ES, VW1100ES
|
||||
// HW15, HW20, HW30ES, HW35ES, HW40ES, HW50ES, HW55ES, HW58ES, HW60, HW65, HW68
|
||||
HDR("HDR", new byte[] { 0x00, 0x7C }),
|
||||
|
||||
// Not available for VW40, VW50, VW60, VW70, VW85, VW95, VW100, VW1000ES, VW1100ES
|
||||
// HW15, HW20, HW30ES, HW35ES, HW40ES, HW50ES, HW55ES, HW58ES
|
||||
INPUT_LAG_REDUCTION("Input Lag Reduction", new byte[] { 0x00, (byte) 0x99 }),
|
||||
|
||||
STATUS_ERROR("Status Error", new byte[] { 0x01, 0x01 }),
|
||||
STATUS_POWER("Status Power", new byte[] { 0x01, 0x02 }),
|
||||
LAMP_USE_TIME("Lamp Use Time", new byte[] { 0x01, 0x13 }),
|
||||
|
||||
// Not available for VW40, VW50, VW60, VW70, VW100
|
||||
STATUS_ERROR2("Status Error 2", new byte[] { 0x01, 0x25 }),
|
||||
|
||||
IR_POWER_ON("Power On", new byte[] { 0x17, 0x2E }),
|
||||
IR_POWER_OFF("Power Off", new byte[] { 0x17, 0x2F }),
|
||||
|
||||
CATEGORY_CODE("Category Code", new byte[] { (byte) 0x80, 0x00 }),
|
||||
MODEL_NAME("Model Name", new byte[] { (byte) 0x80, 0x01 }),
|
||||
SERIAL_NUMBER("Serial Number", new byte[] { (byte) 0x80, 0x02 }),
|
||||
INSTALLATION_LOCATION("Installation Location", new byte[] { (byte) 0x80, 0x03 });
|
||||
|
||||
private String name;
|
||||
private byte[] code;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name the item name
|
||||
* @param code the data code associated to the item
|
||||
*/
|
||||
private SonyProjectorItem(String name, byte[] code) {
|
||||
this.name = name;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code associated to the current item
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item name
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different lamp control modes available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorLampControl {
|
||||
|
||||
HIGH("High", new byte[] { 0x00, 0x01 }),
|
||||
LOW("Low", new byte[] { 0x00, 0x00 });
|
||||
|
||||
private String name;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param name the name of the lamp control mode
|
||||
* @param dataCode the data code identifying the lamp control mode
|
||||
*/
|
||||
private SonyProjectorLampControl(String name, byte[] dataCode) {
|
||||
this.name = name;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current lamp control mode
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current lamp control mode
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available lamp control modes
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available lamp control modes
|
||||
*/
|
||||
public static List<StateOption> getStateOptions() {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorLampControl value : SonyProjectorLampControl.values()) {
|
||||
options.add(new StateOption(value.getName(), value.getName()));
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lamp control mode associated to a name
|
||||
*
|
||||
* @param name the name used to identify the lamp control mode
|
||||
*
|
||||
* @return the lamp control mode associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no lamp control mode is associated to the searched name
|
||||
*/
|
||||
public static SonyProjectorLampControl getFromName(String name) throws SonyProjectorException {
|
||||
for (SonyProjectorLampControl value : SonyProjectorLampControl.values()) {
|
||||
if (value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for a lamp control mode: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lamp control mode associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the lamp control mode
|
||||
*
|
||||
* @return the lamp control mode associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no lamp control mode is associated to the searched data code
|
||||
*/
|
||||
public static SonyProjectorLampControl getFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
for (SonyProjectorLampControl value : SonyProjectorLampControl.values()) {
|
||||
if (Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid data code for a lamp control mode: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different mosquito noise reduction modes available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorMosquitoNr {
|
||||
|
||||
HIGH("High", new byte[] { 0x00, 0x03 }),
|
||||
MIDDLE("Middle", new byte[] { 0x00, 0x02 }),
|
||||
LOW("Low", new byte[] { 0x00, 0x01 }),
|
||||
OFF("Off", new byte[] { 0x00, 0x00 });
|
||||
|
||||
private String name;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param name the name of the mosquito noise reduction mode
|
||||
* @param dataCode the data code identifying the mosquito noise reduction mode
|
||||
*/
|
||||
private SonyProjectorMosquitoNr(String name, byte[] dataCode) {
|
||||
this.name = name;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current mosquito noise reduction mode
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current mosquito noise reduction mode
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available mosquito noise reduction modes
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available mosquito noise reduction modes
|
||||
*/
|
||||
public static List<StateOption> getStateOptions() {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorMosquitoNr value : SonyProjectorMosquitoNr.values()) {
|
||||
options.add(new StateOption(value.getName(), value.getName()));
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mosquito noise reduction mode associated to a name
|
||||
*
|
||||
* @param name the name used to identify the mosquito noise reduction mode
|
||||
*
|
||||
* @return the mosquito noise reduction mode associated to the searched name
|
||||
*
|
||||
* @throws SonyProjectorException - If no mosquito noise reduction mode is associated to the searched name
|
||||
*/
|
||||
public static SonyProjectorMosquitoNr getFromName(String name) throws SonyProjectorException {
|
||||
for (SonyProjectorMosquitoNr value : SonyProjectorMosquitoNr.values()) {
|
||||
if (value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for a mosquito noise reduction mode: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mosquito noise reduction mode associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the mosquito noise reduction mode
|
||||
*
|
||||
* @return the mosquito noise reduction mode associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no mosquito noise reduction mode is associated to the searched data code
|
||||
*/
|
||||
public static SonyProjectorMosquitoNr getFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
for (SonyProjectorMosquitoNr value : SonyProjectorMosquitoNr.values()) {
|
||||
if (Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException(
|
||||
"Invalid data code for a mosquito noise reduction mode: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different motion enhancer modes available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorMotionEnhancer {
|
||||
|
||||
// Category 1: VW260, VW285, VW300, VW315, VW320, VW328, VW350, VW360, VW365, VW385, VW500, VW515, VW520, VW528,
|
||||
// VW570, VW600, VW665, VW675, VW695, VW760, VW870, VW885, VW995, HW45ES, HW60, HW65, HW68
|
||||
CAT1_SMOOTH_HIGH(1, "SmoothHigh", "Smooth High", new byte[] { 0x00, 0x01 }),
|
||||
CAT1_SMOOTH_LOW(1, "SmoothLow", "Smooth Low", new byte[] { 0x00, 0x02 }),
|
||||
CAT1_IMPULSE(1, "Impulse", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT1_COMBINATION(1, "Combination", null, new byte[] { 0x00, 0x04 }),
|
||||
CAT1_TRUE_CINEMA(1, "TrueCinema", "True Cinema", new byte[] { 0x00, 0x05 }),
|
||||
CAT1_OFF(1, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 2: VW80, VW85, VW90, VW95, VW200, VW1000ES, VW1100ES, HW35ES, HW40ES, HW50ES, HW55ES, HW58ES
|
||||
CAT2_HIGH(2, "High", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT2_LOW(2, "Low", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT2_OFF(2, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 3: VW270, VW295
|
||||
CAT3_SMOOTH_HIGH(3, "SmoothHigh", "Smooth High", new byte[] { 0x00, 0x01 }),
|
||||
CAT3_SMOOTH_LOW(3, "SmoothLow", "Smooth Low", new byte[] { 0x00, 0x02 }),
|
||||
CAT3_TRUE_CINEMA(3, "TrueCinema", "True Cinema", new byte[] { 0x00, 0x05 }),
|
||||
CAT3_OFF(3, "Off", null, new byte[] { 0x00, 0x00 });
|
||||
|
||||
private int category;
|
||||
private String name;
|
||||
private @Nullable String label;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param category a category of projector models for which the motion enhancer mode is available
|
||||
* @param name the name of the motion enhancer mode
|
||||
* @param label the label of the motion enhancer mode; can be null when the label is identical to the name
|
||||
* @param dataCode the data code identifying the motion enhancer mode
|
||||
*/
|
||||
private SonyProjectorMotionEnhancer(int category, String name, @Nullable String label, byte[] dataCode) {
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of projector models for the current motion enhancer mode
|
||||
*
|
||||
* @return the category of projector models
|
||||
*/
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current motion enhancer mode
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label of the current motion enhancer mode
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public @Nullable String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current motion enhancer mode
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available motion enhancer modes for a particular category
|
||||
* of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available motion enhancer modes for a provided category
|
||||
* of projector models
|
||||
*/
|
||||
public static List<StateOption> getStateOptions(int category) {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorMotionEnhancer value : SonyProjectorMotionEnhancer.values()) {
|
||||
if (value.getCategory() == category) {
|
||||
options.add(new StateOption(value.getName(),
|
||||
value.getLabel() != null ? value.getLabel() : value.getName()));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the motion enhancer mode associated to a name for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param name the name used to identify the motion enhancer mode
|
||||
*
|
||||
* @return the motion enhancer mode associated to the searched name for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no motion enhancer mode is associated to the searched name for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorMotionEnhancer getFromName(int category, String name) throws SonyProjectorException {
|
||||
for (SonyProjectorMotionEnhancer value : SonyProjectorMotionEnhancer.values()) {
|
||||
if (value.getCategory() == category && value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for a motion enhancer mode: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the motion enhancer mode associated to a data code for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param dataCode the data code used to identify the motion enhancer mode
|
||||
*
|
||||
* @return the motion enhancer mode associated to the searched data code for the provided category of projector
|
||||
* models
|
||||
*
|
||||
* @throws SonyProjectorException - If no motion enhancer mode is associated to the searched data code for the
|
||||
* provided category
|
||||
*/
|
||||
public static SonyProjectorMotionEnhancer getFromDataCode(int category, byte[] dataCode)
|
||||
throws SonyProjectorException {
|
||||
for (SonyProjectorMotionEnhancer value : SonyProjectorMotionEnhancer.values()) {
|
||||
if (value.getCategory() == category && Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException(
|
||||
"Invalid data code for a motion enhancer mode: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different MPEG noise reduction modes available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorMpegNr {
|
||||
|
||||
// Category 1: VW260, VW270, VW285, VW295, VW315, VW320, VW328, VW365, VW>385, VW500, VW515, VW520, VW528, VW550,
|
||||
// VW570, VW600, VW665, VW675, VW695, VW760, VW870, VW885, VW995, HW60, HW65, HW68
|
||||
CAT1_AUTO(1, "Auto", null, new byte[] { 0x00, 0x04 }),
|
||||
CAT1_HIGH(1, "High", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT1_MIDDLE(1, "Middle", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT1_LOW(1, "Low", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT1_OFF(1, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 2: HW35ES, HW40ES, HW45ES, HW50ES, HW55ES, HW58ES
|
||||
CAT2_HIGH(2, "High", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT2_MIDDLE(2, "Middle", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT2_LOW(2, "Low", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT2_OFF(2, "Off", null, new byte[] { 0x00, 0x00 });
|
||||
|
||||
private int category;
|
||||
private String name;
|
||||
private @Nullable String label;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param category a category of projector models for which the MPEG noise reduction mode is available
|
||||
* @param name the name of the MPEG noise reduction mode
|
||||
* @param label the label of the MPEG noise reduction mode; can be null when the label is identical to the name
|
||||
* @param dataCode the data code identifying the MPEG noise reduction mode
|
||||
*/
|
||||
private SonyProjectorMpegNr(int category, String name, @Nullable String label, byte[] dataCode) {
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of projector models for the current MPEG noise reduction mode
|
||||
*
|
||||
* @return the category of projector models
|
||||
*/
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current MPEG noise reduction mode
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label of the current MPEG noise reduction mode
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public @Nullable String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current MPEG noise reduction mode
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available MPEG noise reduction modes for a particular
|
||||
* category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available MPEG noise reduction modes for a provided
|
||||
* category of projector models
|
||||
*/
|
||||
public static List<StateOption> getStateOptions(int category) {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorMpegNr value : SonyProjectorMpegNr.values()) {
|
||||
if (value.getCategory() == category) {
|
||||
options.add(new StateOption(value.getName(),
|
||||
value.getLabel() != null ? value.getLabel() : value.getName()));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MPEG noise reduction mode associated to a name for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param name the name used to identify the MPEG noise reduction mode
|
||||
*
|
||||
* @return the MPEG noise reduction mode associated to the searched name for the provided category of projector
|
||||
* models
|
||||
*
|
||||
* @throws SonyProjectorException - If no MPEG noise reduction mode is associated to the searched name for the
|
||||
* provided category
|
||||
*/
|
||||
public static SonyProjectorMpegNr getFromName(int category, String name) throws SonyProjectorException {
|
||||
for (SonyProjectorMpegNr value : SonyProjectorMpegNr.values()) {
|
||||
if (value.getCategory() == category && value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for a MPEG noise reduction mode: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MPEG noise reduction mode associated to a data code for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param dataCode the data code used to identify the MPEG noise reduction mode
|
||||
*
|
||||
* @return the MPEG noise reduction mode associated to the searched data code for the provided category of projector
|
||||
* models
|
||||
*
|
||||
* @throws SonyProjectorException - If no MPEG noise reduction mode is associated to the searched data code for the
|
||||
* provided category
|
||||
*/
|
||||
public static SonyProjectorMpegNr getFromDataCode(int category, byte[] dataCode) throws SonyProjectorException {
|
||||
for (SonyProjectorMpegNr value : SonyProjectorMpegNr.values()) {
|
||||
if (value.getCategory() == category && Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException(
|
||||
"Invalid data code for a MPEG noise reduction mode: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different noise reduction modes available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorNr {
|
||||
|
||||
// Category 1: VW260, VW270, VW285, VW295, VW300, VW315, VW320, VW328, VW350, VW365, VW385, VW500, VW515, VW520,
|
||||
// VW528, VW550, VW570, VW600, VW665, VW675, VW695, VW760, VW870, VW885, VW995, HW60, HW65, HW68
|
||||
CAT1_AUTO(1, "Auto", null, new byte[] { 0x00, 0x04 }),
|
||||
CAT1_HIGH(1, "High", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT1_MIDDLE(1, "Middle", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT1_LOW(1, "Low", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT1_OFF(1, "Off", null, new byte[] { 0x00, 0x00 }),
|
||||
|
||||
// Category 2: VW40, VW50, VW60, VW70, VW80, VW85, VW90, VW95, VW100, VW200, VW1000ES, VW1100ES,
|
||||
// HW10, HW15, HW20, HW30ES, HW35ES, HW40ES, HW45ES, HW50ES, HW55ES, HW58ES
|
||||
CAT2_HIGH(2, "High", null, new byte[] { 0x00, 0x03 }),
|
||||
CAT2_MIDDLE(2, "Middle", null, new byte[] { 0x00, 0x02 }),
|
||||
CAT2_LOW(2, "Low", null, new byte[] { 0x00, 0x01 }),
|
||||
CAT2_OFF(2, "Off", null, new byte[] { 0x00, 0x00 });
|
||||
|
||||
private int category;
|
||||
private String name;
|
||||
private @Nullable String label;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param category a category of projector models for which the noise reduction mode is available
|
||||
* @param name the name of the noise reduction mode
|
||||
* @param label the label of the noise reduction mode; can be null when the label is identical to the name
|
||||
* @param dataCode the data code identifying the noise reduction mode
|
||||
*/
|
||||
private SonyProjectorNr(int category, String name, @Nullable String label, byte[] dataCode) {
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of projector models for the current noise reduction mode
|
||||
*
|
||||
* @return the category of projector models
|
||||
*/
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current noise reduction mode
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label of the current noise reduction mode
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public @Nullable String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current noise reduction mode
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available noise reduction modes for a particular category
|
||||
* of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available noise reduction modes for a provided category
|
||||
* of projector models
|
||||
*/
|
||||
public static List<StateOption> getStateOptions(int category) {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorNr value : SonyProjectorNr.values()) {
|
||||
if (value.getCategory() == category) {
|
||||
options.add(new StateOption(value.getName(),
|
||||
value.getLabel() != null ? value.getLabel() : value.getName()));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the noise reduction mode associated to a name for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param name the name used to identify the noise reduction mode
|
||||
*
|
||||
* @return the noise reduction mode associated to the searched name for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no noise reduction mode is associated to the searched name for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorNr getFromName(int category, String name) throws SonyProjectorException {
|
||||
for (SonyProjectorNr value : SonyProjectorNr.values()) {
|
||||
if (value.getCategory() == category && value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for a noise reduction mode: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the noise reduction mode associated to a data code for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param dataCode the data code used to identify the noise reduction mode
|
||||
*
|
||||
* @return the noise reduction mode associated to the searched data code for the provided category of projector
|
||||
* models
|
||||
*
|
||||
* @throws SonyProjectorException - If no noise reduction mode is associated to the searched data code for the
|
||||
* provided category
|
||||
*/
|
||||
public static SonyProjectorNr getFromDataCode(int category, byte[] dataCode) throws SonyProjectorException {
|
||||
for (SonyProjectorNr value : SonyProjectorNr.values()) {
|
||||
if (value.getCategory() == category && Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException(
|
||||
"Invalid data code for a noise reduction mode: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.types.StateOption;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different picture positions available for the projector
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorPicturePosition {
|
||||
|
||||
// Category 1: VW385, VW500, VW515, VW520, VW528, VW550, VW570, VW600, VW665, VW675, VW695, VW760, VW870, VW885,
|
||||
// VW995, VW1000ES, VW1100ES
|
||||
CAT1_185(1, "185", "1.85:1", new byte[] { 0x00, 0x00 }),
|
||||
CAT1_235(1, "235", "2.35:1", new byte[] { 0x00, 0x01 }),
|
||||
CAT1_CUSTOM1(1, "Custom1", "Custom 1", new byte[] { 0x00, 0x02 }),
|
||||
CAT1_CUSTOM2(1, "Custom2", "Custom 2", new byte[] { 0x00, 0x03 }),
|
||||
CAT1_CUSTOM3(1, "Custom3", "Custom 3", new byte[] { 0x00, 0x04 }),
|
||||
|
||||
// Category 2: VW95
|
||||
CAT2_POSITION1(2, "Position1", "Position 1", new byte[] { 0x00, 0x00 }),
|
||||
CAT2_POSITION2(2, "Position2", "Position 2", new byte[] { 0x00, 0x01 }),
|
||||
CAT2_POSITION3(2, "Position3", "Position 3", new byte[] { 0x00, 0x02 }),
|
||||
CAT2_POSITION4(2, "Position4", "Position 4", new byte[] { 0x00, 0x03 }),
|
||||
CAT2_POSITION5(2, "Position5", "Position 5", new byte[] { 0x00, 0x04 });
|
||||
|
||||
private int category;
|
||||
private String name;
|
||||
private @Nullable String label;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param category a category of projector models for which the picture position is available
|
||||
* @param name the name of the picture position
|
||||
* @param label the label of the picture position; can be null when the label is identical to the name
|
||||
* @param dataCode the data code identifying the picture position
|
||||
*/
|
||||
private SonyProjectorPicturePosition(int category, String name, @Nullable String label, byte[] dataCode) {
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of projector models for the current picture position
|
||||
*
|
||||
* @return the category of projector models
|
||||
*/
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current picture position
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label of the current picture position
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public @Nullable String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current picture position
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of {@link StateOption} associated to the available picture positions for a particular category of
|
||||
* projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
*
|
||||
* @return the list of {@link StateOption} associated to the available picture positions for a provided category of
|
||||
* projector models
|
||||
*/
|
||||
public static List<StateOption> getStateOptions(int category) {
|
||||
List<StateOption> options = new ArrayList<>();
|
||||
for (SonyProjectorPicturePosition value : SonyProjectorPicturePosition.values()) {
|
||||
if (value.getCategory() == category) {
|
||||
options.add(new StateOption(value.getName(),
|
||||
value.getLabel() != null ? value.getLabel() : value.getName()));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the picture position associated to a name for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param name the name used to identify the picture position
|
||||
*
|
||||
* @return the picture position associated to the searched name for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no picture position is associated to the searched name for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorPicturePosition getFromName(int category, String name) throws SonyProjectorException {
|
||||
for (SonyProjectorPicturePosition value : SonyProjectorPicturePosition.values()) {
|
||||
if (value.getCategory() == category && value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid name for a picture position: " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the picture position associated to a data code for a particular category of projector models
|
||||
*
|
||||
* @param category a category of projector models
|
||||
* @param dataCode the data code used to identify the picture position
|
||||
*
|
||||
* @return the picture position associated to the searched data code for the provided category of projector models
|
||||
*
|
||||
* @throws SonyProjectorException - If no picture position is associated to the searched data code for the provided
|
||||
* category
|
||||
*/
|
||||
public static SonyProjectorPicturePosition getFromDataCode(int category, byte[] dataCode)
|
||||
throws SonyProjectorException {
|
||||
for (SonyProjectorPicturePosition value : SonyProjectorPicturePosition.values()) {
|
||||
if (value.getCategory() == category && Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid data code for a picture position: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different power status of the projector
|
||||
*
|
||||
* @author Markus Wehrle - Initial contribution
|
||||
* @author Laurent Garnier - Transform into an enum
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorStatusPower {
|
||||
|
||||
STANDBY("Standby", new byte[] { 0x00, 0x00 }, false),
|
||||
START_UP("Start Up", new byte[] { 0x00, 0x01 }, true),
|
||||
STARTUP_LAMP("Sartup Lamp", new byte[] { 0x00, 0x02 }, true),
|
||||
POWER_ON("Power On", new byte[] { 0x00, 0x03 }, true),
|
||||
COOLING1("Cooling1", new byte[] { 0x00, 0x04 }, false),
|
||||
COOLING2("Cooling1", new byte[] { 0x00, 0x05 }, false),
|
||||
SAVING_COOLING1("Saving Cooling1", new byte[] { 0x00, 0x06 }, false),
|
||||
SAVING_COOLING2("Saving Cooling2", new byte[] { 0x00, 0x07 }, false),
|
||||
SAVING_STANDBY("Saving Standby", new byte[] { 0x00, 0x08 }, false);
|
||||
|
||||
private String name;
|
||||
private byte[] dataCode;
|
||||
private boolean on;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param name the name of the power status
|
||||
* @param dataCode the data code identifying the power status
|
||||
* @param on the associated ON or OFF status of the power status
|
||||
*/
|
||||
private SonyProjectorStatusPower(String name, byte[] dataCode, boolean on) {
|
||||
this.name = name;
|
||||
this.dataCode = dataCode;
|
||||
this.on = on;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the current power status
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current power status
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated ON or OFF status of the current power status
|
||||
*
|
||||
* @return true if the current power status ios associated to an ON status
|
||||
*/
|
||||
public boolean isOn() {
|
||||
return on;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the power status associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the power status
|
||||
*
|
||||
* @return the power status associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no power status is associated to the searched data code
|
||||
*/
|
||||
public static SonyProjectorStatusPower getFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
for (SonyProjectorStatusPower value : SonyProjectorStatusPower.values()) {
|
||||
if (Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Invalid data code for a power status: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication.sdcp;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorModel;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorConnector;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorItem;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Class for communicating with Sony Projectors through an IP connection
|
||||
* using Pj Talk service (SDCP protocol)
|
||||
*
|
||||
* @author Markus Wehrle - Initial contribution
|
||||
* @author Laurent Garnier - Refactoring to consider SonyProjectorConnector and add a full check of responses
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class SonyProjectorSdcpConnector extends SonyProjectorConnector {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SonyProjectorSdcpConnector.class);
|
||||
|
||||
private static final int DEFAULT_PORT = 53484;
|
||||
private static final String DEFAULT_COMMUNITY = "SONY";
|
||||
private static final long READ_TIMEOUT_MS = TimeUnit.MILLISECONDS.toMillis(3500);
|
||||
private static final int MSG_MIN_SIZE = 10;
|
||||
private static final int MSG_MAX_SIZE = 34;
|
||||
|
||||
protected static final byte[] HEADER = new byte[] { 0x02, 0x0A };
|
||||
private static final byte SET = 0x00;
|
||||
private static final byte GET = 0x01;
|
||||
protected static final byte OK = 0x01;
|
||||
|
||||
private String address;
|
||||
private int port;
|
||||
private String community;
|
||||
|
||||
private @Nullable Socket clientSocket;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param address the IP address of the projector
|
||||
* @param port the TCP port to be used
|
||||
* @param community the community name of the equipment
|
||||
* @param model the projector model in use
|
||||
*/
|
||||
public SonyProjectorSdcpConnector(String address, @Nullable Integer port, @Nullable String community,
|
||||
SonyProjectorModel model) {
|
||||
this(address, port, community, model, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param address the IP address of the projector
|
||||
* @param port the TCP port to be used
|
||||
* @param community the community name of the equipment
|
||||
* @param model the projector model in use
|
||||
* @param simu whether the communication is simulated or real
|
||||
*/
|
||||
protected SonyProjectorSdcpConnector(String address, @Nullable Integer port, @Nullable String community,
|
||||
SonyProjectorModel model, boolean simu) {
|
||||
super(model, false);
|
||||
|
||||
this.address = address;
|
||||
|
||||
// init port
|
||||
if (port != null && port > 0) {
|
||||
this.port = port;
|
||||
} else {
|
||||
this.port = DEFAULT_PORT;
|
||||
}
|
||||
|
||||
// init community
|
||||
if (community != null && !community.isEmpty() && community.length() == 4) {
|
||||
this.community = community;
|
||||
} else {
|
||||
this.community = DEFAULT_COMMUNITY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the community name of the equipment
|
||||
*
|
||||
* @return the community name of the equipment
|
||||
*/
|
||||
public String getCommunity() {
|
||||
return community;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void open() throws SonyProjectorException {
|
||||
if (!connected) {
|
||||
logger.debug("Opening SDCP connection IP {} port {}", this.address, this.port);
|
||||
try {
|
||||
Socket clientSocket = new Socket(this.address, this.port);
|
||||
clientSocket.setSoTimeout(200);
|
||||
|
||||
dataOut = new DataOutputStream(clientSocket.getOutputStream());
|
||||
dataIn = new DataInputStream(clientSocket.getInputStream());
|
||||
|
||||
this.clientSocket = clientSocket;
|
||||
|
||||
connected = true;
|
||||
|
||||
logger.debug("SDCP connection opened");
|
||||
} catch (IOException | SecurityException | IllegalArgumentException e) {
|
||||
logger.debug("Opening SDCP connection failed: {}", e.getMessage());
|
||||
throw new SonyProjectorException("Opening SDCP connection failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
if (connected) {
|
||||
logger.debug("closing SDCP connection");
|
||||
super.close();
|
||||
Socket clientSocket = this.clientSocket;
|
||||
if (clientSocket != null) {
|
||||
try {
|
||||
clientSocket.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
this.clientSocket = null;
|
||||
}
|
||||
connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte[] buildMessage(SonyProjectorItem item, boolean getCommand, byte[] data) {
|
||||
byte[] communityData = community.getBytes();
|
||||
byte[] message = new byte[10 + data.length];
|
||||
message[0] = HEADER[0];
|
||||
message[1] = HEADER[1];
|
||||
message[2] = communityData[0];
|
||||
message[3] = communityData[1];
|
||||
message[4] = communityData[2];
|
||||
message[5] = communityData[3];
|
||||
message[6] = getCommand ? GET : SET;
|
||||
message[7] = item.getCode()[0];
|
||||
message[8] = item.getCode()[1];
|
||||
message[9] = getCommand ? 0 : (byte) data.length;
|
||||
if (!getCommand) {
|
||||
System.arraycopy(data, 0, message, 10, data.length);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes
|
||||
* actually read is returned as an integer.
|
||||
* In case of socket timeout, the returned value is 0.
|
||||
*
|
||||
* @param dataBuffer the buffer into which the data is read.
|
||||
* @return the total number of bytes read into the buffer, or -1 if there is no more data because the end of the
|
||||
* stream has been reached.
|
||||
* @throws SonyProjectorException - If the input stream is null, if the first byte cannot be read for any reason
|
||||
* other than the end of the file, if the input stream has been closed, or if some other I/O error
|
||||
* occurs.
|
||||
*/
|
||||
@Override
|
||||
protected int readInput(byte[] dataBuffer) throws SonyProjectorException {
|
||||
InputStream dataIn = this.dataIn;
|
||||
if (dataIn == null) {
|
||||
throw new SonyProjectorException("readInput failed: input stream is null");
|
||||
}
|
||||
try {
|
||||
return dataIn.read(dataBuffer);
|
||||
} catch (SocketTimeoutException e) {
|
||||
return 0;
|
||||
} catch (IOException e) {
|
||||
logger.debug("readInput failed: {}", e.getMessage());
|
||||
throw new SonyProjectorException("readInput failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized byte[] readResponse() throws SonyProjectorException {
|
||||
logger.debug("readResponse (timeout = {} ms)...", READ_TIMEOUT_MS);
|
||||
byte[] message = new byte[MSG_MAX_SIZE];
|
||||
boolean timeout = false;
|
||||
byte[] dataBuffer = new byte[MSG_MAX_SIZE];
|
||||
int count = 0;
|
||||
long startTimeRead = System.currentTimeMillis();
|
||||
while ((count < MSG_MIN_SIZE) && !timeout) {
|
||||
logger.trace("readResponse readInput...");
|
||||
int len = readInput(dataBuffer);
|
||||
logger.trace("readResponse readInput {} => {}", len, HexUtils.bytesToHex(dataBuffer));
|
||||
if (len > 0) {
|
||||
int oldCount = count;
|
||||
count = ((oldCount + len) > MSG_MAX_SIZE) ? MSG_MAX_SIZE : (oldCount + len);
|
||||
System.arraycopy(dataBuffer, 0, message, oldCount, count - oldCount);
|
||||
}
|
||||
timeout = (System.currentTimeMillis() - startTimeRead) > READ_TIMEOUT_MS;
|
||||
}
|
||||
if ((count < MSG_MIN_SIZE) && timeout) {
|
||||
logger.debug("readResponse timeout: only {} bytes read after {} ms", count, READ_TIMEOUT_MS);
|
||||
throw new SonyProjectorException("readResponse failed: timeout");
|
||||
}
|
||||
logger.debug("readResponse: {}", HexUtils.bytesToHex(message));
|
||||
if (count < MSG_MIN_SIZE) {
|
||||
logger.debug("readResponse: unexpected response data length: {}", count);
|
||||
throw new SonyProjectorException("Unexpected response data length");
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateResponse(byte[] responseMessage, SonyProjectorItem item) throws SonyProjectorException {
|
||||
// Check response size
|
||||
if (responseMessage.length < MSG_MIN_SIZE) {
|
||||
logger.debug("Unexpected response data length: {}", responseMessage.length);
|
||||
throw new SonyProjectorException("Unexpected response data length");
|
||||
}
|
||||
|
||||
// Header should be a sony projector header
|
||||
byte[] headerMsg = Arrays.copyOf(responseMessage, HEADER.length);
|
||||
if (!Arrays.equals(headerMsg, HEADER)) {
|
||||
logger.debug("Unexpected HEADER in response: {} rather than {}", HexUtils.bytesToHex(headerMsg),
|
||||
HexUtils.bytesToHex(HEADER));
|
||||
throw new SonyProjectorException("Unexpected HEADER in response");
|
||||
}
|
||||
|
||||
// Community should be the same as used for sending
|
||||
byte[] communityResponseMsg = Arrays.copyOfRange(responseMessage, 2, 6);
|
||||
if (!Arrays.equals(communityResponseMsg, community.getBytes())) {
|
||||
logger.debug("Unexpected community in response: {} rather than {}",
|
||||
HexUtils.bytesToHex(communityResponseMsg), HexUtils.bytesToHex(community.getBytes()));
|
||||
throw new SonyProjectorException("Unexpected community in response");
|
||||
}
|
||||
|
||||
// Item number should be the same as used for sending
|
||||
byte[] itemResponseMsg = Arrays.copyOfRange(responseMessage, 7, 9);
|
||||
if (!Arrays.equals(itemResponseMsg, item.getCode())) {
|
||||
logger.debug("Unexpected item number in response: {} rather than {}", HexUtils.bytesToHex(itemResponseMsg),
|
||||
HexUtils.bytesToHex(item.getCode()));
|
||||
throw new SonyProjectorException("Unexpected item number in response");
|
||||
}
|
||||
|
||||
// Check response size
|
||||
int dataLength = responseMessage[9] & 0x000000FF;
|
||||
if (responseMessage.length < (10 + dataLength)) {
|
||||
logger.debug("Unexpected response data length: {}", dataLength);
|
||||
throw new SonyProjectorException("Unexpected response data length");
|
||||
}
|
||||
|
||||
// byte 7 is expected to be 1, which indicates that the request was successful
|
||||
if (responseMessage[6] != OK) {
|
||||
String msg = "KO";
|
||||
if (dataLength == 12) {
|
||||
byte[] errorCode = Arrays.copyOfRange(responseMessage, 10, 12);
|
||||
try {
|
||||
SonyProjectorSdcpError error = SonyProjectorSdcpError.getFromDataCode(errorCode);
|
||||
msg = error.getMessage();
|
||||
} catch (SonyProjectorException e) {
|
||||
}
|
||||
}
|
||||
logger.debug("{} received in response", msg);
|
||||
throw new SonyProjectorException(msg + " received in response");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte[] getResponseData(byte[] responseMessage) {
|
||||
// Data length is in 10th byte of message
|
||||
int dataLength = responseMessage[9] & 0x000000FF;
|
||||
if (dataLength > 0) {
|
||||
return Arrays.copyOfRange(responseMessage, 10, 10 + dataLength);
|
||||
} else {
|
||||
return new byte[] { (byte) 0xFF };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the model name
|
||||
*
|
||||
* @return the model name
|
||||
*
|
||||
* @throws SonyProjectorException - In case of any problem
|
||||
*/
|
||||
public String getModelName() throws SonyProjectorException {
|
||||
return new String(getSetting(SonyProjectorItem.MODEL_NAME), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication.sdcp;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different error codes returned by the projector in Ethernet mode
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorSdcpError {
|
||||
|
||||
INVALID_ITEM("Invalid Item", new byte[] { 0x01, 0x01 }),
|
||||
INVALID_ITEM_REQUEST("Invalid Item Request", new byte[] { 0x01, 0x02 }),
|
||||
INVALID_LENGTH("Invalid Length", new byte[] { 0x01, 0x03 }),
|
||||
INVALID_DATA("Invalid Data", new byte[] { 0x01, 0x04 }),
|
||||
SHORT_DATA("Short Data", new byte[] { 0x01, 0x11 }),
|
||||
NOT_APPLICABLE_ITEM("Not Applicable Item", new byte[] { 0x01, (byte) 0x80 }),
|
||||
DIFFERENT_COMMUNITY("Different Community", new byte[] { 0x02, 0x01 }),
|
||||
INVALID_VERSION("Invalid Version", new byte[] { 0x03, 0x01 }),
|
||||
INVALID_CATEGORY("Invalid Category", new byte[] { 0x03, 0x02 }),
|
||||
INVALID_REQUEST("Invalid Request", new byte[] { 0x03, 0x03 }),
|
||||
SHORT_HEADER("Short Header", new byte[] { 0x03, 0x11 }),
|
||||
SHORT_COMMUNITY("Short Community", new byte[] { 0x03, 0x12 }),
|
||||
SHORT_COMMAND("Short Command", new byte[] { 0x03, 0x13 }),
|
||||
NETWORK_TIMEOUT("Network Timeout", new byte[] { 0x20, 0x01 }),
|
||||
COMM_TIMEOUT("Comm Timeout", new byte[] { (byte) 0xF0, 0x01 }),
|
||||
CHECK_SUM_ERROR("Check Sum Error", new byte[] { (byte) 0xF0, 0x10 }),
|
||||
FRAMING_ERROR("Framing Error", new byte[] { (byte) 0xF0, 0x20 }),
|
||||
PARITY_ERROR("Parity Error", new byte[] { (byte) 0xF0, 0x30 }),
|
||||
OVER_RUN_ERROR("Over Run Error", new byte[] { (byte) 0xF0, 0x40 }),
|
||||
OTHER_COMM_ERROR("Other Comm Error", new byte[] { (byte) 0xF0, 0x50 }),
|
||||
UNKNOWN_RESPONSE("Unknown Response", new byte[] { (byte) 0xF0, (byte) 0xF0 }),
|
||||
READ_ERROR("Read Error", new byte[] { (byte) 0xF1, 0x10 }),
|
||||
WRITE_ERROR("Write Error", new byte[] { (byte) 0xF1, 0x20 });
|
||||
|
||||
private String message;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param message the error message
|
||||
* @param dataCode the data code identifying the error
|
||||
*/
|
||||
private SonyProjectorSdcpError(String message, byte[] dataCode) {
|
||||
this.message = message;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error message
|
||||
*
|
||||
* @return the message
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the error
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error associated to a data code
|
||||
*
|
||||
* @param dataCode the data code
|
||||
*
|
||||
* @return the error associated to the data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no error is associated to the data code
|
||||
*/
|
||||
public static SonyProjectorSdcpError getFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
for (SonyProjectorSdcpError value : SonyProjectorSdcpError.values()) {
|
||||
if (Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Unknwon error code: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication.sdcp;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorModel;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorItem;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Class for communicating with Sony Projectors through an IP connection
|
||||
* using Pj Talk service (SDCP protocol)
|
||||
*
|
||||
* @author Markus Wehrle - Initial contribution
|
||||
* @author Laurent Garnier - Refactoring to consider SonyProjectorConnector and add a full check of responses
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class SonyProjectorSdcpSimuConnector extends SonyProjectorSdcpConnector {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SonyProjectorSdcpSimuConnector.class);
|
||||
|
||||
private SonyProjectorItem lastItem = SonyProjectorItem.POWER;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param model the projector model in use
|
||||
*/
|
||||
public SonyProjectorSdcpSimuConnector(SonyProjectorModel model) {
|
||||
super("127.0.0.1", null, null, model, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void open() throws SonyProjectorException {
|
||||
if (!connected) {
|
||||
connected = true;
|
||||
logger.debug("Simulated SDCP connection opened");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
if (connected) {
|
||||
logger.debug("Simulated SDCP connection closed");
|
||||
connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte[] buildMessage(SonyProjectorItem item, boolean getCommand, byte[] data) {
|
||||
lastItem = item;
|
||||
return super.buildMessage(item, getCommand, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized byte[] readResponse() throws SonyProjectorException {
|
||||
byte[] message = new byte[34];
|
||||
byte[] communityData = getCommunity().getBytes();
|
||||
message[0] = HEADER[0];
|
||||
message[1] = HEADER[1];
|
||||
message[2] = communityData[0];
|
||||
message[3] = communityData[1];
|
||||
message[4] = communityData[2];
|
||||
message[5] = communityData[3];
|
||||
message[6] = OK;
|
||||
message[7] = lastItem.getCode()[0];
|
||||
message[8] = lastItem.getCode()[1];
|
||||
message[9] = 2;
|
||||
message[10] = 0;
|
||||
message[11] = 1;
|
||||
logger.debug("readResponse: {}", HexUtils.bytesToHex(message));
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication.serial;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Arrays;
|
||||
import java.util.TooManyListenersException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorModel;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorConnector;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorItem;
|
||||
import org.openhab.core.io.transport.serial.PortInUseException;
|
||||
import org.openhab.core.io.transport.serial.SerialPort;
|
||||
import org.openhab.core.io.transport.serial.SerialPortEvent;
|
||||
import org.openhab.core.io.transport.serial.SerialPortEventListener;
|
||||
import org.openhab.core.io.transport.serial.SerialPortIdentifier;
|
||||
import org.openhab.core.io.transport.serial.SerialPortManager;
|
||||
import org.openhab.core.io.transport.serial.UnsupportedCommOperationException;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Class for communicating with Sony Projectors through a serial connection
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class SonyProjectorSerialConnector extends SonyProjectorConnector implements SerialPortEventListener {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SonyProjectorSerialConnector.class);
|
||||
|
||||
private static final int BAUD_RATE = 38400;
|
||||
private static final long READ_TIMEOUT_MS = TimeUnit.MILLISECONDS.toMillis(3500);
|
||||
|
||||
protected static final byte START_CODE = (byte) 0xA9;
|
||||
protected static final byte END_CODE = (byte) 0x9A;
|
||||
private static final byte GET = (byte) 0x01;
|
||||
private static final byte SET = (byte) 0x00;
|
||||
protected static final byte TYPE_ACK = (byte) 0x03;
|
||||
private static final byte TYPE_ITEM = (byte) 0x02;
|
||||
|
||||
private String serialPortName;
|
||||
private SerialPortManager serialPortManager;
|
||||
|
||||
private @Nullable SerialPort serialPort;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param serialPortManager the serial port manager
|
||||
* @param serialPortName the serial port name to be used
|
||||
* @param model the projector model in use
|
||||
*/
|
||||
public SonyProjectorSerialConnector(SerialPortManager serialPortManager, String serialPortName,
|
||||
SonyProjectorModel model) {
|
||||
this(serialPortManager, serialPortName, model, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param serialPortManager the serial port manager
|
||||
* @param serialPortName the serial port name to be used
|
||||
* @param model the projector model in use
|
||||
* @param simu whether the communication is simulated or real
|
||||
*/
|
||||
public SonyProjectorSerialConnector(SerialPortManager serialPortManager, String serialPortName,
|
||||
SonyProjectorModel model, boolean simu) {
|
||||
super(model, simu);
|
||||
|
||||
this.serialPortManager = serialPortManager;
|
||||
this.serialPortName = serialPortName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void open() throws SonyProjectorException {
|
||||
if (!connected) {
|
||||
logger.debug("Opening serial connection on port {}", serialPortName);
|
||||
try {
|
||||
SerialPortIdentifier portIdentifier = serialPortManager.getIdentifier(serialPortName);
|
||||
if (portIdentifier == null) {
|
||||
logger.debug("Opening serial connection failed: No Such Port: {}", serialPortName);
|
||||
throw new SonyProjectorException("Opening serial connection failed: No Such Port");
|
||||
}
|
||||
|
||||
SerialPort commPort = portIdentifier.open(this.getClass().getName(), 2000);
|
||||
|
||||
commPort.setSerialPortParams(BAUD_RATE, SerialPort.DATABITS_8, SerialPort.STOPBITS_1,
|
||||
SerialPort.PARITY_EVEN);
|
||||
commPort.enableReceiveThreshold(8);
|
||||
commPort.enableReceiveTimeout(100);
|
||||
commPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
|
||||
|
||||
InputStream dataIn = commPort.getInputStream();
|
||||
OutputStream dataOut = commPort.getOutputStream();
|
||||
|
||||
if (dataOut != null) {
|
||||
dataOut.flush();
|
||||
}
|
||||
if (dataIn != null && dataIn.markSupported()) {
|
||||
try {
|
||||
dataIn.reset();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
// RXTX serial port library causes high CPU load
|
||||
// Start event listener, which will just sleep and slow down event
|
||||
// loop
|
||||
try {
|
||||
commPort.addEventListener(this);
|
||||
commPort.notifyOnDataAvailable(true);
|
||||
} catch (TooManyListenersException e) {
|
||||
logger.debug("Too Many Listeners Exception: {}", e.getMessage(), e);
|
||||
}
|
||||
|
||||
this.serialPort = commPort;
|
||||
this.dataIn = dataIn;
|
||||
this.dataOut = dataOut;
|
||||
|
||||
connected = true;
|
||||
|
||||
logger.debug("Serial connection opened");
|
||||
} catch (PortInUseException e) {
|
||||
logger.debug("Opening serial connection failed: Port in Use Exception: {}", e.getMessage(), e);
|
||||
throw new SonyProjectorException("Opening serial connection failed: Port in Use Exception");
|
||||
} catch (UnsupportedCommOperationException e) {
|
||||
logger.debug("Opening serial connection failed: Unsupported Comm Operation Exception: {}",
|
||||
e.getMessage(), e);
|
||||
throw new SonyProjectorException(
|
||||
"Opening serial connection failed: Unsupported Comm Operation Exception");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.debug("Opening serial connection failed: Unsupported Encoding Exception: {}", e.getMessage(), e);
|
||||
throw new SonyProjectorException("Opening serial connection failed: Unsupported Encoding Exception");
|
||||
} catch (IOException e) {
|
||||
logger.debug("Opening serial connection failed: IO Exception: {}", e.getMessage(), e);
|
||||
throw new SonyProjectorException("Opening serial connection failed: IO Exception");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
if (connected) {
|
||||
logger.debug("Closing serial connection");
|
||||
SerialPort serialPort = this.serialPort;
|
||||
if (serialPort != null) {
|
||||
serialPort.removeEventListener();
|
||||
}
|
||||
super.close();
|
||||
if (serialPort != null) {
|
||||
serialPort.close();
|
||||
this.serialPort = null;
|
||||
}
|
||||
connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte[] buildMessage(SonyProjectorItem item, boolean getCommand, byte[] data) {
|
||||
byte[] message = new byte[8];
|
||||
message[0] = START_CODE;
|
||||
message[1] = item.getCode()[0];
|
||||
message[2] = item.getCode()[1];
|
||||
message[3] = getCommand ? GET : SET;
|
||||
message[4] = data[0];
|
||||
message[5] = data[1];
|
||||
message[6] = computeCheckSum(message);
|
||||
message[7] = END_CODE;
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized byte[] readResponse() throws SonyProjectorException {
|
||||
logger.debug("readResponse (timeout = {} ms)...", READ_TIMEOUT_MS);
|
||||
byte[] message = new byte[8];
|
||||
boolean startCodeReached = false;
|
||||
boolean endCodeReached = false;
|
||||
boolean timeout = false;
|
||||
byte[] dataBuffer = new byte[8];
|
||||
int index = 0;
|
||||
long startTimeRead = System.currentTimeMillis();
|
||||
while (!endCodeReached && !timeout) {
|
||||
logger.trace("readResponse readInput...");
|
||||
int len = readInput(dataBuffer);
|
||||
logger.trace("readResponse readInput {} => {}", len, HexUtils.bytesToHex(dataBuffer));
|
||||
if (len > 0) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (dataBuffer[i] == START_CODE) {
|
||||
startCodeReached = true;
|
||||
}
|
||||
if (startCodeReached) {
|
||||
if (index < 8) {
|
||||
message[index++] = dataBuffer[i];
|
||||
}
|
||||
if (dataBuffer[i] == END_CODE) {
|
||||
endCodeReached = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
timeout = (System.currentTimeMillis() - startTimeRead) > READ_TIMEOUT_MS;
|
||||
}
|
||||
if (!endCodeReached && timeout) {
|
||||
logger.debug("readResponse timeout: only {} bytes read after {} ms", index, READ_TIMEOUT_MS);
|
||||
throw new SonyProjectorException("readResponse failed: timeout");
|
||||
}
|
||||
logger.debug("readResponse: {}", HexUtils.bytesToHex(message));
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateResponse(byte[] responseMessage, SonyProjectorItem item) throws SonyProjectorException {
|
||||
if (responseMessage.length != 8) {
|
||||
logger.debug("Unexpected response data length: {}", responseMessage.length);
|
||||
throw new SonyProjectorException("Unexpected response data length");
|
||||
}
|
||||
|
||||
// Check START CODE
|
||||
if (responseMessage[0] != START_CODE) {
|
||||
logger.debug("Unexpected message START CODE in response: {} rather than {}",
|
||||
Integer.toHexString(responseMessage[0] & 0x000000FF), Integer.toHexString(START_CODE & 0x000000FF));
|
||||
throw new SonyProjectorException("Unexpected message START CODE in response");
|
||||
}
|
||||
|
||||
// Check END CODE
|
||||
if (responseMessage[7] != END_CODE) {
|
||||
logger.debug("Unexpected message END CODE in response: {} rather than {}",
|
||||
Integer.toHexString(responseMessage[7] & 0x000000FF), Integer.toHexString(END_CODE & 0x000000FF));
|
||||
throw new SonyProjectorException("Unexpected message END CODE in response");
|
||||
}
|
||||
|
||||
byte checksum = computeCheckSum(responseMessage);
|
||||
if (responseMessage[6] != checksum) {
|
||||
logger.debug("Invalid check sum in response: {} rather than {}",
|
||||
Integer.toHexString(responseMessage[6] & 0x000000FF), Integer.toHexString(checksum & 0x000000FF));
|
||||
throw new SonyProjectorException("Invalid check sum in response");
|
||||
}
|
||||
|
||||
if (responseMessage[3] == TYPE_ITEM) {
|
||||
// Item number should be the same as used for sending
|
||||
byte[] itemResponseMsg = Arrays.copyOfRange(responseMessage, 1, 3);
|
||||
if (!Arrays.equals(itemResponseMsg, item.getCode())) {
|
||||
logger.debug("Unexpected item number in response: {} rather than {}",
|
||||
HexUtils.bytesToHex(itemResponseMsg), HexUtils.bytesToHex(item.getCode()));
|
||||
throw new SonyProjectorException("Unexpected item number in response");
|
||||
}
|
||||
} else if (responseMessage[3] == TYPE_ACK) {
|
||||
// ACK
|
||||
byte[] errorCode = Arrays.copyOfRange(responseMessage, 1, 3);
|
||||
if (!Arrays.equals(errorCode, SonyProjectorSerialError.COMPLETE.getDataCode())) {
|
||||
String msg = "KO";
|
||||
try {
|
||||
SonyProjectorSerialError error = SonyProjectorSerialError.getFromDataCode(errorCode);
|
||||
msg = error.getMessage();
|
||||
} catch (SonyProjectorException e) {
|
||||
}
|
||||
logger.debug("{} received in response", msg);
|
||||
throw new SonyProjectorException(msg + " received in response");
|
||||
}
|
||||
} else {
|
||||
logger.debug("Unexpected TYPE in response: {}", Integer.toHexString(responseMessage[3] & 0x000000FF));
|
||||
throw new SonyProjectorException("Unexpected TYPE in response");
|
||||
}
|
||||
}
|
||||
|
||||
private byte computeCheckSum(byte[] message) {
|
||||
byte result = 0;
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
result |= (message[i] & 0x000000FF);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte[] getResponseData(byte[] responseMessage) {
|
||||
return Arrays.copyOfRange(responseMessage, 4, 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialEvent(SerialPortEvent serialPortEvent) {
|
||||
try {
|
||||
logger.debug("RXTX library CPU load workaround, sleep forever");
|
||||
Thread.sleep(Long.MAX_VALUE);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication.serial;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
|
||||
/**
|
||||
* Represents the different error codes returned by the projector in serial mode
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public enum SonyProjectorSerialError {
|
||||
|
||||
COMPLETE("Complete", new byte[] { 0x00, 0x00 }),
|
||||
UNDEFINED_COMMAND("Undefined Command", new byte[] { 0x01, 0x01 }),
|
||||
SIZE_ERROR("Size Error", new byte[] { 0x01, 0x04 }),
|
||||
SELECT_ERROR("Select Error", new byte[] { 0x01, 0x05 }),
|
||||
RANGE_OVER("Range Over", new byte[] { 0x01, 0x06 }),
|
||||
NOT_APPLICABLE("Not Applicable", new byte[] { 0x01, 0x0A }),
|
||||
CHECK_SUM_ERROR("Check Sum Error", new byte[] { (byte) 0xF0, 0x10 }),
|
||||
FRAMING_ERROR("Framing Error", new byte[] { (byte) 0xF0, 0x20 }),
|
||||
PARITY_ERROR("Parity Error", new byte[] { (byte) 0xF0, 0x30 }),
|
||||
OVER_RUN_ERROR("Over Run Error", new byte[] { (byte) 0xF0, 0x40 }),
|
||||
OTHER_COMM_ERROR("Other Comm Error", new byte[] { (byte) 0xF0, 0x50 });
|
||||
|
||||
private String message;
|
||||
private byte[] dataCode;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param message the error message
|
||||
* @param dataCode the data code identifying the error
|
||||
*/
|
||||
private SonyProjectorSerialError(String message, byte[] dataCode) {
|
||||
this.message = message;
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error message
|
||||
*
|
||||
* @return the message
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data code identifying the error
|
||||
*
|
||||
* @return the data code
|
||||
*/
|
||||
public byte[] getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error associated to a data code
|
||||
*
|
||||
* @param dataCode the data code used to identify the error
|
||||
*
|
||||
* @return the error associated to the searched data code
|
||||
*
|
||||
* @throws SonyProjectorException - If no error is associated to the searched data code
|
||||
*/
|
||||
public static SonyProjectorSerialError getFromDataCode(byte[] dataCode) throws SonyProjectorException {
|
||||
for (SonyProjectorSerialError value : SonyProjectorSerialError.values()) {
|
||||
if (Arrays.equals(dataCode, value.getDataCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new SonyProjectorException("Unknwon error code: " + HexUtils.bytesToHex(dataCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication.serial;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorModel;
|
||||
import org.openhab.core.io.transport.serial.SerialPortManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Class for communicating with Sony Projectors through a serial over IP connection
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class SonyProjectorSerialOverIpConnector extends SonyProjectorSerialConnector {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SonyProjectorSerialOverIpConnector.class);
|
||||
|
||||
private String address;
|
||||
private int port;
|
||||
|
||||
private @Nullable Socket clientSocket;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param serialPortManager the serial port manager
|
||||
* @param address the IP address of the projector
|
||||
* @param port the TCP port to be used
|
||||
* @param model the projector model in use
|
||||
*/
|
||||
public SonyProjectorSerialOverIpConnector(SerialPortManager serialPortManager, String address, Integer port,
|
||||
SonyProjectorModel model) {
|
||||
super(serialPortManager, "dummyPort", model);
|
||||
|
||||
this.address = address;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void open() throws SonyProjectorException {
|
||||
if (!connected) {
|
||||
logger.debug("Opening serial over IP connection on IP {} port {}", this.address, this.port);
|
||||
try {
|
||||
Socket clientSocket = new Socket(this.address, this.port);
|
||||
clientSocket.setSoTimeout(100);
|
||||
|
||||
dataOut = new DataOutputStream(clientSocket.getOutputStream());
|
||||
dataIn = new DataInputStream(clientSocket.getInputStream());
|
||||
|
||||
this.clientSocket = clientSocket;
|
||||
|
||||
connected = true;
|
||||
|
||||
logger.debug("Serial over IP connection opened");
|
||||
} catch (IOException | SecurityException | IllegalArgumentException e) {
|
||||
logger.debug("Opening serial over IP connection failed: {}", e.getMessage());
|
||||
throw new SonyProjectorException("Opening serial over IP connection failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
if (connected) {
|
||||
logger.debug("Closing serial over IP connection");
|
||||
super.close();
|
||||
Socket clientSocket = this.clientSocket;
|
||||
if (clientSocket != null) {
|
||||
try {
|
||||
clientSocket.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
this.clientSocket = null;
|
||||
}
|
||||
connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes
|
||||
* actually read is returned as an integer.
|
||||
* In case of socket timeout, the returned value is 0.
|
||||
*
|
||||
* @param dataBuffer the buffer into which the data is read.
|
||||
* @return the total number of bytes read into the buffer, or -1 if there is no more data because the end of the
|
||||
* stream has been reached.
|
||||
* @throws SonyProjectorException - If the input stream is null, if the first byte cannot be read for any reason
|
||||
* other than the end of the file, if the input stream has been closed, or if some other I/O error
|
||||
* occurs.
|
||||
*/
|
||||
@Override
|
||||
protected int readInput(byte[] dataBuffer) throws SonyProjectorException {
|
||||
InputStream dataIn = this.dataIn;
|
||||
if (dataIn == null) {
|
||||
throw new SonyProjectorException("readInput failed: input stream is null");
|
||||
}
|
||||
try {
|
||||
return dataIn.read(dataBuffer);
|
||||
} catch (SocketTimeoutException e) {
|
||||
return 0;
|
||||
} catch (IOException e) {
|
||||
logger.debug("readInput failed: {}", e.getMessage());
|
||||
throw new SonyProjectorException("readInput failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.communication.serial;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorModel;
|
||||
import org.openhab.core.io.transport.serial.SerialPortManager;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Class for communicating with Sony Projectors through a serial connection
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class SonyProjectorSerialSimuConnector extends SonyProjectorSerialConnector {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SonyProjectorSerialSimuConnector.class);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param serialPortManager the serial port manager
|
||||
* @param model the projector model in use
|
||||
*/
|
||||
public SonyProjectorSerialSimuConnector(SerialPortManager serialPortManager, SonyProjectorModel model) {
|
||||
super(serialPortManager, "dummyPort", model, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void open() throws SonyProjectorException {
|
||||
if (!connected) {
|
||||
connected = true;
|
||||
logger.debug("Simulated serial connection opened");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
if (connected) {
|
||||
logger.debug("Simulated serial connection closed");
|
||||
connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized byte[] readResponse() throws SonyProjectorException {
|
||||
byte[] message = new byte[8];
|
||||
message[0] = START_CODE;
|
||||
message[1] = SonyProjectorSerialError.COMPLETE.getDataCode()[0];
|
||||
message[2] = SonyProjectorSerialError.COMPLETE.getDataCode()[1];
|
||||
message[3] = TYPE_ACK;
|
||||
message[4] = 0x00;
|
||||
message[5] = 0x01;
|
||||
message[6] = computeCheckSum(message);
|
||||
message[7] = END_CODE;
|
||||
logger.debug("readResponse: {}", HexUtils.bytesToHex(message));
|
||||
return message;
|
||||
}
|
||||
|
||||
private byte computeCheckSum(byte[] message) {
|
||||
byte result = 0;
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
result |= (message[i] & 0x000000FF);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.configuration;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The {@link SonyProjectorEthernetConfiguration} class contains fields mapping thing configuration parameters.
|
||||
*
|
||||
* @author Markus Wehrle - Initial contribution
|
||||
* @author Laurent Garnier - New model configuration setting added
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class SonyProjectorEthernetConfiguration {
|
||||
|
||||
public @NonNullByDefault({}) String host;
|
||||
public @Nullable Integer port;
|
||||
public @Nullable String community;
|
||||
public @Nullable String model;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.configuration;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
||||
/**
|
||||
* The {@link SonyProjectorSerialConfiguration} class contains fields mapping thing configuration parameters.
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class SonyProjectorSerialConfiguration {
|
||||
|
||||
public @NonNullByDefault({}) String port;
|
||||
public @NonNullByDefault({}) String model;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.configuration;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
||||
/**
|
||||
* The {@link SonyProjectorSerialOverIpConfiguration} class contains fields mapping thing configuration parameters.
|
||||
*
|
||||
* @author Laurent Garnier - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class SonyProjectorSerialOverIpConfiguration {
|
||||
|
||||
public @NonNullByDefault({}) String host;
|
||||
public @NonNullByDefault({}) Integer port;
|
||||
public @NonNullByDefault({}) String model;
|
||||
}
|
||||
@@ -0,0 +1,727 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sonyprojector.internal.handler;
|
||||
|
||||
import static org.openhab.binding.sonyprojector.internal.SonyProjectorBindingConstants.*;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorException;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorModel;
|
||||
import org.openhab.binding.sonyprojector.internal.SonyProjectorStateDescriptionOptionProvider;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorConnector;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.SonyProjectorStatusPower;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.sdcp.SonyProjectorSdcpConnector;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.sdcp.SonyProjectorSdcpSimuConnector;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.serial.SonyProjectorSerialConnector;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.serial.SonyProjectorSerialOverIpConnector;
|
||||
import org.openhab.binding.sonyprojector.internal.communication.serial.SonyProjectorSerialSimuConnector;
|
||||
import org.openhab.binding.sonyprojector.internal.configuration.SonyProjectorEthernetConfiguration;
|
||||
import org.openhab.binding.sonyprojector.internal.configuration.SonyProjectorSerialConfiguration;
|
||||
import org.openhab.binding.sonyprojector.internal.configuration.SonyProjectorSerialOverIpConfiguration;
|
||||
import org.openhab.core.cache.ExpiringCacheMap;
|
||||
import org.openhab.core.io.transport.serial.SerialPortManager;
|
||||
import org.openhab.core.library.types.DecimalType;
|
||||
import org.openhab.core.library.types.OnOffType;
|
||||
import org.openhab.core.library.types.PercentType;
|
||||
import org.openhab.core.library.types.StringType;
|
||||
import org.openhab.core.thing.ChannelUID;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingStatus;
|
||||
import org.openhab.core.thing.ThingStatusDetail;
|
||||
import org.openhab.core.thing.binding.BaseThingHandler;
|
||||
import org.openhab.core.types.Command;
|
||||
import org.openhab.core.types.RefreshType;
|
||||
import org.openhab.core.types.State;
|
||||
import org.openhab.core.types.UnDefType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The {@link SonyProjectorHandler} is responsible for handling commands, which are
|
||||
* sent to one of the channels.
|
||||
*
|
||||
* @author Markus Wehrle - Initial contribution
|
||||
* @author Laurent Garnier - Refactoring, poll thread for regular channels updates, new serial thing type, new channels
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class SonyProjectorHandler extends BaseThingHandler {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SonyProjectorHandler.class);
|
||||
|
||||
private static final SonyProjectorModel DEFAULT_MODEL = SonyProjectorModel.VW520;
|
||||
private static final long POLLING_INTERVAL = TimeUnit.SECONDS.toSeconds(15);
|
||||
|
||||
private @Nullable ScheduledFuture<?> refreshJob;
|
||||
|
||||
private boolean identifyProjector;
|
||||
private SonyProjectorModel projectorModel = DEFAULT_MODEL;
|
||||
private SonyProjectorConnector connector = new SonyProjectorSdcpSimuConnector(DEFAULT_MODEL);
|
||||
|
||||
private SonyProjectorStateDescriptionOptionProvider stateDescriptionProvider;
|
||||
private SerialPortManager serialPortManager;
|
||||
|
||||
private boolean simu;
|
||||
|
||||
private final Object commandLock = new Object();
|
||||
|
||||
private final ExpiringCacheMap<String, State> cache;
|
||||
|
||||
public SonyProjectorHandler(Thing thing, SonyProjectorStateDescriptionOptionProvider stateDescriptionProvider,
|
||||
SerialPortManager serialPortManager) {
|
||||
super(thing);
|
||||
this.stateDescriptionProvider = stateDescriptionProvider;
|
||||
this.serialPortManager = serialPortManager;
|
||||
this.cache = new ExpiringCacheMap<>(TimeUnit.SECONDS.toMillis(POLLING_INTERVAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCommand(ChannelUID channelUID, Command command) {
|
||||
String channel = channelUID.getId();
|
||||
if (command instanceof RefreshType) {
|
||||
State state = cache.get(channel);
|
||||
if (state != null) {
|
||||
updateState(channel, state);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (commandLock) {
|
||||
try {
|
||||
connector.open();
|
||||
} catch (SonyProjectorException e) {
|
||||
logger.debug("Command {} from channel {} failed: {}", command, channel, e.getMessage());
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
|
||||
return;
|
||||
}
|
||||
try {
|
||||
switch (channel) {
|
||||
case CHANNEL_POWER:
|
||||
if (command == OnOffType.ON) {
|
||||
connector.powerOn();
|
||||
} else if (command == OnOffType.OFF) {
|
||||
connector.powerOff();
|
||||
} else {
|
||||
throw new SonyProjectorException("Invalid command value");
|
||||
}
|
||||
break;
|
||||
case CHANNEL_INPUT:
|
||||
connector.setInput(command.toString());
|
||||
break;
|
||||
case CHANNEL_CALIBRATION_PRESET:
|
||||
connector.setCalibrationPreset(command.toString());
|
||||
refreshChannel(CHANNEL_CONTRAST, true);
|
||||
refreshChannel(CHANNEL_BRIGHTNESS, true);
|
||||
refreshChannel(CHANNEL_COLOR, true);
|
||||
refreshChannel(CHANNEL_HUE, true);
|
||||
refreshChannel(CHANNEL_SHARPNESS, true);
|
||||
refreshChannel(CHANNEL_COLOR_TEMP, true);
|
||||
refreshChannel(CHANNEL_IRIS_MODE, true);
|
||||
refreshChannel(CHANNEL_IRIS_MANUAL, true);
|
||||
refreshChannel(CHANNEL_IRIS_SENSITIVITY, true);
|
||||
refreshChannel(CHANNEL_LAMP_CONTROL, true);
|
||||
refreshChannel(CHANNEL_FILM_PROJECTION, true);
|
||||
refreshChannel(CHANNEL_MOTION_ENHANCER, true);
|
||||
refreshChannel(CHANNEL_CONTRAST_ENHANCER, true);
|
||||
refreshChannel(CHANNEL_FILM_MODE, true);
|
||||
refreshChannel(CHANNEL_GAMMA_CORRECTION, true);
|
||||
refreshChannel(CHANNEL_COLOR_SPACE, true);
|
||||
refreshChannel(CHANNEL_NR, true);
|
||||
refreshChannel(CHANNEL_BLOCK_NR, true);
|
||||
refreshChannel(CHANNEL_MOSQUITO_NR, true);
|
||||
refreshChannel(CHANNEL_MPEG_NR, true);
|
||||
refreshChannel(CHANNEL_XVCOLOR, true);
|
||||
break;
|
||||
case CHANNEL_CONTRAST:
|
||||
if (command instanceof DecimalType) {
|
||||
connector.setContrast(((DecimalType) command).intValue());
|
||||
} else if (command instanceof PercentType) {
|
||||
connector.setContrast(((PercentType) command).intValue());
|
||||
} else {
|
||||
throw new SonyProjectorException("Invalid command value");
|
||||
}
|
||||
break;
|
||||
case CHANNEL_BRIGHTNESS:
|
||||
if (command instanceof DecimalType) {
|
||||
connector.setBrightness(((DecimalType) command).intValue());
|
||||
} else if (command instanceof PercentType) {
|
||||
connector.setBrightness(((PercentType) command).intValue());
|
||||
} else {
|
||||
throw new SonyProjectorException("Invalid command value");
|
||||
}
|
||||
break;
|
||||
case CHANNEL_COLOR:
|
||||
if (command instanceof DecimalType) {
|
||||
connector.setColor(((DecimalType) command).intValue());
|
||||
} else if (command instanceof PercentType) {
|
||||
connector.setColor(((PercentType) command).intValue());
|
||||
} else {
|
||||
throw new SonyProjectorException("Invalid command value");
|
||||
}
|
||||
break;
|
||||
case CHANNEL_HUE:
|
||||
if (command instanceof DecimalType) {
|
||||
connector.setHue(((DecimalType) command).intValue());
|
||||
} else if (command instanceof PercentType) {
|
||||
connector.setHue(((PercentType) command).intValue());
|
||||
} else {
|
||||
throw new SonyProjectorException("Invalid command value");
|
||||
}
|
||||
break;
|
||||
case CHANNEL_SHARPNESS:
|
||||
if (command instanceof DecimalType) {
|
||||
connector.setSharpness(((DecimalType) command).intValue());
|
||||
} else if (command instanceof PercentType) {
|
||||
connector.setSharpness(((PercentType) command).intValue());
|
||||
} else {
|
||||
throw new SonyProjectorException("Invalid command value");
|
||||
}
|
||||
break;
|
||||
case CHANNEL_COLOR_TEMP:
|
||||
connector.setColorTemperature(command.toString());
|
||||
break;
|
||||
case CHANNEL_IRIS_MODE:
|
||||
connector.setIrisMode(command.toString());
|
||||
refreshChannel(CHANNEL_IRIS_MANUAL, true);
|
||||
break;
|
||||
case CHANNEL_IRIS_MANUAL:
|
||||
if (command instanceof DecimalType) {
|
||||
connector.setIrisManual(((DecimalType) command).intValue());
|
||||
} else if (command instanceof PercentType) {
|
||||
connector.setIrisManual(((PercentType) command).intValue());
|
||||
} else {
|
||||
throw new SonyProjectorException("Invalid command value");
|
||||
}
|
||||
break;
|
||||
case CHANNEL_IRIS_SENSITIVITY:
|
||||
connector.setIrisSensitivity(command.toString());
|
||||
break;
|
||||
case CHANNEL_LAMP_CONTROL:
|
||||
connector.setLampControl(command.toString());
|
||||
break;
|
||||
case CHANNEL_FILM_PROJECTION:
|
||||
connector.setFilmProjection(command.toString());
|
||||
break;
|
||||
case CHANNEL_MOTION_ENHANCER:
|
||||
connector.setMotionEnhancer(command.toString());
|
||||
break;
|
||||
case CHANNEL_CONTRAST_ENHANCER:
|
||||
connector.setContrastEnhancer(command.toString());
|
||||
break;
|
||||
case CHANNEL_FILM_MODE:
|
||||
connector.setFilmMode(command.toString());
|
||||
break;
|
||||
case CHANNEL_GAMMA_CORRECTION:
|
||||
connector.setGammaCorrection(command.toString());
|
||||
break;
|
||||
case CHANNEL_COLOR_SPACE:
|
||||
connector.setColorSpace(command.toString());
|
||||
break;
|
||||
case CHANNEL_NR:
|
||||
connector.setNr(command.toString());
|
||||
break;
|
||||
case CHANNEL_BLOCK_NR:
|
||||
connector.setBlockNr(command.toString());
|
||||
break;
|
||||
case CHANNEL_MOSQUITO_NR:
|
||||
connector.setMosquitoNr(command.toString());
|
||||
break;
|
||||
case CHANNEL_MPEG_NR:
|
||||
connector.setMpegNr(command.toString());
|
||||
break;
|
||||
case CHANNEL_XVCOLOR:
|
||||
if (command == OnOffType.ON) {
|
||||
connector.enableXvColor();
|
||||
refreshChannel(CHANNEL_GAMMA_CORRECTION, true);
|
||||
} else if (command == OnOffType.OFF) {
|
||||
connector.disableXvColor();
|
||||
refreshChannel(CHANNEL_GAMMA_CORRECTION, true);
|
||||
} else {
|
||||
throw new SonyProjectorException("Invalid command value");
|
||||
}
|
||||
break;
|
||||
case CHANNEL_PICTURE_MUTING:
|
||||
if (command == OnOffType.ON) {
|
||||
connector.mutePicture();
|
||||
} else if (command == OnOffType.OFF) {
|
||||
connector.unmutePicture();
|
||||
} else {
|
||||
throw new SonyProjectorException("Invalid command value");
|
||||
}
|
||||
break;
|
||||
case CHANNEL_ASPECT:
|
||||
connector.setAspect(command.toString());
|
||||
break;
|
||||
case CHANNEL_OVERSCAN:
|
||||
if (command == OnOffType.ON) {
|
||||
connector.enableOverscan();
|
||||
} else if (command == OnOffType.OFF) {
|
||||
connector.disableOverscan();
|
||||
} else {
|
||||
throw new SonyProjectorException("Invalid command value");
|
||||
}
|
||||
break;
|
||||
case CHANNEL_PICTURE_POSITION:
|
||||
connector.setPicturePosition(command.toString());
|
||||
break;
|
||||
default:
|
||||
throw new SonyProjectorException("Unexpected command");
|
||||
}
|
||||
logger.debug("Command {} from channel {} succeeded", command, channel);
|
||||
} catch (SonyProjectorException e) {
|
||||
logger.debug("Command {} from channel {} failed: {}", command, channel, e.getMessage());
|
||||
refreshChannel(channel, true);
|
||||
}
|
||||
connector.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
logger.debug("Start initializing handler for thing {}", getThing().getUID());
|
||||
|
||||
boolean configOk = false;
|
||||
|
||||
if (getThing().getThingTypeUID().equals(THING_TYPE_ETHERNET)) {
|
||||
SonyProjectorEthernetConfiguration config = getConfigAs(SonyProjectorEthernetConfiguration.class);
|
||||
String configModel = config.model;
|
||||
logger.debug("Ethernet config host {}", config.host);
|
||||
logger.debug("Ethernet config port {}", config.port);
|
||||
logger.debug("Ethernet config model {}", configModel);
|
||||
logger.debug("Ethernet config community {}", config.community);
|
||||
if (config.host == null || config.host.isEmpty()) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"host configuration setting undefined");
|
||||
} else if (configModel == null || configModel.isEmpty()) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"model configuration setting undefined");
|
||||
} else {
|
||||
configOk = true;
|
||||
|
||||
connector = simu ? new SonyProjectorSdcpSimuConnector(DEFAULT_MODEL)
|
||||
: new SonyProjectorSdcpConnector(config.host, config.port, config.community, DEFAULT_MODEL);
|
||||
identifyProjector = "AUTO".equals(configModel);
|
||||
projectorModel = switchToModel("AUTO".equals(configModel) ? null : configModel, true);
|
||||
|
||||
updateStatus(ThingStatus.UNKNOWN);
|
||||
}
|
||||
} else if (getThing().getThingTypeUID().equals(THING_TYPE_SERIAL)) {
|
||||
SonyProjectorSerialConfiguration config = getConfigAs(SonyProjectorSerialConfiguration.class);
|
||||
String configModel = config.model;
|
||||
logger.debug("Serial config port {}", config.port);
|
||||
logger.debug("Serial config model {}", configModel);
|
||||
if (config.port == null || config.port.isEmpty()) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"port configuration setting undefined");
|
||||
} else if (config.port.toLowerCase().startsWith("rfc2217")) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"use Serial over IP connection thing type");
|
||||
} else if (configModel == null || configModel.isEmpty()) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"model configuration setting undefined");
|
||||
} else {
|
||||
configOk = true;
|
||||
|
||||
connector = simu ? new SonyProjectorSerialSimuConnector(serialPortManager, DEFAULT_MODEL)
|
||||
: new SonyProjectorSerialConnector(serialPortManager, config.port, DEFAULT_MODEL);
|
||||
identifyProjector = false;
|
||||
projectorModel = switchToModel(configModel, true);
|
||||
|
||||
updateStatus(ThingStatus.UNKNOWN);
|
||||
}
|
||||
} else if (getThing().getThingTypeUID().equals(THING_TYPE_SERIAL_OVER_IP)) {
|
||||
SonyProjectorSerialOverIpConfiguration config = getConfigAs(SonyProjectorSerialOverIpConfiguration.class);
|
||||
String configModel = config.model;
|
||||
logger.debug("Serial over IP config host {}", config.host);
|
||||
logger.debug("Serial over IP config port {}", config.port);
|
||||
logger.debug("Serial over IP config model {}", configModel);
|
||||
if (config.host == null || config.host.isEmpty()) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"host configuration setting undefined");
|
||||
} else if (config.port == null) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"port configuration setting undefined");
|
||||
} else if (config.port <= 0) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"port configuration setting invalid");
|
||||
} else if (configModel == null || configModel.isEmpty()) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"model configuration setting undefined");
|
||||
} else {
|
||||
configOk = true;
|
||||
|
||||
connector = simu ? new SonyProjectorSerialSimuConnector(serialPortManager, DEFAULT_MODEL)
|
||||
: new SonyProjectorSerialOverIpConnector(serialPortManager, config.host, config.port,
|
||||
DEFAULT_MODEL);
|
||||
identifyProjector = false;
|
||||
projectorModel = switchToModel(configModel, true);
|
||||
|
||||
updateStatus(ThingStatus.UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
if (!configOk) {
|
||||
connector = new SonyProjectorSdcpSimuConnector(DEFAULT_MODEL);
|
||||
} else {
|
||||
ScheduledFuture<?> refreshJob = this.refreshJob;
|
||||
if (refreshJob == null || refreshJob.isCancelled()) {
|
||||
this.refreshJob = scheduler.scheduleWithFixedDelay(() -> {
|
||||
pollProjector();
|
||||
}, 1, POLLING_INTERVAL, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug("Finished initializing!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
logger.debug("Disposing handler for thing {}", getThing().getUID());
|
||||
ScheduledFuture<?> refreshJob = this.refreshJob;
|
||||
if (refreshJob != null && !refreshJob.isCancelled()) {
|
||||
refreshJob.cancel(true);
|
||||
this.refreshJob = null;
|
||||
}
|
||||
connector.close();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
private void pollProjector() {
|
||||
synchronized (commandLock) {
|
||||
logger.debug("Polling the projector to refresh the channels...");
|
||||
|
||||
try {
|
||||
connector.open();
|
||||
} catch (SonyProjectorException e) {
|
||||
logger.debug("Poll projector failed: {}", e.getMessage());
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isOn = refreshPowerState();
|
||||
refreshModel();
|
||||
refreshChannel(CHANNEL_INPUT, isOn);
|
||||
refreshChannel(CHANNEL_CALIBRATION_PRESET, isOn);
|
||||
refreshChannel(CHANNEL_CONTRAST, isOn);
|
||||
refreshChannel(CHANNEL_BRIGHTNESS, isOn);
|
||||
refreshChannel(CHANNEL_COLOR, isOn);
|
||||
refreshChannel(CHANNEL_HUE, isOn);
|
||||
refreshChannel(CHANNEL_SHARPNESS, isOn);
|
||||
refreshChannel(CHANNEL_COLOR_TEMP, isOn);
|
||||
refreshChannel(CHANNEL_IRIS_MODE, isOn);
|
||||
refreshChannel(CHANNEL_IRIS_MANUAL, isOn);
|
||||
refreshChannel(CHANNEL_IRIS_SENSITIVITY, isOn);
|
||||
refreshChannel(CHANNEL_LAMP_CONTROL, isOn);
|
||||
refreshChannel(CHANNEL_FILM_PROJECTION, isOn);
|
||||
refreshChannel(CHANNEL_MOTION_ENHANCER, isOn);
|
||||
refreshChannel(CHANNEL_CONTRAST_ENHANCER, isOn);
|
||||
refreshChannel(CHANNEL_FILM_MODE, isOn);
|
||||
refreshChannel(CHANNEL_GAMMA_CORRECTION, isOn);
|
||||
refreshChannel(CHANNEL_COLOR_SPACE, isOn);
|
||||
refreshChannel(CHANNEL_NR, isOn);
|
||||
refreshChannel(CHANNEL_BLOCK_NR, isOn);
|
||||
refreshChannel(CHANNEL_MOSQUITO_NR, isOn);
|
||||
refreshChannel(CHANNEL_MPEG_NR, isOn);
|
||||
refreshChannel(CHANNEL_XVCOLOR, isOn);
|
||||
refreshChannel(CHANNEL_PICTURE_MUTING, isOn);
|
||||
refreshChannel(CHANNEL_ASPECT, isOn);
|
||||
refreshChannel(CHANNEL_OVERSCAN, isOn);
|
||||
refreshChannel(CHANNEL_PICTURE_POSITION, isOn);
|
||||
refreshChannel(CHANNEL_LAMP_USE_TIME, isOn);
|
||||
|
||||
connector.close();
|
||||
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
|
||||
logger.debug("End of the polling thread");
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshModel() {
|
||||
if (identifyProjector && getThing().getThingTypeUID().equals(THING_TYPE_ETHERNET)) {
|
||||
try {
|
||||
String modelName = ((SonyProjectorSdcpConnector) connector).getModelName();
|
||||
logger.debug("getModelName returned {}", modelName);
|
||||
identifyProjector = false;
|
||||
switchToModel(modelName, false);
|
||||
} catch (SonyProjectorException e) {
|
||||
logger.debug("getModelName failed: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private SonyProjectorModel switchToModel(@Nullable String modelName, boolean force) {
|
||||
SonyProjectorModel model = DEFAULT_MODEL;
|
||||
if (modelName != null && !modelName.isEmpty()) {
|
||||
try {
|
||||
model = SonyProjectorModel.getFromName(modelName, false);
|
||||
logger.debug("Model found: {}", model.getName());
|
||||
} catch (SonyProjectorException e) {
|
||||
logger.info("Model {} is unknow; consider {} by default", modelName, DEFAULT_MODEL.getName());
|
||||
}
|
||||
}
|
||||
if (force || !model.getName().equals(projectorModel.getName())) {
|
||||
connector.setModel(model);
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_INPUT),
|
||||
model.getInputStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_CALIBRATION_PRESET),
|
||||
model.getCalibrPresetStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_COLOR_TEMP),
|
||||
model.getColorTempStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_IRIS_MODE),
|
||||
model.getIrisModeStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_IRIS_SENSITIVITY),
|
||||
model.getIrisSensitivityStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_LAMP_CONTROL),
|
||||
model.getLampControlStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_FILM_PROJECTION),
|
||||
model.getFilmProjectionStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_MOTION_ENHANCER),
|
||||
model.getMotionEnhancerStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_CONTRAST_ENHANCER),
|
||||
model.getContrastEnhancerStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_FILM_MODE),
|
||||
model.getFilmModeStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_GAMMA_CORRECTION),
|
||||
model.getGammaCorrectionStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_COLOR_SPACE),
|
||||
model.getColorSpaceStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_NR),
|
||||
model.getNrStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_BLOCK_NR),
|
||||
model.getBlockNrStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_MOSQUITO_NR),
|
||||
model.getMosquitoNrStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_MPEG_NR),
|
||||
model.getMpegNrStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_ASPECT),
|
||||
model.getAspectStateOptions());
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_PICTURE_POSITION),
|
||||
model.getPicturePositionStateOptions());
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
private boolean refreshPowerState() {
|
||||
boolean on = false;
|
||||
State state = UnDefType.UNDEF;
|
||||
try {
|
||||
SonyProjectorStatusPower value = connector.getStatusPower();
|
||||
logger.debug("Get Status Power returned {}", value);
|
||||
on = value.isOn();
|
||||
state = new StringType(value.getName());
|
||||
} catch (SonyProjectorException e) {
|
||||
logger.debug("Get Status Power failed: {}", e.getMessage());
|
||||
}
|
||||
updateChannelStateAndCache(CHANNEL_POWER, on ? OnOffType.ON : OnOffType.OFF);
|
||||
updateChannelStateAndCache(CHANNEL_POWERSTATE, state);
|
||||
return on;
|
||||
}
|
||||
|
||||
private @Nullable State requestProjectorValue(String channel, boolean requestValue) {
|
||||
State state = null;
|
||||
boolean precond;
|
||||
switch (channel) {
|
||||
case CHANNEL_POWER:
|
||||
case CHANNEL_POWERSTATE:
|
||||
case CHANNEL_INPUT:
|
||||
case CHANNEL_CALIBRATION_PRESET:
|
||||
case CHANNEL_CONTRAST:
|
||||
case CHANNEL_BRIGHTNESS:
|
||||
case CHANNEL_COLOR:
|
||||
case CHANNEL_HUE:
|
||||
case CHANNEL_SHARPNESS:
|
||||
case CHANNEL_COLOR_TEMP:
|
||||
case CHANNEL_CONTRAST_ENHANCER:
|
||||
case CHANNEL_GAMMA_CORRECTION:
|
||||
case CHANNEL_COLOR_SPACE:
|
||||
case CHANNEL_NR:
|
||||
case CHANNEL_PICTURE_MUTING:
|
||||
case CHANNEL_ASPECT:
|
||||
precond = true;
|
||||
break;
|
||||
case CHANNEL_IRIS_MODE:
|
||||
precond = projectorModel.isIrisModeAvailable();
|
||||
break;
|
||||
case CHANNEL_IRIS_MANUAL:
|
||||
precond = projectorModel.isIrisManualAvailable();
|
||||
break;
|
||||
case CHANNEL_IRIS_SENSITIVITY:
|
||||
precond = projectorModel.isIrisSensitivityAvailable();
|
||||
break;
|
||||
case CHANNEL_LAMP_CONTROL:
|
||||
precond = projectorModel.isLampControlAvailable();
|
||||
break;
|
||||
case CHANNEL_FILM_PROJECTION:
|
||||
precond = projectorModel.isFilmProjectionAvailable();
|
||||
break;
|
||||
case CHANNEL_MOTION_ENHANCER:
|
||||
precond = projectorModel.isMotionEnhancerAvailable();
|
||||
break;
|
||||
case CHANNEL_FILM_MODE:
|
||||
precond = projectorModel.isFilmModeAvailable();
|
||||
break;
|
||||
case CHANNEL_BLOCK_NR:
|
||||
precond = projectorModel.isBlockNrAvailable();
|
||||
break;
|
||||
case CHANNEL_MOSQUITO_NR:
|
||||
precond = projectorModel.isMosquitoNrAvailable();
|
||||
break;
|
||||
case CHANNEL_MPEG_NR:
|
||||
precond = projectorModel.isMpegNrAvailable();
|
||||
break;
|
||||
case CHANNEL_XVCOLOR:
|
||||
precond = projectorModel.isXvColorAvailable();
|
||||
break;
|
||||
case CHANNEL_OVERSCAN:
|
||||
precond = projectorModel.isOverscanAvailable();
|
||||
break;
|
||||
case CHANNEL_PICTURE_POSITION:
|
||||
precond = projectorModel.isPicturePositionAvailable();
|
||||
break;
|
||||
case CHANNEL_LAMP_USE_TIME:
|
||||
precond = requestValue;
|
||||
break;
|
||||
default:
|
||||
precond = false;
|
||||
break;
|
||||
}
|
||||
if (isLinked(channel) && precond) {
|
||||
state = UnDefType.UNDEF;
|
||||
if (requestValue) {
|
||||
try {
|
||||
switch (channel) {
|
||||
case CHANNEL_POWER:
|
||||
state = connector.getStatusPower().isOn() ? OnOffType.ON : OnOffType.OFF;
|
||||
break;
|
||||
case CHANNEL_POWERSTATE:
|
||||
state = new StringType(connector.getStatusPower().getName());
|
||||
break;
|
||||
case CHANNEL_INPUT:
|
||||
state = new StringType(connector.getInput());
|
||||
break;
|
||||
case CHANNEL_CALIBRATION_PRESET:
|
||||
state = new StringType(connector.getCalibrationPreset());
|
||||
break;
|
||||
case CHANNEL_CONTRAST:
|
||||
state = new PercentType(connector.getContrast());
|
||||
break;
|
||||
case CHANNEL_BRIGHTNESS:
|
||||
state = new PercentType(connector.getBrightness());
|
||||
break;
|
||||
case CHANNEL_COLOR:
|
||||
state = new PercentType(connector.getColor());
|
||||
break;
|
||||
case CHANNEL_HUE:
|
||||
state = new PercentType(connector.getHue());
|
||||
break;
|
||||
case CHANNEL_SHARPNESS:
|
||||
state = new PercentType(connector.getSharpness());
|
||||
break;
|
||||
case CHANNEL_COLOR_TEMP:
|
||||
state = new StringType(connector.getColorTemperature());
|
||||
break;
|
||||
case CHANNEL_IRIS_MODE:
|
||||
state = new StringType(connector.getIrisMode());
|
||||
break;
|
||||
case CHANNEL_IRIS_MANUAL:
|
||||
state = new PercentType(connector.getIrisManual());
|
||||
break;
|
||||
case CHANNEL_IRIS_SENSITIVITY:
|
||||
state = new StringType(connector.getIrisSensitivity());
|
||||
break;
|
||||
case CHANNEL_LAMP_CONTROL:
|
||||
state = new StringType(connector.getLampControl());
|
||||
break;
|
||||
case CHANNEL_FILM_PROJECTION:
|
||||
state = new StringType(connector.getFilmProjection());
|
||||
break;
|
||||
case CHANNEL_MOTION_ENHANCER:
|
||||
state = new StringType(connector.getMotionEnhancer());
|
||||
break;
|
||||
case CHANNEL_CONTRAST_ENHANCER:
|
||||
state = new StringType(connector.getContrastEnhancer());
|
||||
break;
|
||||
case CHANNEL_FILM_MODE:
|
||||
state = new StringType(connector.getFilmMode());
|
||||
break;
|
||||
case CHANNEL_GAMMA_CORRECTION:
|
||||
state = new StringType(connector.getGammaCorrection());
|
||||
break;
|
||||
case CHANNEL_COLOR_SPACE:
|
||||
state = new StringType(connector.getColorSpace());
|
||||
break;
|
||||
case CHANNEL_NR:
|
||||
state = new StringType(connector.getNr());
|
||||
break;
|
||||
case CHANNEL_BLOCK_NR:
|
||||
state = new StringType(connector.getBlockNr());
|
||||
break;
|
||||
case CHANNEL_MOSQUITO_NR:
|
||||
state = new StringType(connector.getMosquitoNr());
|
||||
break;
|
||||
case CHANNEL_MPEG_NR:
|
||||
state = new StringType(connector.getMpegNr());
|
||||
break;
|
||||
case CHANNEL_XVCOLOR:
|
||||
state = connector.getXvColor();
|
||||
break;
|
||||
case CHANNEL_PICTURE_MUTING:
|
||||
state = connector.getPictureMuting();
|
||||
break;
|
||||
case CHANNEL_ASPECT:
|
||||
state = new StringType(connector.getAspect());
|
||||
break;
|
||||
case CHANNEL_OVERSCAN:
|
||||
state = connector.getOverscan();
|
||||
break;
|
||||
case CHANNEL_PICTURE_POSITION:
|
||||
state = new StringType(connector.getPicturePosition());
|
||||
break;
|
||||
case CHANNEL_LAMP_USE_TIME:
|
||||
state = new DecimalType(connector.getLampUseTime());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
logger.debug("Refresh channel {} with value {}", channel, state);
|
||||
} catch (SonyProjectorException e) {
|
||||
logger.debug("Refresh channel {} failed: {}", channel, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
private void refreshChannel(String channel, boolean requestValue) {
|
||||
updateChannelStateAndCache(channel, requestProjectorValue(channel, requestValue));
|
||||
}
|
||||
|
||||
private void updateChannelStateAndCache(String channel, @Nullable State state) {
|
||||
if (state != null) {
|
||||
updateState(channel, state);
|
||||
|
||||
if (!cache.containsKey(channel)) {
|
||||
cache.put(channel, () -> {
|
||||
synchronized (commandLock) {
|
||||
return requestProjectorValue(channel, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
cache.putValue(channel, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<binding:binding id="sonyprojector" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:binding="https://openhab.org/schemas/binding/v1.0.0"
|
||||
xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd">
|
||||
|
||||
<name>SonyProjector Binding</name>
|
||||
<description>The SonyProjector binding controls a Sony projector through Ethernet (PJ Talk) or serial.</description>
|
||||
|
||||
</binding:binding>
|
||||
@@ -0,0 +1,278 @@
|
||||
# binding
|
||||
binding.sonyprojector.name = Extension Projecteur Sony
|
||||
binding.sonyprojector.description = L'extension Projecteur Sony permet de contrôler un projecteur Sony par connexion Ethernet (PJ Talk) ou série.
|
||||
|
||||
# thing types
|
||||
thing-type.sonyprojector.ethernetconnection.label = Connexion Ethernet Sony
|
||||
thing-type.sonyprojector.ethernetconnection.description = Connexion Ethernet au projecteur Sony en utilisant PJ Talk.
|
||||
|
||||
thing-type.sonyprojector.serialconnection.label = Connexion série Sony
|
||||
thing-type.sonyprojector.serialconnection.description = Connexion série au projecteur Sony.
|
||||
|
||||
thing-type.sonyprojector.serialoveripconnection.label = Connexion série sur IP Sony
|
||||
thing-type.sonyprojector.serialoveripconnection.description = Connexion série sur IP au projecteur Sony.
|
||||
|
||||
# thing type configuration
|
||||
thing-type.config.sonyprojector.ethernetconnection.host.label = Hôte
|
||||
thing-type.config.sonyprojector.ethernetconnection.host.description = Nom d'hôte ou adresse IP du projecteur.
|
||||
|
||||
thing-type.config.sonyprojector.ethernetconnection.port.label = Port
|
||||
thing-type.config.sonyprojector.ethernetconnection.port.description = Port de communication (53484 par défaut).
|
||||
|
||||
thing-type.config.sonyprojector.ethernetconnection.model.label = Modèle
|
||||
thing-type.config.sonyprojector.ethernetconnection.model.description = Modèle du projecteur à contrôler.
|
||||
thing-type.config.sonyprojector.ethernetconnection.model.option.AUTO = Automatique
|
||||
|
||||
thing-type.config.sonyprojector.ethernetconnection.community.label = Communauté
|
||||
thing-type.config.sonyprojector.ethernetconnection.community.description = Communauté du projecteur devant contenir 4 caractères (SONY par défaut).
|
||||
|
||||
thing-type.config.sonyprojector.serialconnection.port.label = Port série
|
||||
thing-type.config.sonyprojector.serialconnection.port.description = Port série à utiliser pour se connecter au projecteur.
|
||||
|
||||
thing-type.config.sonyprojector.serialconnection.model.label = Modèle
|
||||
thing-type.config.sonyprojector.serialconnection.model.description = Modèle du projecteur à contrôler.
|
||||
|
||||
thing-type.config.sonyprojector.serialoveripconnection.host.label = Hôte
|
||||
thing-type.config.sonyprojector.serialoveripconnection.host.description = Nom d'hôte ou adresse IP de la machine connectée au projecteur.
|
||||
|
||||
thing-type.config.sonyprojector.serialoveripconnection.port.label = Port
|
||||
thing-type.config.sonyprojector.serialoveripconnection.port.description = Port de communication.
|
||||
|
||||
thing-type.config.sonyprojector.serialoveripconnection.model.label = Modèle
|
||||
thing-type.config.sonyprojector.serialoveripconnection.model.description = Modèle du projecteur à contrôler.
|
||||
|
||||
# channel types
|
||||
channel-type.sonyprojector.power.label = Mise sous tension
|
||||
channel-type.sonyprojector.power.description = Allume ou éteint le projecteur.
|
||||
|
||||
channel-type.sonyprojector.powerstate.label = Etat alimentation
|
||||
channel-type.sonyprojector.powerstate.description = État actuel d'alimentation du projecteur.
|
||||
|
||||
channel-type.sonyprojector.input.label = Entrée
|
||||
channel-type.sonyprojector.input.description = Sélectionne le périphérique à partir duquel les images seront affichées.
|
||||
channel-type.sonyprojector.input.state.option.HDMI = HDMI
|
||||
channel-type.sonyprojector.input.state.option.HDMI1 = HDMI 1
|
||||
channel-type.sonyprojector.input.state.option.HDMI2 = HDMI 2
|
||||
channel-type.sonyprojector.input.state.option.DVI = DVI
|
||||
channel-type.sonyprojector.input.state.option.Video = Vidéo
|
||||
channel-type.sonyprojector.input.state.option.SVideo = S-Vidéo
|
||||
channel-type.sonyprojector.input.state.option.InputA = Entrée A
|
||||
channel-type.sonyprojector.input.state.option.Component = Composante
|
||||
channel-type.sonyprojector.input.state.option.HDMI2 = HDMI 2
|
||||
|
||||
channel-type.sonyprojector.calibrationpreset.label = Préréglage étalon
|
||||
channel-type.sonyprojector.calibrationpreset.description = Sélectionne le mode de visualisation de l'image en sélectionnant l'un des préréglages étalon.
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.Film1 = Cinéma Film 1
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.Film2 = Cinéma Film 2
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.Reference = Référence
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.TV = TV
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.Photo = Photo
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.Game = Jeu
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.BRTCINE = Cinéma lumière
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.BRTTV = TV lumière
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.Dynamic = Dynamique
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.Standard = Standard
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.Cinema = Cinéma
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.Cinema1 = Cinéma 1
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.Cinema2 = Cinéma 2
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.Cinema3 = Cinéma 3
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.User = Utilisateur
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.User1 = Utilisateur 1
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.User2 = Utilisateur 2
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.User3 = Utilisateur 3
|
||||
channel-type.sonyprojector.calibrationpreset.state.option.Digital = Numérique
|
||||
|
||||
channel-type.sonyprojector.contrast.label = Contraste
|
||||
channel-type.sonyprojector.contrast.description = Règle le contraste de l'ìmage.
|
||||
|
||||
channel-type.sonyprojector.brightness.label = Luminosité
|
||||
channel-type.sonyprojector.brightness.description = Règle la luminosité de l'image.
|
||||
|
||||
channel-type.sonyprojector.color.label = Couleur
|
||||
channel-type.sonyprojector.color.description = Règle la densité de couleur.
|
||||
|
||||
channel-type.sonyprojector.hue.label = Teinte
|
||||
channel-type.sonyprojector.hue.description = Règle la tonalité de couleur.
|
||||
|
||||
channel-type.sonyprojector.sharpness.label = Netteté
|
||||
channel-type.sonyprojector.sharpness.description = Rend les contours de l'image plus nets ou réduit les parasites.
|
||||
|
||||
channel-type.sonyprojector.colortemperature.label = Température couleur
|
||||
channel-type.sonyprojector.colortemperature.description = Règle la température de couleur.
|
||||
channel-type.sonyprojector.colortemperature.state.option.D93 = D93
|
||||
channel-type.sonyprojector.colortemperature.state.option.D75 = D75
|
||||
channel-type.sonyprojector.colortemperature.state.option.D65 = D65
|
||||
channel-type.sonyprojector.colortemperature.state.option.D55 = D55
|
||||
channel-type.sonyprojector.colortemperature.state.option.DCI = DCI
|
||||
channel-type.sonyprojector.colortemperature.state.option.High = Haut
|
||||
channel-type.sonyprojector.colortemperature.state.option.Middle = Moyen
|
||||
channel-type.sonyprojector.colortemperature.state.option.Low = Bas
|
||||
channel-type.sonyprojector.colortemperature.state.option.Low1 = Bas 1
|
||||
channel-type.sonyprojector.colortemperature.state.option.Low2 = Bas 2
|
||||
channel-type.sonyprojector.colortemperature.state.option.Custom = Personnalisé
|
||||
channel-type.sonyprojector.colortemperature.state.option.Custom1 = Personnalisé 1
|
||||
channel-type.sonyprojector.colortemperature.state.option.Custom2 = Personnalisé 2
|
||||
channel-type.sonyprojector.colortemperature.state.option.Custom3 = Personnalisé 3
|
||||
channel-type.sonyprojector.colortemperature.state.option.Custom4 = Personnalisé 4
|
||||
channel-type.sonyprojector.colortemperature.state.option.Custom5 = Personnalisé 5
|
||||
|
||||
channel-type.sonyprojector.irismode.label = Diaphragme avancé
|
||||
channel-type.sonyprojector.irismode.description = Slélectionne la fonction du diaphragme.
|
||||
channel-type.sonyprojector.irismode.state.option.Full = Auto complète
|
||||
channel-type.sonyprojector.irismode.state.option.Limited = Auto limitée
|
||||
channel-type.sonyprojector.irismode.state.option.AutoFull = Auto complète
|
||||
channel-type.sonyprojector.irismode.state.option.AutoLimited = Auto limitée
|
||||
channel-type.sonyprojector.irismode.state.option.Auto = Automatique
|
||||
channel-type.sonyprojector.irismode.state.option.Auto1 = Automatique 1
|
||||
channel-type.sonyprojector.irismode.state.option.Auto2 = Automatique 2
|
||||
channel-type.sonyprojector.irismode.state.option.Manual = Manuel
|
||||
channel-type.sonyprojector.irismode.state.option.On = Activé
|
||||
channel-type.sonyprojector.irismode.state.option.Off = Désactivé
|
||||
|
||||
channel-type.sonyprojector.irismanual.label = Diaphragme manuel
|
||||
channel-type.sonyprojector.irismanual.description = Règle manuellement le diaphragme à une valeur fixe.
|
||||
|
||||
channel-type.sonyprojector.irissensitivity.label = Sensibilité diaphragme
|
||||
channel-type.sonyprojector.irissensitivity.description = Règle la sensibilité du diaphragme.
|
||||
channel-type.sonyprojector.irissensitivity.state.option.Recommend = Recommandé
|
||||
channel-type.sonyprojector.irissensitivity.state.option.Fast = Rapide
|
||||
channel-type.sonyprojector.irissensitivity.state.option.Slow = Lent
|
||||
|
||||
channel-type.sonyprojector.lampcontrol.label = Commande lampe
|
||||
channel-type.sonyprojector.lampcontrol.description = Règle le niveau de sortie de la lampe.
|
||||
channel-type.sonyprojector.lampcontrol.state.option.High = Haut
|
||||
channel-type.sonyprojector.lampcontrol.state.option.Low = Bas
|
||||
|
||||
channel-type.sonyprojector.filmprojection.label = Projection
|
||||
channel-type.sonyprojector.filmprojection.description = Reproduit une image similaire à celle d'un film projeté.
|
||||
channel-type.sonyprojector.filmprojection.state.option.Mode1 = Mode 1
|
||||
channel-type.sonyprojector.filmprojection.state.option.Mode2 = Mode 2
|
||||
channel-type.sonyprojector.filmprojection.state.option.Mode3 = Mode 3
|
||||
channel-type.sonyprojector.filmprojection.state.option.On = Activé
|
||||
channel-type.sonyprojector.filmprojection.state.option.Off = Désactivé
|
||||
|
||||
channel-type.sonyprojector.motionenhancer.label = Meilleur mouvement
|
||||
channel-type.sonyprojector.motionenhancer.description = Reproduit des images en mouvement rapide sans rémanence.
|
||||
channel-type.sonyprojector.motionenhancer.state.option.High = Haut
|
||||
channel-type.sonyprojector.motionenhancer.state.option.Low = Bas
|
||||
channel-type.sonyprojector.motionenhancer.state.option.SmoothHigh = Haut
|
||||
channel-type.sonyprojector.motionenhancer.state.option.SmoothLow = Bas
|
||||
channel-type.sonyprojector.motionenhancer.state.option.TrueCinema = True Cinéma
|
||||
channel-type.sonyprojector.motionenhancer.state.option.Impulse = Impulsion
|
||||
channel-type.sonyprojector.motionenhancer.state.option.Combination = Combinaison
|
||||
channel-type.sonyprojector.motionenhancer.state.option.Off = Désactivé
|
||||
|
||||
channel-type.sonyprojector.contrastenhancer.label = Accentuation contraste
|
||||
channel-type.sonyprojector.contrastenhancer.description = Ajuste automatiquement le niveau des zones lumineuses et des zones sombres pour améliorer le contraste en fonction de la scène.
|
||||
channel-type.sonyprojector.contrastenhancer.state.option.High = Haut
|
||||
channel-type.sonyprojector.contrastenhancer.state.option.Middle = Moyen
|
||||
channel-type.sonyprojector.contrastenhancer.state.option.Low = Bas
|
||||
channel-type.sonyprojector.contrastenhancer.state.option.Off = Désactivé
|
||||
|
||||
channel-type.sonyprojector.filmmode.label = Mode film
|
||||
channel-type.sonyprojector.filmmode.description = Sélectionne le mode de lecture pour une source film.
|
||||
channel-type.sonyprojector.filmmode.state.option.Auto = Automatique
|
||||
channel-type.sonyprojector.filmmode.state.option.Auto1 = Automatique 1
|
||||
channel-type.sonyprojector.filmmode.state.option.Auto2 = Automatique 2
|
||||
channel-type.sonyprojector.filmmode.state.option.Off = Désactivé
|
||||
|
||||
channel-type.sonyprojector.gammacorrection.label = Correction gamma
|
||||
channel-type.sonyprojector.gammacorrection.description = Règle les caractéristiques de transfert de la tonalité d'image.
|
||||
channel-type.sonyprojector.gammacorrection.state.option.Gamma1 = Gamma 1
|
||||
channel-type.sonyprojector.gammacorrection.state.option.Gamma2 = Gamma 2
|
||||
channel-type.sonyprojector.gammacorrection.state.option.Gamma3 = Gamma 3
|
||||
channel-type.sonyprojector.gammacorrection.state.option.Gamma4 = Gamma 4
|
||||
channel-type.sonyprojector.gammacorrection.state.option.Gamma5 = Gamma 5
|
||||
channel-type.sonyprojector.gammacorrection.state.option.Gamma6 = Gamma 6
|
||||
channel-type.sonyprojector.gammacorrection.state.option.Gamma7 = Gamma 7
|
||||
channel-type.sonyprojector.gammacorrection.state.option.Gamma8 = Gamma 8
|
||||
channel-type.sonyprojector.gammacorrection.state.option.Gamma9 = Gamma 9
|
||||
channel-type.sonyprojector.gammacorrection.state.option.Gamma10 = Gamma 10
|
||||
channel-type.sonyprojector.gammacorrection.state.option.Off = Désactivé
|
||||
|
||||
channel-type.sonyprojector.colorspace.label = Espace couleur
|
||||
channel-type.sonyprojector.colorspace.description = Convertit l'espace colorimétrique.
|
||||
channel-type.sonyprojector.colorspace.state.option.BT709 = BT.709
|
||||
channel-type.sonyprojector.colorspace.state.option.BT2020 = BT.2020
|
||||
channel-type.sonyprojector.colorspace.state.option.ColorSpace1 = Espace couleur 1
|
||||
channel-type.sonyprojector.colorspace.state.option.ColorSpace2 = Espace couleur 2
|
||||
channel-type.sonyprojector.colorspace.state.option.ColorSpace3 = Espace couleur 3
|
||||
channel-type.sonyprojector.colorspace.state.option.Custom = Personnalisé
|
||||
channel-type.sonyprojector.colorspace.state.option.Normal = Normal
|
||||
channel-type.sonyprojector.colorspace.state.option.Wide = Large
|
||||
channel-type.sonyprojector.colorspace.state.option.Wide1 = Large 1
|
||||
channel-type.sonyprojector.colorspace.state.option.Wide2 = Large 2
|
||||
channel-type.sonyprojector.colorspace.state.option.Wide3 = Large 3
|
||||
channel-type.sonyprojector.colorspace.state.option.DCI = DCI
|
||||
channel-type.sonyprojector.colorspace.state.option.AdobeRGB = Adobe RGB
|
||||
|
||||
channel-type.sonyprojector.nr.label = Réduction du bruit
|
||||
channel-type.sonyprojector.nr.description = Réduit le flou ou les parasites de l'image.
|
||||
channel-type.sonyprojector.nr.state.option.Auto = Automatique
|
||||
channel-type.sonyprojector.nr.state.option.High = Haut
|
||||
channel-type.sonyprojector.nr.state.option.Middle = Moyen
|
||||
channel-type.sonyprojector.nr.state.option.Low = Bas
|
||||
channel-type.sonyprojector.nr.state.option.Off = Désactivé
|
||||
|
||||
channel-type.sonyprojector.blocknr.label = Réduction du bruit de bloc
|
||||
channel-type.sonyprojector.blocknr.description = Réduit le bruit de bloc, tout particulièrement sur les signaux numériques.
|
||||
channel-type.sonyprojector.blocknr.state.option.High = Haut
|
||||
channel-type.sonyprojector.blocknr.state.option.Middle = Moyen
|
||||
channel-type.sonyprojector.blocknr.state.option.Low = Bas
|
||||
channel-type.sonyprojector.blocknr.state.option.Off = Désactivé
|
||||
|
||||
channel-type.sonyprojector.mosquitonr.label = Réduction du bruit mosquito
|
||||
channel-type.sonyprojector.mosquitonr.description = Réduit le bruit mosquito, tout particulièrement sur les signaux numériques.
|
||||
channel-type.sonyprojector.mosquitonr.state.option.High = Haut
|
||||
channel-type.sonyprojector.mosquitonr.state.option.Middle = Moyen
|
||||
channel-type.sonyprojector.mosquitonr.state.option.Low = Bas
|
||||
channel-type.sonyprojector.mosquitonr.state.option.Off = Désactivé
|
||||
|
||||
channel-type.sonyprojector.mpegnr.label = Réduction du bruit MPEG
|
||||
channel-type.sonyprojector.mpegnr.description = Réduit le bruit de bloc et le bruit mosquito, tout particulièrement sur les signaux numériques.
|
||||
channel-type.sonyprojector.mpegnr.state.option.Auto = Automatique
|
||||
channel-type.sonyprojector.mpegnr.state.option.High = Haut
|
||||
channel-type.sonyprojector.mpegnr.state.option.Middle = Moyen
|
||||
channel-type.sonyprojector.mpegnr.state.option.Low = Bas
|
||||
channel-type.sonyprojector.mpegnr.state.option.Off = Désactivé
|
||||
|
||||
channel-type.sonyprojector.xvcolor.label = x.v.Color
|
||||
channel-type.sonyprojector.xvcolor.description = Activer cette option lors de la visualisation d'un signal vidéo x.v.Color.
|
||||
|
||||
channel-type.sonyprojector.picturemuting.label = Coupure affichage
|
||||
channel-type.sonyprojector.picturemuting.description = Coupe ou restaure l'affichage de l'image.
|
||||
|
||||
channel-type.sonyprojector.aspect.label = Aspect
|
||||
channel-type.sonyprojector.aspect.description = Définit le rapport de format de l'image à afficher.
|
||||
channel-type.sonyprojector.aspect.state.option.Normal = Normal
|
||||
channel-type.sonyprojector.aspect.state.option.VStretch = Etirement vertical
|
||||
channel-type.sonyprojector.aspect.state.option.185 = Zoom 1.85:1
|
||||
channel-type.sonyprojector.aspect.state.option.235 = Zoom 2.35:1
|
||||
channel-type.sonyprojector.aspect.state.option.Stretch = Etirer
|
||||
channel-type.sonyprojector.aspect.state.option.Squeeze = Serrer
|
||||
channel-type.sonyprojector.aspect.state.option.Full = Plein
|
||||
channel-type.sonyprojector.aspect.state.option.Full1 = Plein 1
|
||||
channel-type.sonyprojector.aspect.state.option.Full2 = Plein 2
|
||||
channel-type.sonyprojector.aspect.state.option.WideZoom = Zoom large
|
||||
channel-type.sonyprojector.aspect.state.option.Zoom = Zoom
|
||||
channel-type.sonyprojector.aspect.state.option.Anamorphic = Anamorphique
|
||||
channel-type.sonyprojector.aspect.state.option.Subtitle = Sous-titre
|
||||
|
||||
channel-type.sonyprojector.overscan.label = Surscannage
|
||||
channel-type.sonyprojector.overscan.description = Cache ou non les contours de l'image.
|
||||
|
||||
channel-type.sonyprojector.pictureposition.label = Position image
|
||||
channel-type.sonyprojector.pictureposition.description = Règle la position de l'image.
|
||||
channel-type.sonyprojector.pictureposition.state.option.185 = 1.85:1
|
||||
channel-type.sonyprojector.pictureposition.state.option.235 = 2.35:1
|
||||
channel-type.sonyprojector.pictureposition.state.option.Custom1 = Personnalisé 1
|
||||
channel-type.sonyprojector.pictureposition.state.option.Custom2 = Personnalisé 2
|
||||
channel-type.sonyprojector.pictureposition.state.option.Custom3 = Personnalisé 3
|
||||
channel-type.sonyprojector.pictureposition.state.option.Position1 = Position 1
|
||||
channel-type.sonyprojector.pictureposition.state.option.Position2 = Position 2
|
||||
channel-type.sonyprojector.pictureposition.state.option.Position3 = Position 3
|
||||
channel-type.sonyprojector.pictureposition.state.option.Position4 = Position 4
|
||||
channel-type.sonyprojector.pictureposition.state.option.Position5 = Position 5
|
||||
|
||||
channel-type.sonyprojector.lampusetime.label = Durée de lampe
|
||||
channel-type.sonyprojector.lampusetime.description = Indique la durée en heures pendant laquelle la lampe a été allumée (temps total d'utilisation).
|
||||
@@ -0,0 +1,195 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<thing:thing-descriptions bindingId="sonyprojector"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
|
||||
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
|
||||
|
||||
<channel-type id="power">
|
||||
<item-type>Switch</item-type>
|
||||
<label>Power</label>
|
||||
<description>Power ON/OFF the projector</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="powerstate">
|
||||
<item-type>String</item-type>
|
||||
<label>Power State</label>
|
||||
<description>Current detailed power state of the projector</description>
|
||||
<state readOnly="true"></state>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="input">
|
||||
<item-type>String</item-type>
|
||||
<label>Video Input</label>
|
||||
<description>Select the equipment from which to display images</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="calibrationpreset">
|
||||
<item-type>String</item-type>
|
||||
<label>Calibrated Preset</label>
|
||||
<description>Adjust the picture viewing mode by selecting one of the preset modes</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="contrast" advanced="true">
|
||||
<item-type>Dimmer</item-type>
|
||||
<label>Contrast</label>
|
||||
<description>Adjust the contrast of the picture</description>
|
||||
<state min="0" max="100"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="brightness" advanced="true">
|
||||
<item-type>Dimmer</item-type>
|
||||
<label>Brightness</label>
|
||||
<description>Adjust the brightness of the picture</description>
|
||||
<state min="0" max="100"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="color" advanced="true">
|
||||
<item-type>Dimmer</item-type>
|
||||
<label>Color</label>
|
||||
<description>Adjust the color density</description>
|
||||
<state min="0" max="100"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="hue" advanced="true">
|
||||
<item-type>Dimmer</item-type>
|
||||
<label>Hue</label>
|
||||
<description>Adjust the color tone</description>
|
||||
<state min="0" max="100"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="sharpness" advanced="true">
|
||||
<item-type>Dimmer</item-type>
|
||||
<label>Sharpness</label>
|
||||
<description>Sharpen the outline of the picture or reduce the noise</description>
|
||||
<state min="0" max="100"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="colortemperature" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Color Temperature</label>
|
||||
<description>Adjust the color temperature</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="irismode" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Iris Mode</label>
|
||||
<description>Switch the iris aperture function</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="irismanual" advanced="true">
|
||||
<item-type>Dimmer</item-type>
|
||||
<label>Iris Manual</label>
|
||||
<description>Force the iris aperture to a fixed value</description>
|
||||
<state min="0" max="100"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="irissensitivity" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Iris Sensitivity</label>
|
||||
<description>Select the iris sensitivity</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="lampcontrol" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Lamp Control</label>
|
||||
<description>Switch the lamp output</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="filmprojection" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Film Projection</label>
|
||||
<description>Reproduce an image similar to that of projected film</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="motionenhancer" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Motion Enhancer</label>
|
||||
<description>Reproduce fast-moving pictures smoothly without generating afterimages</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="contrastenhancer" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Contrast Enhancer</label>
|
||||
<description>Correct the level of bright and dark parts automatically</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="filmmode" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Film Mode</label>
|
||||
<description>Select the playback mode for film sources</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="gammacorrection" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Gamma Correction</label>
|
||||
<description>Adjust the response characteristics of the tone of the picture</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="colorspace" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Color Space</label>
|
||||
<description>Convert the color space</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="nr" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Noise Reduction</label>
|
||||
<description>Reduce the roughness or noise of the picture</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="blocknr" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Block Noise Reduction</label>
|
||||
<description>Reduce digital noise that appears in mosaic-like pattern</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="mosquitonr" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Mosquito Noise Reduction</label>
|
||||
<description>Reduce digital noise that appears near the outline of the picture</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="mpegnr" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>MPEG Noise Reduction</label>
|
||||
<description>Reduce block noise and mosquito noise, in particular in digital signals</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="xvcolor" advanced="true">
|
||||
<item-type>Switch</item-type>
|
||||
<label>x.v.Color</label>
|
||||
<description>Set this when playing back an x.v.Color video signal</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="picturemuting" advanced="true">
|
||||
<item-type>Switch</item-type>
|
||||
<label>Picture Muting</label>
|
||||
<description>Mute or unmute the picture</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="aspect" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Aspect Ratio</label>
|
||||
<description>Set the aspect ratio of the picture to be displayed</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="overscan" advanced="true">
|
||||
<item-type>Switch</item-type>
|
||||
<label>Overscan</label>
|
||||
<description>Hide or not the edges of the picture</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="pictureposition" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Picture Position</label>
|
||||
<description>Adjust the picture position</description>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="lampusetime" advanced="true">
|
||||
<item-type>Number</item-type>
|
||||
<label>Lamp Use Time</label>
|
||||
<description>Indicate how long the lamp has been turned on in hours</description>
|
||||
<state readOnly="true" pattern="%d h"></state>
|
||||
</channel-type>
|
||||
|
||||
</thing:thing-descriptions>
|
||||
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<thing:thing-descriptions bindingId="sonyprojector"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
|
||||
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
|
||||
|
||||
<!-- Sony Ethernet Connection Thing Type -->
|
||||
<thing-type id="ethernetconnection">
|
||||
<label>Sony Ethernet Connection</label>
|
||||
<description>Ethernet connection to the Sony projector using PJ Talk</description>
|
||||
|
||||
<channels>
|
||||
<channel id="power" typeId="power"/>
|
||||
<channel id="powerstate" typeId="powerstate"/>
|
||||
<channel id="input" typeId="input"/>
|
||||
<channel id="calibrationpreset" typeId="calibrationpreset"/>
|
||||
<channel id="contrast" typeId="contrast"/>
|
||||
<channel id="brightness" typeId="brightness"/>
|
||||
<channel id="color" typeId="color"/>
|
||||
<channel id="hue" typeId="hue"/>
|
||||
<channel id="sharpness" typeId="sharpness"/>
|
||||
<channel id="colortemperature" typeId="colortemperature"/>
|
||||
<channel id="irismode" typeId="irismode"/>
|
||||
<channel id="irismanual" typeId="irismanual"/>
|
||||
<channel id="irissensitivity" typeId="irissensitivity"/>
|
||||
<channel id="lampcontrol" typeId="lampcontrol"/>
|
||||
<channel id="filmprojection" typeId="filmprojection"/>
|
||||
<channel id="motionenhancer" typeId="motionenhancer"/>
|
||||
<channel id="contrastenhancer" typeId="contrastenhancer"/>
|
||||
<channel id="filmmode" typeId="filmmode"/>
|
||||
<channel id="gammacorrection" typeId="gammacorrection"/>
|
||||
<channel id="colorspace" typeId="colorspace"/>
|
||||
<channel id="nr" typeId="nr"/>
|
||||
<channel id="blocknr" typeId="blocknr"/>
|
||||
<channel id="mosquitonr" typeId="mosquitonr"/>
|
||||
<channel id="mpegnr" typeId="mpegnr"/>
|
||||
<channel id="xvcolor" typeId="xvcolor"/>
|
||||
<channel id="picturemuting" typeId="picturemuting"/>
|
||||
<channel id="aspect" typeId="aspect"/>
|
||||
<channel id="overscan" typeId="overscan"/>
|
||||
<channel id="pictureposition" typeId="pictureposition"/>
|
||||
<channel id="lampusetime" typeId="lampusetime"/>
|
||||
</channels>
|
||||
|
||||
<config-description>
|
||||
<parameter name="host" type="text" required="true">
|
||||
<context>network-address</context>
|
||||
<label>Address</label>
|
||||
<description>Host name or IP address of the projector</description>
|
||||
</parameter>
|
||||
<parameter name="port" type="integer" required="false">
|
||||
<label>Port</label>
|
||||
<description>Communication port. Default is 53484</description>
|
||||
<default>53484</default>
|
||||
</parameter>
|
||||
<parameter name="model" type="text" required="false">
|
||||
<label>Model</label>
|
||||
<description>Projector model to be controlled. Default is AUTO</description>
|
||||
<limitToOptions>true</limitToOptions>
|
||||
<options>
|
||||
<option value="AUTO">Automatic</option>
|
||||
<option value="VPL-HW60">VPL-HW60</option>
|
||||
<option value="VPL-HW65">VPL-HW65</option>
|
||||
<option value="VPL-HW68">VPL-HW68</option>
|
||||
<option value="VPL-VW100">VPL-VW100</option>
|
||||
<option value="VPL-VW200">VPL-VW200</option>
|
||||
<option value="VPL-VW260ES">VPL-VW260ES</option>
|
||||
<option value="VPL-VW270ES">VPL-VW270ES</option>
|
||||
<option value="VPL-VW285ES">VPL-VW285ES</option>
|
||||
<option value="VPL-VW295ES">VPL-VW295ES</option>
|
||||
<option value="VPL-VW300ES">VPL-VW300ES</option>
|
||||
<option value="VPL-VW315">VPL-VW315</option>
|
||||
<option value="VPL-VW320">VPL-VW320</option>
|
||||
<option value="VPL-VW328">VPL-VW328</option>
|
||||
<option value="VPL-VW350ES">VPL-VW350ES</option>
|
||||
<option value="VPL-VW365">VPL-VW365</option>
|
||||
<option value="VPL-VW385ES">VPL-VW385ES</option>
|
||||
<option value="VPL-VW500ES">VPL-VW500ES</option>
|
||||
<option value="VPL-VW515">VPL-VW515</option>
|
||||
<option value="VPL-VW520">VPL-VW520</option>
|
||||
<option value="VPL-VW528">VPL-VW528</option>
|
||||
<option value="VPL-VW550ES">VPL-VW550ES</option>
|
||||
<option value="VPL-VW570ES">VPL-VW570ES</option>
|
||||
<option value="VPL-VW600ES">VPL-VW600ES</option>
|
||||
<option value="VPL-VW665">VPL-VW665</option>
|
||||
<option value="VPL-VW675ES">VPL-VW675ES</option>
|
||||
<option value="VPL-VW695ES">VPL-VW695ES</option>
|
||||
<option value="VPL-VW760ES">VPL-VW760ES</option>
|
||||
<option value="VPL-VW870ES">VPL-VW870ES</option>
|
||||
<option value="VPL-VW885ES">VPL-VW885ES</option>
|
||||
<option value="VPL-VW995ES">VPL-VW995ES</option>
|
||||
<option value="VPL-VW1000ES">VPL-VW1000ES</option>
|
||||
<option value="VPL-VW1100ES">VPL-VW1100ES</option>
|
||||
</options>
|
||||
<default>AUTO</default>
|
||||
</parameter>
|
||||
<parameter name="community" type="text" required="false">
|
||||
<label>Community</label>
|
||||
<description>Community of the projector. Length must be 4 characters. Default is SONY</description>
|
||||
<default>SONY</default>
|
||||
<advanced>true</advanced>
|
||||
</parameter>
|
||||
</config-description>
|
||||
</thing-type>
|
||||
|
||||
</thing:thing-descriptions>
|
||||
@@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<thing:thing-descriptions bindingId="sonyprojector"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
|
||||
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
|
||||
|
||||
<!-- Sony Serial Connection Thing Type -->
|
||||
<thing-type id="serialconnection">
|
||||
<label>Sony Serial Connection</label>
|
||||
<description>Serial connection to the Sony projector</description>
|
||||
|
||||
<channels>
|
||||
<channel id="power" typeId="power"/>
|
||||
<channel id="powerstate" typeId="powerstate"/>
|
||||
<channel id="input" typeId="input"/>
|
||||
<channel id="calibrationpreset" typeId="calibrationpreset"/>
|
||||
<channel id="contrast" typeId="contrast"/>
|
||||
<channel id="brightness" typeId="brightness"/>
|
||||
<channel id="color" typeId="color"/>
|
||||
<channel id="hue" typeId="hue"/>
|
||||
<channel id="sharpness" typeId="sharpness"/>
|
||||
<channel id="colortemperature" typeId="colortemperature"/>
|
||||
<channel id="irismode" typeId="irismode"/>
|
||||
<channel id="irismanual" typeId="irismanual"/>
|
||||
<channel id="irissensitivity" typeId="irissensitivity"/>
|
||||
<channel id="lampcontrol" typeId="lampcontrol"/>
|
||||
<channel id="filmprojection" typeId="filmprojection"/>
|
||||
<channel id="motionenhancer" typeId="motionenhancer"/>
|
||||
<channel id="contrastenhancer" typeId="contrastenhancer"/>
|
||||
<channel id="filmmode" typeId="filmmode"/>
|
||||
<channel id="gammacorrection" typeId="gammacorrection"/>
|
||||
<channel id="colorspace" typeId="colorspace"/>
|
||||
<channel id="nr" typeId="nr"/>
|
||||
<channel id="blocknr" typeId="blocknr"/>
|
||||
<channel id="mosquitonr" typeId="mosquitonr"/>
|
||||
<channel id="mpegnr" typeId="mpegnr"/>
|
||||
<channel id="xvcolor" typeId="xvcolor"/>
|
||||
<channel id="picturemuting" typeId="picturemuting"/>
|
||||
<channel id="aspect" typeId="aspect"/>
|
||||
<channel id="overscan" typeId="overscan"/>
|
||||
<channel id="pictureposition" typeId="pictureposition"/>
|
||||
<channel id="lampusetime" typeId="lampusetime"/>
|
||||
</channels>
|
||||
|
||||
<config-description>
|
||||
<parameter name="port" type="text" required="true">
|
||||
<context>serial-port</context>
|
||||
<limitToOptions>false</limitToOptions>
|
||||
<label>Serial Port</label>
|
||||
<description>Serial port to use for connecting to the projector</description>
|
||||
</parameter>
|
||||
<parameter name="model" type="text" required="true">
|
||||
<label>Model</label>
|
||||
<description>Projector model to be controlled</description>
|
||||
<limitToOptions>true</limitToOptions>
|
||||
<options>
|
||||
<option value="VPL-HW10">VPL-HW10</option>
|
||||
<option value="VPL-HW15">VPL-HW15</option>
|
||||
<option value="VPL-HW20">VPL-HW20</option>
|
||||
<option value="VPL-HW30ES">VPL-HW30ES</option>
|
||||
<option value="VPL-HW35ES">VPL-HW35ES</option>
|
||||
<option value="VPL-HW40ES">VPL-HW40ES</option>
|
||||
<option value="VPL-HW45ES">VPL-HW45ES</option>
|
||||
<option value="VPL-HW50ES">VPL-HW50ES</option>
|
||||
<option value="VPL-HW55ES">VPL-HW55ES</option>
|
||||
<option value="VPL-HW58ES">VPL-HW58ES</option>
|
||||
<option value="VPL-HW60">VPL-HW60</option>
|
||||
<option value="VPL-HW65">VPL-HW65</option>
|
||||
<option value="VPL-HW68">VPL-HW68</option>
|
||||
<option value="VPL-VW40">VPL-VW40</option>
|
||||
<option value="VPL-VW50">VPL-VW50</option>
|
||||
<option value="VPL-VW60">VPL-VW60</option>
|
||||
<option value="VPL-VW70">VPL-VW70</option>
|
||||
<option value="VPL-VW80">VPL-VW80</option>
|
||||
<option value="VPL-VW85">VPL-VW85</option>
|
||||
<option value="VPL-VW90ES">VPL-VW90ES</option>
|
||||
<option value="VPL-VW95ES">VPL-VW95ES</option>
|
||||
<option value="VPL-VW100">VPL-VW100</option>
|
||||
<option value="VPL-VW200">VPL-VW200</option>
|
||||
<option value="VPL-VW260ES">VPL-VW260ES</option>
|
||||
<option value="VPL-VW270ES">VPL-VW270ES</option>
|
||||
<option value="VPL-VW285ES">VPL-VW285ES</option>
|
||||
<option value="VPL-VW295ES">VPL-VW295ES</option>
|
||||
<option value="VPL-VW300ES">VPL-VW300ES</option>
|
||||
<option value="VPL-VW315">VPL-VW315</option>
|
||||
<option value="VPL-VW320">VPL-VW320</option>
|
||||
<option value="VPL-VW328">VPL-VW328</option>
|
||||
<option value="VPL-VW350ES">VPL-VW350ES</option>
|
||||
<option value="VPL-VW365">VPL-VW365</option>
|
||||
<option value="VPL-VW385ES">VPL-VW385ES</option>
|
||||
<option value="VPL-VW500ES">VPL-VW500ES</option>
|
||||
<option value="VPL-VW515">VPL-VW515</option>
|
||||
<option value="VPL-VW520">VPL-VW520</option>
|
||||
<option value="VPL-VW528">VPL-VW528</option>
|
||||
<option value="VPL-VW550ES">VPL-VW550ES</option>
|
||||
<option value="VPL-VW570ES">VPL-VW570ES</option>
|
||||
<option value="VPL-VW600ES">VPL-VW600ES</option>
|
||||
<option value="VPL-VW665">VPL-VW665</option>
|
||||
<option value="VPL-VW675ES">VPL-VW675ES</option>
|
||||
<option value="VPL-VW695ES">VPL-VW695ES</option>
|
||||
<option value="VPL-VW760ES">VPL-VW760ES</option>
|
||||
<option value="VPL-VW870ES">VPL-VW870ES</option>
|
||||
<option value="VPL-VW885ES">VPL-VW885ES</option>
|
||||
<option value="VPL-VW995ES">VPL-VW995ES</option>
|
||||
<option value="VPL-VW1000ES">VPL-VW1000ES</option>
|
||||
<option value="VPL-VW1100ES">VPL-VW1100ES</option>
|
||||
</options>
|
||||
<default>VPL-VW528</default>
|
||||
</parameter>
|
||||
</config-description>
|
||||
</thing-type>
|
||||
|
||||
</thing:thing-descriptions>
|
||||
@@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<thing:thing-descriptions bindingId="sonyprojector"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
|
||||
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
|
||||
|
||||
<!-- Sony Serial over IP Connection Thing Type -->
|
||||
<thing-type id="serialoveripconnection">
|
||||
<label>Sony Serial over IP Connection</label>
|
||||
<description>Serial over IP connection to the Sony projector</description>
|
||||
|
||||
<channels>
|
||||
<channel id="power" typeId="power"/>
|
||||
<channel id="powerstate" typeId="powerstate"/>
|
||||
<channel id="input" typeId="input"/>
|
||||
<channel id="calibrationpreset" typeId="calibrationpreset"/>
|
||||
<channel id="contrast" typeId="contrast"/>
|
||||
<channel id="brightness" typeId="brightness"/>
|
||||
<channel id="color" typeId="color"/>
|
||||
<channel id="hue" typeId="hue"/>
|
||||
<channel id="sharpness" typeId="sharpness"/>
|
||||
<channel id="colortemperature" typeId="colortemperature"/>
|
||||
<channel id="irismode" typeId="irismode"/>
|
||||
<channel id="irismanual" typeId="irismanual"/>
|
||||
<channel id="irissensitivity" typeId="irissensitivity"/>
|
||||
<channel id="lampcontrol" typeId="lampcontrol"/>
|
||||
<channel id="filmprojection" typeId="filmprojection"/>
|
||||
<channel id="motionenhancer" typeId="motionenhancer"/>
|
||||
<channel id="contrastenhancer" typeId="contrastenhancer"/>
|
||||
<channel id="filmmode" typeId="filmmode"/>
|
||||
<channel id="gammacorrection" typeId="gammacorrection"/>
|
||||
<channel id="colorspace" typeId="colorspace"/>
|
||||
<channel id="nr" typeId="nr"/>
|
||||
<channel id="blocknr" typeId="blocknr"/>
|
||||
<channel id="mosquitonr" typeId="mosquitonr"/>
|
||||
<channel id="mpegnr" typeId="mpegnr"/>
|
||||
<channel id="xvcolor" typeId="xvcolor"/>
|
||||
<channel id="picturemuting" typeId="picturemuting"/>
|
||||
<channel id="aspect" typeId="aspect"/>
|
||||
<channel id="overscan" typeId="overscan"/>
|
||||
<channel id="pictureposition" typeId="pictureposition"/>
|
||||
<channel id="lampusetime" typeId="lampusetime"/>
|
||||
</channels>
|
||||
|
||||
<config-description>
|
||||
<parameter name="host" type="text" required="true">
|
||||
<context>network-address</context>
|
||||
<label>Address</label>
|
||||
<description>Host name or IP address of the machine connected to the projector</description>
|
||||
</parameter>
|
||||
<parameter name="port" type="integer" required="true">
|
||||
<label>Port</label>
|
||||
<description>Communication port</description>
|
||||
</parameter>
|
||||
<parameter name="model" type="text" required="true">
|
||||
<label>Model</label>
|
||||
<description>Projector model to be controlled</description>
|
||||
<limitToOptions>true</limitToOptions>
|
||||
<options>
|
||||
<option value="VPL-HW10">VPL-HW10</option>
|
||||
<option value="VPL-HW15">VPL-HW15</option>
|
||||
<option value="VPL-HW20">VPL-HW20</option>
|
||||
<option value="VPL-HW30ES">VPL-HW30ES</option>
|
||||
<option value="VPL-HW35ES">VPL-HW35ES</option>
|
||||
<option value="VPL-HW40ES">VPL-HW40ES</option>
|
||||
<option value="VPL-HW45ES">VPL-HW45ES</option>
|
||||
<option value="VPL-HW50ES">VPL-HW50ES</option>
|
||||
<option value="VPL-HW55ES">VPL-HW55ES</option>
|
||||
<option value="VPL-HW58ES">VPL-HW58ES</option>
|
||||
<option value="VPL-HW60">VPL-HW60</option>
|
||||
<option value="VPL-HW65">VPL-HW65</option>
|
||||
<option value="VPL-HW68">VPL-HW68</option>
|
||||
<option value="VPL-VW40">VPL-VW40</option>
|
||||
<option value="VPL-VW50">VPL-VW50</option>
|
||||
<option value="VPL-VW60">VPL-VW60</option>
|
||||
<option value="VPL-VW70">VPL-VW70</option>
|
||||
<option value="VPL-VW80">VPL-VW80</option>
|
||||
<option value="VPL-VW85">VPL-VW85</option>
|
||||
<option value="VPL-VW90ES">VPL-VW90ES</option>
|
||||
<option value="VPL-VW95ES">VPL-VW95ES</option>
|
||||
<option value="VPL-VW100">VPL-VW100</option>
|
||||
<option value="VPL-VW200">VPL-VW200</option>
|
||||
<option value="VPL-VW260ES">VPL-VW260ES</option>
|
||||
<option value="VPL-VW270ES">VPL-VW270ES</option>
|
||||
<option value="VPL-VW285ES">VPL-VW285ES</option>
|
||||
<option value="VPL-VW295ES">VPL-VW295ES</option>
|
||||
<option value="VPL-VW300ES">VPL-VW300ES</option>
|
||||
<option value="VPL-VW315">VPL-VW315</option>
|
||||
<option value="VPL-VW320">VPL-VW320</option>
|
||||
<option value="VPL-VW328">VPL-VW328</option>
|
||||
<option value="VPL-VW350ES">VPL-VW350ES</option>
|
||||
<option value="VPL-VW365">VPL-VW365</option>
|
||||
<option value="VPL-VW385ES">VPL-VW385ES</option>
|
||||
<option value="VPL-VW500ES">VPL-VW500ES</option>
|
||||
<option value="VPL-VW515">VPL-VW515</option>
|
||||
<option value="VPL-VW520">VPL-VW520</option>
|
||||
<option value="VPL-VW528">VPL-VW528</option>
|
||||
<option value="VPL-VW550ES">VPL-VW550ES</option>
|
||||
<option value="VPL-VW570ES">VPL-VW570ES</option>
|
||||
<option value="VPL-VW600ES">VPL-VW600ES</option>
|
||||
<option value="VPL-VW665">VPL-VW665</option>
|
||||
<option value="VPL-VW675ES">VPL-VW675ES</option>
|
||||
<option value="VPL-VW695ES">VPL-VW695ES</option>
|
||||
<option value="VPL-VW760ES">VPL-VW760ES</option>
|
||||
<option value="VPL-VW870ES">VPL-VW870ES</option>
|
||||
<option value="VPL-VW885ES">VPL-VW885ES</option>
|
||||
<option value="VPL-VW995ES">VPL-VW995ES</option>
|
||||
<option value="VPL-VW1000ES">VPL-VW1000ES</option>
|
||||
<option value="VPL-VW1100ES">VPL-VW1100ES</option>
|
||||
</options>
|
||||
<default>VPL-VW528</default>
|
||||
</parameter>
|
||||
</config-description>
|
||||
</thing-type>
|
||||
|
||||
</thing:thing-descriptions>
|
||||
Reference in New Issue
Block a user