Fully converted driver ultrimis driver.

pull/522/head
Fredrik Öhrström 2022-04-26 12:02:11 +02:00
rodzic fc43958b76
commit c10d324236
4 zmienionych plików z 106 dodań i 163 usunięć

Wyświetl plik

@ -0,0 +1,106 @@
/*
Copyright (C) 2017-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("ultrimis");
di.setMeterType(MeterType::WaterMeter);
di.addLinkMode(LinkMode::T1);
di.addDetection(MANUFACTURER_APA, 0x16, 0x01);
di.setConstructor([](MeterInfo& mi, DriverInfo& di){ return shared_ptr<Meter>(new Driver(mi, di)); });
});
Driver::Driver(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di)
{
addNumericFieldWithExtractor(
"total",
"The total water consumption recorded by this meter.",
PrintProperty::JSON | PrintProperty::FIELD | PrintProperty::IMPORTANT,
Quantity::Volume,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::Volume)
);
addNumericFieldWithExtractor(
"target",
"The total water consumption recorded at the beginning of this month.",
PrintProperty::JSON | PrintProperty::FIELD,
Quantity::Volume,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::Volume)
.set(StorageNr(1))
);
addStringFieldWithExtractorAndLookup(
"current_status",
"Status and error flags.",
PrintProperty::JSON | PrintProperty::FIELD,
FieldMatcher::build()
.set(DifVifKey("03FD17")),
{
{
{
"ERROR_FLAGS",
Translate::Type::BitToString,
0xffffff,
"OK",
{
/* What are the bits?
According to the manual this meter offers these alarms:
Back flow
Meter leak
Water main leak
Zero flow
Tampering detected
No water
Low battery
*/
}
},
},
});
addNumericFieldWithExtractor(
"total_backward_flow",
"The total backward water volume recorded by this meter.",
PrintProperty::JSON | PrintProperty::FIELD,
Quantity::Volume,
VifScaling::Auto,
FieldMatcher::build()
.set(DifVifKey("04933C"))
);
}
}
// Test: Water ultrimis 95969798 NOKEY
// Comment:
// telegram=|2E4401069897969501167A4B0320052F2F_0413320C000003FD1700000044132109000004933C000000002F2F2F2F2F|
// {"media":"cold water","meter":"ultrimis","name":"Water","id":"95969798","total_m3":3.122,"target_m3":2.337,"current_status":"OK","total_backward_flow_m3":0,"timestamp":"1111-11-11T11:11:11Z"}
// |Water;95969798;3.122000;2.337000;OK;0.000000;1111-11-11 11:11.11

Wyświetl plik

@ -109,7 +109,6 @@
X(SONTEX868, MANUFACTURER_SON, 0x08, 0x16) \
X(TOPASESKR, MANUFACTURER_AMT, 0x06, 0xf1) \
X(TOPASESKR, MANUFACTURER_AMT, 0x07, 0xf1) \
X(ULTRIMIS, MANUFACTURER_APA, 0x16, 0x01) \
X(UNISMART, MANUFACTURER_AMX, 0x03, 0x01) \
X(VARIO451, MANUFACTURER_TCH, 0x04, 0x27) \
X(VARIO451, MANUFACTURER_TCH, 0xc3, 0x27) \

Wyświetl plik

@ -1,161 +0,0 @@
/*
Copyright (C) 2017-2020 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"
#include"util.h"
using namespace std;
struct MeterUltrimis : public virtual MeterCommonImplementation {
MeterUltrimis(MeterInfo &mi);
// Total water counted through the meter
double totalWaterConsumption(Unit u);
double targetWaterConsumption(Unit u);
double totalBackwardFlow(Unit u);
bool hasTotalWaterConsumption();
private:
void processContent(Telegram *t);
uint32_t info_codes_ {}; // Really only 24 bits.
double total_water_consumption_m3_ {};
double target_water_consumption_m3_ {};
double total_backward_flow_m3_ {};
string status();
};
shared_ptr<Meter> createUltrimis(MeterInfo &mi)
{
return shared_ptr<Meter>(new MeterUltrimis(mi));
}
MeterUltrimis::MeterUltrimis(MeterInfo &mi) :
MeterCommonImplementation(mi, "ultrimis")
{
setMeterType(MeterType::WaterMeter);
setExpectedTPLSecurityMode(TPLSecurityMode::AES_CBC_IV);
addLinkMode(LinkMode::T1);
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 total water consumption recorded at the beginning of this month.",
PrintProperty::FIELD | PrintProperty::JSON);
addPrint("current_status", Quantity::Text,
[&](){ return status(); },
"Status of meter.",
PrintProperty::FIELD | PrintProperty::JSON);
addPrint("total_backward_flow", Quantity::Volume,
[&](Unit u){ return totalBackwardFlow(u); },
"The total water backward flow.",
PrintProperty::FIELD | PrintProperty::JSON);
}
string MeterUltrimis::status()
{
/* According to the manual this meter offers these alarms:
Back flow
Meter leak
Water main leak
Zero flow
Tampering detected
No water
Low battery
*/
string info = "OK";
if (info_codes_ != 0)
{
info = tostrprintf("ERR(%06x)", info_codes_);
}
return info;
}
void MeterUltrimis::processContent(Telegram *t)
{
/*
(ultrimis) 11: 04 dif (32 Bit Integer/Binary Instantaneous value)
(ultrimis) 12: 13 vif (Volume l)
(ultrimis) 13: * 320C0000 total consumption (3.122000 m3)
(ultrimis) 17: 03 dif (24 Bit Integer/Binary Instantaneous value)
(ultrimis) 18: FD vif (Second extension of VIF-codes)
(ultrimis) 19: 17 vife (Error flags (binary))
(ultrimis) 1a: 0C0C0C
(ultrimis) 1d: 44 dif (32 Bit Integer/Binary Instantaneous value storagenr=1)
(ultrimis) 1e: 13 vif (Volume l)
(ultrimis) 1f: 21090000
(ultrimis) 23: 04 dif (32 Bit Integer/Binary Instantaneous value)
(ultrimis) 24: 93 vif (Volume l)
(ultrimis) 25: 3C vife (backward flow)
(ultrimis) 26: 05000000
*/
int offset;
string key;
if(findKey(MeasurementType::Instantaneous, VIFRange::Volume, 0, 0, &key, &t->dv_entries)) {
extractDVdouble(&t->dv_entries, key, &offset, &total_water_consumption_m3_);
t->addMoreExplanation(offset, " total consumption (%f m3)", total_water_consumption_m3_);
}
extractDVuint24(&t->dv_entries, "03FD17", &offset, &info_codes_);
t->addMoreExplanation(offset, " info codes (%s)", status().c_str());
if(findKey(MeasurementType::Instantaneous, VIFRange::Volume, 1, 0, &key, &t->dv_entries)) {
extractDVdouble(&t->dv_entries, key, &offset, &target_water_consumption_m3_);
t->addMoreExplanation(offset, " target consumption (%f m3)", target_water_consumption_m3_);
}
extractDVdouble(&t->dv_entries, "04933C", &offset, &total_backward_flow_m3_);
t->addMoreExplanation(offset, " total backward flow (%f m3)", total_backward_flow_m3_);
}
double MeterUltrimis::totalWaterConsumption(Unit u)
{
assertQuantity(u, Quantity::Volume);
return convert(total_water_consumption_m3_, Unit::M3, u);
}
bool MeterUltrimis::hasTotalWaterConsumption()
{
return true;
}
double MeterUltrimis::targetWaterConsumption(Unit u)
{
assertQuantity(u, Quantity::Volume);
return convert(target_water_consumption_m3_, Unit::M3, u);
}
double MeterUltrimis::totalBackwardFlow(Unit u)
{
assertQuantity(u, Quantity::Volume);
return convert(total_backward_flow_m3_, Unit::M3, u);
}

Wyświetl plik

@ -105,7 +105,6 @@ LIST_OF_METER_TYPES
X(sensostar, C1_bit|T1_bit, HeatMeter,SENSOSTAR, Sensostar) \
X(sontex868, T1_bit, HeatCostAllocationMeter, SONTEX868, Sontex868) \
X(topaseskr, T1_bit, WaterMeter, TOPASESKR, TopasEsKr) \
X(ultrimis, T1_bit, WaterMeter, ULTRIMIS, Ultrimis) \
X(vario451, T1_bit, HeatMeter, VARIO451, Vario451) \
X(waterstarm, C1_bit|T1_bit, WaterMeter,WATERSTARM, WaterstarM) \
X(whe46x, S1_bit, HeatCostAllocationMeter, WHE46X, Whe46x) \