mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[teleinfo] code cleanup and remove timeout (#9902)
* Remove timeout when waiting frame Signed-off-by: Olivier Marceau <hollysaiqs@marceau.ovh> * Add olivierkeke to code owners list Signed-off-by: Olivier Marceau <hollysaiqs@marceau.ovh> * Code cleanup Signed-off-by: Olivier Marceau <hollysaiqs@marceau.ovh> * Refactor data objects Signed-off-by: Olivier Marceau <hollysaiqs@marceau.ovh> * Apply some sonarlint suggestions Signed-off-by: Olivier Marceau <hollysaiqs@marceau.ovh> * Fix typo Signed-off-by: Olivier Marceau <hollysaiqs@marceau.ovh> * Simplify thing compatibility test Co-authored-by: Connor Petty <mistercpp2000@gmail.com> Signed-off-by: Olivier Marceau <hollysaiqs@marceau.ovh> * Remove dot from PTEC values Signed-off-by: Olivier Marceau <hollysaiqs@marceau.ovh> Co-authored-by: Connor Petty <mistercpp2000@gmail.com>
This commit is contained in:
parent
b675160486
commit
217f25fff6
@ -267,7 +267,7 @@
|
|||||||
/bundles/org.openhab.binding.tado/ @dfrommi
|
/bundles/org.openhab.binding.tado/ @dfrommi
|
||||||
/bundles/org.openhab.binding.tankerkoenig/ @dolic @JueBag
|
/bundles/org.openhab.binding.tankerkoenig/ @dolic @JueBag
|
||||||
/bundles/org.openhab.binding.telegram/ @ZzetT
|
/bundles/org.openhab.binding.telegram/ @ZzetT
|
||||||
/bundles/org.openhab.binding.teleinfo/ @Nokyyz
|
/bundles/org.openhab.binding.teleinfo/ @Nokyyz @olivierkeke
|
||||||
/bundles/org.openhab.binding.tellstick/ @openhab/add-ons-maintainers
|
/bundles/org.openhab.binding.tellstick/ @openhab/add-ons-maintainers
|
||||||
/bundles/org.openhab.binding.tesla/ @kgoderis
|
/bundles/org.openhab.binding.tesla/ @kgoderis
|
||||||
/bundles/org.openhab.binding.tibber/ @kjoglum
|
/bundles/org.openhab.binding.tibber/ @kjoglum
|
||||||
|
@ -24,6 +24,9 @@ import org.openhab.core.thing.ThingTypeUID;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class TeleinfoBindingConstants {
|
public class TeleinfoBindingConstants {
|
||||||
|
|
||||||
|
private TeleinfoBindingConstants() {
|
||||||
|
}
|
||||||
|
|
||||||
private static final String BINDING_ID = "teleinfo";
|
private static final String BINDING_ID = "teleinfo";
|
||||||
|
|
||||||
// List of all Thing Type UIDs
|
// List of all Thing Type UIDs
|
||||||
@ -35,7 +38,7 @@ public class TeleinfoBindingConstants {
|
|||||||
// List of HC frames channel ids
|
// List of HC frames channel ids
|
||||||
public static final String CHANNEL_HC_FRAME_HCHC = "hchc";
|
public static final String CHANNEL_HC_FRAME_HCHC = "hchc";
|
||||||
public static final String CHANNEL_HC_FRAME_HCHP = "hchp";
|
public static final String CHANNEL_HC_FRAME_HCHP = "hchp";
|
||||||
public static final String CHANNEL_HC_FRAME_HHPHC = "hhphc";
|
public static final String CHANNEL_HHPHC = "hhphc";
|
||||||
// List of BASE frames channel ids
|
// List of BASE frames channel ids
|
||||||
public static final String CHANNEL_BASE_FRAME_BASE = "base";
|
public static final String CHANNEL_BASE_FRAME_BASE = "base";
|
||||||
// List of TEMPO frames channel ids
|
// List of TEMPO frames channel ids
|
||||||
@ -46,7 +49,6 @@ public class TeleinfoBindingConstants {
|
|||||||
public static final String CHANNEL_TEMPO_FRAME_BBRHPJB = "bbrhpjb";
|
public static final String CHANNEL_TEMPO_FRAME_BBRHPJB = "bbrhpjb";
|
||||||
public static final String CHANNEL_TEMPO_FRAME_BBRHCJB = "bbrhcjb";
|
public static final String CHANNEL_TEMPO_FRAME_BBRHCJB = "bbrhcjb";
|
||||||
public static final String CHANNEL_TEMPO_FRAME_DEMAIN = "demain";
|
public static final String CHANNEL_TEMPO_FRAME_DEMAIN = "demain";
|
||||||
public static final String CHANNEL_TEMPO_FRAME_HHPHC = "hhphc";
|
|
||||||
public static final String CHANNEL_TEMPO_FRAME_PROGRAMME_CIRCUIT_1 = "programmeCircuit1";
|
public static final String CHANNEL_TEMPO_FRAME_PROGRAMME_CIRCUIT_1 = "programmeCircuit1";
|
||||||
public static final String CHANNEL_TEMPO_FRAME_PROGRAMME_CIRCUIT_2 = "programmeCircuit2";
|
public static final String CHANNEL_TEMPO_FRAME_PROGRAMME_CIRCUIT_2 = "programmeCircuit2";
|
||||||
// List of EJP frames channel ids
|
// List of EJP frames channel ids
|
||||||
@ -54,32 +56,30 @@ public class TeleinfoBindingConstants {
|
|||||||
public static final String CHANNEL_EJP_FRAME_EJPHPM = "ejphpm";
|
public static final String CHANNEL_EJP_FRAME_EJPHPM = "ejphpm";
|
||||||
public static final String CHANNEL_EJP_FRAME_EJPHN = "ejphn";
|
public static final String CHANNEL_EJP_FRAME_EJPHN = "ejphn";
|
||||||
// List of CBEMM Channel ids
|
// List of CBEMM Channel ids
|
||||||
public static final String CHANNEL_CBEMM_ISOUSC = "isousc";
|
public static final String CHANNEL_ISOUSC = "isousc";
|
||||||
public static final String CHANNEL_CBEMM_PTEC = "ptec";
|
public static final String CHANNEL_PTEC = "ptec";
|
||||||
public static final String CHANNEL_CBEMM_IMAX = "imax";
|
public static final String CHANNEL_CBEMM_IMAX = "imax";
|
||||||
public static final String CHANNEL_CBEMM_ADPS = "adps";
|
public static final String CHANNEL_CBEMM_ADPS = "adps";
|
||||||
public static final String CHANNEL_CBEMM_IINST = "iinst";
|
public static final String CHANNEL_CBEMM_IINST = "iinst";
|
||||||
public static final String CHANNEL_CBEMM_MOTDETAT = "motdetat";
|
public static final String CHANNEL_MOTDETAT = "motdetat";
|
||||||
// List of CBEMM EVOLUTION ICC Channel ids
|
// List of CBEMM EVOLUTION ICC Channel ids
|
||||||
public static final String CHANNEL_CBEMM_EVOLUTION_ICC_PAPP = "papp";
|
public static final String CHANNEL_PAPP = "papp";
|
||||||
// List of CBETM Channel ids
|
// List of CBETM Channel ids
|
||||||
public static final String CHANNEL_CBETM_IINST1 = "iinst1";
|
public static final String CHANNEL_CBETM_IINST1 = "iinst1";
|
||||||
public static final String CHANNEL_CBETM_IINST2 = "iinst2";
|
public static final String CHANNEL_CBETM_IINST2 = "iinst2";
|
||||||
public static final String CHANNEL_CBETM_IINST3 = "iinst3";
|
public static final String CHANNEL_CBETM_IINST3 = "iinst3";
|
||||||
public static final String CHANNEL_CBETM_FRAME_TYPE = "frameType";
|
public static final String CHANNEL_CBETM_FRAME_TYPE = "frameType";
|
||||||
public static final String CHANNEL_CBETM_LONG_ISOUSC = "isousc";
|
|
||||||
public static final String CHANNEL_CBETM_LONG_IMAX1 = "imax1";
|
public static final String CHANNEL_CBETM_LONG_IMAX1 = "imax1";
|
||||||
public static final String CHANNEL_CBETM_LONG_IMAX2 = "imax2";
|
public static final String CHANNEL_CBETM_LONG_IMAX2 = "imax2";
|
||||||
public static final String CHANNEL_CBETM_LONG_IMAX3 = "imax3";
|
public static final String CHANNEL_CBETM_LONG_IMAX3 = "imax3";
|
||||||
public static final String CHANNEL_CBETM_LONG_PTEC = "ptec";
|
|
||||||
public static final String CHANNEL_CBETM_LONG_PMAX = "pmax";
|
public static final String CHANNEL_CBETM_LONG_PMAX = "pmax";
|
||||||
public static final String CHANNEL_CBETM_LONG_PAPP = "papp";
|
|
||||||
public static final String CHANNEL_CBETM_LONG_MOTDETAT = "motdetat";
|
|
||||||
public static final String CHANNEL_CBETM_LONG_PPOT = "ppot";
|
public static final String CHANNEL_CBETM_LONG_PPOT = "ppot";
|
||||||
public static final String CHANNEL_CBETM_SHORT_ADIR1 = "adir1";
|
public static final String CHANNEL_CBETM_SHORT_ADIR1 = "adir1";
|
||||||
public static final String CHANNEL_CBETM_SHORT_ADIR2 = "adir2";
|
public static final String CHANNEL_CBETM_SHORT_ADIR2 = "adir2";
|
||||||
public static final String CHANNEL_CBETM_SHORT_ADIR3 = "adir3";
|
public static final String CHANNEL_CBETM_SHORT_ADIR3 = "adir3";
|
||||||
|
|
||||||
|
public static final String NOT_A_CHANNEL = "";
|
||||||
|
|
||||||
public static final String THING_ELECTRICITY_METER_PROPERTY_ADCO = "adco";
|
public static final String THING_ELECTRICITY_METER_PROPERTY_ADCO = "adco";
|
||||||
|
|
||||||
public static final ThingTypeUID THING_HC_CBEMM_ELECTRICITY_METER_TYPE_UID = new ThingTypeUID(BINDING_ID,
|
public static final ThingTypeUID THING_HC_CBEMM_ELECTRICITY_METER_TYPE_UID = new ThingTypeUID(BINDING_ID,
|
||||||
|
@ -22,22 +22,11 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
import org.openhab.binding.teleinfo.internal.data.Frame;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmBaseOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmEjpOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmHcOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmTempoOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccBaseOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccEjpOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccHcOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccTempoOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongBaseOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongEjpOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongHcOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongTempoOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameAdco;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoControllerHandlerListener;
|
import org.openhab.binding.teleinfo.internal.handler.TeleinfoControllerHandlerListener;
|
||||||
|
import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameException;
|
||||||
|
import org.openhab.binding.teleinfo.internal.reader.io.serialport.Label;
|
||||||
import org.openhab.core.config.discovery.AbstractDiscoveryService;
|
import org.openhab.core.config.discovery.AbstractDiscoveryService;
|
||||||
import org.openhab.core.config.discovery.DiscoveryResult;
|
import org.openhab.core.config.discovery.DiscoveryResult;
|
||||||
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
|
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
|
||||||
@ -85,6 +74,7 @@ public class TeleinfoDiscoveryService extends AbstractDiscoveryService
|
|||||||
return SUPPORTED_THING_TYPES;
|
return SUPPORTED_THING_TYPES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void activate() {
|
public void activate() {
|
||||||
TeleinfoAbstractControllerHandler controllerHandlerRef = controllerHandler;
|
TeleinfoAbstractControllerHandler controllerHandlerRef = controllerHandler;
|
||||||
if (controllerHandlerRef != null) {
|
if (controllerHandlerRef != null) {
|
||||||
@ -142,75 +132,56 @@ public class TeleinfoDiscoveryService extends AbstractDiscoveryService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
|
public void onFrameReceived(Frame frame) {
|
||||||
detectNewElectricityMeterFromReceivedFrame(frame);
|
detectNewElectricityMeterFromReceivedFrame(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void detectNewElectricityMeterFromReceivedFrame(final Frame frameSample) {
|
private void detectNewElectricityMeterFromReceivedFrame(final Frame frameSample) {
|
||||||
TeleinfoAbstractControllerHandler controllerHandlerRef = controllerHandler;
|
TeleinfoAbstractControllerHandler controllerHandlerRef = controllerHandler;
|
||||||
if (controllerHandlerRef != null) {
|
if (controllerHandlerRef != null) {
|
||||||
logger.debug("New eletricity meter detection from frame {}", frameSample.getId());
|
logger.debug("New eletricity meter detection from frame {}", frameSample);
|
||||||
if (!(frameSample instanceof FrameAdco)) {
|
if (frameSample.get(Label.ADCO) == null) {
|
||||||
throw new IllegalStateException("Teleinfo frame type not supported: " + frameSample.getClass());
|
throw new IllegalStateException("Missing ADCO key");
|
||||||
}
|
}
|
||||||
final FrameAdco frameAdco = (FrameAdco) frameSample;
|
|
||||||
|
|
||||||
ThingUID thingUID = new ThingUID(getThingTypeUID(frameAdco), frameAdco.getAdco(),
|
String adco = frameSample.get(Label.ADCO);
|
||||||
controllerHandlerRef.getThing().getUID().getId());
|
if (adco != null) {
|
||||||
|
ThingUID thingUID = new ThingUID(getThingTypeUID(frameSample), adco,
|
||||||
|
controllerHandlerRef.getThing().getUID().getId());
|
||||||
|
|
||||||
final Map<String, Object> properties = getThingProperties(frameAdco);
|
final Map<String, Object> properties = getThingProperties(adco);
|
||||||
final String representationProperty = THING_ELECTRICITY_METER_PROPERTY_ADCO;
|
final String representationProperty = THING_ELECTRICITY_METER_PROPERTY_ADCO;
|
||||||
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)
|
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)
|
||||||
.withLabel("Teleinfo ADCO " + frameAdco.getAdco()).withThingType(getThingTypeUID(frameAdco))
|
.withLabel("Teleinfo ADCO " + adco).withThingType(getThingTypeUID(frameSample))
|
||||||
.withBridge(controllerHandlerRef.getThing().getUID())
|
.withBridge(controllerHandlerRef.getThing().getUID())
|
||||||
.withRepresentationProperty(representationProperty).build();
|
.withRepresentationProperty(representationProperty).build();
|
||||||
|
|
||||||
thingDiscovered(discoveryResult);
|
thingDiscovered(discoveryResult);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logNullControllerHandler();
|
logNullControllerHandler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ThingTypeUID getThingTypeUID(final Frame teleinfoFrame) {
|
private ThingTypeUID getThingTypeUID(final Frame teleinfoFrame) {
|
||||||
if (teleinfoFrame instanceof FrameCbemmHcOption) {
|
ThingTypeUID thingTypeUID;
|
||||||
return THING_HC_CBEMM_ELECTRICITY_METER_TYPE_UID;
|
try {
|
||||||
} else if (teleinfoFrame instanceof FrameCbemmBaseOption) {
|
thingTypeUID = teleinfoFrame.getType().getThingTypeUid();
|
||||||
return THING_BASE_CBEMM_ELECTRICITY_METER_TYPE_UID;
|
} catch (InvalidFrameException e) {
|
||||||
} else if (teleinfoFrame instanceof FrameCbemmEjpOption) {
|
throw new IllegalStateException("Frame type can not be evaluated");
|
||||||
return THING_EJP_CBEMM_ELECTRICITY_METER_TYPE_UID;
|
}
|
||||||
} else if (teleinfoFrame instanceof FrameCbemmTempoOption) {
|
if (thingTypeUID != null) {
|
||||||
return THING_TEMPO_CBEMM_ELECTRICITY_METER_TYPE_UID;
|
return thingTypeUID;
|
||||||
} else if (teleinfoFrame instanceof FrameCbemmEvolutionIccHcOption) {
|
|
||||||
return THING_HC_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID;
|
|
||||||
} else if (teleinfoFrame instanceof FrameCbemmEvolutionIccBaseOption) {
|
|
||||||
return THING_BASE_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID;
|
|
||||||
} else if (teleinfoFrame instanceof FrameCbemmEvolutionIccEjpOption) {
|
|
||||||
return THING_EJP_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID;
|
|
||||||
} else if (teleinfoFrame instanceof FrameCbemmEvolutionIccTempoOption) {
|
|
||||||
return THING_TEMPO_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID;
|
|
||||||
} else if (teleinfoFrame instanceof FrameCbetmLongHcOption) {
|
|
||||||
return THING_HC_CBETM_ELECTRICITY_METER_TYPE_UID;
|
|
||||||
} else if (teleinfoFrame instanceof FrameCbetmLongBaseOption) {
|
|
||||||
return THING_BASE_CBETM_ELECTRICITY_METER_TYPE_UID;
|
|
||||||
} else if (teleinfoFrame instanceof FrameCbetmLongEjpOption) {
|
|
||||||
return THING_EJP_CBETM_ELECTRICITY_METER_TYPE_UID;
|
|
||||||
} else if (teleinfoFrame instanceof FrameCbetmLongTempoOption) {
|
|
||||||
return THING_TEMPO_CBETM_ELECTRICITY_METER_TYPE_UID;
|
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Teleinfo frame type not supported: " + teleinfoFrame.getClass());
|
throw new IllegalStateException("Teleinfo frame type not supported: " + teleinfoFrame.getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> getThingProperties(final Frame teleinfoFrame) {
|
private Map<String, Object> getThingProperties(String adco) {
|
||||||
Map<String, Object> properties = new HashMap<String, Object>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
if (teleinfoFrame instanceof FrameAdco) {
|
properties.put(THING_ELECTRICITY_METER_PROPERTY_ADCO, adco);
|
||||||
final FrameAdco frameAdco = (FrameAdco) teleinfoFrame;
|
|
||||||
properties.put(THING_ELECTRICITY_METER_PROPERTY_ADCO, frameAdco.getAdco());
|
|
||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
|
||||||
|
|
||||||
throw new IllegalStateException("Teleinfo frame type not supported: " + teleinfoFrame.getClass());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -10,17 +10,15 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: EPL-2.0
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
*/
|
*/
|
||||||
package org.openhab.binding.teleinfo.internal.dto.common;
|
package org.openhab.binding.teleinfo.internal.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link Hhphc} enumeration defines all HHPHC values.
|
* Define the evolution option values
|
||||||
|
*
|
||||||
|
* @author Olivier MARCEAU - Initial contribution
|
||||||
*
|
*
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
*/
|
||||||
public enum Hhphc {
|
public enum Evolution {
|
||||||
A,
|
ICC,
|
||||||
C,
|
NONE
|
||||||
D,
|
|
||||||
E,
|
|
||||||
Y
|
|
||||||
}
|
}
|
@ -0,0 +1,224 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2021 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.teleinfo.internal.data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameException;
|
||||||
|
import org.openhab.binding.teleinfo.internal.reader.io.serialport.Label;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link Frame} class defines common attributes for any Teleinfo frames.
|
||||||
|
*
|
||||||
|
* @author Nicolas SIBERIL - Initial contribution
|
||||||
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
|
public class Frame implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -1934715078822532494L;
|
||||||
|
|
||||||
|
private Map<Label, String> labelToValues = new EnumMap<>(Label.class);
|
||||||
|
|
||||||
|
public void put(Label label, String value) {
|
||||||
|
labelToValues.put(label, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable String get(Label label) {
|
||||||
|
return labelToValues.get(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable Integer getAsInt(Label label) {
|
||||||
|
String value = labelToValues.get(label);
|
||||||
|
if (value != null) {
|
||||||
|
return Integer.parseInt(value);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Frame() {
|
||||||
|
// default constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
public FrameType getType() throws InvalidFrameException {
|
||||||
|
Phase phase = getPhase();
|
||||||
|
Pricing pricing = getPricing();
|
||||||
|
Evolution evolution = getEvolution();
|
||||||
|
switch (phase) {
|
||||||
|
case ONE_PHASED:
|
||||||
|
switch (evolution) {
|
||||||
|
case ICC:
|
||||||
|
switch (pricing) {
|
||||||
|
case BASE:
|
||||||
|
return FrameType.CBEMM_ICC_BASE;
|
||||||
|
case EJP:
|
||||||
|
return FrameType.CBEMM_ICC_EJP;
|
||||||
|
case HC:
|
||||||
|
return FrameType.CBEMM_ICC_HC;
|
||||||
|
case TEMPO:
|
||||||
|
return FrameType.CBEMM_ICC_TEMPO;
|
||||||
|
default:
|
||||||
|
return FrameType.UNKNOWN;
|
||||||
|
}
|
||||||
|
case NONE:
|
||||||
|
switch (pricing) {
|
||||||
|
case BASE:
|
||||||
|
return FrameType.CBEMM_BASE;
|
||||||
|
case EJP:
|
||||||
|
return FrameType.CBEMM_EJP;
|
||||||
|
case HC:
|
||||||
|
return FrameType.CBEMM_HC;
|
||||||
|
case TEMPO:
|
||||||
|
return FrameType.CBEMM_TEMPO;
|
||||||
|
default:
|
||||||
|
return FrameType.UNKNOWN;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return FrameType.UNKNOWN;
|
||||||
|
|
||||||
|
}
|
||||||
|
case THREE_PHASED:
|
||||||
|
if (isShortFrame()) {
|
||||||
|
return FrameType.CBETM_SHORT;
|
||||||
|
} else {
|
||||||
|
switch (pricing) {
|
||||||
|
case BASE:
|
||||||
|
return FrameType.CBETM_LONG_BASE;
|
||||||
|
case EJP:
|
||||||
|
return FrameType.CBETM_LONG_EJP;
|
||||||
|
case HC:
|
||||||
|
return FrameType.CBETM_LONG_HC;
|
||||||
|
case TEMPO:
|
||||||
|
return FrameType.CBETM_LONG_TEMPO;
|
||||||
|
default:
|
||||||
|
return FrameType.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return FrameType.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Phase getPhase() throws InvalidFrameException {
|
||||||
|
if (labelToValues.containsKey(Label.IINST)) {
|
||||||
|
return Phase.ONE_PHASED;
|
||||||
|
} else if (labelToValues.containsKey(Label.IINST1)) {
|
||||||
|
return Phase.THREE_PHASED;
|
||||||
|
}
|
||||||
|
throw new InvalidFrameException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShortFrame() {
|
||||||
|
return !labelToValues.containsKey(Label.ISOUSC);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Evolution getEvolution() {
|
||||||
|
if (labelToValues.containsKey(Label.PAPP)) {
|
||||||
|
return Evolution.ICC;
|
||||||
|
}
|
||||||
|
return Evolution.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pricing getPricing() throws InvalidFrameException {
|
||||||
|
String optarif = labelToValues.get(Label.OPTARIF);
|
||||||
|
if (optarif == null) {
|
||||||
|
throw new InvalidFrameException();
|
||||||
|
}
|
||||||
|
switch (optarif) {
|
||||||
|
case "BASE":
|
||||||
|
return Pricing.BASE;
|
||||||
|
case "EJP.":
|
||||||
|
return Pricing.EJP;
|
||||||
|
case "HC..":
|
||||||
|
return Pricing.HC;
|
||||||
|
default:
|
||||||
|
if (optarif.matches("BBR.")) {
|
||||||
|
return Pricing.TEMPO;
|
||||||
|
}
|
||||||
|
throw new InvalidFrameException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
labelToValues.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Label, String> getLabelToValues() {
|
||||||
|
return labelToValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
private char getProgrammeChar() {
|
||||||
|
String optarif = labelToValues.get(Label.OPTARIF);
|
||||||
|
if (optarif == null) {
|
||||||
|
throw new IllegalStateException("No OPTARIF field in frame");
|
||||||
|
}
|
||||||
|
return optarif.charAt(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProgrammeCircuit1() {
|
||||||
|
char program = getProgrammeChar();
|
||||||
|
return convertProgrammeCircuit1(program);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProgrammeCircuit2() {
|
||||||
|
char program = getProgrammeChar();
|
||||||
|
return convertProgrammeCircuit2(program);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String convertProgrammeCircuit1(char value) {
|
||||||
|
String prgCircuit1 = computeProgrammeCircuitBinaryValue(value).substring(3, 5);
|
||||||
|
switch (prgCircuit1) {
|
||||||
|
case "01":
|
||||||
|
return "A";
|
||||||
|
case "10":
|
||||||
|
return "B";
|
||||||
|
case "11":
|
||||||
|
return "C";
|
||||||
|
default:
|
||||||
|
final String error = String.format("Programme circuit 1 '%s' is unknown", prgCircuit1);
|
||||||
|
throw new IllegalStateException(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String convertProgrammeCircuit2(char value) {
|
||||||
|
String prgCircuit2 = computeProgrammeCircuitBinaryValue(value).substring(5, 8);
|
||||||
|
switch (prgCircuit2) {
|
||||||
|
case "000":
|
||||||
|
return "P0";
|
||||||
|
case "001":
|
||||||
|
return "P1";
|
||||||
|
case "010":
|
||||||
|
return "P2";
|
||||||
|
case "011":
|
||||||
|
return "P3";
|
||||||
|
case "100":
|
||||||
|
return "P4";
|
||||||
|
case "101":
|
||||||
|
return "P5";
|
||||||
|
case "110":
|
||||||
|
return "P6";
|
||||||
|
case "111":
|
||||||
|
return "P7";
|
||||||
|
default:
|
||||||
|
final String error = String.format("Programme circuit 2 '%s' is unknown", prgCircuit2);
|
||||||
|
throw new IllegalStateException(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String computeProgrammeCircuitBinaryValue(char value) {
|
||||||
|
return String.format("%8s", Integer.toBinaryString(value)).replace(' ', '0');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2021 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.teleinfo.internal.data;
|
||||||
|
|
||||||
|
import static org.openhab.binding.teleinfo.internal.TeleinfoBindingConstants.*;
|
||||||
|
|
||||||
|
import org.openhab.core.thing.ThingTypeUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define all the frame type values
|
||||||
|
*
|
||||||
|
* @author Olivier MARCEAU - Initial contribution
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum FrameType {
|
||||||
|
CBETM_SHORT(null),
|
||||||
|
CBETM_LONG_BASE(THING_BASE_CBETM_ELECTRICITY_METER_TYPE_UID),
|
||||||
|
CBETM_LONG_EJP(THING_EJP_CBETM_ELECTRICITY_METER_TYPE_UID),
|
||||||
|
CBETM_LONG_HC(THING_HC_CBETM_ELECTRICITY_METER_TYPE_UID),
|
||||||
|
CBETM_LONG_TEMPO(THING_TEMPO_CBETM_ELECTRICITY_METER_TYPE_UID),
|
||||||
|
CBEMM_BASE(THING_BASE_CBEMM_ELECTRICITY_METER_TYPE_UID),
|
||||||
|
CBEMM_EJP(THING_EJP_CBEMM_ELECTRICITY_METER_TYPE_UID),
|
||||||
|
CBEMM_HC(THING_HC_CBEMM_ELECTRICITY_METER_TYPE_UID),
|
||||||
|
CBEMM_TEMPO(THING_TEMPO_CBEMM_ELECTRICITY_METER_TYPE_UID),
|
||||||
|
CBEMM_ICC_BASE(THING_BASE_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID),
|
||||||
|
CBEMM_ICC_EJP(THING_EJP_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID),
|
||||||
|
CBEMM_ICC_TEMPO(THING_TEMPO_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID),
|
||||||
|
CBEMM_ICC_HC(THING_HC_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID),
|
||||||
|
UNKNOWN(null);
|
||||||
|
|
||||||
|
private ThingTypeUID thingTypeUid;
|
||||||
|
|
||||||
|
FrameType(ThingTypeUID thingTypeUid) {
|
||||||
|
this.thingTypeUid = thingTypeUid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ThingTypeUID getThingTypeUid() {
|
||||||
|
return thingTypeUid;
|
||||||
|
}
|
||||||
|
}
|
@ -10,16 +10,15 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: EPL-2.0
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
*/
|
*/
|
||||||
package org.openhab.binding.teleinfo.internal.dto.common;
|
package org.openhab.binding.teleinfo.internal.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link FrameBaseOption} interface defines common attributes for Base option.
|
* Define all the phase values
|
||||||
|
*
|
||||||
|
* @author Olivier MARCEAU - Initial contribution
|
||||||
*
|
*
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
*/
|
||||||
public interface FrameBaseOption {
|
public enum Phase {
|
||||||
|
ONE_PHASED,
|
||||||
int getBase();
|
THREE_PHASED
|
||||||
|
|
||||||
void setBase(int base);
|
|
||||||
}
|
}
|
@ -10,23 +10,17 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: EPL-2.0
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
*/
|
*/
|
||||||
package org.openhab.binding.teleinfo.internal.dto.common;
|
package org.openhab.binding.teleinfo.internal.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link Ptec} enumeration defines all PTEC values.
|
* Define all the pricing option values
|
||||||
|
*
|
||||||
|
* @author Olivier MARCEAU - Initial contribution
|
||||||
*
|
*
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
*/
|
||||||
public enum Ptec {
|
public enum Pricing {
|
||||||
TH,
|
BASE,
|
||||||
|
TEMPO,
|
||||||
HC,
|
HC,
|
||||||
HP,
|
EJP
|
||||||
HN,
|
|
||||||
PM,
|
|
||||||
HCJB,
|
|
||||||
HCJW,
|
|
||||||
HCJR,
|
|
||||||
HPJB,
|
|
||||||
HPJW,
|
|
||||||
HPJR
|
|
||||||
}
|
}
|
@ -1,50 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link Frame} class defines common attributes for any Teleinfo frames.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public abstract class Frame implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -1934715078822532494L;
|
|
||||||
|
|
||||||
private UUID id;
|
|
||||||
private LocalDate timestamp; // UTC timestamp
|
|
||||||
|
|
||||||
public Frame() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalDate getTimestamp() {
|
|
||||||
return timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimestamp(LocalDate timestamp) {
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbemm;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameAdco;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Ptec;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbemm} class defines common attributes for CBEMM Teleinfo frames.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public abstract class FrameCbemm extends FrameAdco {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -8500010131430582841L;
|
|
||||||
|
|
||||||
private int isousc;
|
|
||||||
private int iinst; // ampères
|
|
||||||
private Integer adps; // ampères
|
|
||||||
private Integer imax; // ampères
|
|
||||||
private Ptec ptec;
|
|
||||||
private String motdetat;
|
|
||||||
|
|
||||||
public FrameCbemm() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIsousc() {
|
|
||||||
return isousc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsousc(int isousc) {
|
|
||||||
this.isousc = isousc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIinst() {
|
|
||||||
return iinst;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIinst(int iinst) {
|
|
||||||
this.iinst = iinst;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getAdps() {
|
|
||||||
return adps;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdps(Integer adps) {
|
|
||||||
this.adps = adps;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getImax() {
|
|
||||||
return imax;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setImax(Integer imax) {
|
|
||||||
this.imax = imax;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Ptec getPtec() {
|
|
||||||
return ptec;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPtec(Ptec ptec) {
|
|
||||||
this.ptec = ptec;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMotdetat() {
|
|
||||||
return motdetat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMotdetat(String motdetat) {
|
|
||||||
this.motdetat = motdetat;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbemm;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameBaseOption;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbemmBaseOption} class defines a CBEMM Teleinfo frame with Base option.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public class FrameCbemmBaseOption extends FrameCbemm implements FrameBaseOption {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 5560141193379363335L;
|
|
||||||
|
|
||||||
private int base;
|
|
||||||
|
|
||||||
public FrameCbemmBaseOption() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBase() {
|
|
||||||
return base;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBase(int base) {
|
|
||||||
this.base = base;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbemm;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameEjpOption;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbemmEjpOption} class defines a CBEMM Teleinfo frame with EJP option.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public class FrameCbemmEjpOption extends FrameCbemm implements FrameEjpOption {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -1934715078822532494L;
|
|
||||||
|
|
||||||
private int ejphpm;
|
|
||||||
private int ejphn;
|
|
||||||
private Integer pejp;
|
|
||||||
|
|
||||||
public FrameCbemmEjpOption() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getEjphpm() {
|
|
||||||
return ejphpm;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getEjphn() {
|
|
||||||
return ejphn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getPejp() {
|
|
||||||
return pejp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEjphpm(int ejphpm) {
|
|
||||||
this.ejphpm = ejphpm;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEjphn(int ejphn) {
|
|
||||||
this.ejphn = ejphn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPejp(Integer pejp) {
|
|
||||||
this.pejp = pejp;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbemm;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameHcOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbemmHcOption} class defines a CBEMM Teleinfo frame with HC/HP option.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public class FrameCbemmHcOption extends FrameCbemm implements FrameHcOption {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -1934715078822532494L;
|
|
||||||
|
|
||||||
private int hchc;
|
|
||||||
private int hchp;
|
|
||||||
private Hhphc hhphc;
|
|
||||||
|
|
||||||
public FrameCbemmHcOption() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHchc() {
|
|
||||||
return hchc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHchc(int hchc) {
|
|
||||||
this.hchc = hchc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHchp() {
|
|
||||||
return hchp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHchp(int hchp) {
|
|
||||||
this.hchp = hchp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Hhphc getHhphc() {
|
|
||||||
return hhphc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHhphc(Hhphc hhphc) {
|
|
||||||
this.hhphc = hhphc;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,141 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbemm;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbemmTempoOption} class defines a CBEMM Teleinfo frame with Tempo option.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public class FrameCbemmTempoOption extends FrameCbemm implements FrameTempoOption {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 6423861816467362730L;
|
|
||||||
|
|
||||||
private int bbrhpjr;
|
|
||||||
private int bbrhcjr;
|
|
||||||
private int bbrhpjw;
|
|
||||||
private int bbrhcjw;
|
|
||||||
private int bbrhpjb;
|
|
||||||
private int bbrhcjb;
|
|
||||||
private CouleurDemain demain;
|
|
||||||
private Hhphc hhphc;
|
|
||||||
private ProgrammeCircuit1 programmeCircuit1;
|
|
||||||
private ProgrammeCircuit2 programmeCircuit2;
|
|
||||||
|
|
||||||
public FrameCbemmTempoOption() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhpjr() {
|
|
||||||
return bbrhpjr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhcjr() {
|
|
||||||
return bbrhcjr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhpjw() {
|
|
||||||
return bbrhpjw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhcjw() {
|
|
||||||
return bbrhcjw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhpjb() {
|
|
||||||
return bbrhpjb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhcjb() {
|
|
||||||
return bbrhcjb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CouleurDemain getDemain() {
|
|
||||||
return demain;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhpjr(int bbrhpjr) {
|
|
||||||
this.bbrhpjr = bbrhpjr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhcjr(int bbrhcjr) {
|
|
||||||
this.bbrhcjr = bbrhcjr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhpjw(int bbrhpjw) {
|
|
||||||
this.bbrhpjw = bbrhpjw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhcjw(int bbrhcjw) {
|
|
||||||
this.bbrhcjw = bbrhcjw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhpjb(int bbrhpjb) {
|
|
||||||
this.bbrhpjb = bbrhpjb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhcjb(int bbrhcjb) {
|
|
||||||
this.bbrhcjb = bbrhcjb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDemain(CouleurDemain demain) {
|
|
||||||
this.demain = demain;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Hhphc getHhphc() {
|
|
||||||
return hhphc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHhphc(Hhphc hhphc) {
|
|
||||||
this.hhphc = hhphc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProgrammeCircuit1 getProgrammeCircuit1() {
|
|
||||||
return programmeCircuit1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setProgrammeCircuit1(ProgrammeCircuit1 programmeCircuit1) {
|
|
||||||
this.programmeCircuit1 = programmeCircuit1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProgrammeCircuit2 getProgrammeCircuit2() {
|
|
||||||
return programmeCircuit2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setProgrammeCircuit2(ProgrammeCircuit2 programmeCircuit2) {
|
|
||||||
this.programmeCircuit2 = programmeCircuit2;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbemm.evoicc;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbemmEvolutionIcc} class defines CBEMM Evolution ICC Teleinfo frames.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public abstract class FrameCbemmEvolutionIcc extends FrameCbemm {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 5532008316299149750L;
|
|
||||||
|
|
||||||
private int papp; // Volt.ampères
|
|
||||||
|
|
||||||
public FrameCbemmEvolutionIcc() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPapp() {
|
|
||||||
return papp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPapp(int papp) {
|
|
||||||
this.papp = papp;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbemm.evoicc;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameBaseOption;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbemmEvolutionIccBaseOption} class defines a CBEMM Evolution ICC Teleinfo frame with Base option.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public class FrameCbemmEvolutionIccBaseOption extends FrameCbemmEvolutionIcc implements FrameBaseOption {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1623781914779495089L;
|
|
||||||
|
|
||||||
private int base;
|
|
||||||
|
|
||||||
public FrameCbemmEvolutionIccBaseOption() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBase() {
|
|
||||||
return base;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBase(int base) {
|
|
||||||
this.base = base;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbemm.evoicc;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameEjpOption;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbemmEvolutionIccEjpOption} class defines a CBEMM Evolution ICC Teleinfo frame with EJP option.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public class FrameCbemmEvolutionIccEjpOption extends FrameCbemmEvolutionIcc implements FrameEjpOption {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -5053572570767309239L;
|
|
||||||
|
|
||||||
private int ejphpm;
|
|
||||||
private int ejphn;
|
|
||||||
private Integer pejp;
|
|
||||||
|
|
||||||
public FrameCbemmEvolutionIccEjpOption() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getEjphpm() {
|
|
||||||
return ejphpm;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getEjphn() {
|
|
||||||
return ejphn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getPejp() {
|
|
||||||
return pejp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEjphpm(int ejphpm) {
|
|
||||||
this.ejphpm = ejphpm;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEjphn(int ejphn) {
|
|
||||||
this.ejphn = ejphn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPejp(Integer pejp) {
|
|
||||||
this.pejp = pejp;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbemm.evoicc;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameHcOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbemmEvolutionIccHcOption} class defines a CBEMM Evolution ICC Teleinfo frame with HC option.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public class FrameCbemmEvolutionIccHcOption extends FrameCbemmEvolutionIcc implements FrameHcOption {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 3133144820515675037L;
|
|
||||||
|
|
||||||
private int hchc;
|
|
||||||
private int hchp;
|
|
||||||
private Hhphc hhphc;
|
|
||||||
|
|
||||||
public FrameCbemmEvolutionIccHcOption() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHchc() {
|
|
||||||
return hchc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHchc(int hchc) {
|
|
||||||
this.hchc = hchc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHchp() {
|
|
||||||
return hchp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHchp(int hchp) {
|
|
||||||
this.hchp = hchp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Hhphc getHhphc() {
|
|
||||||
return hhphc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHhphc(Hhphc hhphc) {
|
|
||||||
this.hhphc = hhphc;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,141 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbemm.evoicc;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbemmEvolutionIccTempoOption} class defines a CBEMM Evolution ICC Teleinfo frame with Tempo option.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public class FrameCbemmEvolutionIccTempoOption extends FrameCbemmEvolutionIcc implements FrameTempoOption {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -1606685089266015480L;
|
|
||||||
|
|
||||||
private int bbrhpjr;
|
|
||||||
private int bbrhcjr;
|
|
||||||
private int bbrhpjw;
|
|
||||||
private int bbrhcjw;
|
|
||||||
private int bbrhpjb;
|
|
||||||
private int bbrhcjb;
|
|
||||||
private CouleurDemain demain;
|
|
||||||
private Hhphc hhphc;
|
|
||||||
private ProgrammeCircuit1 programmeCircuit1;
|
|
||||||
private ProgrammeCircuit2 programmeCircuit2;
|
|
||||||
|
|
||||||
public FrameCbemmEvolutionIccTempoOption() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhpjr() {
|
|
||||||
return bbrhpjr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhcjr() {
|
|
||||||
return bbrhcjr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhpjw() {
|
|
||||||
return bbrhpjw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhcjw() {
|
|
||||||
return bbrhcjw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhpjb() {
|
|
||||||
return bbrhpjb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhcjb() {
|
|
||||||
return bbrhcjb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CouleurDemain getDemain() {
|
|
||||||
return demain;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhpjr(int bbrhpjr) {
|
|
||||||
this.bbrhpjr = bbrhpjr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhcjr(int bbrhcjr) {
|
|
||||||
this.bbrhcjr = bbrhcjr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhpjw(int bbrhpjw) {
|
|
||||||
this.bbrhpjw = bbrhpjw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhcjw(int bbrhcjw) {
|
|
||||||
this.bbrhcjw = bbrhcjw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhpjb(int bbrhpjb) {
|
|
||||||
this.bbrhpjb = bbrhpjb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhcjb(int bbrhcjb) {
|
|
||||||
this.bbrhcjb = bbrhcjb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDemain(CouleurDemain demain) {
|
|
||||||
this.demain = demain;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Hhphc getHhphc() {
|
|
||||||
return hhphc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHhphc(Hhphc hhphc) {
|
|
||||||
this.hhphc = hhphc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProgrammeCircuit1 getProgrammeCircuit1() {
|
|
||||||
return programmeCircuit1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setProgrammeCircuit1(ProgrammeCircuit1 programmeCircuit1) {
|
|
||||||
this.programmeCircuit1 = programmeCircuit1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProgrammeCircuit2 getProgrammeCircuit2() {
|
|
||||||
return programmeCircuit2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setProgrammeCircuit2(ProgrammeCircuit2 programmeCircuit2) {
|
|
||||||
this.programmeCircuit2 = programmeCircuit2;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbetm;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameAdco;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbetm} class defines common attributes for CBETM Teleinfo frames.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public abstract class FrameCbetm extends FrameAdco {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 2083723009359732507L;
|
|
||||||
|
|
||||||
private int iinst1; // ampères
|
|
||||||
private int iinst2; // ampères
|
|
||||||
private int iinst3; // ampères
|
|
||||||
|
|
||||||
public FrameCbetm() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIinst1() {
|
|
||||||
return iinst1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIinst1(int iinst1) {
|
|
||||||
this.iinst1 = iinst1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIinst2() {
|
|
||||||
return iinst2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIinst2(int iinst2) {
|
|
||||||
this.iinst2 = iinst2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIinst3() {
|
|
||||||
return iinst3;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIinst3(int iinst3) {
|
|
||||||
this.iinst3 = iinst3;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,111 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbetm;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Ptec;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbetmLong} class defines common attributes for CBETM Long Teleinfo frames.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public abstract class FrameCbetmLong extends FrameCbetm {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -2527584397688316017L;
|
|
||||||
|
|
||||||
private int isousc;
|
|
||||||
private Integer imax1; // ampères
|
|
||||||
private Integer imax2; // ampères
|
|
||||||
private Integer imax3; // ampères
|
|
||||||
private Ptec ptec;
|
|
||||||
private int pmax; // W
|
|
||||||
private int papp; // Volt.ampères
|
|
||||||
private String motdetat;
|
|
||||||
private String ppot;
|
|
||||||
|
|
||||||
public FrameCbetmLong() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIsousc() {
|
|
||||||
return isousc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsousc(int isousc) {
|
|
||||||
this.isousc = isousc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getImax1() {
|
|
||||||
return imax1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setImax1(Integer imax1) {
|
|
||||||
this.imax1 = imax1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getImax2() {
|
|
||||||
return imax2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setImax2(Integer imax2) {
|
|
||||||
this.imax2 = imax2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getImax3() {
|
|
||||||
return imax3;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setImax3(Integer imax3) {
|
|
||||||
this.imax3 = imax3;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Ptec getPtec() {
|
|
||||||
return ptec;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPtec(Ptec ptec) {
|
|
||||||
this.ptec = ptec;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPmax() {
|
|
||||||
return pmax;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPmax(int pmax) {
|
|
||||||
this.pmax = pmax;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPapp() {
|
|
||||||
return papp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPapp(int papp) {
|
|
||||||
this.papp = papp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMotdetat() {
|
|
||||||
return motdetat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMotdetat(String motdetat) {
|
|
||||||
this.motdetat = motdetat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPpot() {
|
|
||||||
return ppot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPpot(String ppot) {
|
|
||||||
this.ppot = ppot;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbetm;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameBaseOption;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbetmLongBaseOption} class defines a CBETM Teleinfo frame with Base option.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public class FrameCbetmLongBaseOption extends FrameCbetmLong implements FrameBaseOption {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 7248276012515193856L;
|
|
||||||
|
|
||||||
private int base;
|
|
||||||
|
|
||||||
public FrameCbetmLongBaseOption() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBase() {
|
|
||||||
return base;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBase(int base) {
|
|
||||||
this.base = base;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbetm;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameEjpOption;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbetmLongEjpOption} class defines a CBETM Teleinfo frame with EJP option.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public class FrameCbetmLongEjpOption extends FrameCbetmLong implements FrameEjpOption {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1104569000621483323L;
|
|
||||||
|
|
||||||
private int ejphpm;
|
|
||||||
private int ejphn;
|
|
||||||
private Integer pejp;
|
|
||||||
|
|
||||||
public FrameCbetmLongEjpOption() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getEjphpm() {
|
|
||||||
return ejphpm;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getEjphn() {
|
|
||||||
return ejphn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getPejp() {
|
|
||||||
return pejp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEjphpm(int ejphpm) {
|
|
||||||
this.ejphpm = ejphpm;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEjphn(int ejphn) {
|
|
||||||
this.ejphn = ejphn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPejp(Integer pejp) {
|
|
||||||
this.pejp = pejp;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbetm;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameHcOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbetmLongHcOption} class defines a CBETM Teleinfo frame with HC/HP option.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public class FrameCbetmLongHcOption extends FrameCbetmLong implements FrameHcOption {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -590729310348196198L;
|
|
||||||
|
|
||||||
private int hchc;
|
|
||||||
private int hchp;
|
|
||||||
private Hhphc hhphc;
|
|
||||||
|
|
||||||
public FrameCbetmLongHcOption() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHchc() {
|
|
||||||
return hchc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHchc(int hchc) {
|
|
||||||
this.hchc = hchc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHchp() {
|
|
||||||
return hchp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHchp(int hchp) {
|
|
||||||
this.hchp = hchp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Hhphc getHhphc() {
|
|
||||||
return hhphc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHhphc(Hhphc hhphc) {
|
|
||||||
this.hhphc = hhphc;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,141 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbetm;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbetmLongTempoOption} class defines a CBETM Teleinfo frame with Tempo option.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public class FrameCbetmLongTempoOption extends FrameCbetmLong implements FrameTempoOption {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 333018110121838463L;
|
|
||||||
|
|
||||||
private int bbrhpjr;
|
|
||||||
private int bbrhcjr;
|
|
||||||
private int bbrhpjw;
|
|
||||||
private int bbrhcjw;
|
|
||||||
private int bbrhpjb;
|
|
||||||
private int bbrhcjb;
|
|
||||||
private CouleurDemain demain;
|
|
||||||
private Hhphc hhphc;
|
|
||||||
private ProgrammeCircuit1 programmeCircuit1;
|
|
||||||
private ProgrammeCircuit2 programmeCircuit2;
|
|
||||||
|
|
||||||
public FrameCbetmLongTempoOption() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhpjr() {
|
|
||||||
return bbrhpjr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhcjr() {
|
|
||||||
return bbrhcjr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhpjw() {
|
|
||||||
return bbrhpjw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhcjw() {
|
|
||||||
return bbrhcjw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhpjb() {
|
|
||||||
return bbrhpjb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBbrhcjb() {
|
|
||||||
return bbrhcjb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CouleurDemain getDemain() {
|
|
||||||
return demain;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhpjr(int bbrhpjr) {
|
|
||||||
this.bbrhpjr = bbrhpjr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhcjr(int bbrhcjr) {
|
|
||||||
this.bbrhcjr = bbrhcjr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhpjw(int bbrhpjw) {
|
|
||||||
this.bbrhpjw = bbrhpjw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhcjw(int bbrhcjw) {
|
|
||||||
this.bbrhcjw = bbrhcjw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhpjb(int bbrhpjb) {
|
|
||||||
this.bbrhpjb = bbrhpjb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBbrhcjb(int bbrhcjb) {
|
|
||||||
this.bbrhcjb = bbrhcjb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDemain(CouleurDemain demain) {
|
|
||||||
this.demain = demain;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Hhphc getHhphc() {
|
|
||||||
return hhphc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHhphc(Hhphc hhphc) {
|
|
||||||
this.hhphc = hhphc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProgrammeCircuit1 getProgrammeCircuit1() {
|
|
||||||
return programmeCircuit1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setProgrammeCircuit1(ProgrammeCircuit1 programmeCircuit1) {
|
|
||||||
this.programmeCircuit1 = programmeCircuit1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProgrammeCircuit2 getProgrammeCircuit2() {
|
|
||||||
return programmeCircuit2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setProgrammeCircuit2(ProgrammeCircuit2 programmeCircuit2) {
|
|
||||||
this.programmeCircuit2 = programmeCircuit2;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.cbetm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameCbetmShort} class defines a CBETM Short Teleinfo frames.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public class FrameCbetmShort extends FrameCbetm {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 4269743289079544119L;
|
|
||||||
|
|
||||||
private Integer adir1; // ampères
|
|
||||||
private Integer adir2; // ampères
|
|
||||||
private Integer adir3; // ampères
|
|
||||||
|
|
||||||
public FrameCbetmShort() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getAdir1() {
|
|
||||||
return adir1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdir1(Integer adir1) {
|
|
||||||
this.adir1 = adir1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getAdir2() {
|
|
||||||
return adir2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdir2(Integer adir2) {
|
|
||||||
this.adir2 = adir2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getAdir3() {
|
|
||||||
return adir3;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdir3(Integer adir3) {
|
|
||||||
this.adir3 = adir3;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.common;
|
|
||||||
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameAdco} class defines common attributes for CBEMM and CBETM Teleinfo frames.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public abstract class FrameAdco extends Frame {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1384731471611580773L;
|
|
||||||
|
|
||||||
private String adco;
|
|
||||||
|
|
||||||
public FrameAdco() {
|
|
||||||
// default constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAdco() {
|
|
||||||
return adco;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdco(String adco) {
|
|
||||||
this.adco = adco;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.common;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameEjpOption} interface defines common attributes for EJP option.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public interface FrameEjpOption {
|
|
||||||
|
|
||||||
int getEjphpm();
|
|
||||||
|
|
||||||
void setEjphpm(int ejphpm);
|
|
||||||
|
|
||||||
int getEjphn();
|
|
||||||
|
|
||||||
void setEjphn(int ejphn);
|
|
||||||
|
|
||||||
Integer getPejp();
|
|
||||||
|
|
||||||
void setPejp(Integer pejp);
|
|
||||||
}
|
|
@ -1,84 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.dto.common;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FrameTempoOption} interface defines common attributes for Tempo option.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
public interface FrameTempoOption {
|
|
||||||
|
|
||||||
public static enum CouleurDemain {
|
|
||||||
Bleu,
|
|
||||||
Blanc,
|
|
||||||
Rouge
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum ProgrammeCircuit1 {
|
|
||||||
A,
|
|
||||||
B,
|
|
||||||
C
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum ProgrammeCircuit2 {
|
|
||||||
P0,
|
|
||||||
P1,
|
|
||||||
P2,
|
|
||||||
P3,
|
|
||||||
P4,
|
|
||||||
P5,
|
|
||||||
P6,
|
|
||||||
P7
|
|
||||||
}
|
|
||||||
|
|
||||||
int getBbrhpjr();
|
|
||||||
|
|
||||||
void setBbrhpjr(int bbrhpjr);
|
|
||||||
|
|
||||||
int getBbrhcjr();
|
|
||||||
|
|
||||||
void setBbrhcjr(int bbrhcjr);
|
|
||||||
|
|
||||||
int getBbrhpjw();
|
|
||||||
|
|
||||||
void setBbrhpjw(int bbrhpjw);
|
|
||||||
|
|
||||||
int getBbrhcjw();
|
|
||||||
|
|
||||||
void setBbrhcjw(int bbrhcjw);
|
|
||||||
|
|
||||||
int getBbrhpjb();
|
|
||||||
|
|
||||||
void setBbrhpjb(int bbrhpjb);
|
|
||||||
|
|
||||||
int getBbrhcjb();
|
|
||||||
|
|
||||||
void setBbrhcjb(int bbrhcjb);
|
|
||||||
|
|
||||||
CouleurDemain getDemain();
|
|
||||||
|
|
||||||
void setDemain(CouleurDemain couleurDemain);
|
|
||||||
|
|
||||||
Hhphc getHhphc();
|
|
||||||
|
|
||||||
void setHhphc(Hhphc hhphc);
|
|
||||||
|
|
||||||
ProgrammeCircuit1 getProgrammeCircuit1();
|
|
||||||
|
|
||||||
void setProgrammeCircuit1(ProgrammeCircuit1 programmeCircuit1);
|
|
||||||
|
|
||||||
ProgrammeCircuit2 getProgrammeCircuit2();
|
|
||||||
|
|
||||||
void setProgrammeCircuit2(ProgrammeCircuit2 programmeCircuit2);
|
|
||||||
}
|
|
@ -19,7 +19,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.binding.teleinfo.internal.TeleinfoDiscoveryService;
|
import org.openhab.binding.teleinfo.internal.TeleinfoDiscoveryService;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
import org.openhab.binding.teleinfo.internal.data.Frame;
|
||||||
import org.openhab.core.thing.Bridge;
|
import org.openhab.core.thing.Bridge;
|
||||||
import org.openhab.core.thing.binding.BaseBridgeHandler;
|
import org.openhab.core.thing.binding.BaseBridgeHandler;
|
||||||
import org.openhab.core.thing.binding.ThingHandlerService;
|
import org.openhab.core.thing.binding.ThingHandlerService;
|
||||||
@ -34,7 +34,7 @@ public abstract class TeleinfoAbstractControllerHandler extends BaseBridgeHandle
|
|||||||
|
|
||||||
private Set<TeleinfoControllerHandlerListener> listeners = new CopyOnWriteArraySet<>();
|
private Set<TeleinfoControllerHandlerListener> listeners = new CopyOnWriteArraySet<>();
|
||||||
|
|
||||||
public TeleinfoAbstractControllerHandler(Bridge bridge) {
|
protected TeleinfoAbstractControllerHandler(Bridge bridge) {
|
||||||
super(bridge);
|
super(bridge);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ public abstract class TeleinfoAbstractControllerHandler extends BaseBridgeHandle
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void fireOnFrameReceivedEvent(final Frame frame) {
|
protected void fireOnFrameReceivedEvent(final Frame frame) {
|
||||||
listeners.forEach(l -> l.onFrameReceived(this, frame));
|
listeners.forEach(l -> l.onFrameReceived(frame));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
package org.openhab.binding.teleinfo.internal.handler;
|
package org.openhab.binding.teleinfo.internal.handler;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
import org.openhab.binding.teleinfo.internal.data.Frame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link TeleinfoControllerHandlerListener} interface defines all events pushed by a
|
* The {@link TeleinfoControllerHandlerListener} interface defines all events pushed by a
|
||||||
@ -24,5 +24,5 @@ import org.openhab.binding.teleinfo.internal.dto.Frame;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public interface TeleinfoControllerHandlerListener {
|
public interface TeleinfoControllerHandlerListener {
|
||||||
|
|
||||||
void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, final Frame frame);
|
void onFrameReceived(final Frame frame);
|
||||||
}
|
}
|
||||||
|
@ -14,15 +14,19 @@ package org.openhab.binding.teleinfo.internal.handler;
|
|||||||
|
|
||||||
import static org.openhab.binding.teleinfo.internal.TeleinfoBindingConstants.*;
|
import static org.openhab.binding.teleinfo.internal.TeleinfoBindingConstants.*;
|
||||||
|
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameBaseOption;
|
import org.openhab.binding.teleinfo.internal.data.Frame;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameEjpOption;
|
import org.openhab.binding.teleinfo.internal.data.Phase;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameHcOption;
|
import org.openhab.binding.teleinfo.internal.data.Pricing;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption;
|
import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameException;
|
||||||
|
import org.openhab.binding.teleinfo.internal.reader.io.serialport.Label;
|
||||||
|
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ValueType;
|
||||||
|
import org.openhab.core.library.types.DateTimeType;
|
||||||
import org.openhab.core.library.types.QuantityType;
|
import org.openhab.core.library.types.QuantityType;
|
||||||
import org.openhab.core.library.types.StringType;
|
import org.openhab.core.library.types.StringType;
|
||||||
import org.openhab.core.library.unit.Units;
|
|
||||||
import org.openhab.core.thing.Bridge;
|
import org.openhab.core.thing.Bridge;
|
||||||
import org.openhab.core.thing.Channel;
|
import org.openhab.core.thing.Channel;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
@ -37,17 +41,18 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link TeleinfoAbstractElectricityMeterHandler} class defines a skeleton for Electricity Meters handlers.
|
* The {@link TeleinfoElectricityMeterHandler} class defines a skeleton for Electricity Meters handlers.
|
||||||
*
|
*
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
* @author Nicolas SIBERIL - Initial contribution
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public abstract class TeleinfoAbstractElectricityMeterHandler extends BaseThingHandler
|
public class TeleinfoElectricityMeterHandler extends BaseThingHandler implements TeleinfoControllerHandlerListener {
|
||||||
implements TeleinfoControllerHandlerListener {
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(TeleinfoAbstractElectricityMeterHandler.class);
|
|
||||||
protected TeleinfoElectricityMeterConfiguration configuration = new TeleinfoElectricityMeterConfiguration();
|
|
||||||
|
|
||||||
public TeleinfoAbstractElectricityMeterHandler(Thing thing) {
|
private final Logger logger = LoggerFactory.getLogger(TeleinfoElectricityMeterHandler.class);
|
||||||
|
protected TeleinfoElectricityMeterConfiguration configuration = new TeleinfoElectricityMeterConfiguration();
|
||||||
|
private boolean wasLastFrameShort = false;
|
||||||
|
|
||||||
|
public TeleinfoElectricityMeterHandler(Thing thing) {
|
||||||
super(thing);
|
super(thing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,47 +104,6 @@ public abstract class TeleinfoAbstractElectricityMeterHandler extends BaseThingH
|
|||||||
// no commands supported
|
// no commands supported
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateStatesForBaseFrameOption(FrameBaseOption frameBaseOption) {
|
|
||||||
updateState(CHANNEL_BASE_FRAME_BASE, QuantityType.valueOf(frameBaseOption.getBase(), Units.WATT_HOUR));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateStatesForHcFrameOption(FrameHcOption frameHcOption) {
|
|
||||||
updateState(CHANNEL_HC_FRAME_HCHC, QuantityType.valueOf(frameHcOption.getHchc(), Units.WATT_HOUR));
|
|
||||||
updateState(CHANNEL_HC_FRAME_HCHP, QuantityType.valueOf(frameHcOption.getHchp(), Units.WATT_HOUR));
|
|
||||||
updateState(CHANNEL_HC_FRAME_HHPHC, new StringType(frameHcOption.getHhphc().name()));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateStatesForTempoFrameOption(FrameTempoOption frameTempoOption) {
|
|
||||||
updateState(CHANNEL_TEMPO_FRAME_BBRHPJR, QuantityType.valueOf(frameTempoOption.getBbrhpjr(), Units.WATT_HOUR));
|
|
||||||
updateState(CHANNEL_TEMPO_FRAME_BBRHCJR, QuantityType.valueOf(frameTempoOption.getBbrhcjr(), Units.WATT_HOUR));
|
|
||||||
updateState(CHANNEL_TEMPO_FRAME_BBRHPJW, QuantityType.valueOf(frameTempoOption.getBbrhpjw(), Units.WATT_HOUR));
|
|
||||||
updateState(CHANNEL_TEMPO_FRAME_BBRHCJW, QuantityType.valueOf(frameTempoOption.getBbrhcjw(), Units.WATT_HOUR));
|
|
||||||
updateState(CHANNEL_TEMPO_FRAME_BBRHPJB, QuantityType.valueOf(frameTempoOption.getBbrhpjb(), Units.WATT_HOUR));
|
|
||||||
updateState(CHANNEL_TEMPO_FRAME_BBRHCJB, QuantityType.valueOf(frameTempoOption.getBbrhcjb(), Units.WATT_HOUR));
|
|
||||||
updateState(CHANNEL_TEMPO_FRAME_HHPHC, new StringType(frameTempoOption.getHhphc().name()));
|
|
||||||
updateState(CHANNEL_TEMPO_FRAME_PROGRAMME_CIRCUIT_1,
|
|
||||||
new StringType(frameTempoOption.getProgrammeCircuit1().name()));
|
|
||||||
updateState(CHANNEL_TEMPO_FRAME_PROGRAMME_CIRCUIT_2,
|
|
||||||
new StringType(frameTempoOption.getProgrammeCircuit2().name()));
|
|
||||||
|
|
||||||
if (frameTempoOption.getDemain() == null) {
|
|
||||||
updateState(CHANNEL_TEMPO_FRAME_DEMAIN, UnDefType.NULL);
|
|
||||||
} else {
|
|
||||||
updateState(CHANNEL_TEMPO_FRAME_DEMAIN, new StringType(frameTempoOption.getDemain().name()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateStatesForEjpFrameOption(FrameEjpOption frameEjpOption) {
|
|
||||||
updateState(CHANNEL_EJP_FRAME_EJPHN, QuantityType.valueOf(frameEjpOption.getEjphn(), Units.WATT_HOUR));
|
|
||||||
updateState(CHANNEL_EJP_FRAME_EJPHPM, QuantityType.valueOf(frameEjpOption.getEjphpm(), Units.WATT_HOUR));
|
|
||||||
|
|
||||||
if (frameEjpOption.getPejp() == null) {
|
|
||||||
updateState(CHANNEL_EJP_FRAME_PEJP, UnDefType.NULL);
|
|
||||||
} else {
|
|
||||||
updateState(CHANNEL_EJP_FRAME_PEJP, QuantityType.valueOf(frameEjpOption.getPejp(), Units.MINUTE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateStatus(ThingStatus status, ThingStatusDetail statusDetail, @Nullable String description) {
|
protected void updateStatus(ThingStatus status, ThingStatusDetail statusDetail, @Nullable String description) {
|
||||||
super.updateStatus(status, statusDetail, description);
|
super.updateStatus(status, statusDetail, description);
|
||||||
@ -162,4 +126,60 @@ public abstract class TeleinfoAbstractElectricityMeterHandler extends BaseThingH
|
|||||||
protected void updateStatus(ThingStatus status) {
|
protected void updateStatus(ThingStatus status) {
|
||||||
this.updateStatus(status, ThingStatusDetail.NONE, null);
|
this.updateStatus(status, ThingStatusDetail.NONE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFrameReceived(Frame frame) {
|
||||||
|
String adco = configuration.getAdco();
|
||||||
|
if (adco.equalsIgnoreCase(frame.get(Label.ADCO))) {
|
||||||
|
updateStatesForChannels(frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateStatesForChannels(Frame frame) {
|
||||||
|
for (Entry<Label, String> entry : frame.getLabelToValues().entrySet()) {
|
||||||
|
Label label = entry.getKey();
|
||||||
|
if (!label.getChannelName().equals(NOT_A_CHANNEL)) {
|
||||||
|
if (label == Label.PTEC) {
|
||||||
|
updateState(label.getChannelName(), StringType.valueOf(entry.getValue().replace(".", "")));
|
||||||
|
} else if (label.getType() == ValueType.STRING) {
|
||||||
|
updateState(label.getChannelName(), StringType.valueOf(entry.getValue()));
|
||||||
|
} else if (label.getType() == ValueType.INTEGER) {
|
||||||
|
updateState(label.getChannelName(),
|
||||||
|
QuantityType.valueOf(Integer.parseInt(entry.getValue()), label.getUnit()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (frame.getPricing() == Pricing.TEMPO) {
|
||||||
|
updateState(CHANNEL_TEMPO_FRAME_PROGRAMME_CIRCUIT_1, StringType.valueOf(frame.getProgrammeCircuit1()));
|
||||||
|
updateState(CHANNEL_TEMPO_FRAME_PROGRAMME_CIRCUIT_2, StringType.valueOf(frame.getProgrammeCircuit2()));
|
||||||
|
}
|
||||||
|
} catch (InvalidFrameException e) {
|
||||||
|
logger.warn("Can not find pricing option.");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Phase phase = frame.getPhase();
|
||||||
|
if (phase == Phase.ONE_PHASED) {
|
||||||
|
updateStateForMissingAlert(frame, Label.ADPS);
|
||||||
|
} else if (phase == Phase.THREE_PHASED) {
|
||||||
|
if (!wasLastFrameShort) {
|
||||||
|
updateStateForMissingAlert(frame, Label.ADIR1);
|
||||||
|
updateStateForMissingAlert(frame, Label.ADIR2);
|
||||||
|
updateStateForMissingAlert(frame, Label.ADIR3);
|
||||||
|
}
|
||||||
|
wasLastFrameShort = frame.isShortFrame();
|
||||||
|
}
|
||||||
|
} catch (InvalidFrameException e) {
|
||||||
|
logger.warn("Can not find phase.");
|
||||||
|
}
|
||||||
|
|
||||||
|
updateState(CHANNEL_LAST_UPDATE, new DateTimeType());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateStateForMissingAlert(Frame frame, Label label) {
|
||||||
|
if (!frame.getLabelToValues().containsKey(label)) {
|
||||||
|
updateState(label.getChannelName(), UnDefType.NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,18 +20,6 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.teleinfo.internal.handler.cbemm.TeleinfoBaseCbemmElectricityMeterHandler;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.cbemm.TeleinfoEjpCbemmElectricityMeterHandler;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.cbemm.TeleinfoHcCbemmElectricityMeterHandler;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.cbemm.TeleinfoTempoCbemmElectricityMeterHandler;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.cbemm.evoicc.TeleinfoBaseCbemmEvoIccElectricityMeterHandler;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.cbemm.evoicc.TeleinfoEjpCbemmEvoIccElectricityMeterHandler;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.cbemm.evoicc.TeleinfoHcCbemmEvoIccElectricityMeterHandler;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.cbemm.evoicc.TeleinfoTempoCbemmEvoIccElectricityMeterHandler;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.cbetm.TeleinfoBaseCbetmLongElectricityMeterHandler;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.cbetm.TeleinfoEjpCbetmLongElectricityMeterHandler;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.cbetm.TeleinfoHcCbetmLongElectricityMeterHandler;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.cbetm.TeleinfoTempoCbetmLongElectricityMeterHandler;
|
|
||||||
import org.openhab.binding.teleinfo.internal.serial.TeleinfoSerialControllerHandler;
|
import org.openhab.binding.teleinfo.internal.serial.TeleinfoSerialControllerHandler;
|
||||||
import org.openhab.core.io.transport.serial.SerialPortManager;
|
import org.openhab.core.io.transport.serial.SerialPortManager;
|
||||||
import org.openhab.core.thing.Bridge;
|
import org.openhab.core.thing.Bridge;
|
||||||
@ -83,30 +71,8 @@ public class TeleinfoThingHandlerFactory extends BaseThingHandlerFactory {
|
|||||||
return new TeleinfoSerialControllerHandler((Bridge) thing, serialPortManager);
|
return new TeleinfoSerialControllerHandler((Bridge) thing, serialPortManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (THING_BASE_CBEMM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
|
if (SUPPORTED_THING_TYPES_UIDS.contains(thing.getThingTypeUID())) {
|
||||||
return new TeleinfoBaseCbemmElectricityMeterHandler(thing);
|
return new TeleinfoElectricityMeterHandler(thing);
|
||||||
} else if (THING_HC_CBEMM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
|
|
||||||
return new TeleinfoHcCbemmElectricityMeterHandler(thing);
|
|
||||||
} else if (THING_TEMPO_CBEMM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
|
|
||||||
return new TeleinfoTempoCbemmElectricityMeterHandler(thing);
|
|
||||||
} else if (THING_EJP_CBEMM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
|
|
||||||
return new TeleinfoEjpCbemmElectricityMeterHandler(thing);
|
|
||||||
} else if (THING_BASE_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
|
|
||||||
return new TeleinfoBaseCbemmEvoIccElectricityMeterHandler(thing);
|
|
||||||
} else if (THING_HC_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
|
|
||||||
return new TeleinfoHcCbemmEvoIccElectricityMeterHandler(thing);
|
|
||||||
} else if (THING_TEMPO_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
|
|
||||||
return new TeleinfoTempoCbemmEvoIccElectricityMeterHandler(thing);
|
|
||||||
} else if (THING_EJP_CBEMM_EVO_ICC_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
|
|
||||||
return new TeleinfoEjpCbemmEvoIccElectricityMeterHandler(thing);
|
|
||||||
} else if (THING_BASE_CBETM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
|
|
||||||
return new TeleinfoBaseCbetmLongElectricityMeterHandler(thing);
|
|
||||||
} else if (THING_HC_CBETM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
|
|
||||||
return new TeleinfoHcCbetmLongElectricityMeterHandler(thing);
|
|
||||||
} else if (THING_TEMPO_CBETM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
|
|
||||||
return new TeleinfoTempoCbetmLongElectricityMeterHandler(thing);
|
|
||||||
} else if (THING_EJP_CBETM_ELECTRICITY_METER_TYPE_UID.equals(thing.getThingTypeUID())) {
|
|
||||||
return new TeleinfoEjpCbetmLongElectricityMeterHandler(thing);
|
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Teleinfo frame type not supported: " + thing.getThingTypeUID());
|
throw new IllegalStateException("Teleinfo frame type not supported: " + thing.getThingTypeUID());
|
||||||
}
|
}
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.handler.cbemm;
|
|
||||||
|
|
||||||
import static org.openhab.binding.teleinfo.internal.TeleinfoBindingConstants.*;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemm;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractElectricityMeterHandler;
|
|
||||||
import org.openhab.core.library.types.DateTimeType;
|
|
||||||
import org.openhab.core.library.types.QuantityType;
|
|
||||||
import org.openhab.core.library.types.StringType;
|
|
||||||
import org.openhab.core.library.unit.Units;
|
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
import org.openhab.core.types.UnDefType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TeleinfoAbstractCbemmElectricityMeterHandler} class defines a skeleton for CBEMM Electricity Meters
|
|
||||||
* handlers.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public abstract class TeleinfoAbstractCbemmElectricityMeterHandler extends TeleinfoAbstractElectricityMeterHandler {
|
|
||||||
|
|
||||||
public TeleinfoAbstractCbemmElectricityMeterHandler(Thing thing) {
|
|
||||||
super(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateStatesForCommonCbemmChannels(FrameCbemm frame) {
|
|
||||||
// update common channels
|
|
||||||
updateState(CHANNEL_CBEMM_ISOUSC, QuantityType.valueOf(frame.getIsousc(), Units.AMPERE));
|
|
||||||
updateState(CHANNEL_CBEMM_PTEC, new StringType(frame.getPtec().name()));
|
|
||||||
if (frame.getImax() == null) {
|
|
||||||
updateState(CHANNEL_CBEMM_IMAX, UnDefType.NULL);
|
|
||||||
} else {
|
|
||||||
updateState(CHANNEL_CBEMM_IMAX, QuantityType.valueOf(frame.getImax(), Units.AMPERE));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frame.getAdps() == null) {
|
|
||||||
updateState(CHANNEL_CBEMM_ADPS, UnDefType.NULL);
|
|
||||||
} else {
|
|
||||||
updateState(CHANNEL_CBEMM_ADPS, QuantityType.valueOf(frame.getAdps(), Units.AMPERE));
|
|
||||||
}
|
|
||||||
updateState(CHANNEL_CBEMM_IINST, QuantityType.valueOf(frame.getIinst(), Units.AMPERE));
|
|
||||||
|
|
||||||
updateState(CHANNEL_LAST_UPDATE, new DateTimeType());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.handler.cbemm;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmBaseOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TeleinfoBaseCbemmElectricityMeterHandler} class defines a handler for a BASE CBEMM Electricity Meters
|
|
||||||
* thing.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
* @author Olivier MARCEAU - Change ADCO property to parameter
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class TeleinfoBaseCbemmElectricityMeterHandler extends TeleinfoAbstractCbemmElectricityMeterHandler {
|
|
||||||
|
|
||||||
public TeleinfoBaseCbemmElectricityMeterHandler(Thing thing) {
|
|
||||||
super(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
|
|
||||||
final FrameCbemmBaseOption frameCbemmBaseOption = (FrameCbemmBaseOption) frame;
|
|
||||||
|
|
||||||
String adco = configuration.getAdco();
|
|
||||||
if (frameCbemmBaseOption.getAdco().equalsIgnoreCase(adco)) {
|
|
||||||
updateStatesForCommonCbemmChannels(frameCbemmBaseOption);
|
|
||||||
updateStatesForBaseFrameOption(frameCbemmBaseOption);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.handler.cbemm;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmEjpOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TeleinfoEjpCbemmElectricityMeterHandler} class defines a handler for a EJB CBEMM Electricity Meters
|
|
||||||
* thing.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
* @author Olivier MARCEAU - Change ADCO property to parameter
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class TeleinfoEjpCbemmElectricityMeterHandler extends TeleinfoAbstractCbemmElectricityMeterHandler {
|
|
||||||
|
|
||||||
public TeleinfoEjpCbemmElectricityMeterHandler(Thing thing) {
|
|
||||||
super(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
|
|
||||||
final FrameCbemmEjpOption frameCbemmEjpOption = (FrameCbemmEjpOption) frame;
|
|
||||||
|
|
||||||
String adco = configuration.getAdco();
|
|
||||||
if (frameCbemmEjpOption.getAdco().equalsIgnoreCase(adco)) {
|
|
||||||
updateStatesForCommonCbemmChannels(frameCbemmEjpOption);
|
|
||||||
updateStatesForEjpFrameOption(frameCbemmEjpOption);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.handler.cbemm;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmHcOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TeleinfoHcCbemmElectricityMeterHandler} class defines a handler for a HC CBEMM Electricity Meters thing.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
* @author Olivier MARCEAU - Change ADCO property to parameter
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class TeleinfoHcCbemmElectricityMeterHandler extends TeleinfoAbstractCbemmElectricityMeterHandler {
|
|
||||||
|
|
||||||
public TeleinfoHcCbemmElectricityMeterHandler(Thing thing) {
|
|
||||||
super(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
|
|
||||||
final FrameCbemmHcOption frameCbemmHcOption = (FrameCbemmHcOption) frame;
|
|
||||||
|
|
||||||
String adco = configuration.getAdco();
|
|
||||||
if (frameCbemmHcOption.getAdco().equalsIgnoreCase(adco)) {
|
|
||||||
updateStatesForCommonCbemmChannels(frameCbemmHcOption);
|
|
||||||
updateStatesForHcFrameOption(frameCbemmHcOption);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.handler.cbemm;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmTempoOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TeleinfoTempoCbemmElectricityMeterHandler} class defines a handler for a TEMPO CBEMM Electricity Meters
|
|
||||||
* thing.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
* @author Olivier MARCEAU - Change ADCO property to parameter
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class TeleinfoTempoCbemmElectricityMeterHandler extends TeleinfoAbstractCbemmElectricityMeterHandler {
|
|
||||||
|
|
||||||
public TeleinfoTempoCbemmElectricityMeterHandler(Thing thing) {
|
|
||||||
super(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
|
|
||||||
final FrameCbemmTempoOption frameCbemmTempoOption = (FrameCbemmTempoOption) frame;
|
|
||||||
|
|
||||||
String adco = configuration.getAdco();
|
|
||||||
if (frameCbemmTempoOption.getAdco().equalsIgnoreCase(adco)) {
|
|
||||||
updateStatesForCommonCbemmChannels(frameCbemmTempoOption);
|
|
||||||
updateStatesForTempoFrameOption(frameCbemmTempoOption);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.handler.cbemm.evoicc;
|
|
||||||
|
|
||||||
import static org.openhab.binding.teleinfo.internal.TeleinfoBindingConstants.CHANNEL_CBEMM_EVOLUTION_ICC_PAPP;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIcc;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.cbemm.TeleinfoAbstractCbemmElectricityMeterHandler;
|
|
||||||
import org.openhab.core.library.types.QuantityType;
|
|
||||||
import org.openhab.core.library.unit.Units;
|
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TeleinfoAbstractCbemmEvoIccElectricityMeterHandler} class defines a skeleton for CBEMM Evolution ICC
|
|
||||||
* Electricity Meters
|
|
||||||
* handlers.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public abstract class TeleinfoAbstractCbemmEvoIccElectricityMeterHandler
|
|
||||||
extends TeleinfoAbstractCbemmElectricityMeterHandler {
|
|
||||||
|
|
||||||
public TeleinfoAbstractCbemmEvoIccElectricityMeterHandler(Thing thing) {
|
|
||||||
super(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateStatesForCommonCbemmEvolutionIccChannels(FrameCbemmEvolutionIcc frame) {
|
|
||||||
updateStatesForCommonCbemmChannels(frame);
|
|
||||||
updateState(CHANNEL_CBEMM_EVOLUTION_ICC_PAPP, QuantityType.valueOf(frame.getPapp(), Units.VOLT_AMPERE));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.handler.cbemm.evoicc;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccBaseOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TeleinfoBaseCbemmEvoIccElectricityMeterHandler} class defines a handler for a BASE CBEMM Evolution ICC
|
|
||||||
* Electricity Meters thing.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
* @author Olivier MARCEAU - Change ADCO property to parameter
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class TeleinfoBaseCbemmEvoIccElectricityMeterHandler extends TeleinfoAbstractCbemmEvoIccElectricityMeterHandler {
|
|
||||||
|
|
||||||
public TeleinfoBaseCbemmEvoIccElectricityMeterHandler(Thing thing) {
|
|
||||||
super(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
|
|
||||||
final FrameCbemmEvolutionIccBaseOption frameCbemmEvoIccBaseOption = (FrameCbemmEvolutionIccBaseOption) frame;
|
|
||||||
|
|
||||||
String adco = configuration.getAdco();
|
|
||||||
if (frameCbemmEvoIccBaseOption.getAdco().equalsIgnoreCase(adco)) {
|
|
||||||
updateStatesForCommonCbemmEvolutionIccChannels(frameCbemmEvoIccBaseOption);
|
|
||||||
updateStatesForBaseFrameOption(frameCbemmEvoIccBaseOption);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.handler.cbemm.evoicc;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccEjpOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TeleinfoEjpCbemmEvoIccElectricityMeterHandler} class defines a handler for a EJP CBEMM Evolution ICC
|
|
||||||
* Electricity Meters thing.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
* @author Olivier MARCEAU - Change ADCO property to parameter
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class TeleinfoEjpCbemmEvoIccElectricityMeterHandler extends TeleinfoAbstractCbemmEvoIccElectricityMeterHandler {
|
|
||||||
|
|
||||||
public TeleinfoEjpCbemmEvoIccElectricityMeterHandler(Thing thing) {
|
|
||||||
super(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
|
|
||||||
final FrameCbemmEvolutionIccEjpOption frameCbemmEvoIccEjpOption = (FrameCbemmEvolutionIccEjpOption) frame;
|
|
||||||
|
|
||||||
String adco = configuration.getAdco();
|
|
||||||
if (frameCbemmEvoIccEjpOption.getAdco().equalsIgnoreCase(adco)) {
|
|
||||||
updateStatesForCommonCbemmEvolutionIccChannels(frameCbemmEvoIccEjpOption);
|
|
||||||
updateStatesForEjpFrameOption(frameCbemmEvoIccEjpOption);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.handler.cbemm.evoicc;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccHcOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TeleinfoHcCbemmEvoIccElectricityMeterHandler} class defines a handler for a HC CBEMM Evolution ICC
|
|
||||||
* Electricity Meters thing.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
* @author Olivier MARCEAU - Change ADCO property to parameter
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class TeleinfoHcCbemmEvoIccElectricityMeterHandler extends TeleinfoAbstractCbemmEvoIccElectricityMeterHandler {
|
|
||||||
|
|
||||||
public TeleinfoHcCbemmEvoIccElectricityMeterHandler(Thing thing) {
|
|
||||||
super(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
|
|
||||||
final FrameCbemmEvolutionIccHcOption frameCbemmEvoIccHcOption = (FrameCbemmEvolutionIccHcOption) frame;
|
|
||||||
|
|
||||||
String adco = configuration.getAdco();
|
|
||||||
if (frameCbemmEvoIccHcOption.getAdco().equalsIgnoreCase(adco)) {
|
|
||||||
updateStatesForCommonCbemmEvolutionIccChannels(frameCbemmEvoIccHcOption);
|
|
||||||
updateStatesForHcFrameOption(frameCbemmEvoIccHcOption);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.handler.cbemm.evoicc;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccTempoOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TeleinfoTempoCbemmEvoIccElectricityMeterHandler} class defines a handler for a TEMPO CBEMM Evolution ICC
|
|
||||||
* Electricity Meters thing.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
* @author Olivier MARCEAU - Change ADCO property to parameter
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class TeleinfoTempoCbemmEvoIccElectricityMeterHandler
|
|
||||||
extends TeleinfoAbstractCbemmEvoIccElectricityMeterHandler {
|
|
||||||
|
|
||||||
public TeleinfoTempoCbemmEvoIccElectricityMeterHandler(Thing thing) {
|
|
||||||
super(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
|
|
||||||
final FrameCbemmEvolutionIccTempoOption frameCbemmEvoIccTempoOption = (FrameCbemmEvolutionIccTempoOption) frame;
|
|
||||||
|
|
||||||
String adco = configuration.getAdco();
|
|
||||||
if (frameCbemmEvoIccTempoOption.getAdco().equalsIgnoreCase(adco)) {
|
|
||||||
updateStatesForCommonCbemmEvolutionIccChannels(frameCbemmEvoIccTempoOption);
|
|
||||||
updateStatesForTempoFrameOption(frameCbemmEvoIccTempoOption);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,112 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.handler.cbetm;
|
|
||||||
|
|
||||||
import static org.openhab.binding.teleinfo.internal.TeleinfoBindingConstants.*;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetm;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLong;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmShort;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractElectricityMeterHandler;
|
|
||||||
import org.openhab.core.library.types.DateTimeType;
|
|
||||||
import org.openhab.core.library.types.QuantityType;
|
|
||||||
import org.openhab.core.library.types.StringType;
|
|
||||||
import org.openhab.core.library.unit.Units;
|
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
import org.openhab.core.types.UnDefType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TeleinfoAbstractCbetmElectricityMeterHandler} class defines a skeleton for CBETM Electricity Meters
|
|
||||||
* handlers.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public abstract class TeleinfoAbstractCbetmElectricityMeterHandler extends TeleinfoAbstractElectricityMeterHandler {
|
|
||||||
|
|
||||||
public TeleinfoAbstractCbetmElectricityMeterHandler(Thing thing) {
|
|
||||||
super(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateStatesForCommonCbetmChannels(FrameCbetm frameCbetm) {
|
|
||||||
updateState(CHANNEL_CBETM_IINST1, QuantityType.valueOf(frameCbetm.getIinst1(), Units.AMPERE));
|
|
||||||
updateState(CHANNEL_CBETM_IINST2, QuantityType.valueOf(frameCbetm.getIinst2(), Units.AMPERE));
|
|
||||||
updateState(CHANNEL_CBETM_IINST3, QuantityType.valueOf(frameCbetm.getIinst3(), Units.AMPERE));
|
|
||||||
|
|
||||||
if (frameCbetm instanceof FrameCbetmLong) {
|
|
||||||
FrameCbetmLong frameCbetmLong = (FrameCbetmLong) frameCbetm;
|
|
||||||
|
|
||||||
updateState(CHANNEL_CBETM_FRAME_TYPE, new StringType("LONG"));
|
|
||||||
|
|
||||||
updateState(CHANNEL_CBETM_LONG_ISOUSC, QuantityType.valueOf(frameCbetmLong.getIsousc(), Units.AMPERE));
|
|
||||||
updateState(CHANNEL_CBETM_LONG_PTEC, new StringType(frameCbetmLong.getPtec().name()));
|
|
||||||
if (frameCbetmLong.getImax1() == null) {
|
|
||||||
updateState(CHANNEL_CBETM_LONG_IMAX1, UnDefType.NULL);
|
|
||||||
} else {
|
|
||||||
updateState(CHANNEL_CBETM_LONG_IMAX1, QuantityType.valueOf(frameCbetmLong.getImax1(), Units.AMPERE));
|
|
||||||
}
|
|
||||||
if (frameCbetmLong.getImax2() == null) {
|
|
||||||
updateState(CHANNEL_CBETM_LONG_IMAX2, UnDefType.NULL);
|
|
||||||
} else {
|
|
||||||
updateState(CHANNEL_CBETM_LONG_IMAX2, QuantityType.valueOf(frameCbetmLong.getImax2(), Units.AMPERE));
|
|
||||||
}
|
|
||||||
if (frameCbetmLong.getImax3() == null) {
|
|
||||||
updateState(CHANNEL_CBETM_LONG_IMAX3, UnDefType.NULL);
|
|
||||||
} else {
|
|
||||||
updateState(CHANNEL_CBETM_LONG_IMAX3, QuantityType.valueOf(frameCbetmLong.getImax3(), Units.AMPERE));
|
|
||||||
}
|
|
||||||
|
|
||||||
updateState(CHANNEL_CBETM_LONG_PMAX, QuantityType.valueOf(frameCbetmLong.getPmax(), Units.WATT));
|
|
||||||
updateState(CHANNEL_CBETM_LONG_PAPP, QuantityType.valueOf(frameCbetmLong.getPapp(), Units.VOLT_AMPERE));
|
|
||||||
updateState(CHANNEL_CBETM_LONG_PPOT, new StringType(frameCbetmLong.getPpot()));
|
|
||||||
|
|
||||||
updateState(CHANNEL_CBETM_SHORT_ADIR1, UnDefType.NULL);
|
|
||||||
updateState(CHANNEL_CBETM_SHORT_ADIR2, UnDefType.NULL);
|
|
||||||
updateState(CHANNEL_CBETM_SHORT_ADIR3, UnDefType.NULL);
|
|
||||||
} else { // FrameCbetmShort
|
|
||||||
FrameCbetmShort frameCbetmShort = (FrameCbetmShort) frameCbetm;
|
|
||||||
|
|
||||||
updateState(CHANNEL_CBETM_FRAME_TYPE, new StringType("SHORT"));
|
|
||||||
|
|
||||||
if (frameCbetmShort.getAdir1() == null) {
|
|
||||||
updateState(CHANNEL_CBETM_SHORT_ADIR1, UnDefType.NULL);
|
|
||||||
} else {
|
|
||||||
updateState(CHANNEL_CBETM_SHORT_ADIR1, QuantityType.valueOf(frameCbetmShort.getAdir1(), Units.AMPERE));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frameCbetmShort.getAdir2() == null) {
|
|
||||||
updateState(CHANNEL_CBETM_SHORT_ADIR2, UnDefType.NULL);
|
|
||||||
} else {
|
|
||||||
updateState(CHANNEL_CBETM_SHORT_ADIR2, QuantityType.valueOf(frameCbetmShort.getAdir2(), Units.AMPERE));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frameCbetmShort.getAdir3() == null) {
|
|
||||||
updateState(CHANNEL_CBETM_SHORT_ADIR3, UnDefType.NULL);
|
|
||||||
} else {
|
|
||||||
updateState(CHANNEL_CBETM_SHORT_ADIR3, QuantityType.valueOf(frameCbetmShort.getAdir3(), Units.AMPERE));
|
|
||||||
}
|
|
||||||
|
|
||||||
updateState(CHANNEL_CBETM_LONG_ISOUSC, UnDefType.NULL);
|
|
||||||
updateState(CHANNEL_CBETM_LONG_PTEC, UnDefType.NULL);
|
|
||||||
updateState(CHANNEL_CBETM_LONG_IMAX1, UnDefType.NULL);
|
|
||||||
updateState(CHANNEL_CBETM_LONG_IMAX2, UnDefType.NULL);
|
|
||||||
updateState(CHANNEL_CBETM_LONG_IMAX3, UnDefType.NULL);
|
|
||||||
updateState(CHANNEL_CBETM_LONG_PMAX, UnDefType.NULL);
|
|
||||||
updateState(CHANNEL_CBETM_LONG_PAPP, UnDefType.NULL);
|
|
||||||
updateState(CHANNEL_CBETM_LONG_PPOT, UnDefType.NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateState(CHANNEL_LAST_UPDATE, new DateTimeType());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.handler.cbetm;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetm;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongBaseOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TeleinfoBaseCbetmLongElectricityMeterHandler} class defines a handler for a BASE CBETM Electricity Meters
|
|
||||||
* thing.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
* @author Olivier MARCEAU - Change ADCO property to parameter
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class TeleinfoBaseCbetmLongElectricityMeterHandler extends TeleinfoAbstractCbetmElectricityMeterHandler {
|
|
||||||
|
|
||||||
public TeleinfoBaseCbetmLongElectricityMeterHandler(Thing thing) {
|
|
||||||
super(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
|
|
||||||
final FrameCbetm frameCbetm = (FrameCbetm) frame;
|
|
||||||
|
|
||||||
String adco = configuration.getAdco();
|
|
||||||
if (frameCbetm.getAdco().equalsIgnoreCase(adco)) {
|
|
||||||
updateStatesForCommonCbetmChannels(frameCbetm);
|
|
||||||
if (frameCbetm instanceof FrameCbetmLongBaseOption) {
|
|
||||||
updateStatesForBaseFrameOption((FrameCbetmLongBaseOption) frameCbetm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.handler.cbetm;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetm;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongEjpOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TeleinfoEjpCbetmLongElectricityMeterHandler} class defines a handler for a EJP CBETM Electricity Meters
|
|
||||||
* thing.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
* @author Olivier MARCEAU - Change ADCO property to parameter
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class TeleinfoEjpCbetmLongElectricityMeterHandler extends TeleinfoAbstractCbetmElectricityMeterHandler {
|
|
||||||
|
|
||||||
public TeleinfoEjpCbetmLongElectricityMeterHandler(Thing thing) {
|
|
||||||
super(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
|
|
||||||
final FrameCbetm frameCbetm = (FrameCbetm) frame;
|
|
||||||
|
|
||||||
String adco = configuration.getAdco();
|
|
||||||
if (frameCbetm.getAdco().equalsIgnoreCase(adco)) {
|
|
||||||
updateStatesForCommonCbetmChannels(frameCbetm);
|
|
||||||
if (frameCbetm instanceof FrameCbetmLongEjpOption) {
|
|
||||||
updateStatesForEjpFrameOption((FrameCbetmLongEjpOption) frameCbetm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.handler.cbetm;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetm;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongHcOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TeleinfoHcCbetmLongElectricityMeterHandler} class defines a handler for a HC CBETM Electricity Meters
|
|
||||||
* thing.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
* @author Olivier MARCEAU - Change ADCO property to parameter
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class TeleinfoHcCbetmLongElectricityMeterHandler extends TeleinfoAbstractCbetmElectricityMeterHandler {
|
|
||||||
|
|
||||||
public TeleinfoHcCbetmLongElectricityMeterHandler(Thing thing) {
|
|
||||||
super(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
|
|
||||||
final FrameCbetm frameCbetm = (FrameCbetm) frame;
|
|
||||||
|
|
||||||
String adco = configuration.getAdco();
|
|
||||||
if (frameCbetm.getAdco().equalsIgnoreCase(adco)) {
|
|
||||||
updateStatesForCommonCbetmChannels(frameCbetm);
|
|
||||||
|
|
||||||
if (frameCbetm instanceof FrameCbetmLongHcOption) {
|
|
||||||
updateStatesForHcFrameOption((FrameCbetmLongHcOption) frameCbetm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.handler.cbetm;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetm;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongTempoOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
|
||||||
import org.openhab.core.thing.Thing;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TeleinfoTempoCbetmLongElectricityMeterHandler} class defines a handler for a TEMPO CBETM Electricity
|
|
||||||
* Meters
|
|
||||||
* thing.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
* @author Olivier MARCEAU - Change ADCO property to parameter
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class TeleinfoTempoCbetmLongElectricityMeterHandler extends TeleinfoAbstractCbetmElectricityMeterHandler {
|
|
||||||
|
|
||||||
public TeleinfoTempoCbetmLongElectricityMeterHandler(Thing thing) {
|
|
||||||
super(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFrameReceived(TeleinfoAbstractControllerHandler controllerHandler, Frame frame) {
|
|
||||||
final FrameCbetm frameCbetm = (FrameCbetm) frame;
|
|
||||||
|
|
||||||
String adco = configuration.getAdco();
|
|
||||||
if (frameCbetm.getAdco().equalsIgnoreCase(adco)) {
|
|
||||||
updateStatesForCommonCbetmChannels(frameCbetm);
|
|
||||||
|
|
||||||
if (frameCbetm instanceof FrameCbetmLongTempoOption) {
|
|
||||||
updateStatesForTempoFrameOption((FrameCbetmLongTempoOption) frameCbetm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,7 +17,7 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
import org.openhab.binding.teleinfo.internal.data.Frame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link TeleinfoReaderAdaptor} class defines an adaptor at {@link TeleinfoReader} interface.
|
* The {@link TeleinfoReaderAdaptor} class defines an adaptor at {@link TeleinfoReader} interface.
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
package org.openhab.binding.teleinfo.internal.reader;
|
package org.openhab.binding.teleinfo.internal.reader;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
import org.openhab.binding.teleinfo.internal.data.Frame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link TeleinfoReaderListener} interface defines all events pushed by a {@link TeleinfoReader}.
|
* The {@link TeleinfoReaderListener} interface defines all events pushed by a {@link TeleinfoReader}.
|
||||||
|
@ -17,57 +17,13 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
import org.openhab.binding.teleinfo.internal.data.Frame;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemm;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmBaseOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmEjpOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmHcOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.FrameCbemmTempoOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIcc;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccBaseOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccEjpOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccHcOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccTempoOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLong;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongBaseOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongEjpOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongHcOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongTempoOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmShort;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameBaseOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameEjpOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameHcOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption.CouleurDemain;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption.ProgrammeCircuit1;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption.ProgrammeCircuit2;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Ptec;
|
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
|
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.FrameUtil;
|
import org.openhab.binding.teleinfo.internal.reader.io.serialport.FrameUtil;
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameException;
|
import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameException;
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.Label;
|
import org.openhab.binding.teleinfo.internal.reader.io.serialport.Label;
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.converter.Converter;
|
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.converter.CouleurDemainConverter;
|
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.converter.FloatConverter;
|
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.converter.HhphcConverter;
|
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.converter.IntegerConverter;
|
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.converter.PtecConverter;
|
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.converter.StringConverter;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -82,63 +38,24 @@ import org.slf4j.LoggerFactory;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class TeleinfoInputStream extends InputStream {
|
public class TeleinfoInputStream extends InputStream {
|
||||||
|
|
||||||
public static final long DEFAULT_TIMEOUT_NEXT_HEADER_FRAME_US = 33400;
|
|
||||||
public static final long DEFAULT_TIMEOUT_READING_FRAME_US = 33400;
|
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(TeleinfoInputStream.class);
|
private final Logger logger = LoggerFactory.getLogger(TeleinfoInputStream.class);
|
||||||
private static final Map<Class<?>, Converter> LABEL_VALUE_CONVERTERS;
|
|
||||||
|
|
||||||
private BufferedReader bufferedReader;
|
private BufferedReader bufferedReader;
|
||||||
private @Nullable String groupLine;
|
private @Nullable String groupLine;
|
||||||
private ExecutorService executorService;
|
|
||||||
private long waitNextHeaderFrameTimeoutInUs;
|
|
||||||
private long readingFrameTimeoutInUs;
|
|
||||||
private boolean autoRepairInvalidADPSgroupLine;
|
private boolean autoRepairInvalidADPSgroupLine;
|
||||||
private boolean useOwnScheduler;
|
private final Frame frame = new Frame();
|
||||||
|
|
||||||
static {
|
|
||||||
LABEL_VALUE_CONVERTERS = new HashMap<>();
|
|
||||||
LABEL_VALUE_CONVERTERS.put(Integer.class, new IntegerConverter());
|
|
||||||
LABEL_VALUE_CONVERTERS.put(String.class, new StringConverter());
|
|
||||||
LABEL_VALUE_CONVERTERS.put(Float.class, new FloatConverter());
|
|
||||||
LABEL_VALUE_CONVERTERS.put(Ptec.class, new PtecConverter());
|
|
||||||
LABEL_VALUE_CONVERTERS.put(Hhphc.class, new HhphcConverter());
|
|
||||||
LABEL_VALUE_CONVERTERS.put(CouleurDemain.class, new CouleurDemainConverter());
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeleinfoInputStream(final InputStream teleinfoInputStream) {
|
public TeleinfoInputStream(final InputStream teleinfoInputStream) {
|
||||||
this(teleinfoInputStream, DEFAULT_TIMEOUT_NEXT_HEADER_FRAME_US, DEFAULT_TIMEOUT_READING_FRAME_US, false);
|
this(teleinfoInputStream, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TeleinfoInputStream(final InputStream teleinfoInputStream, boolean autoRepairInvalidADPSgroupLine) {
|
public TeleinfoInputStream(final @Nullable InputStream teleinfoInputStream,
|
||||||
this(teleinfoInputStream, DEFAULT_TIMEOUT_NEXT_HEADER_FRAME_US, DEFAULT_TIMEOUT_READING_FRAME_US,
|
boolean autoRepairInvalidADPSgroupLine) {
|
||||||
autoRepairInvalidADPSgroupLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeleinfoInputStream(final @Nullable InputStream teleinfoInputStream, long waitNextHeaderFrameTimeoutInUs,
|
|
||||||
long readingFrameTimeoutInUs, boolean autoRepairInvalidADPSgroupLine) {
|
|
||||||
this(teleinfoInputStream, waitNextHeaderFrameTimeoutInUs, readingFrameTimeoutInUs,
|
|
||||||
autoRepairInvalidADPSgroupLine, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeleinfoInputStream(final @Nullable InputStream teleinfoInputStream, long waitNextHeaderFrameTimeoutInUs,
|
|
||||||
long readingFrameTimeoutInUs, boolean autoRepairInvalidADPSgroupLine,
|
|
||||||
@Nullable ExecutorService executorService) {
|
|
||||||
if (teleinfoInputStream == null) {
|
if (teleinfoInputStream == null) {
|
||||||
throw new IllegalArgumentException("Teleinfo inputStream is null");
|
throw new IllegalArgumentException("Teleinfo inputStream is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.waitNextHeaderFrameTimeoutInUs = waitNextHeaderFrameTimeoutInUs;
|
|
||||||
this.readingFrameTimeoutInUs = readingFrameTimeoutInUs;
|
|
||||||
this.autoRepairInvalidADPSgroupLine = autoRepairInvalidADPSgroupLine;
|
this.autoRepairInvalidADPSgroupLine = autoRepairInvalidADPSgroupLine;
|
||||||
if (executorService == null) {
|
|
||||||
this.executorService = Executors.newFixedThreadPool(2);
|
|
||||||
this.useOwnScheduler = true;
|
|
||||||
} else {
|
|
||||||
this.executorService = executorService;
|
|
||||||
this.useOwnScheduler = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.bufferedReader = new BufferedReader(new InputStreamReader(teleinfoInputStream, StandardCharsets.US_ASCII));
|
this.bufferedReader = new BufferedReader(new InputStreamReader(teleinfoInputStream, StandardCharsets.US_ASCII));
|
||||||
|
|
||||||
groupLine = null;
|
groupLine = null;
|
||||||
@ -148,9 +65,6 @@ public class TeleinfoInputStream extends InputStream {
|
|||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
logger.debug("close() [start]");
|
logger.debug("close() [start]");
|
||||||
bufferedReader.close();
|
bufferedReader.close();
|
||||||
if (useOwnScheduler) {
|
|
||||||
executorService.shutdownNow();
|
|
||||||
}
|
|
||||||
super.close();
|
super.close();
|
||||||
logger.debug("close() [end]");
|
logger.debug("close() [end]");
|
||||||
}
|
}
|
||||||
@ -164,137 +78,65 @@ public class TeleinfoInputStream extends InputStream {
|
|||||||
* @throws InvalidFrameException
|
* @throws InvalidFrameException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public synchronized @Nullable Frame readNextFrame() throws TimeoutException, InvalidFrameException, IOException {
|
public synchronized @Nullable Frame readNextFrame() throws InvalidFrameException, IOException {
|
||||||
// seek the next header frame
|
// seek the next header frame
|
||||||
Future<@Nullable Void> seekNextHeaderFrameTask = executorService.submit(() -> {
|
while (!isHeaderFrame(groupLine)) {
|
||||||
while (!isHeaderFrame(groupLine)) {
|
groupLine = bufferedReader.readLine();
|
||||||
groupLine = bufferedReader.readLine();
|
if (logger.isTraceEnabled()) {
|
||||||
if (logger.isTraceEnabled()) {
|
logger.trace("groupLine = {}", groupLine);
|
||||||
logger.trace("groupLine = {}", groupLine);
|
|
||||||
}
|
|
||||||
if (groupLine == null) { // end of stream
|
|
||||||
logger.trace("end of stream reached !");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.trace("header frame found !");
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
logger.debug("seeking the next header frame...");
|
|
||||||
logger.trace("waitNextHeaderFrameTimeoutInUs = {}", waitNextHeaderFrameTimeoutInUs);
|
|
||||||
seekNextHeaderFrameTask.get(waitNextHeaderFrameTimeoutInUs, TimeUnit.MICROSECONDS);
|
|
||||||
|
|
||||||
if (groupLine == null) { // end of stream
|
if (groupLine == null) { // end of stream
|
||||||
|
logger.trace("end of stream reached !");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
|
||||||
logger.debug("Got interrupted exception", e);
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
rethrowTaskExecutionException(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<Label, Object>> nextFrameFuture = executorService.submit(new Callable<Map<Label, Object>>() {
|
frame.clear();
|
||||||
@Override
|
while ((groupLine = bufferedReader.readLine()) != null && !isHeaderFrame(groupLine)) {
|
||||||
public Map<Label, Object> call() throws Exception {
|
logger.trace("groupLine = {}", groupLine);
|
||||||
// read label values
|
String groupLineRef = groupLine;
|
||||||
Map<Label, Object> frameValues = new HashMap<>();
|
if (groupLineRef != null) {
|
||||||
while ((groupLine = bufferedReader.readLine()) != null && !isHeaderFrame(groupLine)) {
|
String[] groupLineTokens = groupLineRef.split("\\s");
|
||||||
logger.trace("groupLine = {}", groupLine);
|
if (groupLineTokens.length != 2 && groupLineTokens.length != 3) {
|
||||||
String groupLineRef = groupLine;
|
final String error = String.format("The groupLine '%1$s' is incomplete", groupLineRef);
|
||||||
if (groupLineRef != null) {
|
throw new InvalidFrameException(error);
|
||||||
String[] groupLineTokens = groupLineRef.split("\\s");
|
}
|
||||||
if (groupLineTokens.length != 2 && groupLineTokens.length != 3) {
|
String labelStr = groupLineTokens[0];
|
||||||
final String error = String.format("The groupLine '%1$s' is incomplete", groupLineRef);
|
String valueString = groupLineTokens[1];
|
||||||
throw new InvalidFrameException(error);
|
|
||||||
}
|
|
||||||
String labelStr = groupLineTokens[0];
|
|
||||||
String valueString = groupLineTokens[1];
|
|
||||||
|
|
||||||
// verify integrity (through checksum)
|
// verify integrity (through checksum)
|
||||||
char checksum = (groupLineTokens.length == 3 ? groupLineTokens[2].charAt(0) : ' ');
|
char checksum = (groupLineTokens.length == 3 ? groupLineTokens[2].charAt(0) : ' ');
|
||||||
char computedChecksum = FrameUtil.computeGroupLineChecksum(labelStr, valueString);
|
char computedChecksum = FrameUtil.computeGroupLineChecksum(labelStr, valueString);
|
||||||
if (computedChecksum != checksum) {
|
if (computedChecksum != checksum) {
|
||||||
logger.trace("computedChecksum = {}", computedChecksum);
|
logger.trace("computedChecksum = {}", computedChecksum);
|
||||||
logger.trace("checksum = {}", checksum);
|
logger.trace("checksum = {}", checksum);
|
||||||
final String error = String.format(
|
final String error = String.format(
|
||||||
"The groupLine '%s' is corrupted (integrity not checked). Actual checksum: '%s' / Expected checksum: '%s'",
|
"The groupLine '%s' is corrupted (integrity not checked). Actual checksum: '%s' / Expected checksum: '%s'",
|
||||||
groupLineRef, checksum, computedChecksum);
|
groupLineRef, checksum, computedChecksum);
|
||||||
throw new InvalidFrameException(error);
|
throw new InvalidFrameException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
Label label;
|
Label label;
|
||||||
try {
|
try {
|
||||||
label = Label.valueOf(labelStr);
|
label = Label.valueOf(labelStr);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
if (autoRepairInvalidADPSgroupLine && labelStr.startsWith(Label.ADPS.name())) {
|
if (autoRepairInvalidADPSgroupLine && labelStr.startsWith(Label.ADPS.name())) {
|
||||||
// in this hardware issue, label variable is composed by label name and value. E.g:
|
// in this hardware issue, label variable is composed by label name and value. E.g:
|
||||||
// ADPS032
|
// ADPS032
|
||||||
logger.warn("Try to auto repair malformed ADPS groupLine '{}'", labelStr);
|
logger.warn("Try to auto repair malformed ADPS groupLine '{}'", labelStr);
|
||||||
label = Label.ADPS;
|
label = Label.ADPS;
|
||||||
valueString = labelStr.substring(Label.ADPS.name().length());
|
valueString = labelStr.substring(Label.ADPS.name().length());
|
||||||
} else {
|
} else {
|
||||||
final String error = String.format("The label '%s' is unknown", labelStr);
|
final String error = String.format("The label '%s' is unknown", labelStr);
|
||||||
throw new InvalidFrameException(error);
|
throw new InvalidFrameException(error);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Class<?> labelType = label.getType();
|
|
||||||
Converter converter = LABEL_VALUE_CONVERTERS.get(labelType);
|
|
||||||
try {
|
|
||||||
Object value = converter.convert(valueString);
|
|
||||||
if (value != null) {
|
|
||||||
frameValues.put(label, value);
|
|
||||||
}
|
|
||||||
} catch (ConversionException e) {
|
|
||||||
final String error = String.format("An error occurred during '%s' value conversion",
|
|
||||||
valueString);
|
|
||||||
throw new InvalidFrameException(error, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return frameValues;
|
frame.put(label, valueString);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
logger.debug("reading data frame...");
|
|
||||||
logger.trace("readingFrameTimeoutInUs = {}", readingFrameTimeoutInUs);
|
|
||||||
Map<Label, Object> frameValues = nextFrameFuture.get(readingFrameTimeoutInUs, TimeUnit.MICROSECONDS);
|
|
||||||
|
|
||||||
// build the frame from map values
|
|
||||||
final Frame frame = buildFrame(frameValues);
|
|
||||||
frame.setTimestamp(LocalDate.now());
|
|
||||||
frame.setId(UUID.randomUUID());
|
|
||||||
|
|
||||||
return frame;
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
logger.debug("Got interrupted exception", e);
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
rethrowTaskExecutionException(e);
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getWaitNextHeaderFrameTimeoutInUs() {
|
return frame;
|
||||||
return waitNextHeaderFrameTimeoutInUs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWaitNextHeaderFrameTimeoutInUs(long waitNextHeaderFrameTimeoutInUs) {
|
|
||||||
this.waitNextHeaderFrameTimeoutInUs = waitNextHeaderFrameTimeoutInUs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getReadingFrameTimeoutInUs() {
|
|
||||||
return readingFrameTimeoutInUs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReadingFrameTimeoutInUs(long readingFrameTimeoutInUs) {
|
|
||||||
this.readingFrameTimeoutInUs = readingFrameTimeoutInUs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAutoRepairInvalidADPSgroupLine() {
|
public boolean isAutoRepairInvalidADPSgroupLine() {
|
||||||
@ -314,377 +156,4 @@ public class TeleinfoInputStream extends InputStream {
|
|||||||
// A new teleinfo trame begin with '3' and '2' bytes (END OF TEXT et START OF TEXT)
|
// A new teleinfo trame begin with '3' and '2' bytes (END OF TEXT et START OF TEXT)
|
||||||
return (line != null && line.length() > 1 && line.codePointAt(0) == 3 && line.codePointAt(1) == 2);
|
return (line != null && line.length() > 1 && line.codePointAt(0) == 3 && line.codePointAt(1) == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Frame buildFrame(final Map<Label, Object> frameValues) throws InvalidFrameException {
|
|
||||||
if (frameValues.containsKey(Label.IINST1)) {
|
|
||||||
if (frameValues.containsKey(Label.IMAX1)) {
|
|
||||||
return buildFrameCbetmLong(frameValues);
|
|
||||||
} else {
|
|
||||||
return buildFrameCbetmShort(frameValues);
|
|
||||||
}
|
|
||||||
} else if (frameValues.containsKey(Label.PAPP)) {
|
|
||||||
return buildFrameCbemmEvolutionIcc(frameValues);
|
|
||||||
} else {
|
|
||||||
return buildFrameCbemm(frameValues);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbetmLong buildFrameCbetmLong(final Map<Label, Object> frameValues) throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbetmLong(Map<Label, Object>) [start]");
|
|
||||||
final FrameCbetmLong frameCbetm;
|
|
||||||
String optionTarif = getRequiredLabelValue(Label.OPTARIF, frameValues);
|
|
||||||
if ("BASE".equals(optionTarif)) {
|
|
||||||
frameCbetm = buildFrameCbetmLongBaseOption(frameValues);
|
|
||||||
} else if ("HC..".equals(optionTarif)) {
|
|
||||||
frameCbetm = buildFrameCbetmLongHcOption(frameValues);
|
|
||||||
} else if ("EJP.".equals(optionTarif)) {
|
|
||||||
frameCbetm = buildFrameCbetmLongEjpOption(frameValues);
|
|
||||||
} else if (optionTarif.startsWith("BBR") && optionTarif.length() == 4) {
|
|
||||||
ProgrammeCircuit1 prgCircuit1 = convertProgrammeCircuit1(optionTarif.charAt(3));
|
|
||||||
ProgrammeCircuit2 prgCircuit2 = convertProgrammeCircuit2(optionTarif.charAt(3));
|
|
||||||
frameCbetm = buildFrameCbetmLongTempoOption(frameValues, prgCircuit1, prgCircuit2);
|
|
||||||
} else {
|
|
||||||
final String error = String.format("The option Tarif '%s' is not supported", optionTarif);
|
|
||||||
throw new InvalidFrameException(error);
|
|
||||||
}
|
|
||||||
logger.trace("buildFrameCbetmLong(Map<Label, Object>) [end]");
|
|
||||||
return frameCbetm;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setCbetmCommonFrameFields(final FrameCbetmLong frame, final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("setCbetmCommonFrameFields(Frame, Map<Label, Object>) [start]");
|
|
||||||
frame.setAdco(getRequiredLabelValue(Label.ADCO, frameValues));
|
|
||||||
frame.setIsousc(getRequiredLabelValue(Label.ISOUSC, frameValues));
|
|
||||||
frame.setIinst1(getRequiredLabelValue(Label.IINST1, frameValues));
|
|
||||||
frame.setIinst2(getRequiredLabelValue(Label.IINST2, frameValues));
|
|
||||||
frame.setIinst3(getRequiredLabelValue(Label.IINST3, frameValues));
|
|
||||||
frame.setImax1(getRequiredLabelValue(Label.IMAX1, frameValues));
|
|
||||||
frame.setImax2(getRequiredLabelValue(Label.IMAX2, frameValues));
|
|
||||||
frame.setImax3(getRequiredLabelValue(Label.IMAX3, frameValues));
|
|
||||||
frame.setPtec(getRequiredLabelValue(Label.PTEC, frameValues));
|
|
||||||
frame.setPmax(getRequiredLabelValue(Label.PMAX, frameValues));
|
|
||||||
frame.setPapp(getRequiredLabelValue(Label.PAPP, frameValues));
|
|
||||||
frame.setMotdetat(getRequiredLabelValue(Label.MOTDETAT, frameValues));
|
|
||||||
frame.setPpot(getRequiredLabelValue(Label.PPOT, frameValues));
|
|
||||||
logger.trace("setCbetmCommonFrameFields(Frame, Map<Label, Object>) [end]");
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbetmLongBaseOption buildFrameCbetmLongBaseOption(final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbetmBaseOption(Map<Label, Object>) [start]");
|
|
||||||
FrameCbetmLongBaseOption frame = new FrameCbetmLongBaseOption();
|
|
||||||
setCbetmCommonFrameFields(frame, frameValues);
|
|
||||||
setFrameBaseOptionFields(frame, frameValues);
|
|
||||||
logger.trace("buildFrameCbetmBaseOption(Map<Label, Object>) [end]");
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbetmLongHcOption buildFrameCbetmLongHcOption(final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbetmHcOption(Map<Label, Object>) [start]");
|
|
||||||
FrameCbetmLongHcOption frame = new FrameCbetmLongHcOption();
|
|
||||||
setCbetmCommonFrameFields(frame, frameValues);
|
|
||||||
setFrameHcOptionFields(frame, frameValues);
|
|
||||||
logger.trace("buildFrameCbetmHcOption(Map<Label, Object>) [end]");
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbetmLongEjpOption buildFrameCbetmLongEjpOption(final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbetmEjpOption(Map<Label, Object>) [start]");
|
|
||||||
FrameCbetmLongEjpOption frame = new FrameCbetmLongEjpOption();
|
|
||||||
setCbetmCommonFrameFields(frame, frameValues);
|
|
||||||
setFrameEjpOptionFields(frame, frameValues);
|
|
||||||
logger.trace("buildFrameCbetmEjpOption(Map<Label, Object>) [end]");
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbetmLongTempoOption buildFrameCbetmLongTempoOption(final Map<Label, Object> frameValues,
|
|
||||||
ProgrammeCircuit1 prgCircuit1, ProgrammeCircuit2 prgCircuit2) throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbetmTempoOption(Map<Label, Object>) [start]");
|
|
||||||
FrameCbetmLongTempoOption frame = new FrameCbetmLongTempoOption();
|
|
||||||
setCbetmCommonFrameFields(frame, frameValues);
|
|
||||||
setFrameTempoOptionFields(frame, frameValues, prgCircuit1, prgCircuit2);
|
|
||||||
logger.trace("buildFrameCbetmTempoOption(Map<Label, Object>) [end]");
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbetmShort buildFrameCbetmShort(final Map<Label, Object> frameValues) throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbetmShort(Map<Label, Object>) [start]");
|
|
||||||
FrameCbetmShort frame = new FrameCbetmShort();
|
|
||||||
frame.setAdco(getRequiredLabelValue(Label.ADCO, frameValues));
|
|
||||||
frame.setIinst1(getRequiredLabelValue(Label.IINST1, frameValues));
|
|
||||||
frame.setIinst2(getRequiredLabelValue(Label.IINST2, frameValues));
|
|
||||||
frame.setIinst3(getRequiredLabelValue(Label.IINST3, frameValues));
|
|
||||||
frame.setAdir1(getOptionalLabelValue(Label.ADIR1, frameValues));
|
|
||||||
frame.setAdir2(getOptionalLabelValue(Label.ADIR2, frameValues));
|
|
||||||
frame.setAdir3(getOptionalLabelValue(Label.ADIR3, frameValues));
|
|
||||||
logger.trace("buildFrameCbetmShort(Map<Label, Object>) [end]");
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbemm buildFrameCbemm(final Map<Label, Object> frameValues) throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbemm(Map<Label, Object>) [start]");
|
|
||||||
final FrameCbemm frameCbemm;
|
|
||||||
String optionTarif = getRequiredLabelValue(Label.OPTARIF, frameValues);
|
|
||||||
if ("BASE".equals(optionTarif)) {
|
|
||||||
frameCbemm = buildFrameCbemmBaseOption(frameValues);
|
|
||||||
} else if ("HC..".equals(optionTarif)) {
|
|
||||||
frameCbemm = buildFrameCbemmHcOption(frameValues);
|
|
||||||
} else if ("EJP.".equals(optionTarif)) {
|
|
||||||
frameCbemm = buildFrameCbemmEjpOption(frameValues);
|
|
||||||
} else if (optionTarif.startsWith("BBR") && optionTarif.length() == 4) {
|
|
||||||
ProgrammeCircuit1 prgCircuit1 = convertProgrammeCircuit1(optionTarif.charAt(3));
|
|
||||||
ProgrammeCircuit2 prgCircuit2 = convertProgrammeCircuit2(optionTarif.charAt(3));
|
|
||||||
frameCbemm = buildFrameCbemmTempoOption(frameValues, prgCircuit1, prgCircuit2);
|
|
||||||
} else {
|
|
||||||
final String error = String.format("The option Tarif '%s' is not supported", optionTarif);
|
|
||||||
throw new InvalidFrameException(error);
|
|
||||||
}
|
|
||||||
logger.trace("buildFrameCbemm(Map<Label, Object>) [end]");
|
|
||||||
return frameCbemm;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setCbemmCommonFrameFields(final FrameCbemm frame, final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("setCbemmCommonFrameFields(Frame, Map<Label, Object>) [start]");
|
|
||||||
frame.setAdco(getRequiredLabelValue(Label.ADCO, frameValues));
|
|
||||||
frame.setIsousc(getRequiredLabelValue(Label.ISOUSC, frameValues));
|
|
||||||
frame.setIinst(getRequiredLabelValue(Label.IINST, frameValues));
|
|
||||||
frame.setImax(getOptionalLabelValue(Label.IMAX, frameValues));
|
|
||||||
frame.setPtec(getRequiredLabelValue(Label.PTEC, frameValues));
|
|
||||||
frame.setAdps(getOptionalLabelValue(Label.ADPS, frameValues));
|
|
||||||
frame.setMotdetat(getRequiredLabelValue(Label.MOTDETAT, frameValues));
|
|
||||||
logger.trace("setCbemmCommonFrameFields(Frame, Map<Label, Object>) [end]");
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbemmBaseOption buildFrameCbemmBaseOption(final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbemmBaseOption(Map<Label, Object>) [start]");
|
|
||||||
FrameCbemmBaseOption frame = new FrameCbemmBaseOption();
|
|
||||||
setCbemmCommonFrameFields(frame, frameValues);
|
|
||||||
setFrameBaseOptionFields(frame, frameValues);
|
|
||||||
logger.trace("buildFrameCbemmBaseOption(Map<Label, Object>) [end]");
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbemmHcOption buildFrameCbemmHcOption(final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbemmHcOption(Map<Label, Object>) [start]");
|
|
||||||
FrameCbemmHcOption frame = new FrameCbemmHcOption();
|
|
||||||
setCbemmCommonFrameFields(frame, frameValues);
|
|
||||||
setFrameHcOptionFields(frame, frameValues);
|
|
||||||
logger.trace("buildFrameCbemmHcOption(Map<Label, Object>) [end]");
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbemmEjpOption buildFrameCbemmEjpOption(final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbemmEjpOption(Map<Label, Object>) [start]");
|
|
||||||
FrameCbemmEjpOption frame = new FrameCbemmEjpOption();
|
|
||||||
setCbemmCommonFrameFields(frame, frameValues);
|
|
||||||
setFrameEjpOptionFields(frame, frameValues);
|
|
||||||
logger.trace("buildFrameCbemmEjpOption(Map<Label, Object>) [end]");
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbemmTempoOption buildFrameCbemmTempoOption(final Map<Label, Object> frameValues,
|
|
||||||
ProgrammeCircuit1 prgCircuit1, ProgrammeCircuit2 prgCircuit2) throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbemmTempoOption(Map<Label, Object>) [start]");
|
|
||||||
FrameCbemmTempoOption frame = new FrameCbemmTempoOption();
|
|
||||||
setCbemmCommonFrameFields(frame, frameValues);
|
|
||||||
setFrameTempoOptionFields(frame, frameValues, prgCircuit1, prgCircuit2);
|
|
||||||
logger.trace("buildFrameCbemmTempoOption(Map<Label, Object>) [end]");
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbemmEvolutionIcc buildFrameCbemmEvolutionIcc(final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbemmEvolutionIcc(Map<Label, Object>) [start]");
|
|
||||||
final FrameCbemmEvolutionIcc frameCbemmEvoIcc;
|
|
||||||
String optionTarif = getRequiredLabelValue(Label.OPTARIF, frameValues);
|
|
||||||
if ("BASE".equals(optionTarif)) {
|
|
||||||
frameCbemmEvoIcc = buildFrameCbemmEvolutionIccBaseOption(frameValues);
|
|
||||||
} else if ("HC..".equals(optionTarif)) {
|
|
||||||
frameCbemmEvoIcc = buildFrameCbemmEvolutionIccHcOption(frameValues);
|
|
||||||
} else if ("EJP.".equals(optionTarif)) {
|
|
||||||
frameCbemmEvoIcc = buildFrameCbemmEvolutionIccEjpOption(frameValues);
|
|
||||||
} else if (optionTarif.startsWith("BBR") && optionTarif.length() == 4) {
|
|
||||||
ProgrammeCircuit1 prgCircuit1 = convertProgrammeCircuit1(optionTarif.charAt(3));
|
|
||||||
ProgrammeCircuit2 prgCircuit2 = convertProgrammeCircuit2(optionTarif.charAt(3));
|
|
||||||
frameCbemmEvoIcc = buildFrameCbemmEvolutionIccTempoOption(frameValues, prgCircuit1, prgCircuit2);
|
|
||||||
} else {
|
|
||||||
final String error = String.format("The option Tarif '%s' is not supported", optionTarif);
|
|
||||||
throw new InvalidFrameException(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("buildFrameCbemmEvolutionIcc(Map<Label, Object>) [end]");
|
|
||||||
return frameCbemmEvoIcc;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setCbemmEvolutionIccCommonFrameFields(final FrameCbemmEvolutionIcc frame,
|
|
||||||
final Map<Label, Object> frameValues) throws InvalidFrameException {
|
|
||||||
logger.trace("setCbemmEvolutionIccCommonFrameFields(Frame, Map<Label, Object>) [start]");
|
|
||||||
setCbemmCommonFrameFields(frame, frameValues);
|
|
||||||
frame.setPapp(getRequiredLabelValue(Label.PAPP, frameValues));
|
|
||||||
logger.trace("setCbemmEvolutionIccCommonFrameFields(Frame, Map<Label, Object>) [end]");
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbemmEvolutionIccBaseOption buildFrameCbemmEvolutionIccBaseOption(final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbemmEvolutionIccBaseOption(Map<Label, Object>) [start]");
|
|
||||||
FrameCbemmEvolutionIccBaseOption frame = new FrameCbemmEvolutionIccBaseOption();
|
|
||||||
setCbemmEvolutionIccCommonFrameFields(frame, frameValues);
|
|
||||||
setFrameBaseOptionFields(frame, frameValues);
|
|
||||||
logger.trace("buildFrameCbemmEvolutionIccBaseOption(Map<Label, Object>) [end]");
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbemmEvolutionIccHcOption buildFrameCbemmEvolutionIccHcOption(final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbemmEvolutionIccHcOption(Map<Label, Object>) [start]");
|
|
||||||
FrameCbemmEvolutionIccHcOption frame = new FrameCbemmEvolutionIccHcOption();
|
|
||||||
setCbemmEvolutionIccCommonFrameFields(frame, frameValues);
|
|
||||||
setFrameHcOptionFields(frame, frameValues);
|
|
||||||
logger.trace("buildFrameCbemmEvolutionIccHcOption(Map<Label, Object>) [end]");
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbemmEvolutionIccTempoOption buildFrameCbemmEvolutionIccTempoOption(
|
|
||||||
final Map<Label, Object> frameValues, ProgrammeCircuit1 prgCircuit1, ProgrammeCircuit2 prgCircuit2)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbemmEvolutionIccTempoOption(Map<Label, Object>) [start]");
|
|
||||||
FrameCbemmEvolutionIccTempoOption frame = new FrameCbemmEvolutionIccTempoOption();
|
|
||||||
setCbemmEvolutionIccCommonFrameFields(frame, frameValues);
|
|
||||||
setFrameTempoOptionFields(frame, frameValues, prgCircuit1, prgCircuit2);
|
|
||||||
logger.trace("buildFrameCbemmEvolutionIccTempoOption(Map<Label, Object>) [end]");
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrameCbemmEvolutionIccEjpOption buildFrameCbemmEvolutionIccEjpOption(final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("buildFrameCbemmEvolutionIccEjpOption(Map<Label, Object>) [start]");
|
|
||||||
FrameCbemmEvolutionIccEjpOption frame = new FrameCbemmEvolutionIccEjpOption();
|
|
||||||
setCbemmEvolutionIccCommonFrameFields(frame, frameValues);
|
|
||||||
setFrameEjpOptionFields(frame, frameValues);
|
|
||||||
logger.trace("buildFrameCbemmEvolutionIccEjpOption(Map<Label, Object>) [end]");
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setFrameBaseOptionFields(final FrameBaseOption frameBaseOption, final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("setFrameBaseOptionFields(FrameBaseOption) [start]");
|
|
||||||
frameBaseOption.setBase(getRequiredLabelValue(Label.BASE, frameValues));
|
|
||||||
logger.trace("setFrameBaseOptionFields(FrameBaseOption) [end]");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setFrameHcOptionFields(final FrameHcOption frameHcOption, final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("setFrameHcOptionFields(FrameHcOption) [start]");
|
|
||||||
frameHcOption.setHchc(getRequiredLabelValue(Label.HCHC, frameValues));
|
|
||||||
frameHcOption.setHchp(getRequiredLabelValue(Label.HCHP, frameValues));
|
|
||||||
frameHcOption.setHhphc(getRequiredLabelValue(Label.HHPHC, frameValues));
|
|
||||||
logger.trace("setFrameHcOptionFields(FrameHcOption) [end]");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setFrameEjpOptionFields(final FrameEjpOption frameEjpOption, final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("setFrameEjpOptionFields(FrameEjpOption) [start]");
|
|
||||||
frameEjpOption.setEjphn(getRequiredLabelValue(Label.EJPHN, frameValues));
|
|
||||||
frameEjpOption.setEjphpm(getRequiredLabelValue(Label.EJPHPM, frameValues));
|
|
||||||
frameEjpOption.setPejp(getOptionalLabelValue(Label.PEJP, frameValues));
|
|
||||||
logger.trace("setFrameEjpOptionFields(FrameEjpOption) [end]");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setFrameTempoOptionFields(final FrameTempoOption frameTempoOption,
|
|
||||||
final Map<Label, Object> frameValues, ProgrammeCircuit1 prgCircuit1, ProgrammeCircuit2 prgCircuit2)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
logger.trace("setFrameTempoOptionFields(FrameTempoOption) [start]");
|
|
||||||
frameTempoOption.setBbrhpjr(getRequiredLabelValue(Label.BBRHPJR, frameValues));
|
|
||||||
frameTempoOption.setBbrhcjr(getRequiredLabelValue(Label.BBRHCJR, frameValues));
|
|
||||||
frameTempoOption.setBbrhpjw(getRequiredLabelValue(Label.BBRHPJW, frameValues));
|
|
||||||
frameTempoOption.setBbrhcjw(getRequiredLabelValue(Label.BBRHCJW, frameValues));
|
|
||||||
frameTempoOption.setBbrhpjb(getRequiredLabelValue(Label.BBRHPJB, frameValues));
|
|
||||||
frameTempoOption.setBbrhcjb(getRequiredLabelValue(Label.BBRHCJB, frameValues));
|
|
||||||
frameTempoOption.setDemain(getOptionalLabelValue(Label.DEMAIN, frameValues));
|
|
||||||
frameTempoOption.setHhphc(getRequiredLabelValue(Label.HHPHC, frameValues));
|
|
||||||
frameTempoOption.setProgrammeCircuit1(prgCircuit1);
|
|
||||||
frameTempoOption.setProgrammeCircuit2(prgCircuit2);
|
|
||||||
logger.trace("setFrameTempoOptionFields(FrameTempoOption) [end]");
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private <T> T getRequiredLabelValue(Label label, final Map<Label, Object> frameValues)
|
|
||||||
throws InvalidFrameException {
|
|
||||||
if (!frameValues.containsKey(label)) {
|
|
||||||
final String error = String.format("The required label '%1$s' is missing in frame", label);
|
|
||||||
throw new InvalidFrameException(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (T) frameValues.get(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private <T> T getOptionalLabelValue(Label label, final Map<Label, Object> frameValues) {
|
|
||||||
return (T) frameValues.get(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ProgrammeCircuit1 convertProgrammeCircuit1(char value) {
|
|
||||||
String prgCircuit1 = computeProgrammeCircuitBinaryValue(value).substring(3, 5);
|
|
||||||
switch (prgCircuit1) {
|
|
||||||
case "01":
|
|
||||||
return ProgrammeCircuit1.A;
|
|
||||||
case "10":
|
|
||||||
return ProgrammeCircuit1.B;
|
|
||||||
case "11":
|
|
||||||
return ProgrammeCircuit1.C;
|
|
||||||
default:
|
|
||||||
final String error = String.format("Programme circuit 1 '%s' is unknown", prgCircuit1);
|
|
||||||
throw new IllegalStateException(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ProgrammeCircuit2 convertProgrammeCircuit2(char value) {
|
|
||||||
String prgCircuit2 = computeProgrammeCircuitBinaryValue(value).substring(5, 8);
|
|
||||||
switch (prgCircuit2) {
|
|
||||||
case "000":
|
|
||||||
return ProgrammeCircuit2.P0;
|
|
||||||
case "001":
|
|
||||||
return ProgrammeCircuit2.P1;
|
|
||||||
case "010":
|
|
||||||
return ProgrammeCircuit2.P2;
|
|
||||||
case "011":
|
|
||||||
return ProgrammeCircuit2.P3;
|
|
||||||
case "100":
|
|
||||||
return ProgrammeCircuit2.P4;
|
|
||||||
case "101":
|
|
||||||
return ProgrammeCircuit2.P5;
|
|
||||||
case "110":
|
|
||||||
return ProgrammeCircuit2.P6;
|
|
||||||
case "111":
|
|
||||||
return ProgrammeCircuit2.P7;
|
|
||||||
default:
|
|
||||||
final String error = String.format("Programme circuit 2 '%s' is unknown", prgCircuit2);
|
|
||||||
throw new IllegalStateException(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String computeProgrammeCircuitBinaryValue(char value) {
|
|
||||||
return String.format("%8s", Integer.toBinaryString(value)).replace(' ', '0');
|
|
||||||
}
|
|
||||||
|
|
||||||
private void rethrowTaskExecutionException(ExecutionException e)
|
|
||||||
throws InvalidFrameException, IOException, TimeoutException {
|
|
||||||
Throwable cause = e.getCause();
|
|
||||||
if (cause instanceof InvalidFrameException) {
|
|
||||||
throw (InvalidFrameException) cause;
|
|
||||||
} else if (cause instanceof IOException) {
|
|
||||||
throw (IOException) cause;
|
|
||||||
} else if (cause instanceof TimeoutException) {
|
|
||||||
throw (TimeoutException) cause;
|
|
||||||
} else {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.reader.io.serialport;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link ConversionException} class defines a conversion exception.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class ConversionException extends Exception {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -1109821041874271681L;
|
|
||||||
private static final String ERROR_MESSAGE = "Unable to convert '%1$s' value";
|
|
||||||
|
|
||||||
private String valueToConvert;
|
|
||||||
|
|
||||||
public ConversionException(String valueToConvert) {
|
|
||||||
this(valueToConvert, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConversionException(String valueToConvert, @Nullable Throwable cause) {
|
|
||||||
super(String.format(ERROR_MESSAGE, valueToConvert), cause);
|
|
||||||
this.valueToConvert = valueToConvert;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValueToConvert() {
|
|
||||||
return valueToConvert;
|
|
||||||
}
|
|
||||||
}
|
|
@ -26,7 +26,7 @@ public class InvalidFrameException extends Exception {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 4729529258857792922L;
|
private static final long serialVersionUID = 4729529258857792922L;
|
||||||
|
|
||||||
private Date timestamp;
|
private final Date timestamp;
|
||||||
|
|
||||||
public InvalidFrameException() {
|
public InvalidFrameException() {
|
||||||
timestamp = new Date();
|
timestamp = new Date();
|
||||||
|
@ -12,10 +12,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.teleinfo.internal.reader.io.serialport;
|
package org.openhab.binding.teleinfo.internal.reader.io.serialport;
|
||||||
|
|
||||||
|
import static org.openhab.binding.teleinfo.internal.TeleinfoBindingConstants.*;
|
||||||
|
|
||||||
|
import javax.measure.Unit;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption.CouleurDemain;
|
import org.openhab.core.library.unit.Units;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Ptec;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link Label} enum defines all Teleinfo labels and their format.
|
* The {@link Label} enum defines all Teleinfo labels and their format.
|
||||||
@ -25,56 +27,60 @@ import org.openhab.binding.teleinfo.internal.dto.common.Ptec;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public enum Label {
|
public enum Label {
|
||||||
|
|
||||||
ADCO(String.class, 12),
|
ADCO(ValueType.STRING, NOT_A_CHANNEL, Units.ONE),
|
||||||
OPTARIF(String.class, 4),
|
OPTARIF(ValueType.STRING, NOT_A_CHANNEL, Units.ONE),
|
||||||
BASE(Integer.class, 9),
|
BASE(ValueType.INTEGER, CHANNEL_BASE_FRAME_BASE, Units.WATT_HOUR),
|
||||||
HCHC(Integer.class, 9),
|
HCHC(ValueType.INTEGER, CHANNEL_HC_FRAME_HCHC, Units.WATT_HOUR),
|
||||||
HCHP(Integer.class, 9),
|
HCHP(ValueType.INTEGER, CHANNEL_HC_FRAME_HCHP, Units.WATT_HOUR),
|
||||||
EJPHN(Integer.class, 9),
|
EJPHN(ValueType.INTEGER, CHANNEL_EJP_FRAME_EJPHN, Units.WATT_HOUR),
|
||||||
EJPHPM(Integer.class, 9),
|
EJPHPM(ValueType.INTEGER, CHANNEL_EJP_FRAME_EJPHN, Units.WATT_HOUR),
|
||||||
GAZ(Integer.class, 7),
|
PTEC(ValueType.STRING, CHANNEL_PTEC, Units.ONE),
|
||||||
AUTRE(Integer.class, 7),
|
MOTDETAT(ValueType.STRING, CHANNEL_MOTDETAT, Units.AMPERE),
|
||||||
PTEC(Ptec.class, 4),
|
ISOUSC(ValueType.INTEGER, CHANNEL_ISOUSC, Units.AMPERE),
|
||||||
MOTDETAT(String.class, 6),
|
IINST(ValueType.INTEGER, CHANNEL_CBEMM_IINST, Units.AMPERE),
|
||||||
ISOUSC(Integer.class, 2),
|
IINST1(ValueType.INTEGER, CHANNEL_CBETM_IINST1, Units.AMPERE),
|
||||||
IINST(Integer.class, 3),
|
IINST2(ValueType.INTEGER, CHANNEL_CBETM_IINST2, Units.AMPERE),
|
||||||
IINST1(Integer.class, 3),
|
IINST3(ValueType.INTEGER, CHANNEL_CBETM_IINST3, Units.AMPERE),
|
||||||
IINST2(Integer.class, 3),
|
ADIR1(ValueType.INTEGER, CHANNEL_CBETM_SHORT_ADIR1, Units.AMPERE),
|
||||||
IINST3(Integer.class, 3),
|
ADIR2(ValueType.INTEGER, CHANNEL_CBETM_SHORT_ADIR2, Units.AMPERE),
|
||||||
ADIR1(Integer.class, 3),
|
ADIR3(ValueType.INTEGER, CHANNEL_CBETM_SHORT_ADIR3, Units.AMPERE),
|
||||||
ADIR2(Integer.class, 3),
|
ADPS(ValueType.INTEGER, CHANNEL_CBEMM_ADPS, Units.AMPERE),
|
||||||
ADIR3(Integer.class, 3),
|
IMAX(ValueType.INTEGER, CHANNEL_CBEMM_IMAX, Units.AMPERE),
|
||||||
ADPS(Integer.class, 3),
|
IMAX1(ValueType.INTEGER, CHANNEL_CBETM_LONG_IMAX1, Units.AMPERE),
|
||||||
IMAX(Integer.class, 3),
|
IMAX2(ValueType.INTEGER, CHANNEL_CBETM_LONG_IMAX2, Units.AMPERE),
|
||||||
IMAX1(Integer.class, 3),
|
IMAX3(ValueType.INTEGER, CHANNEL_CBETM_LONG_IMAX3, Units.AMPERE),
|
||||||
IMAX2(Integer.class, 3),
|
PMAX(ValueType.INTEGER, CHANNEL_CBETM_LONG_PMAX, Units.WATT),
|
||||||
IMAX3(Integer.class, 3),
|
HHPHC(ValueType.STRING, CHANNEL_HHPHC, Units.ONE),
|
||||||
PMAX(Integer.class, 5),
|
PPOT(ValueType.STRING, CHANNEL_CBETM_LONG_PPOT, Units.ONE),
|
||||||
PPOT(String.class, 2),
|
PAPP(ValueType.INTEGER, CHANNEL_PAPP, Units.VOLT_AMPERE),
|
||||||
HHPHC(Hhphc.class, 1),
|
BBRHCJB(ValueType.INTEGER, CHANNEL_TEMPO_FRAME_BBRHCJB, Units.WATT_HOUR),
|
||||||
PAPP(Integer.class, 5),
|
BBRHPJB(ValueType.INTEGER, CHANNEL_TEMPO_FRAME_BBRHPJB, Units.WATT_HOUR),
|
||||||
BBRHCJB(Integer.class, 9),
|
BBRHCJW(ValueType.INTEGER, CHANNEL_TEMPO_FRAME_BBRHCJW, Units.WATT_HOUR),
|
||||||
BBRHPJB(Integer.class, 9),
|
BBRHPJW(ValueType.INTEGER, CHANNEL_TEMPO_FRAME_BBRHPJW, Units.WATT_HOUR),
|
||||||
BBRHCJW(Integer.class, 9),
|
BBRHCJR(ValueType.INTEGER, CHANNEL_TEMPO_FRAME_BBRHCJR, Units.WATT_HOUR),
|
||||||
BBRHPJW(Integer.class, 9),
|
BBRHPJR(ValueType.INTEGER, CHANNEL_TEMPO_FRAME_BBRHPJR, Units.WATT_HOUR),
|
||||||
BBRHCJR(Integer.class, 9),
|
PEJP(ValueType.INTEGER, CHANNEL_EJP_FRAME_PEJP, Units.MINUTE),
|
||||||
BBRHPJR(Integer.class, 9),
|
DEMAIN(ValueType.STRING, CHANNEL_TEMPO_FRAME_DEMAIN, Units.ONE);
|
||||||
PEJP(Integer.class, 2),
|
|
||||||
DEMAIN(CouleurDemain.class, 4);
|
|
||||||
|
|
||||||
private Class<?> type;
|
private ValueType type;
|
||||||
private int size;
|
private String channelName;
|
||||||
|
private Unit<?> unit;
|
||||||
|
|
||||||
Label(Class<?> type, int size) {
|
Label(ValueType type, String channelName, Unit<?> unit) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.size = size;
|
this.channelName = channelName;
|
||||||
|
this.unit = unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<?> getType() {
|
public ValueType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public String getChannelName() {
|
||||||
return size;
|
return channelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Unit<?> getUnit() {
|
||||||
|
return unit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,24 +10,15 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: EPL-2.0
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
*/
|
*/
|
||||||
package org.openhab.binding.teleinfo.internal.dto.common;
|
package org.openhab.binding.teleinfo.internal.reader.io.serialport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link FrameHcOption} interface defines common attributes for HC option.
|
* Defines all the type of values
|
||||||
|
*
|
||||||
|
* @author Olivier MARCEAU - Initial contribution
|
||||||
*
|
*
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
*/
|
||||||
public interface FrameHcOption {
|
public enum ValueType {
|
||||||
|
INTEGER,
|
||||||
int getHchc();
|
STRING
|
||||||
|
|
||||||
void setHchc(int hchc);
|
|
||||||
|
|
||||||
int getHchp();
|
|
||||||
|
|
||||||
void setHchp(int hchp);
|
|
||||||
|
|
||||||
Hhphc getHhphc();
|
|
||||||
|
|
||||||
void setHhphc(Hhphc hhphc);
|
|
||||||
}
|
}
|
@ -1,28 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.reader.io.serialport.converter;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link Converter} interface defines a converter to translate a Teleinfo String value into Java object.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public interface Converter {
|
|
||||||
|
|
||||||
public @Nullable Object convert(String value) throws ConversionException;
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.reader.io.serialport.converter;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption.CouleurDemain;
|
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link CouleurDemainConverter} class defines a converter to translate a Teleinfo String value into
|
|
||||||
* {@link org.openhab.binding.teleinfo.internal.dto.common.Ptec} object.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class CouleurDemainConverter implements Converter {
|
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(CouleurDemainConverter.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Object convert(String value) throws ConversionException {
|
|
||||||
logger.debug("convert(String) [start]");
|
|
||||||
if (logger.isTraceEnabled()) {
|
|
||||||
logger.trace("value = {}", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
CouleurDemain convertedValue = null;
|
|
||||||
switch (value) {
|
|
||||||
case "----":
|
|
||||||
// convertedValue = null;
|
|
||||||
break;
|
|
||||||
case "BLEU":
|
|
||||||
convertedValue = CouleurDemain.Bleu;
|
|
||||||
break;
|
|
||||||
case "BLAN":
|
|
||||||
convertedValue = CouleurDemain.Blanc;
|
|
||||||
break;
|
|
||||||
case "ROUG":
|
|
||||||
convertedValue = CouleurDemain.Rouge;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ConversionException(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug("convert(String) [end]");
|
|
||||||
return convertedValue;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.reader.io.serialport.converter;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link FloatConverter} class defines a converter to translate a Teleinfo String value into Float object.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class FloatConverter implements Converter {
|
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(FloatConverter.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Object convert(String value) throws ConversionException {
|
|
||||||
logger.debug("convert(String) [start]");
|
|
||||||
if (logger.isTraceEnabled()) {
|
|
||||||
logger.trace("value = {}", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
Object convertedValue = null;
|
|
||||||
try {
|
|
||||||
convertedValue = Float.parseFloat(value);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
throw new ConversionException(value, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug("convert(String) [end]");
|
|
||||||
return convertedValue;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.reader.io.serialport.converter;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
|
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link HhphcConverter} class defines a converter to translate a Teleinfo String value into
|
|
||||||
* {@link Hhphc} object.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class HhphcConverter implements Converter {
|
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(HhphcConverter.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Object convert(String value) throws ConversionException {
|
|
||||||
logger.debug("convert(String) [start]");
|
|
||||||
if (logger.isTraceEnabled()) {
|
|
||||||
logger.trace("value = {}", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
Hhphc convertedValue = null;
|
|
||||||
switch (value) {
|
|
||||||
case "A":
|
|
||||||
convertedValue = Hhphc.A;
|
|
||||||
break;
|
|
||||||
case "C":
|
|
||||||
convertedValue = Hhphc.C;
|
|
||||||
break;
|
|
||||||
case "D":
|
|
||||||
convertedValue = Hhphc.D;
|
|
||||||
break;
|
|
||||||
case "E":
|
|
||||||
convertedValue = Hhphc.E;
|
|
||||||
break;
|
|
||||||
case "Y":
|
|
||||||
convertedValue = Hhphc.Y;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ConversionException(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug("convert(String) [end]");
|
|
||||||
return convertedValue;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.reader.io.serialport.converter;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link IntegerConverter} class defines a converter to translate a Teleinfo String value into Integer object.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class IntegerConverter implements Converter {
|
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(IntegerConverter.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Object convert(String value) throws ConversionException {
|
|
||||||
logger.debug("convert(String) [start]");
|
|
||||||
if (logger.isTraceEnabled()) {
|
|
||||||
logger.trace("value = {}", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
Object convertedValue = null;
|
|
||||||
try {
|
|
||||||
convertedValue = Integer.parseInt(value, 10);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
throw new ConversionException(value, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug("convert(String) [end]");
|
|
||||||
return convertedValue;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.reader.io.serialport.converter;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Ptec;
|
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link PtecConverter} class defines a converter to translate a Teleinfo String value into
|
|
||||||
* {@link Ptec} object.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class PtecConverter implements Converter {
|
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(PtecConverter.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Object convert(String value) throws ConversionException {
|
|
||||||
logger.debug("convert(String) [start]");
|
|
||||||
if (logger.isTraceEnabled()) {
|
|
||||||
logger.trace("value = {}", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ptec convertedValue = null;
|
|
||||||
switch (value) {
|
|
||||||
case "TH..":
|
|
||||||
convertedValue = Ptec.TH;
|
|
||||||
break;
|
|
||||||
case "HC..":
|
|
||||||
convertedValue = Ptec.HC;
|
|
||||||
break;
|
|
||||||
case "HP..":
|
|
||||||
convertedValue = Ptec.HP;
|
|
||||||
break;
|
|
||||||
case "HN..":
|
|
||||||
convertedValue = Ptec.HN;
|
|
||||||
break;
|
|
||||||
case "PM..":
|
|
||||||
convertedValue = Ptec.PM;
|
|
||||||
break;
|
|
||||||
case "HCJB":
|
|
||||||
convertedValue = Ptec.HCJB;
|
|
||||||
break;
|
|
||||||
case "HCJW":
|
|
||||||
convertedValue = Ptec.HCJW;
|
|
||||||
break;
|
|
||||||
case "HCJR":
|
|
||||||
convertedValue = Ptec.HCJR;
|
|
||||||
break;
|
|
||||||
case "HPJB":
|
|
||||||
convertedValue = Ptec.HPJB;
|
|
||||||
break;
|
|
||||||
case "HPJW":
|
|
||||||
convertedValue = Ptec.HPJW;
|
|
||||||
break;
|
|
||||||
case "HPJR":
|
|
||||||
convertedValue = Ptec.HPJR;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ConversionException(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug("convert(String) [end]");
|
|
||||||
return convertedValue;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010-2021 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.teleinfo.internal.reader.io.serialport.converter;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.ConversionException;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link StringConverter} class defines a converter to translate a Teleinfo String value into String object.
|
|
||||||
*
|
|
||||||
* @author Nicolas SIBERIL - Initial contribution
|
|
||||||
*/
|
|
||||||
@NonNullByDefault
|
|
||||||
public class StringConverter implements Converter {
|
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(StringConverter.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Object convert(String value) throws ConversionException {
|
|
||||||
logger.debug("convert(String) [start]");
|
|
||||||
if (logger.isTraceEnabled()) {
|
|
||||||
logger.trace("value = {}", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug("convert(String) [end]");
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,12 +13,10 @@
|
|||||||
package org.openhab.binding.teleinfo.internal.serial;
|
package org.openhab.binding.teleinfo.internal.serial;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
import org.openhab.binding.teleinfo.internal.data.Frame;
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.TeleinfoInputStream;
|
import org.openhab.binding.teleinfo.internal.reader.io.TeleinfoInputStream;
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameException;
|
import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameException;
|
||||||
import org.openhab.core.io.transport.serial.SerialPort;
|
import org.openhab.core.io.transport.serial.SerialPort;
|
||||||
@ -33,52 +31,35 @@ import org.slf4j.LoggerFactory;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class TeleinfoReceiveThread extends Thread {
|
public class TeleinfoReceiveThread extends Thread {
|
||||||
|
|
||||||
private static final int SERIAL_PORT_DELAY_RETRY_IN_SECONDS = 60;
|
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(TeleinfoReceiveThread.class);
|
private final Logger logger = LoggerFactory.getLogger(TeleinfoReceiveThread.class);
|
||||||
|
|
||||||
private SerialPort serialPort;
|
private SerialPort serialPort;
|
||||||
private @Nullable TeleinfoReceiveThreadListener listener;
|
private @Nullable TeleinfoReceiveThreadListener listener;
|
||||||
private boolean autoRepairInvalidADPSgroupLine;
|
private boolean autoRepairInvalidADPSgroupLine;
|
||||||
private ExecutorService executorService;
|
|
||||||
|
|
||||||
public TeleinfoReceiveThread(SerialPort serialPort, final TeleinfoSerialControllerHandler listener,
|
public TeleinfoReceiveThread(SerialPort serialPort, final TeleinfoSerialControllerHandler listener,
|
||||||
boolean autoRepairInvalidADPSgroupLine, ExecutorService scheduler) {
|
boolean autoRepairInvalidADPSgroupLine) {
|
||||||
super("OH-binding-TeleinfoReceiveThread-" + listener.getThing().getUID().getId());
|
super("OH-binding-TeleinfoReceiveThread-" + listener.getThing().getUID().getId());
|
||||||
setDaemon(true);
|
setDaemon(true);
|
||||||
this.serialPort = serialPort;
|
this.serialPort = serialPort;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.autoRepairInvalidADPSgroupLine = autoRepairInvalidADPSgroupLine;
|
this.autoRepairInvalidADPSgroupLine = autoRepairInvalidADPSgroupLine;
|
||||||
this.executorService = scheduler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try (TeleinfoInputStream teleinfoStream = new TeleinfoInputStream(serialPort.getInputStream(),
|
try (TeleinfoInputStream teleinfoStream = new TeleinfoInputStream(serialPort.getInputStream(),
|
||||||
TeleinfoInputStream.DEFAULT_TIMEOUT_NEXT_HEADER_FRAME_US * 100,
|
autoRepairInvalidADPSgroupLine)) {
|
||||||
TeleinfoInputStream.DEFAULT_TIMEOUT_READING_FRAME_US * 100, autoRepairInvalidADPSgroupLine,
|
|
||||||
executorService)) {
|
|
||||||
while (!interrupted()) {
|
while (!interrupted()) {
|
||||||
TeleinfoReceiveThreadListener listener = this.listener;
|
TeleinfoReceiveThreadListener listener = this.listener;
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
try {
|
try {
|
||||||
Frame nextFrame = teleinfoStream.readNextFrame();
|
Frame nextFrame = teleinfoStream.readNextFrame();
|
||||||
if (nextFrame != null)
|
if (nextFrame != null)
|
||||||
listener.onFrameReceived(this, nextFrame);
|
listener.onFrameReceived(nextFrame);
|
||||||
} catch (InvalidFrameException e) {
|
} catch (InvalidFrameException e) {
|
||||||
logger.warn("Got invalid frame. Detail: \"{}\"", e.getLocalizedMessage());
|
logger.warn("Got invalid frame. Detail: \"{}\"", e.getLocalizedMessage());
|
||||||
listener.onInvalidFrameReceived(this, e);
|
listener.onInvalidFrameReceived(this, e);
|
||||||
} catch (TimeoutException e) {
|
|
||||||
logger.warn("Got timeout during frame reading", e);
|
|
||||||
logger.warn("Retry in progress. Next retry in {} seconds...",
|
|
||||||
SERIAL_PORT_DELAY_RETRY_IN_SECONDS);
|
|
||||||
listener.continueOnReadNextFrameTimeoutException();
|
|
||||||
try {
|
|
||||||
Thread.sleep(SERIAL_PORT_DELAY_RETRY_IN_SECONDS * 1000);
|
|
||||||
} catch (InterruptedException e1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Got I/O exception. Detail: \"{}\"", e.getLocalizedMessage(), e);
|
logger.warn("Got I/O exception. Detail: \"{}\"", e.getLocalizedMessage(), e);
|
||||||
listener.onSerialPortInputStreamIOException(this, e);
|
listener.onSerialPortInputStreamIOException(this, e);
|
||||||
|
@ -15,7 +15,7 @@ package org.openhab.binding.teleinfo.internal.serial;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
import org.openhab.binding.teleinfo.internal.data.Frame;
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameException;
|
import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,7 +26,7 @@ import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameEx
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public interface TeleinfoReceiveThreadListener {
|
public interface TeleinfoReceiveThreadListener {
|
||||||
|
|
||||||
void onFrameReceived(final TeleinfoReceiveThread receiveThread, final Frame frame);
|
void onFrameReceived(final Frame frame);
|
||||||
|
|
||||||
void onInvalidFrameReceived(final TeleinfoReceiveThread receiveThread, final InvalidFrameException error);
|
void onInvalidFrameReceived(final TeleinfoReceiveThread receiveThread, final InvalidFrameException error);
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
import org.openhab.binding.teleinfo.internal.data.Frame;
|
||||||
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler;
|
||||||
import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameException;
|
import org.openhab.binding.teleinfo.internal.reader.io.serialport.InvalidFrameException;
|
||||||
import org.openhab.core.io.transport.serial.PortInUseException;
|
import org.openhab.core.io.transport.serial.PortInUseException;
|
||||||
@ -103,7 +103,7 @@ public class TeleinfoSerialControllerHandler extends TeleinfoAbstractControllerH
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFrameReceived(TeleinfoReceiveThread receiveThread, Frame frame) {
|
public void onFrameReceived(Frame frame) {
|
||||||
updateStatus(ThingStatus.ONLINE);
|
updateStatus(ThingStatus.ONLINE);
|
||||||
fireOnFrameReceivedEvent(frame);
|
fireOnFrameReceivedEvent(frame);
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ public class TeleinfoSerialControllerHandler extends TeleinfoAbstractControllerH
|
|||||||
}
|
}
|
||||||
logger.debug("Starting receive thread");
|
logger.debug("Starting receive thread");
|
||||||
TeleinfoReceiveThread receiveThread = new TeleinfoReceiveThread(commPort, this,
|
TeleinfoReceiveThread receiveThread = new TeleinfoReceiveThread(commPort, this,
|
||||||
config.autoRepairInvalidADPSgroupLine, scheduler);
|
config.autoRepairInvalidADPSgroupLine);
|
||||||
this.receiveThread = receiveThread;
|
this.receiveThread = receiveThread;
|
||||||
receiveThread.start();
|
receiveThread.start();
|
||||||
|
|
||||||
|
@ -18,16 +18,9 @@ import java.io.FileInputStream;
|
|||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.Frame;
|
import org.openhab.binding.teleinfo.internal.data.Frame;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccBaseOption;
|
import org.openhab.binding.teleinfo.internal.data.FrameType;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccHcOption;
|
import org.openhab.binding.teleinfo.internal.reader.io.serialport.Label;
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIccTempoOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongBaseOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.cbetm.FrameCbetmLongEjpOption;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption.ProgrammeCircuit1;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption.ProgrammeCircuit2;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Hhphc;
|
|
||||||
import org.openhab.binding.teleinfo.internal.dto.common.Ptec;
|
|
||||||
import org.openhab.binding.teleinfo.util.TestUtils;
|
import org.openhab.binding.teleinfo.util.TestUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,144 +29,134 @@ import org.openhab.binding.teleinfo.util.TestUtils;
|
|||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class TeleinfoInputStreamTest {
|
public class TeleinfoInputStreamTest {
|
||||||
private static final int TIMEOUT_US = 5000000;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadNextFrameCbetmBase1() throws Exception {
|
public void testReadNextFrameCbetmBase1() throws Exception {
|
||||||
try (TeleinfoInputStream in = new TeleinfoInputStream(
|
try (TeleinfoInputStream in = new TeleinfoInputStream(
|
||||||
new FileInputStream(TestUtils.getTestFile("cbetm-base-option-1.raw")), TIMEOUT_US, TIMEOUT_US, false)) {
|
new FileInputStream(TestUtils.getTestFile("cbetm-base-option-1.raw")), false)) {
|
||||||
Frame frame = in.readNextFrame();
|
Frame frame = in.readNextFrame();
|
||||||
|
|
||||||
assertNotNull(frame);
|
assertNotNull(frame);
|
||||||
assertEquals(FrameCbetmLongBaseOption.class, frame.getClass());
|
assertEquals(FrameType.CBETM_LONG_BASE, frame.getType());
|
||||||
FrameCbetmLongBaseOption frameCbetmLongBaseOption = (FrameCbetmLongBaseOption) frame;
|
assertEquals("XXXXXXXXXXXX", frame.get(Label.ADCO));
|
||||||
assertEquals("XXXXXXXXXXXX", frameCbetmLongBaseOption.getAdco());
|
assertEquals(20, frame.getAsInt(Label.ISOUSC));
|
||||||
assertEquals(20, frameCbetmLongBaseOption.getIsousc());
|
assertEquals(1181243, frame.getAsInt(Label.BASE));
|
||||||
assertEquals(1181243, frameCbetmLongBaseOption.getBase());
|
assertEquals("TH..", frame.get(Label.PTEC));
|
||||||
assertEquals(Ptec.TH, frameCbetmLongBaseOption.getPtec());
|
assertEquals(0, frame.getAsInt(Label.IINST1));
|
||||||
assertEquals(0, frameCbetmLongBaseOption.getIinst1());
|
assertEquals(2, frame.getAsInt(Label.IINST2));
|
||||||
assertEquals(2, frameCbetmLongBaseOption.getIinst2());
|
assertEquals(0, frame.getAsInt(Label.IINST3));
|
||||||
assertEquals(0, frameCbetmLongBaseOption.getIinst3());
|
assertEquals(26, frame.getAsInt(Label.IMAX1));
|
||||||
assertEquals(26, frameCbetmLongBaseOption.getImax1().intValue());
|
assertEquals(18, frame.getAsInt(Label.IMAX2));
|
||||||
assertEquals(18, frameCbetmLongBaseOption.getImax2().intValue());
|
assertEquals(27, frame.getAsInt(Label.IMAX3));
|
||||||
assertEquals(27, frameCbetmLongBaseOption.getImax3().intValue());
|
assertEquals(7990, frame.getAsInt(Label.PMAX));
|
||||||
assertEquals(7990, frameCbetmLongBaseOption.getPmax());
|
assertEquals(540, frame.getAsInt(Label.PAPP));
|
||||||
assertEquals(540, frameCbetmLongBaseOption.getPapp());
|
assertEquals("00", frame.get(Label.PPOT));
|
||||||
assertEquals("00", frameCbetmLongBaseOption.getPpot());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadNextFrameCbemmEvoIccHc1() throws Exception {
|
public void testReadNextFrameCbemmEvoIccHc1() throws Exception {
|
||||||
try (TeleinfoInputStream in = new TeleinfoInputStream(
|
try (TeleinfoInputStream in = new TeleinfoInputStream(
|
||||||
new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-hc-option-1.raw")), TIMEOUT_US, TIMEOUT_US,
|
new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-hc-option-1.raw")), false)) {
|
||||||
false)) {
|
|
||||||
Frame frame = in.readNextFrame();
|
Frame frame = in.readNextFrame();
|
||||||
|
|
||||||
assertNotNull(frame);
|
assertNotNull(frame);
|
||||||
assertEquals(FrameCbemmEvolutionIccHcOption.class, frame.getClass());
|
assertEquals(FrameType.CBEMM_ICC_HC, frame.getType());
|
||||||
FrameCbemmEvolutionIccHcOption frameCbemmEvolutionIccHcOption = (FrameCbemmEvolutionIccHcOption) frame;
|
assertEquals("XXXXXXXXXXXX", frame.get(Label.ADCO));
|
||||||
assertEquals("XXXXXXXXXXXX", frameCbemmEvolutionIccHcOption.getAdco());
|
assertEquals(30, frame.getAsInt(Label.ISOUSC));
|
||||||
assertEquals(30, frameCbemmEvolutionIccHcOption.getIsousc());
|
assertEquals(6906827, frame.getAsInt(Label.HCHC));
|
||||||
assertEquals(6906827, frameCbemmEvolutionIccHcOption.getHchc());
|
assertEquals(7617931, frame.getAsInt(Label.HCHP));
|
||||||
assertEquals(7617931, frameCbemmEvolutionIccHcOption.getHchp());
|
assertEquals("HP..", frame.get(Label.PTEC));
|
||||||
assertEquals(Ptec.HP, frameCbemmEvolutionIccHcOption.getPtec());
|
assertEquals(3, frame.getAsInt(Label.IINST));
|
||||||
assertEquals(3, frameCbemmEvolutionIccHcOption.getIinst());
|
assertEquals(44, frame.getAsInt(Label.IMAX));
|
||||||
assertEquals(44, frameCbemmEvolutionIccHcOption.getImax().intValue());
|
assertEquals(680, frame.getAsInt(Label.PAPP));
|
||||||
assertEquals(680, frameCbemmEvolutionIccHcOption.getPapp());
|
assertNull(frame.get(Label.ADPS));
|
||||||
assertNull(frameCbemmEvolutionIccHcOption.getAdps());
|
assertEquals("A", frame.get(Label.HHPHC));
|
||||||
assertEquals(Hhphc.A, frameCbemmEvolutionIccHcOption.getHhphc());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadNextFrameCbetmEjp1() throws Exception {
|
public void testReadNextFrameCbetmEjp1() throws Exception {
|
||||||
try (TeleinfoInputStream in = new TeleinfoInputStream(
|
try (TeleinfoInputStream in = new TeleinfoInputStream(
|
||||||
new FileInputStream(TestUtils.getTestFile("cbetm-ejp-option-1.raw")), TIMEOUT_US, TIMEOUT_US, false)) {
|
new FileInputStream(TestUtils.getTestFile("cbetm-ejp-option-1.raw")), false)) {
|
||||||
Frame frame = in.readNextFrame();
|
Frame frame = in.readNextFrame();
|
||||||
|
|
||||||
assertNotNull(frame);
|
assertNotNull(frame);
|
||||||
assertEquals(FrameCbetmLongEjpOption.class, frame.getClass());
|
assertEquals(FrameType.CBETM_LONG_EJP, frame.getType());
|
||||||
FrameCbetmLongEjpOption frameCbetmLongEjpOption = (FrameCbetmLongEjpOption) frame;
|
assertEquals("XXXXXXXXXX", frame.get(Label.ADCO));
|
||||||
assertEquals("XXXXXXXXXX", frameCbetmLongEjpOption.getAdco());
|
assertEquals(30, frame.getAsInt(Label.ISOUSC));
|
||||||
assertEquals(30, frameCbetmLongEjpOption.getIsousc());
|
assertEquals(1111111, frame.getAsInt(Label.EJPHN));
|
||||||
assertEquals(1111111, frameCbetmLongEjpOption.getEjphn());
|
assertEquals(2222222, frame.getAsInt(Label.EJPHPM));
|
||||||
assertEquals(2222222, frameCbetmLongEjpOption.getEjphpm());
|
assertNull(frame.get(Label.PEJP));
|
||||||
assertNull(frameCbetmLongEjpOption.getPejp());
|
assertEquals("HN..", frame.get(Label.PTEC));
|
||||||
assertEquals(Ptec.HN, frameCbetmLongEjpOption.getPtec());
|
assertEquals(10, frame.getAsInt(Label.IINST1));
|
||||||
assertEquals(10, frameCbetmLongEjpOption.getIinst1());
|
assertEquals(5, frame.getAsInt(Label.IINST2));
|
||||||
assertEquals(5, frameCbetmLongEjpOption.getIinst2());
|
assertEquals(8, frame.getAsInt(Label.IINST3));
|
||||||
assertEquals(8, frameCbetmLongEjpOption.getIinst3());
|
assertEquals(38, frame.getAsInt(Label.IMAX1));
|
||||||
assertEquals(38, frameCbetmLongEjpOption.getImax1().intValue());
|
assertEquals(42, frame.getAsInt(Label.IMAX2));
|
||||||
assertEquals(42, frameCbetmLongEjpOption.getImax2().intValue());
|
assertEquals(44, frame.getAsInt(Label.IMAX3));
|
||||||
assertEquals(44, frameCbetmLongEjpOption.getImax3().intValue());
|
assertEquals(17480, frame.getAsInt(Label.PMAX));
|
||||||
assertEquals(17480, frameCbetmLongEjpOption.getPmax());
|
assertEquals(5800, frame.getAsInt(Label.PAPP));
|
||||||
assertEquals(5800, frameCbetmLongEjpOption.getPapp());
|
assertEquals("00", frame.get(Label.PPOT));
|
||||||
assertEquals("00", frameCbetmLongEjpOption.getPpot());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadNextFrameCbemmEvoIccTempo1() throws Exception {
|
public void testReadNextFrameCbemmEvoIccTempo1() throws Exception {
|
||||||
try (TeleinfoInputStream in = new TeleinfoInputStream(
|
try (TeleinfoInputStream in = new TeleinfoInputStream(
|
||||||
new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-tempo-option-1.raw")), TIMEOUT_US, TIMEOUT_US,
|
new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-tempo-option-1.raw")), false)) {
|
||||||
false)) {
|
|
||||||
Frame frame = in.readNextFrame();
|
Frame frame = in.readNextFrame();
|
||||||
|
|
||||||
assertNotNull(frame);
|
assertNotNull(frame);
|
||||||
assertEquals(FrameCbemmEvolutionIccTempoOption.class, frame.getClass());
|
assertEquals(FrameType.CBEMM_ICC_TEMPO, frame.getType());
|
||||||
FrameCbemmEvolutionIccTempoOption frameCbemmEvolutionIccTempoOption = (FrameCbemmEvolutionIccTempoOption) frame;
|
assertEquals("XXXXXXXXXXXX", frame.get(Label.ADCO));
|
||||||
assertEquals("XXXXXXXXXXXX", frameCbemmEvolutionIccTempoOption.getAdco());
|
assertEquals(45, frame.getAsInt(Label.ISOUSC));
|
||||||
assertEquals(45, frameCbemmEvolutionIccTempoOption.getIsousc());
|
assertEquals(2697099, frame.getAsInt(Label.BBRHCJB));
|
||||||
assertEquals(2697099, frameCbemmEvolutionIccTempoOption.getBbrhcjb());
|
assertEquals(3494559, frame.getAsInt(Label.BBRHPJB));
|
||||||
assertEquals(3494559, frameCbemmEvolutionIccTempoOption.getBbrhpjb());
|
assertEquals(41241, frame.getAsInt(Label.BBRHCJW));
|
||||||
assertEquals(41241, frameCbemmEvolutionIccTempoOption.getBbrhcjw());
|
assertEquals(194168, frame.getAsInt(Label.BBRHPJW));
|
||||||
assertEquals(194168, frameCbemmEvolutionIccTempoOption.getBbrhpjw());
|
assertEquals(0, frame.getAsInt(Label.BBRHCJR));
|
||||||
assertEquals(0, frameCbemmEvolutionIccTempoOption.getBbrhcjr());
|
assertEquals(89736, frame.getAsInt(Label.BBRHPJR));
|
||||||
assertEquals(89736, frameCbemmEvolutionIccTempoOption.getBbrhpjr());
|
assertEquals("HPJR", frame.get(Label.PTEC));
|
||||||
assertEquals(Ptec.HPJR, frameCbemmEvolutionIccTempoOption.getPtec());
|
assertEquals("----", frame.get(Label.DEMAIN));
|
||||||
assertNull(frameCbemmEvolutionIccTempoOption.getDemain());
|
assertEquals(3, frame.getAsInt(Label.IINST));
|
||||||
assertEquals(3, frameCbemmEvolutionIccTempoOption.getIinst());
|
assertEquals(37, frame.getAsInt(Label.IMAX));
|
||||||
assertEquals(37, frameCbemmEvolutionIccTempoOption.getImax().intValue());
|
assertEquals(620, frame.getAsInt(Label.PAPP));
|
||||||
assertEquals(620, frameCbemmEvolutionIccTempoOption.getPapp());
|
assertFalse(frame.getLabelToValues().containsKey(Label.ADPS));
|
||||||
assertNull(frameCbemmEvolutionIccTempoOption.getAdps());
|
assertNull(frame.get(Label.ADPS));
|
||||||
assertEquals(Hhphc.Y, frameCbemmEvolutionIccTempoOption.getHhphc());
|
assertEquals("Y", frame.get(Label.HHPHC));
|
||||||
assertEquals(ProgrammeCircuit1.B, frameCbemmEvolutionIccTempoOption.getProgrammeCircuit1());
|
assertEquals("B", frame.getProgrammeCircuit1());
|
||||||
assertEquals(ProgrammeCircuit2.P2, frameCbemmEvolutionIccTempoOption.getProgrammeCircuit2());
|
assertEquals("P2", frame.getProgrammeCircuit2());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadNextFrameCbemmEvoIccBase1() throws Exception {
|
public void testReadNextFrameCbemmEvoIccBase1() throws Exception {
|
||||||
try (TeleinfoInputStream in = new TeleinfoInputStream(
|
try (TeleinfoInputStream in = new TeleinfoInputStream(
|
||||||
new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-base-option-1.raw")), TIMEOUT_US, TIMEOUT_US,
|
new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-base-option-1.raw")), false)) {
|
||||||
false)) {
|
|
||||||
Frame frame = in.readNextFrame();
|
Frame frame = in.readNextFrame();
|
||||||
assertNotNull(frame);
|
assertNotNull(frame);
|
||||||
assertEquals(FrameCbemmEvolutionIccBaseOption.class, frame.getClass());
|
assertEquals(FrameType.CBEMM_ICC_BASE, frame.getType());
|
||||||
FrameCbemmEvolutionIccBaseOption frameCbemmEvolutionIccBaseOption = (FrameCbemmEvolutionIccBaseOption) frame;
|
assertEquals("031762120162", frame.get(Label.ADCO));
|
||||||
assertEquals("031762120162", frameCbemmEvolutionIccBaseOption.getAdco());
|
assertEquals(30, frame.getAsInt(Label.ISOUSC));
|
||||||
assertEquals(30, frameCbemmEvolutionIccBaseOption.getIsousc());
|
assertEquals(190575, frame.getAsInt(Label.BASE));
|
||||||
assertEquals(190575, frameCbemmEvolutionIccBaseOption.getBase());
|
assertEquals("TH..", frame.get(Label.PTEC));
|
||||||
assertEquals(Ptec.TH, frameCbemmEvolutionIccBaseOption.getPtec());
|
assertEquals(1, frame.getAsInt(Label.IINST));
|
||||||
assertEquals(1, frameCbemmEvolutionIccBaseOption.getIinst());
|
assertEquals(90, frame.getAsInt(Label.IMAX));
|
||||||
assertEquals(90, frameCbemmEvolutionIccBaseOption.getImax().intValue());
|
assertEquals(270, frame.getAsInt(Label.PAPP));
|
||||||
assertEquals(270, frameCbemmEvolutionIccBaseOption.getPapp());
|
assertNull(frame.get(Label.ADPS));
|
||||||
assertNull(frameCbemmEvolutionIccBaseOption.getAdps());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvalidADPSgrouplineWithAutoRepairActivated() throws Exception {
|
public void testInvalidADPSgrouplineWithAutoRepairActivated() throws Exception {
|
||||||
try (TeleinfoInputStream in = new TeleinfoInputStream(
|
try (TeleinfoInputStream in = new TeleinfoInputStream(
|
||||||
new FileInputStream(TestUtils.getTestFile("invalid-adps-groupline.raw")), TIMEOUT_US, TIMEOUT_US,
|
new FileInputStream(TestUtils.getTestFile("invalid-adps-groupline.raw")), true)) {
|
||||||
true)) {
|
|
||||||
Frame frame = in.readNextFrame();
|
Frame frame = in.readNextFrame();
|
||||||
|
|
||||||
assertNotNull(frame);
|
assertNotNull(frame);
|
||||||
assertEquals(FrameCbemmEvolutionIccBaseOption.class, frame.getClass());
|
assertEquals(Frame.class, frame.getClass());
|
||||||
FrameCbemmEvolutionIccBaseOption frameCbemmEvolutionIccBaseOption = (FrameCbemmEvolutionIccBaseOption) frame;
|
assertEquals(37, frame.getAsInt(Label.ADPS));
|
||||||
assertEquals(37, frameCbemmEvolutionIccBaseOption.getAdps().intValue());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user