In the IZAR meter, add the remaining battery life of the module.

pull/106/head
Erwan Martin 2020-04-22 22:38:40 +02:00
rodzic b967372c5b
commit 85f18ae3b1
5 zmienionych plików z 23 dodań i 1 usunięć

Wyświetl plik

@ -45,6 +45,7 @@ private:
uint32_t uint32FromBytes(const vector<uchar> &data, int offset, bool reverse = false);
vector<uchar> decodePrios(const vector<uchar> &payload, uint32_t key);
double remaining_battery_life;
uint16_t h0_year;
uint8_t h0_month;
uint8_t h0_day;
@ -98,6 +99,11 @@ MeterIzar::MeterIzar(WMBus *bus, MeterInfo &mi) :
"The date when the meter recorded the most recent billing value.",
true, true);
addPrint("remaining_battery_life", Quantity::Time, Unit::Year,
[&](Unit u){ return convert(remaining_battery_life, Unit::Year, u); },
"How many more years the battery is expected to last",
true, true);
}
double MeterIzar::totalWaterConsumption(Unit u)
@ -173,6 +179,9 @@ void MeterIzar::processContent(Telegram *t)
return;
}
// get the remaining battery life (in year)
remaining_battery_life = (frame[12] & 0x1F) / 2.0;
total_water_consumption_l_ = uint32FromBytes(decoded_content, 1, true);
last_month_total_water_consumption_l_ = uint32FromBytes(decoded_content, 5, true);

Wyświetl plik

@ -104,6 +104,12 @@ void MeterCommonImplementation::addPrint(string vname, Quantity vquantity,
prints_.push_back( { vname, vquantity, defaultUnitForQuantity(vquantity), getValueFunc, NULL, help, field, json });
}
void MeterCommonImplementation::addPrint(string vname, Quantity vquantity, Unit unit,
function<double(Unit)> getValueFunc, string help, bool field, bool json)
{
prints_.push_back( { vname, vquantity, unit, getValueFunc, NULL, help, field, json });
}
void MeterCommonImplementation::addPrint(string vname, Quantity vquantity,
function<string()> getValueFunc,
string help, bool field, bool json)

Wyświetl plik

@ -84,6 +84,8 @@ protected:
void addManufacturer(int m);
void addPrint(string vname, Quantity vquantity,
function<double(Unit)> getValueFunc, string help, bool field, bool json);
void addPrint(string vname, Quantity vquantity, Unit unit,
function<double(Unit)> getValueFunc, string help, bool field, bool json);
void addPrint(string vname, Quantity vquantity,
function<std::string()> getValueFunc, string help, bool field, bool json);
bool handleTelegram(vector<uchar> frame);

4
src/units.cc 100644 → 100755
Wyświetl plik

@ -23,6 +23,10 @@ using namespace std;
#define LIST_OF_CONVERSIONS \
X(Second, Hour, {vto=vfrom/3600.0;}) \
X(Hour, Second, {vto=vfrom*3600.0;}) \
X(Year, Second, {vto=vfrom*3600.0*24.0*365;}) \
X(Second, Year, {vto=vfrom/3600.0/24.0/365;}) \
X(Hour, Year, {vto=vfrom/24.0/365;}) \
X(Year, Hour, {vto=vfrom*24.0*365;}) \
X(KWH, GJ, {vto=vfrom*0.0036;}) \
X(GJ, KWH,{vto=vfrom/0.0036;}) \
X(M3, L, {vto=vfrom*1000.0;}) \

3
src/units.h 100644 → 100755
Wyświetl plik

@ -45,7 +45,8 @@
X(HCA,hca,"hca",HCA,"heat cost allocation") \
X(TXT,txt,"txt",Text,"text") \
X(Second,s,"s",Time,"second") \
X(Hour,h,"h",Time,"hour")
X(Hour,h,"h",Time,"hour") \
X(Year,y,"y",Time,"year")
enum class Unit
{