Refactor driver ev200.

pull/609/head
Fredrik Öhrström 2022-09-10 19:17:06 +02:00
rodzic 9ab034bff3
commit 173124c50e
4 zmienionych plików z 1 dodań i 112 usunięć

Wyświetl plik

@ -215,7 +215,7 @@ telegram=|9E44C5147956341200047A7B0090052F2F_046D25248A2B04063D1F000001FD1700041
# Test Elster V200H water meter
telegram=|2E449215303099990D077AB50820452F2F_0C12495849004C12557545000FB10445007022C50BFFFFFFFF0000FFF000|
{"media":"water","meter":"ev200","name":"Voda","id":"99993030","total_m3":49.5849,"target_m3":45.7555,"timestamp":"1111-11-11T11:11:11Z"}
|Voda;99993030;49.584900;45.755500;1111-11-11 11:11.11
|Voda;99993030;49.5849;45.7555;1111-11-11 11:11.11
# Test Elster Merlin 868 radio attachement
telegram=|2E4492159293949511377ABE0020252F2F_04135515000004FD971D80800000441300000000426C000002FDFD02B300|

Wyświetl plik

@ -43,7 +43,6 @@
X(ESYSWM, MANUFACTURER_ESY, 0x37, 0x30) \
X(EM24, MANUFACTURER_KAM, 0x02, 0x33) \
X(EMERLIN868,MANUFACTURER_ELR, 0x37, 0x11) \
X(EV200, MANUFACTURER_ELR, 0x07, 0x0d) \
X(EVO868, MANUFACTURER_MAD, 0x07, 0x50) \
X(FHKVDATAIII,MANUFACTURER_TCH, 0x80, 0x69) \
X(FHKVDATAIII,MANUFACTURER_TCH, 0x80, 0x94) \

Wyświetl plik

@ -1,109 +0,0 @@
/*
Copyright (C) 2017-2020 Fredrik Öhrström (gpl-3.0-or-later)
Copyright (C) 2018 David Mallon (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"
using namespace std;
struct MeterEV200 : public virtual MeterCommonImplementation {
MeterEV200(MeterInfo &mi);
// Total water counted through the meter
double totalWaterConsumption(Unit u);
bool hasTotalWaterConsumption();
double targetWaterConsumption(Unit u);
bool hasTargetWaterConsumption();
private:
void processContent(Telegram *t);
double actual_total_water_consumption_m3_ {};
double last_total_water_consumption_m3h_ {};
};
MeterEV200::MeterEV200(MeterInfo &mi) :
MeterCommonImplementation(mi, "ev200")
{
setMeterType(MeterType::WaterMeter);
setExpectedTPLSecurityMode(TPLSecurityMode::AES_CBC_IV);
addLinkMode(LinkMode::T1);
// version 0x68
// version 0x7c Sensus 640
addPrint("total", Quantity::Volume,
[&](Unit u){ return totalWaterConsumption(u); },
"The total water consumption recorded by this meter.",
PrintProperty::FIELD | PrintProperty::JSON);
addPrint("target", Quantity::Volume,
[&](Unit u){ return targetWaterConsumption(u); },
"The target water consumption recorded at previous period.",
PrintProperty::FIELD | PrintProperty::JSON);
}
shared_ptr<Meter> createEV200(MeterInfo &mi)
{
return shared_ptr<Meter>(new MeterEV200(mi));
}
void MeterEV200::processContent(Telegram *t)
{
int offset;
string key;
if(findKey(MeasurementType::Instantaneous, VIFRange::Volume, 0, 0, &key, &t->dv_entries)) {
extractDVdouble(&t->dv_entries, key, &offset, &actual_total_water_consumption_m3_);
t->addMoreExplanation(offset, " actual total consumption (%f m3)", actual_total_water_consumption_m3_);
}
if(findKey(MeasurementType::Instantaneous, VIFRange::Volume, 1, 0, &key, &t->dv_entries)) {
extractDVdouble(&t->dv_entries, key, &offset, &last_total_water_consumption_m3h_);
t->addMoreExplanation(offset, " last total consumption (%f m3)", last_total_water_consumption_m3h_);
}
}
double MeterEV200::totalWaterConsumption(Unit u)
{
assertQuantity(u, Quantity::Volume);
return convert(actual_total_water_consumption_m3_, Unit::M3, u);
}
bool MeterEV200::hasTotalWaterConsumption()
{
return true;
}
double MeterEV200::targetWaterConsumption(Unit u)
{
assertQuantity(u, Quantity::Volume);
return convert(last_total_water_consumption_m3h_, Unit::M3, u);
}
bool MeterEV200::hasTargetWaterConsumption()
{
return true;
}

Wyświetl plik

@ -70,7 +70,6 @@ LIST_OF_METER_TYPES
X(esyswm, T1_bit, ElectricityMeter, ESYSWM, ESYSWM) \
X(em24, C1_bit, ElectricityMeter, EM24, EM24) \
X(emerlin868, T1_bit, WaterMeter, EMERLIN868, EMerlin868) \
X(ev200, T1_bit, WaterMeter, EV200, EV200) \
X(evo868, T1_bit, WaterMeter, EVO868, EVO868) \
X(fhkvdataiii,T1_bit, HeatCostAllocationMeter, FHKVDATAIII, FHKVDataIII) \
X(fhkvdataiv, T1_bit, HeatCostAllocationMeter, FHKVDATAIV, FHKVDataIV) \