Apply previous state when receiving only accumulated values from meter

This commit is contained in:
Gunnar Skjold 2023-09-05 08:57:15 +02:00
parent b435f0eaaf
commit bcea9698dd
3 changed files with 17 additions and 5 deletions

View File

@ -1187,7 +1187,12 @@ bool readHanPort() {
// Rudimentary detector for L&G proprietary format, this is terrible code... Fix later
if(payload[0] == CosemTypeStructure && payload[2] == CosemTypeArray && payload[1] == payload[3]) {
debugV_P(PSTR("LNG"));
data = new LNG(payload, meterState.getMeterType(), &meterConfig, ctx, &Debug);
LNG lngData = LNG(payload, meterState.getMeterType(), &meterConfig, ctx, &Debug);
if(lngData.getListType() >= 3) {
data = new AmsData();
data->apply(meterState);
data->apply(lngData);
}
} else if(payload[0] == CosemTypeStructure &&
payload[2] == CosemTypeLongUnsigned &&
payload[5] == CosemTypeLongUnsigned &&
@ -1197,11 +1202,16 @@ bool readHanPort() {
payload[17] == CosemTypeLongUnsigned
) {
debugV_P(PSTR("LNG2"));
data = new LNG2(payload, meterState.getMeterType(), &meterConfig, ctx, &Debug);
LNG2 lngData = LNG2(payload, meterState.getMeterType(), &meterConfig, ctx, &Debug);
if(lngData.getListType() >= 3) {
data = new AmsData();
data->apply(meterState);
data->apply(lngData);
}
} else {
debugV_P(PSTR("DLMS"));
// TODO: Split IEC6205675 into DataParserKaifa and DataParserObis. This way we can add other means of parsing, for those other proprietary formats
data = new IEC6205675(payload, meterState.getMeterType(), &meterConfig, ctx);
data = new IEC6205675(payload, meterState.getMeterType(), &meterConfig, ctx, meterState);
}
} else if(ctx.type == DATA_TAG_DSMR) {
data = new IEC6205621(payload, tz);

View File

@ -4,7 +4,7 @@
#include "ntohll.h"
#include "Uptime.h"
IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, MeterConfig* meterConfig, DataParserContext &ctx) {
IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, MeterConfig* meterConfig, DataParserContext &ctx, AmsData &state) {
float val;
char str[64];
@ -184,6 +184,8 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, MeterConfig* meterCo
lastUpdateMillis = millis64();
} else if(data->base.length == 0x0C) {
apply(state);
listType = 3;
idx += 4;

View File

@ -15,7 +15,7 @@ struct AmsOctetTimestamp {
class IEC6205675 : public AmsData {
public:
IEC6205675(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, DataParserContext &ctx);
IEC6205675(const char* payload, uint8_t useMeterType, MeterConfig* meterConfig, DataParserContext &ctx, AmsData &state);
private:
CosemData* getCosemDataAt(uint8_t index, const char* ptr);