Refactored driver lse_08 to new format.

pull/708/head
Fredrik Öhrström 2022-11-26 23:05:37 +01:00
rodzic df9403696f
commit d925a6869c
7 zmienionych plików z 136 dodań i 141 usunięć

Wyświetl plik

@ -8,8 +8,8 @@ telegram=|244465323251839134087a4f0000000b6e0403004b6e660300426c9e29326cffff046d
# Test another HCA from Qundis
telegram=|294465324185990401087a0080000082046c7f018b046e210300046d1a0e6f0202fdac7e012301fd0c01|
{"media":"heat cost allocation","meter":"lse_08","name":"HCA2","id":"04998541","set_date":"2003-01-31","consumption_at_set_date_hca":321,"device_date_time":"2003-02-15 14:26","duration_since_readout_h":2.489167,"software_version":"1","timestamp":"1111-11-11T11:11:11Z"}
|HCA2;04998541;2003-01-31;321.000000;1111-11-11 11:11.11
{"media":"heat cost allocation","meter":"lse_08","name":"HCA2","id":"04998541","status":"TPL_MFCT_80","set_date":"2003-01-31","consumption_at_set_date_hca":321,"device_date_time":"2003-02-15 14:26","duration_since_readout_h":2.489167,"model_version":"01","timestamp":"1111-11-11T11:11:11Z"}
|HCA2;04998541;2003-01-31;321;1111-11-11 11:11.11
# Test Qundis QWater5.5 S1 meter.

Wyświetl plik

@ -0,0 +1,132 @@
/*
Copyright (C) 2019-2022 Fredrik Öhrström (gpl-3.0-or-later)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include"meters_common_implementation.h"
namespace
{
struct Driver : public virtual MeterCommonImplementation
{
Driver(MeterInfo &mi, DriverInfo &di);
};
static bool ok = registerDriver([](DriverInfo&di)
{
di.setName("lse_08");
di.setDefaultFields("name,id,set_date,consumption_at_set_date_hca,timestamp");
di.setMeterType(MeterType::HeatCostAllocationMeter);
di.addLinkMode(LinkMode::C1);
di.addLinkMode(LinkMode::T1);
di.addLinkMode(LinkMode::S1);
di.addDetection(MANUFACTURER_LSE, 0x08, 0x01);
di.setConstructor([](MeterInfo& mi, DriverInfo& di){ return shared_ptr<Meter>(new Driver(mi, di)); });
});
Driver::Driver(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di)
{
addStringFieldWithExtractorAndLookup(
"status",
"Meter status from tpl status field.",
PrintProperty::JSON | PrintProperty::FIELD | PrintProperty::IMPORTANT |
PrintProperty::STATUS | PrintProperty::JOIN_TPL_STATUS,
FieldMatcher::build()
.set(DifVifKey("01FD73")),
Translate::Lookup(
{
{
{
"ERROR_FLAGS",
Translate::Type::BitToString,
0xff,
"OK",
{
// Bits unknown
}
},
},
}));
addNumericFieldWithExtractor(
"current_consumption",
"The current heat cost allocation.",
PrintProperty::JSON | PrintProperty::OPTIONAL,
Quantity::HCA,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::HeatCostAllocation)
);
addStringFieldWithExtractor(
"set_date",
"The most recent billing period date.",
PrintProperty::JSON | PrintProperty::FIELD,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::Date)
.set(StorageNr(8))
);
addNumericFieldWithExtractor(
"consumption_at_set_date",
"Heat cost allocation at the most recent billing period date.",
PrintProperty::JSON | PrintProperty::FIELD,
Quantity::HCA,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::HeatCostAllocation)
.set(StorageNr(8))
);
addStringFieldWithExtractor(
"device_date_time",
"Date and time when the meter sent the telegram.",
PrintProperty::JSON,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::DateTime)
);
addNumericFieldWithExtractor(
"duration_since_readout",
"Duration since last measurement.",
PrintProperty::JSON,
Quantity::Time,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::DurationSinceReadout)
.add(VIFCombinable::FutureValue)
);
addStringFieldWithExtractor(
"model_version",
"model version.",
PrintProperty::JSON | PrintProperty::OPTIONAL,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::ModelVersion)
);
}
}
// Test: HCA2 qcaloric 04998541 NOKEY
// telegram=|294465324185990401087a0080000082046c7f018b046e210300046d1a0e6f0202fdac7e012301fd0c01|
// {"media":"heat cost allocation","meter":"lse_08","name":"HCA2","id":"04998541","status":"TPL_MFCT_80","set_date":"2003-01-31","consumption_at_set_date_hca":321,"device_date_time":"2003-02-15 14:26","duration_since_readout_h":2.489167,"model_version":"01","timestamp":"1111-11-11T11:11:11Z"}
// |HCA2;04998541;2003-01-31;321;1111-11-11 11:11.11

Wyświetl plik

@ -27,6 +27,7 @@ namespace
static bool ok = registerDriver([](DriverInfo&di)
{
di.setName("qcaloric");
di.addNameAlias("lse_08");
di.addNameAlias("whe5x");
di.addNameAlias("whe46x");
di.setDefaultFields("name,id,current_consumption_hca,set_date,consumption_at_set_date_hca,timestamp");
@ -207,7 +208,6 @@ namespace
}
}
// Test: MyElement qcaloric 78563412 NOKEY
// telegram=|314493441234567835087a740000200b6e2701004b6e450100426c5f2ccb086e790000c2086c7f21326cffff046d200b7422|
// {"media":"heat cost allocation","meter":"qcaloric","name":"MyElement","id":"78563412","status":"OK","current_consumption_hca":127,"set_date":"2018-12-31","consumption_at_set_date_hca":145,"set_date_1":"2018-12-31","consumption_at_set_date_1_hca":145,"set_date_17":"2019-01-31","consumption_at_set_date_17_hca":79,"error_date":"2127-15-31","device_date_time":"2019-02-20 11:32","timestamp":"1111-11-11T11:11:11Z"}

Wyświetl plik

@ -58,6 +58,7 @@
X(Customer,0x7D11,0x7D11, Quantity::Text, Unit::TXT) \
X(ErrorFlags,0x7D17,0x7D17, Quantity::Text, Unit::TXT) \
X(DigitalInput,0x7D1B,0x7D1B, Quantity::Text, Unit::TXT) \
X(DurationSinceReadout,0x7D2c,0x7D2f, Quantity::Time, Unit::Hour) \
X(DurationOfTariff,0x7D31,0x7D33, Quantity::Time, Unit::Hour) \
X(Dimensionless,0x7D3A,0x7D3A, Quantity::Counter, Unit::COUNTER) \
X(Voltage,0x7D40,0x7D4F, Quantity::Voltage, Unit::Volt) \
@ -66,7 +67,6 @@
X(CumulationCounter,0x7D61,0x7D61, Quantity::Counter, Unit::COUNTER) \
X(SpecialSupplierInformation,0x7D67,0x7D67, Quantity::Text, Unit::TXT) \
X(RemainingBattery,0x7D74,0x7D74, Quantity::Time, Unit::Day) \
X(DurationSinceReadout,0x7DAC,0x7DAC, Quantity::Time, Unit::Hour) \
X(AnyVolumeVIF,0x00,0x00, Quantity::Volume, Unit::Unknown) \
X(AnyEnergyVIF,0x00,0x00, Quantity::Energy, Unit::Unknown) \
X(AnyPowerVIF,0x00,0x00, Quantity::Power, Unit::Unknown)

Wyświetl plik

@ -28,7 +28,6 @@
//
#define METER_DETECTION \
X(CCx01, MANUFACTURER_GSS, 0x02, 0x01) \
X(LSE_08, MANUFACTURER_LSE, 0x08, 0x01) \
X(MULTICAL302,MANUFACTURER_KAM, 0x04, 0x30) \
X(MULTICAL302,MANUFACTURER_KAM, 0x0d, 0x30) \
X(MULTICAL302,MANUFACTURER_KAM, 0x0c, 0x30) \

Wyświetl plik

@ -1,135 +0,0 @@
/*
Copyright (C) 2019-2021 Fredrik Öhrström (gpl-3.0-or-later)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include"dvparser.h"
#include"meters.h"
#include"meters_common_implementation.h"
#include"wmbus.h"
#include"wmbus_utils.h"
struct MeterLSE_08 : public virtual MeterCommonImplementation {
MeterLSE_08(MeterInfo &mi);
string setDate();
double consumptionAtSetDate(Unit u);
private:
void processContent(Telegram *t);
double consumption_at_set_date_hca_ {};
string set_date_;
string device_date_time_;
int duration_since_readout_s_ {};
string software_version_;
};
MeterLSE_08::MeterLSE_08(MeterInfo &mi) :
MeterCommonImplementation(mi, "lse_08")
{
setMeterType(MeterType::HeatCostAllocationMeter);
setExpectedTPLSecurityMode(TPLSecurityMode::AES_CBC_IV);
addLinkMode(LinkMode::C1);
addLinkMode(LinkMode::S1);
addPrint("set_date", Quantity::Text,
[&](){ return setDate(); },
"The most recent billing period date.",
PrintProperty::FIELD | PrintProperty::JSON);
addPrint("consumption_at_set_date", Quantity::HCA,
[&](Unit u){ return consumptionAtSetDate(u); },
"Heat cost allocation at the most recent billing period date.",
PrintProperty::FIELD | PrintProperty::JSON);
addPrint("device_date_time", Quantity::Text,
[&](){ return device_date_time_; },
"Device date time.",
PrintProperty::JSON);
addPrint("duration_since_readout", Quantity::Time,
[&](Unit u) {
assertQuantity(u, Quantity::Time);
return convert(duration_since_readout_s_, Unit::Second, u);
},
"Device date time.",
PrintProperty::JSON);
addPrint("software_version", Quantity::Text,
[&](){ return software_version_; },
"Software version.",
PrintProperty::JSON);
}
shared_ptr<Meter> createLSE_08(MeterInfo &mi)
{
return shared_ptr<Meter>(new MeterLSE_08(mi));
}
string MeterLSE_08::setDate()
{
return set_date_;
}
double MeterLSE_08::consumptionAtSetDate(Unit u)
{
assertQuantity(u, Quantity::HCA);
return convert(consumption_at_set_date_hca_, Unit::HCA, u);
}
void MeterLSE_08::processContent(Telegram *t)
{
int offset;
string key;
if (findKey(MeasurementType::Instantaneous, VIFRange::HeatCostAllocation, 8, 0, &key, &t->dv_entries)) {
extractDVdouble(&t->dv_entries, key, &offset, &consumption_at_set_date_hca_);
t->addMoreExplanation(offset, " consumption at set date (%f hca)", consumption_at_set_date_hca_);
}
if (findKey(MeasurementType::Instantaneous, VIFRange::Date, 8, 0, &key, &t->dv_entries)) {
struct tm date;
extractDVdate(&t->dv_entries, key, &offset, &date);
set_date_ = strdate(&date);
t->addMoreExplanation(offset, " set date (%s)", set_date_.c_str());
}
if (findKey(MeasurementType::Instantaneous, VIFRange::DateTime, 0, 0, &key, &t->dv_entries)) {
struct tm datetime;
extractDVdate(&t->dv_entries, key, &offset, &datetime);
device_date_time_ = strdatetime(&datetime);
t->addMoreExplanation(offset, " device datetime (%s)", device_date_time_.c_str());
}
uint64_t seconds;
if (extractDVlong(&t->dv_entries, "02FDAC7E", &offset, &seconds))
{
duration_since_readout_s_ = (int)seconds;
t->addMoreExplanation(offset, " duration (%d s)", duration_since_readout_s_);
}
uint64_t serial;
if (extractDVlong(&t->dv_entries, "01FD0C", &offset, &serial))
{
// 01 --> 01
software_version_ = to_string(serial);
t->addMoreExplanation(offset, " software version (%s)", software_version_.c_str());
}
}

Wyświetl plik

@ -68,7 +68,6 @@ LIST_OF_METER_TYPES
X(multical803,C1_bit, HeatMeter, MULTICAL803, Multical803) \
X(rfmamb, T1_bit, TempHygroMeter, RFMAMB, RfmAmb) \
X(rfmtx1, T1_bit, WaterMeter, RFMTX1, RfmTX1) \
X(lse_08, S1_bit|C1_bit, HeatCostAllocationMeter, LSE_08, LSE_08) \
enum class MeterDriver {