[smartmeter] Fix trying to create channels from invalid data (#10008)
Fixes #6762 * Fix Unit tests The method was used to create the pattern for a regex and for building the channel id. I ave separated them now. At least the tests are green ;) Signed-off-by: Stefan Triller <github@stefantriller.de>pull/10046/head
parent
570f86d043
commit
bc5ffb26e2
|
@ -36,14 +36,18 @@ public class SmartMeterBindingConstants {
|
||||||
public static final String CONFIGURATION_CONVERSION = "conversionRatio";
|
public static final String CONFIGURATION_CONVERSION = "conversionRatio";
|
||||||
public static final String CONFIGURATION_CHANNEL_NEGATE = "negate";
|
public static final String CONFIGURATION_CHANNEL_NEGATE = "negate";
|
||||||
public static final String CHANNEL_PROPERTY_OBIS = "obis";
|
public static final String CHANNEL_PROPERTY_OBIS = "obis";
|
||||||
public static final String OBIS_PATTERN_CHANNELID = getObisChannelId(ObisCode.OBIS_PATTERN);
|
public static final String OBIS_PATTERN_CHANNELID = getObisChannelIdPattern(ObisCode.OBIS_PATTERN);
|
||||||
/** Obis format */
|
/** Obis format */
|
||||||
public static final String OBIS_FORMAT_MINIMAL = "%d-%d:%d.%d.%d";
|
public static final String OBIS_FORMAT_MINIMAL = "%d-%d:%d.%d.%d";
|
||||||
/** Obis format */
|
/** Obis format */
|
||||||
public static final String OBIS_FORMAT = OBIS_FORMAT_MINIMAL + "*%d";
|
public static final String OBIS_FORMAT = OBIS_FORMAT_MINIMAL + "*%d";
|
||||||
public static final String CHANNEL_TYPE_METERREADER_OBIS = "channel-type:" + BINDING_ID + ":obis";
|
public static final String CHANNEL_TYPE_METERREADER_OBIS = "channel-type:" + BINDING_ID + ":obis";
|
||||||
|
|
||||||
public static String getObisChannelId(String obis) {
|
public static String getObisChannelIdPattern(String obis) {
|
||||||
return obis.replaceAll("\\.", "-").replaceAll(":|\\*", "_");
|
return obis.replaceAll("\\.", "-").replaceAll(":|\\*", "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getObisChannelId(String obis) {
|
||||||
|
return getObisChannelIdPattern(obis).replaceAll("[^\\w-]", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,7 @@ public class Iec62056_21SerialConnector extends ConnectorBase<DataMessage> {
|
||||||
@Override
|
@Override
|
||||||
public void newDataMessage(@Nullable DataMessage dataMessage) {
|
public void newDataMessage(@Nullable DataMessage dataMessage) {
|
||||||
logger.debug("Datamessage read: {}", dataMessage);
|
logger.debug("Datamessage read: {}", dataMessage);
|
||||||
|
emitter.onError(new IllegalArgumentException("Error while emitting dataMessage"));
|
||||||
emitter.onNext(dataMessage);
|
emitter.onNext(dataMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue