kopia lustrzana https://github.com/weetmuts/wmbusmeters
78 wiersze
2.7 KiB
C++
78 wiersze
2.7 KiB
C++
/*
|
|
Copyright (C) 2021-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("dme_07");
|
|
di.setDefaultFields("name,id,total_m3,status,timestamp");
|
|
di.setMeterType(MeterType::WaterMeter);
|
|
di.addLinkMode(LinkMode::T1);
|
|
di.addDetection(MANUFACTURER_DME, 0x07, 0x7b);
|
|
|
|
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",
|
|
"Status of meter.",
|
|
PrintProperty::JSON | PrintProperty::FIELD | PrintProperty::IMPORTANT | PrintProperty::STATUS,
|
|
FieldMatcher::build()
|
|
.set(MeasurementType::Instantaneous)
|
|
.set(VIFRange::ErrorFlags),
|
|
{
|
|
{
|
|
{
|
|
"ERROR_FLAGS",
|
|
Translate::Type::BitToString,
|
|
AlwaysTrigger, MaskBits(0xffff),
|
|
"OK",
|
|
{
|
|
}
|
|
},
|
|
},
|
|
});
|
|
|
|
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)
|
|
);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
// Test: DigiWasser dme_07 93929190 NOKEY
|
|
// telegram=|1E44A511909192937B077A9F0010052F2F_04130347030002FD1700002F2F2F|
|
|
// {"media":"water","meter":"dme_07","name":"DigiWasser","id":"93929190","status":"OK","total_m3":214.787,"timestamp":"1111-11-11T11:11:11Z"}
|
|
// |DigiWasser;93929190;214.787;OK;1111-11-11 11:11.11
|