kopia lustrzana https://github.com/weetmuts/wmbusmeters
Add qwater driver and fix another bug in analyze.
rodzic
3547382184
commit
f89596d850
|
@ -44,7 +44,6 @@ static bool ok = registerDriver([](DriverInfo&di)
|
|||
di.addDetection(MANUFACTURER_LSE, 0x07, 0x18);
|
||||
di.addDetection(MANUFACTURER_LSE, 0x07, 0x16);
|
||||
di.addDetection(MANUFACTURER_LSE, 0x07, 0x17);
|
||||
di.addDetection(MANUFACTURER_QDS, 0x37, 0x33);
|
||||
|
||||
di.setConstructor([](MeterInfo& mi, DriverInfo& di){ return shared_ptr<Meter>(new MeterLSE_07_17(mi, di)); });
|
||||
});
|
||||
|
@ -188,9 +187,6 @@ MeterLSE_07_17::MeterLSE_07_17(MeterInfo &mi, DriverInfo &di) :
|
|||
device_date_time_ = strdatetime(&datetime);
|
||||
t->addMoreExplanation(offset, " device datetime (%s)", device_date_time_.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// How do the following error codes on the display map to the code in the telegram?
|
||||
// According to the datasheet, these errors can appear on the display:
|
||||
// LEAC Leak in the system (no associated error code)
|
||||
|
|
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
Copyright (C) 2022 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"meters_common_implementation.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct MeterQWater : public virtual MeterCommonImplementation
|
||||
{
|
||||
MeterQWater(MeterInfo &mi, DriverInfo &di);
|
||||
|
||||
double total_water_consumption_m3_ {};
|
||||
|
||||
double due_date_water_consumption_m3_ {};
|
||||
string due_date_ {};
|
||||
|
||||
double due_date_17_water_consumption_m3_ {};
|
||||
string due_date_17_ {};
|
||||
|
||||
string error_code_ {};
|
||||
string error_date_ {};
|
||||
|
||||
string device_date_time_ {};
|
||||
};
|
||||
|
||||
static bool ok = registerDriver([](DriverInfo&di)
|
||||
{
|
||||
di.setName("qwater");
|
||||
di.setMeterType(MeterType::WaterMeter);
|
||||
di.setExpectedTPLSecurityMode(TPLSecurityMode::AES_CBC_IV);
|
||||
di.addLinkMode(LinkMode::S1);
|
||||
di.addDetection(MANUFACTURER_QDS, 0x37, 0x33);
|
||||
di.addDetection(MANUFACTURER_QDS, 0x06, 0x18);
|
||||
|
||||
di.setConstructor([](MeterInfo& mi, DriverInfo& di){ return shared_ptr<Meter>(new MeterQWater(mi, di)); });
|
||||
});
|
||||
|
||||
MeterQWater::MeterQWater(MeterInfo &mi, DriverInfo &di) :
|
||||
MeterCommonImplementation(mi, di)
|
||||
{
|
||||
addFieldWithExtractor(
|
||||
"total",
|
||||
Quantity::Volume,
|
||||
NoDifVifKey,
|
||||
VifScaling::Auto,
|
||||
MeasurementType::Instantaneous,
|
||||
ValueInformation::Volume,
|
||||
StorageNr(0),
|
||||
TariffNr(0),
|
||||
IndexNr(1),
|
||||
PrintProperty::JSON | PrintProperty::FIELD | PrintProperty::IMPORTANT,
|
||||
"The total water consumption recorded by this meter.",
|
||||
SET_FUNC(total_water_consumption_m3_, Unit::M3),
|
||||
GET_FUNC(total_water_consumption_m3_, Unit::M3));
|
||||
|
||||
addFieldWithExtractor(
|
||||
"due_date",
|
||||
Quantity::Volume,
|
||||
NoDifVifKey,
|
||||
VifScaling::Auto,
|
||||
MeasurementType::Instantaneous,
|
||||
ValueInformation::Volume,
|
||||
StorageNr(1),
|
||||
TariffNr(0),
|
||||
IndexNr(1),
|
||||
PrintProperty::JSON | PrintProperty::FIELD | PrintProperty::IMPORTANT,
|
||||
"The water consumption at the due date.",
|
||||
SET_FUNC(due_date_water_consumption_m3_, Unit::M3),
|
||||
GET_FUNC(due_date_water_consumption_m3_, Unit::M3));
|
||||
|
||||
addStringFieldWithExtractor(
|
||||
"due_date",
|
||||
Quantity::Text,
|
||||
NoDifVifKey,
|
||||
MeasurementType::Instantaneous,
|
||||
ValueInformation::Date,
|
||||
StorageNr(1),
|
||||
TariffNr(0),
|
||||
IndexNr(1),
|
||||
PrintProperty::JSON | PrintProperty::FIELD,
|
||||
"The due date configured on the meter.",
|
||||
SET_STRING_FUNC(due_date_),
|
||||
GET_STRING_FUNC(due_date_));
|
||||
|
||||
addFieldWithExtractor(
|
||||
"due_date_17",
|
||||
Quantity::Volume,
|
||||
NoDifVifKey,
|
||||
VifScaling::Auto,
|
||||
MeasurementType::Instantaneous,
|
||||
ValueInformation::Volume,
|
||||
StorageNr(17),
|
||||
TariffNr(0),
|
||||
IndexNr(1),
|
||||
PrintProperty::JSON,
|
||||
"The water consumption at the 17th historical due date.",
|
||||
SET_FUNC(due_date_17_water_consumption_m3_, Unit::M3),
|
||||
GET_FUNC(due_date_17_water_consumption_m3_, Unit::M3));
|
||||
|
||||
addStringFieldWithExtractor(
|
||||
"due_date_17",
|
||||
Quantity::Text,
|
||||
NoDifVifKey,
|
||||
MeasurementType::Instantaneous,
|
||||
ValueInformation::Date,
|
||||
StorageNr(17),
|
||||
TariffNr(0),
|
||||
IndexNr(1),
|
||||
PrintProperty::JSON,
|
||||
"The due date configured for the 17th historical value.",
|
||||
SET_STRING_FUNC(due_date_17_),
|
||||
GET_STRING_FUNC(due_date_17_));
|
||||
|
||||
addStringFieldWithExtractorAndLookup(
|
||||
"error_code",
|
||||
Quantity::Text,
|
||||
DifVifKey("02BB56"),
|
||||
MeasurementType::Unknown,
|
||||
ValueInformation::Any,
|
||||
AnyStorageNr,
|
||||
AnyTariffNr,
|
||||
IndexNr(1),
|
||||
PrintProperty::JSON | PrintProperty::FIELD,
|
||||
"Error code of the Meter, 0 means no error.",
|
||||
SET_STRING_FUNC(error_code_),
|
||||
GET_STRING_FUNC(error_code_),
|
||||
{
|
||||
{
|
||||
{
|
||||
"ERROR_FLAGS",
|
||||
Translate::Type::BitToString,
|
||||
0xffff,
|
||||
"OK",
|
||||
{
|
||||
{ 0x01, "?" },
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
addStringFieldWithExtractor(
|
||||
"error_date",
|
||||
Quantity::Text,
|
||||
NoDifVifKey,
|
||||
MeasurementType::AtError,
|
||||
ValueInformation::Date,
|
||||
StorageNr(0),
|
||||
TariffNr(0),
|
||||
IndexNr(1),
|
||||
PrintProperty::JSON,
|
||||
"The date the error occured at. If no error, reads 2127-15-31 (FFFF).",
|
||||
SET_STRING_FUNC(error_date_),
|
||||
GET_STRING_FUNC(error_date_));
|
||||
|
||||
addStringFieldWithExtractor(
|
||||
"device_date_time",
|
||||
Quantity::Text,
|
||||
NoDifVifKey,
|
||||
MeasurementType::Instantaneous,
|
||||
ValueInformation::DateTime,
|
||||
StorageNr(0),
|
||||
TariffNr(0),
|
||||
IndexNr(1),
|
||||
PrintProperty::JSON,
|
||||
"Date when measurement was recorded.",
|
||||
SET_STRING_FUNC(device_date_time_),
|
||||
GET_STRING_FUNC(device_date_time_));
|
||||
}
|
||||
|
||||
// Test: MyQWater qwater 12353648 NOKEY
|
||||
// telegram=|374493444836351218067ac70000200c13911900004c1391170000426cbf2ccc081391170000c2086cbf2c02bb560000326cffff046d1e02de21fed0|
|
||||
// {"media":"warm water","meter":"qwater","name":"MyQWater","id":"12353648","total_m3":1.991,"due_date_m3":1.791,"due_date":"2021-12-31","due_date_17_m3":1.791,"due_date_17":"2021-12-31","error_code":"OK","error_date":"2127-15-31","device_date_time":"2022-01-30 02:30","timestamp":"1111-11-11T11:11:11Z"}
|
||||
// |MyQWater;12353648;1.991000;1.791000;2021-12-31;OK;1111-11-11 11:11.11
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 2017-2021 Fredrik Öhrström
|
||||
Copyright (C) 2017-2022 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
|
||||
|
@ -15,6 +15,11 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// This is the old style meter detection. Drivers are succesively rewritten
|
||||
// from meter_xyz.cc to driver_xyz.cc only old style drivers are listed here.
|
||||
// The new driver_xyz.cc file format is selfcontained so eventually this
|
||||
// file be empty and go away.
|
||||
//
|
||||
// This file is only included into meters.cc
|
||||
//
|
||||
// List of numbers that can be used to detect the meter driver from a telegram.
|
||||
|
|
|
@ -85,7 +85,11 @@ bool registerDriver(function<void(DriverInfo&)> setup)
|
|||
for (auto &p : all_registered_drivers_)
|
||||
{
|
||||
bool foo = p.second.detect(d.mfct, d.type, d.version);
|
||||
assert(!foo);
|
||||
if (foo)
|
||||
{
|
||||
error("Internal error: driver %s tried to register the same auto detect combo as driver %s alread has taken!\n",
|
||||
di.name().str().c_str(), p.second.name().str().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -550,6 +554,10 @@ LIST_OF_METERS
|
|||
if (auto_driver == "")
|
||||
{
|
||||
auto_driver = toString(auto_di.driver());
|
||||
if (auto_driver == "unknown")
|
||||
{
|
||||
auto_driver = "";
|
||||
}
|
||||
}
|
||||
|
||||
// Will be non-empty if an explicit driver has been selected.
|
||||
|
@ -557,7 +565,8 @@ LIST_OF_METERS
|
|||
int force_length = 0;
|
||||
int force_understood = 0;
|
||||
|
||||
if (force_driver == "" && auto_driver == "")
|
||||
// If an auto driver is found and no other driver has been forced, use the auto driver.
|
||||
if (force_driver == "" && auto_driver != "")
|
||||
{
|
||||
force_driver = auto_driver;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,11 @@ LIST_OF_METER_TYPES
|
|||
#undef X
|
||||
};
|
||||
|
||||
// This is the old style meter list. Drivers are succesively rewritten
|
||||
// from meter_xyz.cc to driver_xyz.cc only old style drivers are listed here.
|
||||
// The new driver_xyz.cc file format is selfcontained so eventually this
|
||||
// macro LIST_OF_METERS will be empty and go away.
|
||||
|
||||
#define LIST_OF_METERS \
|
||||
X(auto, 0, AutoMeter, AUTO, Auto) \
|
||||
X(unknown, 0, UnknownMeter, UNKNOWN, Unknown) \
|
||||
|
|
Ładowanie…
Reference in New Issue