diff --git a/src/driver_amiplus.cc b/src/driver_amiplus.cc index b1c17e6..9a17db6 100644 --- a/src/driver_amiplus.cc +++ b/src/driver_amiplus.cc @@ -53,7 +53,7 @@ static bool ok = registerDriver([](DriverInfo&di) MeterAmiplus::MeterAmiplus(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) { - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_consumption", Quantity::Energy, NoDifVifKey, @@ -68,7 +68,7 @@ MeterAmiplus::MeterAmiplus(MeterInfo &mi, DriverInfo &di) : MeterCommonImplement SET_FUNC(total_energy_consumption_kwh_, Unit::KWH), GET_FUNC(total_energy_consumption_kwh_, Unit::KWH)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "current_power_consumption", Quantity::Power, NoDifVifKey, @@ -83,7 +83,7 @@ MeterAmiplus::MeterAmiplus(MeterInfo &mi, DriverInfo &di) : MeterCommonImplement SET_FUNC(current_power_consumption_kw_, Unit::KW), GET_FUNC(current_power_consumption_kw_, Unit::KW)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_production", Quantity::Energy, DifVifKey("0E833C"), @@ -98,7 +98,7 @@ MeterAmiplus::MeterAmiplus(MeterInfo &mi, DriverInfo &di) : MeterCommonImplement SET_FUNC(total_energy_production_kwh_, Unit::KWH), GET_FUNC(total_energy_production_kwh_, Unit::KWH)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "current_power_production", Quantity::Power, DifVifKey("0BAB3C"), @@ -113,7 +113,7 @@ MeterAmiplus::MeterAmiplus(MeterInfo &mi, DriverInfo &di) : MeterCommonImplement SET_FUNC(current_power_production_kw_, Unit::KW), GET_FUNC(current_power_production_kw_, Unit::KW)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "voltage_at_phase_1", Quantity::Voltage, DifVifKey("0AFDC9FC01"), @@ -128,7 +128,7 @@ MeterAmiplus::MeterAmiplus(MeterInfo &mi, DriverInfo &di) : MeterCommonImplement SET_FUNC(phase_1_v_, Unit::Volt), GET_FUNC(phase_1_v_, Unit::Volt)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "voltage_at_phase_2", Quantity::Voltage, DifVifKey("0AFDC9FC02"), @@ -143,7 +143,7 @@ MeterAmiplus::MeterAmiplus(MeterInfo &mi, DriverInfo &di) : MeterCommonImplement SET_FUNC(phase_2_v_, Unit::Volt), GET_FUNC(phase_2_v_, Unit::Volt)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "voltage_at_phase_3", Quantity::Voltage, DifVifKey("0AFDC9FC03"), @@ -172,7 +172,7 @@ MeterAmiplus::MeterAmiplus(MeterInfo &mi, DriverInfo &di) : MeterCommonImplement SET_STRING_FUNC(device_date_time_), GET_STRING_FUNC(device_date_time_)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_consumption_tariff_1", Quantity::Energy, DifVifKey("8E1003"), @@ -187,7 +187,7 @@ MeterAmiplus::MeterAmiplus(MeterInfo &mi, DriverInfo &di) : MeterCommonImplement SET_FUNC(total_energy_consumption_tariff_1_kwh_, Unit::KWH), GET_FUNC(total_energy_consumption_tariff_1_kwh_, Unit::KWH)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_consumption_tariff_2", Quantity::Energy, DifVifKey("8E2003"), @@ -203,7 +203,7 @@ MeterAmiplus::MeterAmiplus(MeterInfo &mi, DriverInfo &di) : MeterCommonImplement GET_FUNC(total_energy_consumption_tariff_2_kwh_, Unit::KWH)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_consumption_tariff_3", Quantity::Energy, DifVifKey("8E3003"), @@ -218,7 +218,7 @@ MeterAmiplus::MeterAmiplus(MeterInfo &mi, DriverInfo &di) : MeterCommonImplement SET_FUNC(total_energy_consumption_tariff_3_kwh_, Unit::KWH), GET_FUNC(total_energy_consumption_tariff_3_kwh_, Unit::KWH)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_production_tariff_1", Quantity::Energy, DifVifKey("8E10833C"), @@ -234,7 +234,7 @@ MeterAmiplus::MeterAmiplus(MeterInfo &mi, DriverInfo &di) : MeterCommonImplement GET_FUNC(total_energy_production_tariff_1_kwh_, Unit::KWH)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_production_tariff_2", Quantity::Energy, DifVifKey("8E20833C"), @@ -250,7 +250,7 @@ MeterAmiplus::MeterAmiplus(MeterInfo &mi, DriverInfo &di) : MeterCommonImplement GET_FUNC(total_energy_production_tariff_2_kwh_, Unit::KWH)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_production_tariff_3", Quantity::Energy, DifVifKey("8E30833C"), diff --git a/src/driver_apator08.cc b/src/driver_apator08.cc index f83e126..47f10ac 100644 --- a/src/driver_apator08.cc +++ b/src/driver_apator08.cc @@ -42,7 +42,7 @@ static bool ok = registerDriver([](DriverInfo&di) MeterApator08::MeterApator08(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) { - addField( + addNumericField( "total", Quantity::Volume, PrintProperty::JSON | PrintProperty::FIELD | PrintProperty::IMPORTANT, diff --git a/src/driver_aventieshca.cc b/src/driver_aventieshca.cc index fd5eaf2..707fc23 100644 --- a/src/driver_aventieshca.cc +++ b/src/driver_aventieshca.cc @@ -40,7 +40,7 @@ static bool ok = registerDriver([](DriverInfo&di) MeterAventiesHCA::MeterAventiesHCA(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) { - addFieldWithExtractor( + addNumericFieldWithExtractor( "current_consumption", Quantity::HCA, NoDifVifKey, @@ -55,7 +55,7 @@ MeterAventiesHCA::MeterAventiesHCA(MeterInfo &mi, DriverInfo &di) : MeterCommonI SET_FUNC(current_consumption_hca_, Unit::HCA), GET_FUNC(current_consumption_hca_, Unit::HCA)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "consumption_at_set_date", Quantity::HCA, NoDifVifKey, @@ -76,7 +76,7 @@ MeterAventiesHCA::MeterAventiesHCA(MeterInfo &mi, DriverInfo &di) : MeterCommonI strprintf(key, "consumption_at_set_date_%d", i); strprintf(info, "Heat cost allocation at the %d billing period date.", i); - addFieldWithExtractor( + addNumericFieldWithExtractor( key, Quantity::HCA, NoDifVifKey, diff --git a/src/driver_aventieswm.cc b/src/driver_aventieswm.cc index aa3527d..a13553d 100644 --- a/src/driver_aventieswm.cc +++ b/src/driver_aventieswm.cc @@ -43,7 +43,7 @@ static bool ok = registerDriver([](DriverInfo&di) MeterAventiesWM::MeterAventiesWM(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) { - addFieldWithExtractor( + addNumericFieldWithExtractor( "total", Quantity::Volume, NoDifVifKey, @@ -63,7 +63,7 @@ MeterAventiesWM::MeterAventiesWM(MeterInfo &mi, DriverInfo &di) : string msg, info; strprintf(msg, "consumption_at_set_date_%d", i); strprintf(info, "Water consumption at the %d billing period date.", i); - addFieldWithExtractor( + addNumericFieldWithExtractor( msg, Quantity::Volume, NoDifVifKey, diff --git a/src/driver_c5isf.cc b/src/driver_c5isf.cc index 6ea7e4a..8d061fd 100644 --- a/src/driver_c5isf.cc +++ b/src/driver_c5isf.cc @@ -70,7 +70,7 @@ MeterC5isf::MeterC5isf(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementatio { // Fields common for T1A1, T1A2, T1B........... - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_consumption", Quantity::Energy, FIND_FIELD(MeasurementType::Instantaneous, VIFRange::EnergyWh), @@ -79,7 +79,7 @@ MeterC5isf::MeterC5isf(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementatio SET_FUNC(total_energy_kwh_, Unit::KWH), GET_FUNC(total_energy_kwh_, Unit::KWH)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_volume", Quantity::Volume, FIND_FIELD(MeasurementType::Instantaneous, VIFRange::Volume), @@ -152,7 +152,7 @@ MeterC5isf::MeterC5isf(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementatio for (int i=0; i<14; ++i) { - addFieldWithExtractor( + addNumericFieldWithExtractor( tostrprintf("prev_%d_month", i+1), Quantity::Energy, FIND_FIELD_S(MeasurementType::Instantaneous, VIFRange::EnergyWh, StorageNr(32+i)), @@ -166,7 +166,7 @@ MeterC5isf::MeterC5isf(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementatio for (int i=0; i<14; ++i) { - addFieldWithExtractor( + addNumericFieldWithExtractor( tostrprintf("prev_%d_month", i+1), Quantity::Volume, FIND_FIELD_S(MeasurementType::Instantaneous, VIFRange::Volume, StorageNr(32+i)), @@ -178,7 +178,7 @@ MeterC5isf::MeterC5isf(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementatio // Telegram type T1B /////////////////////////////////////////////////////// - addFieldWithExtractor( + addNumericFieldWithExtractor( "due_energy_consumption", Quantity::Energy, FIND_FIELD_S(MeasurementType::Instantaneous, VIFRange::EnergyWh, StorageNr(8)), @@ -196,7 +196,7 @@ MeterC5isf::MeterC5isf(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementatio SET_STRING_FUNC(due_date_), GET_STRING_FUNC(due_date_)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "volume_flow", Quantity::Flow, FIND_FIELD(MeasurementType::Instantaneous, VIFRange::VolumeFlow), @@ -205,7 +205,7 @@ MeterC5isf::MeterC5isf(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementatio SET_FUNC(volume_flow_m3h_, Unit::M3H), GET_FUNC(volume_flow_m3h_, Unit::M3H)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "power", Quantity::Power, FIND_FIELD(MeasurementType::Instantaneous, VIFRange::PowerW), @@ -214,7 +214,7 @@ MeterC5isf::MeterC5isf(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementatio SET_FUNC(power_kw_, Unit::KW), GET_FUNC(power_kw_, Unit::KW)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_consumption_last_month", Quantity::Energy, FIND_FIELD_S(MeasurementType::Instantaneous, VIFRange::EnergyWh, StorageNr(32)), @@ -232,7 +232,7 @@ MeterC5isf::MeterC5isf(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementatio SET_STRING_FUNC(last_month_date_), GET_STRING_FUNC(last_month_date_)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "max_power_last_month", Quantity::Power, NoDifVifKey, @@ -247,7 +247,7 @@ MeterC5isf::MeterC5isf(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementatio SET_FUNC(max_power_last_month_kw_, Unit::KW), GET_FUNC(max_power_last_month_kw_, Unit::KW)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "flow_temperature", Quantity::Temperature, NoDifVifKey, @@ -262,7 +262,7 @@ MeterC5isf::MeterC5isf(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementatio SET_FUNC(flow_temperature_c_, Unit::C), GET_FUNC(flow_temperature_c_, Unit::C)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "return_temperature", Quantity::Temperature, NoDifVifKey, diff --git a/src/driver_iperl.cc b/src/driver_iperl.cc index 36def53..5f617ed 100644 --- a/src/driver_iperl.cc +++ b/src/driver_iperl.cc @@ -53,7 +53,7 @@ MeterIperl::MeterIperl(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementatio // version 0x68 // version 0x7c Sensus 640 - addFieldWithExtractor( + addNumericFieldWithExtractor( "total", Quantity::Volume, NoDifVifKey, @@ -68,7 +68,7 @@ MeterIperl::MeterIperl(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementatio SET_FUNC(total_water_consumption_m3_, Unit::M3), GET_FUNC(total_water_consumption_m3_, Unit::M3)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "max_flow", Quantity::Flow, NoDifVifKey, diff --git a/src/driver_itron.cc b/src/driver_itron.cc index 0c83e9e..2b9b8a6 100644 --- a/src/driver_itron.cc +++ b/src/driver_itron.cc @@ -52,7 +52,7 @@ MeterItron::MeterItron(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementatio addLinkMode(LinkMode::T1); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total", Quantity::Volume, NoDifVifKey, @@ -81,7 +81,7 @@ MeterItron::MeterItron(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementatio SET_STRING_FUNC(meter_date_), GET_STRING_FUNC(meter_date_)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "target", Quantity::Volume, NoDifVifKey, diff --git a/src/driver_lse_07_17.cc b/src/driver_lse_07_17.cc index d19cc55..4d5a871 100644 --- a/src/driver_lse_07_17.cc +++ b/src/driver_lse_07_17.cc @@ -51,7 +51,7 @@ static bool ok = registerDriver([](DriverInfo&di) MeterLSE_07_17::MeterLSE_07_17(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) { - addFieldWithExtractor( + addNumericFieldWithExtractor( "total", Quantity::Volume, NoDifVifKey, @@ -66,7 +66,7 @@ MeterLSE_07_17::MeterLSE_07_17(MeterInfo &mi, DriverInfo &di) : SET_FUNC(total_water_consumption_m3_, Unit::M3), GET_FUNC(total_water_consumption_m3_, Unit::M3)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "due_date", Quantity::Volume, NoDifVifKey, diff --git a/src/driver_microclima.cc b/src/driver_microclima.cc index 71bc485..15c9102 100644 --- a/src/driver_microclima.cc +++ b/src/driver_microclima.cc @@ -47,7 +47,7 @@ static bool ok = registerDriver([](DriverInfo&di) MeterMicroClima::MeterMicroClima(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) { - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_consumption", Quantity::Energy, NoDifVifKey, @@ -62,7 +62,7 @@ MeterMicroClima::MeterMicroClima(MeterInfo &mi, DriverInfo &di) : MeterCommonImp SET_FUNC(total_energy_kwh_, Unit::KWH), GET_FUNC(total_energy_kwh_, Unit::KWH)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_consumption_tariff1", Quantity::Energy, NoDifVifKey, @@ -77,7 +77,7 @@ MeterMicroClima::MeterMicroClima(MeterInfo &mi, DriverInfo &di) : MeterCommonImp SET_FUNC(total_energy_tariff1_kwh_, Unit::KWH), GET_FUNC(total_energy_tariff1_kwh_, Unit::KWH)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_volume", Quantity::Volume, NoDifVifKey, @@ -92,7 +92,7 @@ MeterMicroClima::MeterMicroClima(MeterInfo &mi, DriverInfo &di) : MeterCommonImp SET_FUNC(total_volume_m3_, Unit::M3), GET_FUNC(total_volume_m3_, Unit::M3)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_volume_tariff2", Quantity::Volume, NoDifVifKey, @@ -107,7 +107,7 @@ MeterMicroClima::MeterMicroClima(MeterInfo &mi, DriverInfo &di) : MeterCommonImp SET_FUNC(total_volume_tariff2_m3_, Unit::M3), GET_FUNC(total_volume_tariff2_m3_, Unit::M3)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "volume_flow", Quantity::Flow, NoDifVifKey, @@ -122,7 +122,7 @@ MeterMicroClima::MeterMicroClima(MeterInfo &mi, DriverInfo &di) : MeterCommonImp SET_FUNC(volume_flow_m3h_, Unit::M3H), GET_FUNC(volume_flow_m3h_, Unit::M3H)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "power", Quantity::Power, NoDifVifKey, @@ -137,7 +137,7 @@ MeterMicroClima::MeterMicroClima(MeterInfo &mi, DriverInfo &di) : MeterCommonImp SET_FUNC(power_kw_, Unit::KW), GET_FUNC(power_kw_, Unit::KW)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "flow_temperature", Quantity::Temperature, NoDifVifKey, @@ -152,7 +152,7 @@ MeterMicroClima::MeterMicroClima(MeterInfo &mi, DriverInfo &di) : MeterCommonImp SET_FUNC(flow_temperature_c_, Unit::C), GET_FUNC(flow_temperature_c_, Unit::C)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "return_temperature", Quantity::Temperature, NoDifVifKey, @@ -167,7 +167,7 @@ MeterMicroClima::MeterMicroClima(MeterInfo &mi, DriverInfo &di) : MeterCommonImp SET_FUNC(return_temperature_c_, Unit::C), GET_FUNC(return_temperature_c_, Unit::C)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "temperature_difference", Quantity::Temperature, NoDifVifKey, diff --git a/src/driver_minomess.cc b/src/driver_minomess.cc index 3b34369..4b8d98e 100644 --- a/src/driver_minomess.cc +++ b/src/driver_minomess.cc @@ -43,7 +43,7 @@ static bool ok = registerDriver([](DriverInfo&di) MeterMinomess::MeterMinomess(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) { - addFieldWithExtractor( + addNumericFieldWithExtractor( "total", Quantity::Volume, NoDifVifKey, @@ -75,7 +75,7 @@ MeterMinomess::MeterMinomess(MeterInfo &mi, DriverInfo &di) : MeterCommonImpleme SET_STRING_FUNC(meter_date_), GET_STRING_FUNC(meter_date_)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "target", Quantity::Volume, NoDifVifKey, diff --git a/src/driver_piigth.cc b/src/driver_piigth.cc index 6ba2bab..474f078 100644 --- a/src/driver_piigth.cc +++ b/src/driver_piigth.cc @@ -45,7 +45,7 @@ static bool ok = registerDriver([](DriverInfo&di) MeterPIIGTH::MeterPIIGTH(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) { - addFieldWithExtractor( + addNumericFieldWithExtractor( "temperature", Quantity::Temperature, NoDifVifKey, @@ -60,7 +60,7 @@ MeterPIIGTH::MeterPIIGTH(MeterInfo &mi, DriverInfo &di) : SET_FUNC(temperature_c_, Unit::C), GET_FUNC(temperature_c_, Unit::C)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "average_temperature_1h", Quantity::Temperature, NoDifVifKey, @@ -75,7 +75,7 @@ MeterPIIGTH::MeterPIIGTH(MeterInfo &mi, DriverInfo &di) : SET_FUNC(average_temperature_1h_c_, Unit::C), GET_FUNC(average_temperature_1h_c_, Unit::C)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "average_temperature_24h", Quantity::Temperature, NoDifVifKey, @@ -91,7 +91,7 @@ MeterPIIGTH::MeterPIIGTH(MeterInfo &mi, DriverInfo &di) : GET_FUNC(average_temperature_24h_c_, Unit::C)); /* - addFieldWithExtractor( + addNumericFieldWithExtractor( "relative_humidity", Quantity::Temperature, DifVifKey("02FB1A"), diff --git a/src/driver_qwater.cc b/src/driver_qwater.cc index f7e36c1..9d1a198 100644 --- a/src/driver_qwater.cc +++ b/src/driver_qwater.cc @@ -52,7 +52,7 @@ static bool ok = registerDriver([](DriverInfo&di) MeterQWater::MeterQWater(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) { - addFieldWithExtractor( + addNumericFieldWithExtractor( "total", Quantity::Volume, NoDifVifKey, @@ -67,7 +67,7 @@ MeterQWater::MeterQWater(MeterInfo &mi, DriverInfo &di) : SET_FUNC(total_water_consumption_m3_, Unit::M3), GET_FUNC(total_water_consumption_m3_, Unit::M3)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "due_date", Quantity::Volume, NoDifVifKey, @@ -96,7 +96,7 @@ MeterQWater::MeterQWater(MeterInfo &mi, DriverInfo &di) : SET_STRING_FUNC(due_date_), GET_STRING_FUNC(due_date_)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "due_date_17", Quantity::Volume, NoDifVifKey, diff --git a/src/driver_sharky.cc b/src/driver_sharky.cc index 021262e..5c40ca1 100644 --- a/src/driver_sharky.cc +++ b/src/driver_sharky.cc @@ -46,7 +46,7 @@ static bool ok = registerDriver([](DriverInfo&di) MeterSharky::MeterSharky(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) { - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_consumption", Quantity::Energy, NoDifVifKey, @@ -61,7 +61,7 @@ MeterSharky::MeterSharky(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementat SET_FUNC(total_energy_kwh_, Unit::KWH), GET_FUNC(total_energy_kwh_, Unit::KWH)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_consumption_tariff1", Quantity::Energy, NoDifVifKey, @@ -76,7 +76,7 @@ MeterSharky::MeterSharky(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementat SET_FUNC(total_energy_tariff1_kwh_, Unit::KWH), GET_FUNC(total_energy_tariff1_kwh_, Unit::KWH)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_volume", Quantity::Volume, NoDifVifKey, @@ -91,7 +91,7 @@ MeterSharky::MeterSharky(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementat SET_FUNC(total_volume_m3_, Unit::M3), GET_FUNC(total_volume_m3_, Unit::M3)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_volume_tariff2", Quantity::Volume, NoDifVifKey, @@ -106,7 +106,7 @@ MeterSharky::MeterSharky(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementat SET_FUNC(total_volume_tariff2_m3_, Unit::M3), GET_FUNC(total_volume_tariff2_m3_, Unit::M3)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "volume_flow", Quantity::Flow, NoDifVifKey, @@ -121,7 +121,7 @@ MeterSharky::MeterSharky(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementat SET_FUNC(volume_flow_m3h_, Unit::M3H), GET_FUNC(volume_flow_m3h_, Unit::M3H)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "power", Quantity::Power, NoDifVifKey, @@ -136,7 +136,7 @@ MeterSharky::MeterSharky(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementat SET_FUNC(power_kw_, Unit::KW), GET_FUNC(power_kw_, Unit::KW)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "flow_temperature", Quantity::Temperature, NoDifVifKey, @@ -151,7 +151,7 @@ MeterSharky::MeterSharky(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementat SET_FUNC(flow_temperature_c_, Unit::C), GET_FUNC(flow_temperature_c_, Unit::C)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "return_temperature", Quantity::Temperature, NoDifVifKey, @@ -166,7 +166,7 @@ MeterSharky::MeterSharky(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementat SET_FUNC(return_temperature_c_, Unit::C), GET_FUNC(return_temperature_c_, Unit::C)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "temperature_difference", Quantity::Temperature, NoDifVifKey, diff --git a/src/driver_sharky774.cc b/src/driver_sharky774.cc index 596228a..9e13d95 100644 --- a/src/driver_sharky774.cc +++ b/src/driver_sharky774.cc @@ -47,7 +47,7 @@ static bool ok = registerDriver([](DriverInfo&di) MeterSharky774::MeterSharky774(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) { - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_consumption", Quantity::Energy, NoDifVifKey, @@ -62,7 +62,7 @@ MeterSharky774::MeterSharky774(MeterInfo &mi, DriverInfo &di) : MeterCommonImpl SET_FUNC(total_energy_consumption_kwh_, Unit::KWH), GET_FUNC(total_energy_consumption_kwh_, Unit::KWH)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_volume", Quantity::Volume, NoDifVifKey, @@ -77,7 +77,7 @@ MeterSharky774::MeterSharky774(MeterInfo &mi, DriverInfo &di) : MeterCommonImpl SET_FUNC(total_volume_m3_, Unit::M3), GET_FUNC(total_volume_m3_, Unit::M3)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "volume_flow", Quantity::Flow, NoDifVifKey, @@ -92,7 +92,7 @@ MeterSharky774::MeterSharky774(MeterInfo &mi, DriverInfo &di) : MeterCommonImpl SET_FUNC(volume_flow_m3h_, Unit::M3H), GET_FUNC(volume_flow_m3h_, Unit::M3H)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "power", Quantity::Power, NoDifVifKey, @@ -107,7 +107,7 @@ MeterSharky774::MeterSharky774(MeterInfo &mi, DriverInfo &di) : MeterCommonImpl SET_FUNC(power_kw_, Unit::KW), GET_FUNC(power_kw_, Unit::KW)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "flow_temperature", Quantity::Temperature, NoDifVifKey, @@ -122,7 +122,7 @@ MeterSharky774::MeterSharky774(MeterInfo &mi, DriverInfo &di) : MeterCommonImpl SET_FUNC(flow_temperature_c_, Unit::C), GET_FUNC(flow_temperature_c_, Unit::C)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "return_temperature", Quantity::Temperature, NoDifVifKey, @@ -137,14 +137,14 @@ MeterSharky774::MeterSharky774(MeterInfo &mi, DriverInfo &di) : MeterCommonImpl SET_FUNC(return_temperature_c_, Unit::C), GET_FUNC(return_temperature_c_, Unit::C)); - addField("temperature_difference", + addNumericField("temperature_difference", Quantity::Temperature, PrintProperty::JSON | PrintProperty::FIELD, "The temperature difference.", [](Unit u, double v) {}, [this](Unit u) { return flow_temperature_c_ - return_temperature_c_; }); - addFieldWithExtractor( + addNumericFieldWithExtractor( "operating_time", Quantity::Time, DifVifKey("0AA618"), @@ -159,7 +159,7 @@ MeterSharky774::MeterSharky774(MeterInfo &mi, DriverInfo &di) : MeterCommonImpl SET_FUNC(operating_time_h_, Unit::Hour), GET_FUNC(operating_time_h_, Unit::Hour)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "energy_at_set_date", Quantity::Energy, NoDifVifKey, diff --git a/src/driver_supercom587.cc b/src/driver_supercom587.cc index ae5476d..901e54c 100644 --- a/src/driver_supercom587.cc +++ b/src/driver_supercom587.cc @@ -41,7 +41,7 @@ static bool ok = registerDriver([](DriverInfo&di) MeterSupercom587::MeterSupercom587(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) { - addFieldWithExtractor( + addNumericFieldWithExtractor( "total", Quantity::Volume, NoDifVifKey, diff --git a/src/driver_ultraheat.cc b/src/driver_ultraheat.cc index f746a22..e320af4 100644 --- a/src/driver_ultraheat.cc +++ b/src/driver_ultraheat.cc @@ -43,7 +43,7 @@ static bool ok = registerDriver([](DriverInfo&di) MeterUltraHeat::MeterUltraHeat(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) { - addFieldWithExtractor( + addNumericFieldWithExtractor( "heat", Quantity::Energy, NoDifVifKey, @@ -58,7 +58,7 @@ MeterUltraHeat::MeterUltraHeat(MeterInfo &mi, DriverInfo &di) : MeterCommonImple SET_FUNC(heat_mj_, Unit::MJ), GET_FUNC(heat_mj_, Unit::MJ)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "volume", Quantity::Volume, NoDifVifKey, @@ -73,7 +73,7 @@ MeterUltraHeat::MeterUltraHeat(MeterInfo &mi, DriverInfo &di) : MeterCommonImple SET_FUNC(volume_m3_, Unit::M3), GET_FUNC(volume_m3_, Unit::M3)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "power", Quantity::Power, NoDifVifKey, @@ -88,7 +88,7 @@ MeterUltraHeat::MeterUltraHeat(MeterInfo &mi, DriverInfo &di) : MeterCommonImple SET_FUNC(power_kw_, Unit::KW), GET_FUNC(power_kw_, Unit::KW)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "flow", Quantity::Flow, NoDifVifKey, @@ -103,7 +103,7 @@ MeterUltraHeat::MeterUltraHeat(MeterInfo &mi, DriverInfo &di) : MeterCommonImple SET_FUNC(flow_m3h_, Unit::M3H), GET_FUNC(flow_m3h_, Unit::M3H)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "flow", Quantity::Temperature, NoDifVifKey, @@ -118,7 +118,7 @@ MeterUltraHeat::MeterUltraHeat(MeterInfo &mi, DriverInfo &di) : MeterCommonImple SET_FUNC(flow_c_, Unit::C), GET_FUNC(flow_c_, Unit::C)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "return", Quantity::Temperature, NoDifVifKey, diff --git a/src/driver_vario451mid.cc b/src/driver_vario451mid.cc index 8ed2dac..9a905d5 100644 --- a/src/driver_vario451mid.cc +++ b/src/driver_vario451mid.cc @@ -42,7 +42,7 @@ static bool ok = registerDriver([](DriverInfo&di) MeterVario451Mid::MeterVario451Mid(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) { - addFieldWithExtractor( + addNumericFieldWithExtractor( "total_energy_consumption", Quantity::Energy, NoDifVifKey, @@ -57,7 +57,7 @@ MeterVario451Mid::MeterVario451Mid(MeterInfo &mi, DriverInfo &di) : MeterCommon SET_FUNC(total_energy_consumption_kwh_, Unit::KWH), GET_FUNC(total_energy_consumption_kwh_, Unit::KWH)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "energy_at_old_date", Quantity::Energy, NoDifVifKey, @@ -86,7 +86,7 @@ MeterVario451Mid::MeterVario451Mid(MeterInfo &mi, DriverInfo &di) : MeterCommon SET_STRING_FUNC(old_date_txt_), GET_STRING_FUNC(old_date_txt_)); - addFieldWithExtractor( + addNumericFieldWithExtractor( "energy_at_set_date", Quantity::Energy, NoDifVifKey, diff --git a/src/meters.cc b/src/meters.cc index df1c78f..8f69c3a 100644 --- a/src/meters.cc +++ b/src/meters.cc @@ -793,8 +793,6 @@ void MeterCommonImplementation::addPrint(string vname, Quantity vquantity, NULL, NULL, NULL, - NULL, - NULL, NoLookup )); } @@ -823,8 +821,6 @@ void MeterCommonImplementation::addPrint(string vname, Quantity vquantity, Unit NULL, NULL, NULL, - NULL, - NULL, NoLookup )); } @@ -851,13 +847,11 @@ void MeterCommonImplementation::addPrint(string vname, Quantity vquantity, getValueFunc, NULL, NULL, - NULL, - NULL, NoLookup )); } -void MeterCommonImplementation::addFieldWithExtractor( +void MeterCommonImplementation::addNumericFieldWithExtractor( string vname, Quantity vquantity, DifVifKey dif_vif_key, @@ -876,51 +870,6 @@ void MeterCommonImplementation::addFieldWithExtractor( string field_name = vname+"_"+default_unit; fields_.push_back(field_name); - // Compose the extract function. - function extract = - [](FieldInfo *fi, Meter *m, Telegram *t) - { - bool found = false; - string key = fi->difVifKey().str(); - int offset {}; - if (key == "") - { - // Search for key. - bool ok = findKeyWithNr(fi->measurementType(), - fi->vifRange(), - fi->storageNr().intValue(), - fi->tariffNr().intValue(), - fi->indexNr().intValue(), - &key, - &t->values); - if (!ok) return false; - } - double extracted_double_value = NAN; - if (extractDVdouble(&t->values, - key, - &offset, - &extracted_double_value, - fi->vifScaling() == VifScaling::Auto || - fi->vifScaling() == VifScaling::AutoSigned, - fi->vifScaling() == VifScaling::NoneSigned || - fi->vifScaling() == VifScaling::AutoSigned)) - { - Unit decoded_unit = fi->defaultUnit(); - if (fi->vifRange() != VIFRange::Any && - fi->vifRange() != VIFRange::AnyVolumeVIF && - fi->vifRange() != VIFRange::AnyEnergyVIF && - fi->vifRange() != VIFRange::AnyPowerVIF && - fi->vifRange() != VIFRange::None) - { - decoded_unit = toDefaultUnit(fi->vifRange()); - } - fi->setValueDouble(decoded_unit, extracted_double_value); - t->addMoreExplanation(offset, fi->renderJson(&m->conversions())); - found = true; - } - return found; - }; - prints_.push_back( FieldInfo(vname, vquantity, @@ -939,13 +888,11 @@ void MeterCommonImplementation::addFieldWithExtractor( NULL, setValueFunc, NULL, - extract, - NULL, NoLookup )); } -void MeterCommonImplementation::addField( +void MeterCommonImplementation::addNumericField( string vname, Quantity vquantity, PrintProperties print_properties, @@ -975,8 +922,6 @@ void MeterCommonImplementation::addField( NULL, setValueFunc, NULL, - NULL, - NULL, NoLookup )); } @@ -999,62 +944,6 @@ void MeterCommonImplementation::addStringFieldWithExtractor( string field_name = vname+"_"+default_unit; fields_.push_back(field_name); - // Compose the extract function. - function extract = - [](FieldInfo *fi, Meter *m, Telegram *t) - { - bool found = false; - string key = fi->difVifKey().str(); - int offset {}; - if (key == "") - { - // Search for key. - bool ok = findKeyWithNr(fi->measurementType(), - fi->vifRange(), - fi->storageNr().intValue(), - fi->tariffNr().intValue(), - fi->indexNr().intValue(), - &key, - &t->values); - if (!ok) return false; - } - if (fi->vifRange() == VIFRange::DateTime) - { - struct tm datetime; - extractDVdate(&t->values, key, &offset, &datetime); - string extracted_device_date_time = strdatetime(&datetime); - fi->setValueString(extracted_device_date_time); - t->addMoreExplanation(offset, fi->renderJsonText()); - found = true; - } - else if (fi->vifRange() == VIFRange::Date) - { - struct tm date; - extractDVdate(&t->values, key, &offset, &date); - string extracted_device_date = strdate(&date); - fi->setValueString(extracted_device_date); - t->addMoreExplanation(offset, fi->renderJsonText()); - found = true; - } - else if (fi->vifRange() == VIFRange::EnhancedIdentification || - fi->vifRange() == VIFRange::FabricationNo) - { - string extracted_id; - extractDVReadableString(&t->values, key, &offset, &extracted_id); - fi->setValueString(extracted_id); - t->addMoreExplanation(offset, fi->renderJsonText()); - found = true; - } - else - { - error("Internal error: Cannot extract text string from vif %s in %s:%d\n", - toString(fi->vifRange()), - __FILE__, __LINE__); - - } - return found; - }; - prints_.push_back( FieldInfo(vname, vquantity, @@ -1073,8 +962,6 @@ void MeterCommonImplementation::addStringFieldWithExtractor( getValueFunc, NULL, setValueFunc, - NULL, - extract, NoLookup )); } @@ -1098,36 +985,6 @@ void MeterCommonImplementation::addStringFieldWithExtractorAndLookup( string field_name = vname+"_"+default_unit; fields_.push_back(field_name); - // Compose the extract function. - function extract = - [](FieldInfo *fi, Meter *m, Telegram *t) - { - bool found = false; - string key = fi->difVifKey().str(); - int offset {}; - if (key == "") - { - // Search for key. - bool ok = findKeyWithNr(fi->measurementType(), - fi->vifRange(), - fi->storageNr().intValue(), - fi->tariffNr().intValue(), - fi->indexNr().intValue(), - &key, - &t->values); - if (!ok) return false; - } - uint64_t extracted_bits {}; - if (extractDVlong(&t->values, key, &offset, &extracted_bits)) - { - string translated_bits = fi->lookup().translate(extracted_bits); - fi->setValueString(translated_bits); - t->addMoreExplanation(offset, fi->renderJsonText()); - found = true; - } - return found; - }; - prints_.push_back( FieldInfo(vname, vquantity, @@ -1146,8 +1003,6 @@ void MeterCommonImplementation::addStringFieldWithExtractorAndLookup( getValueFunc, NULL, setValueFunc, - NULL, - extract, lookup )); } @@ -2168,14 +2023,13 @@ bool isValidKey(string& key, MeterDriver mt) void FieldInfo::performExtraction(Meter *m, Telegram *t) { - if (extract_double_) + if (xuantity_ == Quantity::Text) { - extract_double_(this, m, t); + extractString(m, t); } - - if (extract_string_) + else { - extract_string_(this, m, t); + extractNumeric(m, t); } } @@ -2187,3 +2041,111 @@ DriverName MeterInfo::driverName() } return driver_name; } + +bool FieldInfo::extractNumeric(Meter *m, Telegram *t) +{ + bool found = false; + string key = difVifKey().str(); + int offset {}; + if (key == "") + { + // Search for key. + bool ok = findKeyWithNr(measurementType(), + vifRange(), + storageNr().intValue(), + tariffNr().intValue(), + indexNr().intValue(), + &key, + &t->values); + if (!ok) return false; + } + double extracted_double_value = NAN; + if (extractDVdouble(&t->values, + key, + &offset, + &extracted_double_value, + vifScaling() == VifScaling::Auto || + vifScaling() == VifScaling::AutoSigned, + vifScaling() == VifScaling::NoneSigned || + vifScaling() == VifScaling::AutoSigned)) + { + Unit decoded_unit = defaultUnit(); + if (vifRange() != VIFRange::Any && + vifRange() != VIFRange::AnyVolumeVIF && + vifRange() != VIFRange::AnyEnergyVIF && + vifRange() != VIFRange::AnyPowerVIF && + vifRange() != VIFRange::None) + { + decoded_unit = toDefaultUnit(vifRange()); + } + setValueDouble(decoded_unit, extracted_double_value); + t->addMoreExplanation(offset, renderJson(&m->conversions())); + found = true; + } + return found; +} + +bool FieldInfo::extractString(Meter *m, Telegram *t) +{ + bool found = false; + string key = difVifKey().str(); + int offset {}; + if (key == "") + { + // Search for key. + bool ok = findKeyWithNr(measurementType(), + vifRange(), + storageNr().intValue(), + tariffNr().intValue(), + indexNr().intValue(), + &key, + &t->values); + if (!ok) return false; + } + uint64_t extracted_bits {}; + if (lookup_.hasLookups()) + { + if (extractDVlong(&t->values, key, &offset, &extracted_bits)) + { + string translated_bits = lookup().translate(extracted_bits); + setValueString(translated_bits); + t->addMoreExplanation(offset, renderJsonText()); + found = true; + } + } + else if (vifRange() == VIFRange::DateTime) + { + struct tm datetime; + extractDVdate(&t->values, key, &offset, &datetime); + string extracted_device_date_time = strdatetime(&datetime); + setValueString(extracted_device_date_time); + t->addMoreExplanation(offset, renderJsonText()); + found = true; + } + else if (vifRange() == VIFRange::Date) + { + struct tm date; + extractDVdate(&t->values, key, &offset, &date); + string extracted_device_date = strdate(&date); + setValueString(extracted_device_date); + t->addMoreExplanation(offset, renderJsonText()); + found = true; + } + else if (vifRange() == VIFRange::EnhancedIdentification || + vifRange() == VIFRange::FabricationNo) + { + string extracted_id; + extractDVReadableString(&t->values, key, &offset, &extracted_id); + setValueString(extracted_id); + t->addMoreExplanation(offset, renderJsonText()); + found = true; + } + else + { + error("Internal error: Cannot extract text string from vif %s in %s:%d\n", + toString(vifRange()), + __FILE__, __LINE__); + + } + return found; +} diff --git a/src/meters.h b/src/meters.h index 17a6b85..1f4428b 100644 --- a/src/meters.h +++ b/src/meters.h @@ -326,8 +326,6 @@ struct FieldInfo function get_value_string, function set_value_double, function set_value_string, - function extract_double, - function extract_string, Translate::Lookup lookup ) : vname_(vname), @@ -347,8 +345,6 @@ struct FieldInfo get_value_string_(get_value_string), set_value_double_(set_value_double), set_value_string_(set_value_string), - extract_double_(extract_double), - extract_string_(extract_string), lookup_(lookup) {} @@ -374,6 +370,8 @@ struct FieldInfo void setValueDouble(Unit u, double d) { if (set_value_double_) set_value_double_(u, d); } void setValueString(string s) { if (set_value_string_) set_value_string_(s); } + bool extractNumeric(Meter *m, Telegram *t); + bool extractString(Meter *m, Telegram *t); void performExtraction(Meter *m, Telegram *t); string renderJsonOnlyDefaultUnit(); @@ -402,8 +400,6 @@ private: function get_value_string_; // Callback to fetch the value from the meter. function set_value_double_; // Call back to set the value in the c++ object function set_value_string_; // Call back to set the value string in the c++ object - function extract_double_; // Extract field from telegram and insert into meter. - function extract_string_; // Extract field from telegram and insert into meter. Translate::Lookup lookup_; }; diff --git a/src/meters_common_implementation.h b/src/meters_common_implementation.h index f4c9e47..4d05965 100644 --- a/src/meters_common_implementation.h +++ b/src/meters_common_implementation.h @@ -95,7 +95,7 @@ protected: #define FIND_SFIELD_STI(TYPE,INFO,STORAGE,TARIFF,INDEX) NoDifVifKey,TYPE,INFO,STORAGE,TARIFF,INDEX - void addFieldWithExtractor( + void addNumericFieldWithExtractor( string vname, // Name of value without unit, eg total Quantity vquantity, // Value belongs to this quantity. DifVifKey dif_vif_key, // You can hardocde a dif vif header here or use NoDifVifKey @@ -110,7 +110,7 @@ protected: function setValueFunc, // Use the SET macro above. function getValueFunc); // Use the GET macro above. - void addField( + void addNumericField( string vname, // Name of value without unit, eg total Quantity vquantity, // Value belongs to this quantity. PrintProperties print_properties, // Should this be printed by default in fields,json and hr.