kopia lustrzana https://github.com/weetmuts/wmbusmeters
Accept offset form extras meterinfo in apator162
rodzic
8dd3e87c44
commit
70476b1027
|
@ -33,8 +33,10 @@ struct MeterApator162 : public virtual WaterMeter, public virtual MeterCommonImp
|
|||
private:
|
||||
|
||||
void processContent(Telegram *t);
|
||||
void processExtras(string miExtras);
|
||||
|
||||
double total_water_consumption_m3_ {};
|
||||
unsigned short offset_ = 0;
|
||||
};
|
||||
|
||||
shared_ptr<WaterMeter> createApator162(MeterInfo &mi)
|
||||
|
@ -45,6 +47,8 @@ shared_ptr<WaterMeter> createApator162(MeterInfo &mi)
|
|||
MeterApator162::MeterApator162(MeterInfo &mi) :
|
||||
MeterCommonImplementation(mi, MeterDriver::APATOR162)
|
||||
{
|
||||
processExtras(mi.extras);
|
||||
|
||||
setExpectedTPLSecurityMode(TPLSecurityMode::AES_CBC_IV);
|
||||
|
||||
addLinkMode(LinkMode::T1);
|
||||
|
@ -56,6 +60,32 @@ MeterApator162::MeterApator162(MeterInfo &mi) :
|
|||
true, true);
|
||||
}
|
||||
|
||||
void MeterApator162::processExtras(string miExtras)
|
||||
{
|
||||
map<string,string> extras;
|
||||
bool ok = parseExtras(miExtras, &extras);
|
||||
if (!ok)
|
||||
{
|
||||
error("(apator162) invalid extra parameters (%s)\n", miExtras.c_str());
|
||||
}
|
||||
|
||||
if (extras.size() > 0)
|
||||
{
|
||||
if (extras.count("offset") > 0)
|
||||
{
|
||||
try {
|
||||
offset_ = stoi(extras["offset"]);
|
||||
}
|
||||
catch (const std::invalid_argument &e) {
|
||||
error("(apator162) invalid extra parameters offset (%s)\n", extras["offset"].c_str());
|
||||
}
|
||||
catch (const std::out_of_range &e) {
|
||||
error("(apator162) out of range extra parameters offset (%s)\n", extras["offset"].c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double MeterApator162::totalWaterConsumption(Unit u)
|
||||
{
|
||||
assertQuantity(u, Quantity::Volume);
|
||||
|
@ -82,6 +112,13 @@ void MeterApator162::processContent(Telegram *t)
|
|||
// Current assumption of this proprietary protocol is that byte 13 tells
|
||||
// us where the current total water consumption is located.
|
||||
int o = 0;
|
||||
|
||||
if (offset_ > 0) {
|
||||
o = offset_;
|
||||
strprintf(total, "%02x%02x%02x%02x", content[o], content[o+1], content[o+2], content[o+3]);
|
||||
debug("(apator162) using offset from the configuration (offset=%d) that results with total value: %s\n", o, total.c_str());
|
||||
}
|
||||
else {
|
||||
uchar guess10 = content[10];
|
||||
uchar guess11 = content[11];
|
||||
uchar guess12 = content[12];
|
||||
|
@ -164,6 +201,7 @@ void MeterApator162::processContent(Telegram *t)
|
|||
strprintf(total, "%02x%02x%02x%02x", content[o], content[o+1], content[o+2], content[o+3]);
|
||||
debug("(apator162) adjusting to offset %d instead\n", o);
|
||||
}
|
||||
}
|
||||
|
||||
vendor_values["0413"] = { 25, DVEntry(MeasurementType::Instantaneous, 0x13, 0, 0, 0, total) };
|
||||
int offset;
|
||||
|
|
Ładowanie…
Reference in New Issue