diff --git a/src/driver_sharky.cc b/src/driver_sharky.cc index 5c40ca1..dd54fe0 100644 --- a/src/driver_sharky.cc +++ b/src/driver_sharky.cc @@ -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), diff --git a/src/dvparser.h b/src/dvparser.h index d3697a1..c83083c 100644 --- a/src/dvparser.h +++ b/src/dvparser.h @@ -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 }; diff --git a/src/meters.cc b/src/meters.cc index fcd6a42..899035b 100644 --- a/src/meters.cc +++ b/src/meters.cc @@ -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 setValueFunc, + function 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, diff --git a/src/meters_common_implementation.h b/src/meters_common_implementation.h index 0843bec..f3b09d7 100644 --- a/src/meters_common_implementation.h +++ b/src/meters_common_implementation.h @@ -109,6 +109,16 @@ protected: function setValueFunc, // Use the SET macro above. function 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 setValueFunc, // Use the SET macro above. + function getValueFunc); // Use the GET macro above. + void addNumericField( string vname, // Name of value without unit, eg total Quantity vquantity, // Value belongs to this quantity.