Added support for Hydrus meter.

pull/52/head
weetmuts 2019-11-26 14:24:17 +01:00
rodzic 4af4d0e49e
commit 78d7eb55da
7 zmienionych plików z 215 dodań i 0 usunięć

Wyświetl plik

@ -105,6 +105,7 @@ METER_OBJS:=\
$(BUILD)/meter_lansenth.o \
$(BUILD)/meter_rfmamb.o \
$(BUILD)/meter_izar.o \
$(BUILD)/meter_hydrus.o \
$(BUILD)/printer.o \
$(BUILD)/serial.o \
$(BUILD)/shell.o \

Wyświetl plik

@ -176,6 +176,7 @@ Sensus iPERL (iperl)
Apator at-wmbus-16-2 (apator162) (non-standard protocol)
Techem MK Radio 3 (mkradio3) (non-standard protocol)
Diehl/Sappel IZAR RC 868 I R4 PL (izar)
Diehl HYDRUS (hydrus)
Supported heat cost allocators:
Qundis Q caloric (qcaloric)

Wyświetl plik

@ -62,3 +62,7 @@ telegram=|5744b40988227711101b7ab20800000265a00842658f088201659f08226589081265a0
# Test IZAR RC 868 I R4 PL water meter telegram
telegram=|1944304C72242421D401A2|013D4013DD8B46A4999C1293E582CC|
{"media":"water","meter":"izar","name":"IzarWater","id":"21242472","total_m3":3.488,"last_month_total_m3":3.486,"timestamp":"1111-11-11T11:11:11Z"}
# Test Hydrus water meter telegram
telegram=|4E44A5116464646470077AED004005|2F2F01FD08300C13741100007C1300000000FC101300000000FC201300000000726C00000B3B00000002FD748713025A6800C4016D3B177F2ACC011300020000|
{"media":"water","meter":"hydrus","name":"HydrusWater","id":"64646464","total_m3":1.174,"max_flow_m3h":0,"flow_temperature_c":10.4,"total_at_date_m3":0.2,"at_date":"2019-10-31 23:59","timestamp":"1111-11-11T11:11:11Z"}

203
src/meter_hydrus.cc 100644
Wyświetl plik

@ -0,0 +1,203 @@
/*
Copyright (C) 2019 Fredrik Öhrström
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 MeterHydrus : public virtual WaterMeter, public virtual MeterCommonImplementation {
MeterHydrus(WMBus *bus, MeterInfo &mi);
// Total water counted through the meter
double totalWaterConsumption(Unit u);
double totalWaterConsumptionAtDate(Unit u);
bool hasTotalWaterConsumption();
double maxFlow(Unit u);
bool hasMaxFlow();
double flowTemperature(Unit u);
private:
void processContent(Telegram *t);
double total_water_consumption_m3_ {};
double total_water_consumption_at_date_m3_ {};
string at_date_;
double max_flow_m3h_ {};
double flow_temperature_c_ { 127 };
};
MeterHydrus::MeterHydrus(WMBus *bus, MeterInfo &mi) :
MeterCommonImplementation(bus, mi, MeterType::HYDRUS, MANUFACTURER_DME)
{
setEncryptionMode(EncryptionMode::AES_CBC);
addMedia(0x07);
addLinkMode(LinkMode::T1);
setExpectedVersion(0x70);
addPrint("total", Quantity::Volume,
[&](Unit u){ return totalWaterConsumption(u); },
"The total water consumption recorded by this meter.",
true, true);
addPrint("max_flow", Quantity::Flow,
[&](Unit u){ return maxFlow(u); },
"The maxium flow recorded during previous period.",
true, true);
addPrint("flow_temperature", Quantity::Temperature,
[&](Unit u){ return flowTemperature(u); },
"The water temperature.",
true, true);
addPrint("total_at_date", Quantity::Volume,
[&](Unit u){ return totalWaterConsumptionAtDate(u); },
"The total water consumption recorded at date.",
true, true);
addPrint("at_date", Quantity::Text,
[&](){ return at_date_; },
"Date when total water consumption was recorded.",
true, true);
MeterCommonImplementation::bus()->onTelegram(calll(this,handleTelegram,Telegram*));
}
unique_ptr<WaterMeter> createHydrus(WMBus *bus, MeterInfo &mi)
{
return unique_ptr<WaterMeter>(new MeterHydrus(bus, mi));
}
void MeterHydrus::processContent(Telegram *t)
{
/*
(hydrus) 0f: 2F skip
(hydrus) 10: 2F skip
(hydrus) 11: 01 dif (8 Bit Integer/Binary Instantaneous value)
(hydrus) 12: FD vif (Second extension of VIF-codes)
(hydrus) 13: 08 vife (Access Number (transmission count))
(hydrus) 14: 30
(hydrus) 15: 0C dif (8 digit BCD Instantaneous value)
(hydrus) 16: 13 vif (Volume l)
(hydrus) 17: * 74110000 total consumption (1.174000 m3)
(hydrus) 1b: 7C dif (8 digit BCD Value during error state storagenr=1)
(hydrus) 1c: 13 vif (Volume l)
(hydrus) 1d: 00000000
(hydrus) 21: FC dif (8 digit BCD Value during error state storagenr=1)
(hydrus) 22: 10 dife (subunit=0 tariff=1 storagenr=1)
(hydrus) 23: 13 vif (Volume l)
(hydrus) 24: 00000000
(hydrus) 28: FC dif (8 digit BCD Value during error state storagenr=1)
(hydrus) 29: 20 dife (subunit=0 tariff=2 storagenr=1)
(hydrus) 2a: 13 vif (Volume l)
(hydrus) 2b: 00000000
(hydrus) 2f: 72 dif (16 Bit Integer/Binary Value during error state storagenr=1)
(hydrus) 30: 6C vif (Date type G)
(hydrus) 31: 0000
(hydrus) 33: 0B dif (6 digit BCD Instantaneous value)
(hydrus) 34: 3B vif (Volume flow l/h)
(hydrus) 35: * 000000 max flow (0.000000 m3/h)
(hydrus) 38: 02 dif (16 Bit Integer/Binary Instantaneous value)
(hydrus) 39: FD vif (Second extension of VIF-codes)
(hydrus) 3a: 74 vife (Reserved)
(hydrus) 3b: 8713
(hydrus) 3d: 02 dif (16 Bit Integer/Binary Instantaneous value)
(hydrus) 3e: 5A vif (Flow temperature 10¹ °C)
(hydrus) 3f: 6800
(hydrus) 41: C4 dif (32 Bit Integer/Binary Instantaneous value storagenr=1)
(hydrus) 42: 01 dife (subunit=0 tariff=0 storagenr=3)
(hydrus) 43: 6D vif (Date and time type)
(hydrus) 44: 3B177F2A
(hydrus) 48: CC dif (8 digit BCD Instantaneous value storagenr=1)
(hydrus) 49: 01 dife (subunit=0 tariff=0 storagenr=3)
(hydrus) 4a: 13 vif (Volume l)
(hydrus) 4b: 00020000
*/
map<string,pair<int,DVEntry>> values;
parseDV(t, t->content, t->content.begin(), t->content.size(), &values);
int offset;
string key;
if(findKey(MeasurementType::Unknown, ValueInformation::Volume, 0, &key, &values)) {
extractDVdouble(&values, key, &offset, &total_water_consumption_m3_);
t->addMoreExplanation(offset, " total consumption (%f m3)", total_water_consumption_m3_);
}
if(findKey(MeasurementType::Unknown, ValueInformation::VolumeFlow, 0, &key, &values)) {
extractDVdouble(&values, key, &offset, &max_flow_m3h_);
t->addMoreExplanation(offset, " max flow (%f m3/h)", max_flow_m3h_);
}
if(findKey(MeasurementType::Unknown, ValueInformation::FlowTemperature, 0, &key, &values)) {
extractDVdouble(&values, key, &offset, &flow_temperature_c_);
t->addMoreExplanation(offset, " flow temperature (%f °C)", flow_temperature_c_);
}
if(findKey(MeasurementType::Unknown, ValueInformation::Volume, 3, &key, &values)) {
extractDVdouble(&values, key, &offset, &total_water_consumption_at_date_m3_);
t->addMoreExplanation(offset, " total consumption at date (%f m3)", total_water_consumption_at_date_m3_);
}
if (findKey(MeasurementType::Unknown, ValueInformation::DateTime, 3, &key, &values)) {
struct tm datetime;
extractDVdate(&values, key, &offset, &datetime);
at_date_ = strdatetime(&datetime);
t->addMoreExplanation(offset, " at date (%s)", at_date_.c_str());
}
}
double MeterHydrus::totalWaterConsumption(Unit u)
{
assertQuantity(u, Quantity::Volume);
return convert(total_water_consumption_m3_, Unit::M3, u);
}
double MeterHydrus::totalWaterConsumptionAtDate(Unit u)
{
assertQuantity(u, Quantity::Volume);
return convert(total_water_consumption_at_date_m3_, Unit::M3, u);
}
bool MeterHydrus::hasTotalWaterConsumption()
{
return true;
}
double MeterHydrus::maxFlow(Unit u)
{
assertQuantity(u, Quantity::Flow);
return convert(max_flow_m3h_, Unit::M3H, u);
}
bool MeterHydrus::hasMaxFlow()
{
return true;
}
double MeterHydrus::flowTemperature(Unit u)
{
assertQuantity(u, Quantity::Temperature);
return convert(flow_temperature_c_, Unit::C, u);
}

Wyświetl plik

@ -30,6 +30,7 @@
X(apator162, C1_bit|T1_bit, Water, APATOR162, Apator162) \
X(eurisii, T1_bit, HeatCostAllocation, EURISII, EurisII) \
X(flowiq3100, C1_bit, Water, FLOWIQ3100, Multical21) \
X(hydrus, T1_bit, Water, HYDRUS, Hydrus) \
X(iperl, T1_bit, Water, IPERL, Iperl) \
X(izar, T1_bit, Water, IZAR, Izar) \
X(lansenth, T1_bit, TempHygro, LANSENTH, LansenTH) \
@ -188,6 +189,7 @@ unique_ptr<WaterMeter> createSupercom587(WMBus *bus, MeterInfo &m);
unique_ptr<WaterMeter> createMKRadio3(WMBus *bus, MeterInfo &m);
unique_ptr<WaterMeter> createApator162(WMBus *bus, MeterInfo &m);
unique_ptr<WaterMeter> createIperl(WMBus *bus, MeterInfo &m);
unique_ptr<WaterMeter> createHydrus(WMBus *bus, MeterInfo &m);
unique_ptr<WaterMeter> createIzar(WMBus *bus, MeterInfo &m);
unique_ptr<HeatCostMeter> createQCaloric(WMBus *bus, MeterInfo &m);
unique_ptr<HeatCostMeter> createEurisII(WMBus *bus, MeterInfo &m);

Wyświetl plik

@ -63,6 +63,9 @@ Received telegram from: 11772288
Received telegram from: 21242472
manufacturer: (SAP) Sappel
device type: Oil meter
Received telegram from: 64646464
manufacturer: (DME) DIEHL Metering, Germany
device type: Water meter
EOF
EXPECTED=$(cat $LOGFILE_EXPECTED)

Wyświetl plik

@ -24,6 +24,7 @@ $PROG --format=json simulations/simulation_t1.txt \
Tempoo lansenth 00010203 "" \
Rummet rfmamb 11772288 "" \
IzarWater izar 21242472 "" \
HydrusWater hydrus 64646464 "" \
> $TEST/test_output.txt
if [ "$?" == "0" ]
then