Properly handle subunit in sharky driver.

pull/522/head
Fredrik Öhrström 2022-04-19 09:43:10 +02:00
rodzic 47c9b8c653
commit b7be96e25b
4 zmienionych plików z 51 dodań i 12 usunięć

Wyświetl plik

@ -79,13 +79,11 @@ MeterSharky::MeterSharky(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementat
addNumericFieldWithExtractor(
"total_volume",
Quantity::Volume,
NoDifVifKey,
VifScaling::Auto,
MeasurementType::Instantaneous,
VIFRange::Volume,
StorageNr(0),
TariffNr(0),
IndexNr(1),
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::Volume)
,
PrintProperty::JSON | PrintProperty::FIELD,
"The total heating media volume recorded by this meter.",
SET_FUNC(total_volume_m3_, Unit::M3),

Wyświetl plik

@ -201,18 +201,18 @@ struct FieldMatcher
bool match_vif_range = false;
VIFRange vif_range { VIFRange::Any };
// Match the storage nr.
bool match_storage_nr = false;
// Match the storage nr. If no storage is specified, default to match only 0.
bool match_storage_nr = true;
StorageNr storage_nr_from { 0 };
StorageNr storage_nr_to { 0 };
// Match the tariff nr.
bool match_tariff_nr = false;
// Match the tariff nr. If no tariff is specified, default to match only 0.
bool match_tariff_nr = true;
TariffNr tariff_nr_from { 0 };
TariffNr tariff_nr_to { 0 };
// Match the subunit.
bool match_subunit_nr = false;
// Match the subunit. If no subunit is specified, default to match only 0.
bool match_subunit_nr = true;
SubUnitNr subunit_nr_from { 0 };
SubUnitNr subunit_nr_to { 0 };

Wyświetl plik

@ -872,6 +872,37 @@ void MeterCommonImplementation::addNumericFieldWithExtractor(
));
}
void MeterCommonImplementation::addNumericFieldWithExtractor(
string vname,
Quantity vquantity,
VifScaling vif_scaling,
FieldMatcher matcher,
PrintProperties print_properties,
string help,
function<void(Unit,double)> setValueFunc,
function<double(Unit)> getValueFunc)
{
string default_unit = unitToStringLowerCase(defaultUnitForQuantity(vquantity));
string field_name = vname+"_"+default_unit;
fields_.push_back(field_name);
prints_.push_back(
FieldInfo(vname,
vquantity,
defaultUnitForQuantity(vquantity),
vif_scaling,
matcher,
help,
print_properties,
field_name,
getValueFunc,
NULL,
setValueFunc,
NULL,
NoLookup
));
}
void MeterCommonImplementation::addNumericField(
string vname,
Quantity vquantity,

Wyświetl plik

@ -109,6 +109,16 @@ protected:
function<void(Unit,double)> setValueFunc, // Use the SET macro above.
function<double(Unit)> getValueFunc); // Use the GET macro above.
void addNumericFieldWithExtractor(
string vname, // Name of value without unit, eg total
Quantity vquantity, // Value belongs to this quantity.
VifScaling vif_scaling,
FieldMatcher matcher,
PrintProperties print_properties, // Should this be printed by default in fields,json and hr.
string help,
function<void(Unit,double)> setValueFunc, // Use the SET macro above.
function<double(Unit)> getValueFunc); // Use the GET macro above.
void addNumericField(
string vname, // Name of value without unit, eg total
Quantity vquantity, // Value belongs to this quantity.