Full converted driver iperl.

pull/522/head
Fredrik Öhrström 2022-04-23 23:10:55 +02:00
rodzic 61b9cd1df4
commit 2fc9fd11d5
1 zmienionych plików z 39 dodań i 61 usunięć

Wyświetl plik

@ -18,79 +18,57 @@
#include"meters_common_implementation.h"
using namespace std;
struct MeterIperl : public virtual MeterCommonImplementation
namespace
{
MeterIperl(MeterInfo &mi, DriverInfo &di);
struct Driver : public virtual MeterCommonImplementation
{
Driver(MeterInfo &mi, DriverInfo &di);
};
private:
static bool ok = registerDriver([](DriverInfo&di)
{
di.setName("iperl");
di.setMeterType(MeterType::WaterMeter);
di.addLinkMode(LinkMode::T1);
di.addDetection(MANUFACTURER_SEN, 0x06, 0x68);
di.addDetection(MANUFACTURER_SEN, 0x07, 0x68);
di.addDetection(MANUFACTURER_SEN, 0x07, 0x7c);
di.setConstructor([](MeterInfo& mi, DriverInfo& di){ return shared_ptr<Meter>(new Driver(mi, di)); });
});
double total_water_consumption_m3_ {};
double max_flow_m3h_ {};
};
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)
);
static bool ok = registerDriver([](DriverInfo&di)
{
di.setName("iperl");
di.setMeterType(MeterType::WaterMeter);
di.addLinkMode(LinkMode::T1);
di.addDetection(MANUFACTURER_SEN, 0x06, 0x68);
di.addDetection(MANUFACTURER_SEN, 0x07, 0x68);
di.addDetection(MANUFACTURER_SEN, 0x07, 0x7c);
di.setConstructor([](MeterInfo& mi, DriverInfo& di){ return shared_ptr<Meter>(new MeterIperl(mi, di)); });
});
MeterIperl::MeterIperl(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di)
{
setMeterType(MeterType::WaterMeter);
setExpectedTPLSecurityMode(TPLSecurityMode::AES_CBC_IV);
addLinkMode(LinkMode::T1);
// version 0x68
// version 0x7c Sensus 640
addNumericFieldWithExtractor(
"total",
Quantity::Volume,
NoDifVifKey,
VifScaling::Auto,
MeasurementType::Instantaneous,
VIFRange::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));
addNumericFieldWithExtractor(
"max_flow",
Quantity::Flow,
NoDifVifKey,
VifScaling::Auto,
MeasurementType::Instantaneous,
VIFRange::VolumeFlow,
StorageNr(0),
TariffNr(0),
IndexNr(1),
PrintProperty::JSON | PrintProperty::FIELD | PrintProperty::IMPORTANT,
"The maxium flow recorded during previous period.",
SET_FUNC(max_flow_m3h_, Unit::M3H),
GET_FUNC(max_flow_m3h_, Unit::M3H));
addNumericFieldWithExtractor(
"max_flow",
"The maxium flow recorded during previous period.",
PrintProperty::JSON | PrintProperty::FIELD | PrintProperty::IMPORTANT,
Quantity::Flow,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::VolumeFlow));
}
}
// Test: MoreWater iperl 12345699 NOKEY
// Comment: Test iPerl T1 telegram, that after decryption, has 2f2f markers.
// telegram=|1E44AE4C9956341268077A36001000#2F2F0413181E0000023B00002F2F2F2F|
// telegram=|1E44AE4C9956341268077A36001000_2F2F0413181E0000023B00002F2F2F2F|
// {"media":"water","meter":"iperl","name":"MoreWater","id":"12345699","total_m3":7.704,"max_flow_m3h":0,"timestamp":"1111-11-11T11:11:11Z"}
// |MoreWater;12345699;7.704000;0.000000;1111-11-11 11:11.11
// Test: WaterWater iperl 33225544 NOKEY
// Comment: Test iPerl T1 telegram not encrypted, which has no 2f2f markers.
// telegram=|1844AE4C4455223368077A55000000|041389E20100023B0000|
// telegram=|1844AE4C4455223368077A55000000_041389E20100023B0000|
// {"media":"water","meter":"iperl","name":"WaterWater","id":"33225544","total_m3":123.529,"max_flow_m3h":0,"timestamp":"1111-11-11T11:11:11Z"}
// |WaterWater;33225544;123.529000;0.000000;1111-11-11 11:11.11