Add more fields to abbb23.

pull/1021/head
Fredrik Öhrström 2023-08-26 20:08:47 +02:00
rodzic a920e25d45
commit 906c288298
5 zmienionych plików z 468 dodań i 7 usunięć

Wyświetl plik

@ -713,6 +713,170 @@ namespace
Unit::NUMBER
);
addStringFieldWithExtractorAndLookup(
"digital_output_{subunit_counter}",
"The state for output register 1-2.",
DEFAULT_PRINT_PROPERTIES,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::DigitalOutput)
.set(StorageNr(0))
.set(TariffNr(0))
.set(SubUnitNr(1),SubUnitNr(2))
.add(VIFCombinableRaw(0)),
Translate::Lookup()
.add(Translate::Rule("OUTPUT", Translate::Type::BitToString)
.set(MaskBits(0xff))
));
addStringFieldWithExtractorAndLookup(
"digital_input_{subunit_counter-2counter}",
"The state for input register 1-2.",
DEFAULT_PRINT_PROPERTIES,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::DigitalInput)
.set(SubUnitNr(3),SubUnitNr(4))
.add(VIFCombinableRaw(0)),
Translate::Lookup()
.add(Translate::Rule("INPUT", Translate::Type::BitToString)
.set(MaskBits(0xff))
));
addStringFieldWithExtractorAndLookup(
"digital_historic_input_{subunit_counter-2counter}",
"The state for input register 3-4.",
DEFAULT_PRINT_PROPERTIES,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::DigitalInput)
.set(StorageNr(1))
.set(SubUnitNr(3),SubUnitNr(4))
.add(VIFCombinableRaw(0)),
Translate::Lookup()
.add(Translate::Rule("INPUT", Translate::Type::BitToString)
.set(MaskBits(0xff))
));
addNumericFieldWithExtractor(
"input_{subunit_counter-2counter}",
"Number of times input 1-2 counted a 1.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Dimensionless,
VifScaling::None,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(SubUnitNr(3),SubUnitNr(4))
.set(VIFRange::CumulationCounter)
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"resettable_energy_consumption",
"Resettable cumulative active imported energy.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.add(VIFCombinableRaw(0x7f72))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"resettable_energy_production",
"Resettable cumulative active exported energy.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(1))
.add(VIFCombinableRaw(0x7f72))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"resettable_reactive_energy_consumption",
"Resettable cumulative reactive imported energy.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(2))
.add(VIFCombinableRaw(0x7f72))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"resettable_reactive_energy_production",
"Resettable cumulative reactive exported energy.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(3))
.add(VIFCombinableRaw(0x7f72))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"reset_energy_consumption",
"Number of times the resettable energy imported value has been reset.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Dimensionless,
VifScaling::None,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRaw(0x7f71))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"reset_energy_production",
"Number of times the resettable active energy exported value has been reset.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Dimensionless,
VifScaling::None,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRaw(0x7f71))
.set(SubUnitNr(1))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"reset_reactive_energy_consumption",
"Number of times the resettable reactive energy imported value has been reset.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Dimensionless,
VifScaling::None,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRaw(0x7f71))
.set(SubUnitNr(2))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"reset_reactive_energy_production",
"Number of times the resettable reactive energy exported value has been reset.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Dimensionless,
VifScaling::None,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRaw(0x7f71))
.set(SubUnitNr(3))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"energy_co2",
"Energy in co2.",
@ -757,6 +921,283 @@ namespace
Unit::FACTOR
);
addNumericFieldWithExtractor(
"total_apparent_energy_consumption",
"Total cumulative apparent kvah imported energy.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Apparent_Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(4))
.add(VIFCombinableRaw(0)),
Unit::KVAH
);
addNumericFieldWithExtractor(
"total_apparent_energy_production",
"Total cumulative apparent kvah exported energy.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Apparent_Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(5))
.add(VIFCombinableRaw(0)),
Unit::KVAH
);
addNumericFieldWithExtractor(
"total_energy_consumption_l1",
"Total imported active energy for L1 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.add(VIFCombinableRaw(0x7f01))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_energy_consumption_l2",
"Total imported active energy for L2 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.add(VIFCombinableRaw(0x7f02))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_energy_consumption_l3",
"Total imported active energy for L3 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.add(VIFCombinableRaw(0x7f03))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_reactive_energy_consumption_l1",
"Total imported reactive energy for L1 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(2))
.add(VIFCombinableRaw(0x7f01))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_reactive_energy_consumption_l2",
"Total imported reactive energy for L2 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(2))
.add(VIFCombinableRaw(0x7f02))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_reactive_energy_consumption_l3",
"Total imported reactive energy for L3 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(2))
.add(VIFCombinableRaw(0x7f03))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_apparent_energy_consumption_l1",
"Total imported apparent energy for L1 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(4))
.add(VIFCombinableRaw(0x7f01))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_apparent_energy_consumption_l2",
"Total imported apparent energy for L2 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(4))
.add(VIFCombinableRaw(0x7f02))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_apparent_energy_consumption_l3",
"Total imported apparent energy for L3 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(4))
.add(VIFCombinableRaw(0x7f03))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_energy_production_l1",
"Total exported active energy for L1 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(1))
.add(VIFCombinableRaw(0x7f01))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_energy_production_l2",
"Total exported active energy for L2 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(1))
.add(VIFCombinableRaw(0x7f02))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_energy_production_l3",
"Total exported active energy for L3 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(1))
.add(VIFCombinableRaw(0x7f03))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_reactive_energy_production_l1",
"Total exported reactive energy for L1 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(3))
.add(VIFCombinableRaw(0x7f01))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_reactive_energy_production_l2",
"Total exported reactive energy for L2 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(3))
.add(VIFCombinableRaw(0x7f02))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_reactive_energy_production_l3",
"Total exported reactive energy for L3 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(3))
.add(VIFCombinableRaw(0x7f03))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_apparent_energy_production_l1",
"Total exported apparent energy for L1 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(5))
.add(VIFCombinableRaw(0x7f01))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_apparent_energy_production_l2",
"Total exported apparent energy for L2 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(5))
.add(VIFCombinableRaw(0x7f02))
.add(VIFCombinableRaw(0))
);
addNumericFieldWithExtractor(
"total_apparent_energy_production_l3",
"Total exported apparent energy for L3 phase.",
DEFAULT_PRINT_PROPERTIES,
Quantity::Energy,
VifScaling::Auto,
FieldMatcher::build()
.set(MeasurementType::Instantaneous)
.set(VIFRange::AnyEnergyVIF)
.set(SubUnitNr(5))
.add(VIFCombinableRaw(0x7f03))
.add(VIFCombinableRaw(0))
);
}
}

Wyświetl plik

@ -1245,6 +1245,7 @@ bool FieldMatcher::matches(DVEntry &dv_entry)
// Test ranges and types.
bool b =
(!match_vif_range || isInsideVIFRange(dv_entry.vif, vif_range)) &&
(!match_vif_raw || dv_entry.vif == vif_raw) &&
(!match_measurement_type || dv_entry.measurement_type == measurement_type) &&
(!match_storage_nr || (dv_entry.storage_nr >= storage_nr_from && dv_entry.storage_nr <= storage_nr_to)) &&
(!match_tariff_nr || (dv_entry.tariff_nr >= tariff_nr_from && dv_entry.tariff_nr <= tariff_nr_to)) &&
@ -1350,6 +1351,11 @@ string FieldMatcher::str()
s = s+"VR("+toString(vif_range)+") ";
}
if (match_vif_raw)
{
s = s+"VRR("+to_string(vif_raw)+") ";
}
if (vif_combinables.size() > 0)
{
s += "Comb(";

Wyświetl plik

@ -57,6 +57,7 @@
X(Location,0x7D10,0x7D10, Quantity::Text, Unit::TXT) \
X(Customer,0x7D11,0x7D11, Quantity::Text, Unit::TXT) \
X(ErrorFlags,0x7D17,0x7D17, Quantity::Text, Unit::TXT) \
X(DigitalOutput,0x7D1A,0x7D1A, Quantity::Text, Unit::TXT) \
X(DigitalInput,0x7D1B,0x7D1B, Quantity::Text, Unit::TXT) \
X(DurationSinceReadout,0x7D2c,0x7D2f, Quantity::Time, Unit::Hour) \
X(DurationOfTariff,0x7D31,0x7D33, Quantity::Time, Unit::Hour) \
@ -81,6 +82,11 @@ LIST_OF_VIF_RANGES
#undef X
};
struct VIFRaw {
VIFRaw(uint16_t v) : value(v) {}
uint16_t value;
};
const char *toString(VIFRange v);
Unit toDefaultUnit(VIFRange v);
VIFRange toVIFRange(int i);
@ -399,6 +405,10 @@ struct FieldMatcher
bool match_vif_range = false;
VIFRange vif_range { VIFRange::Any };
// Match the vif exactly, used for manufacturer specific vifs.
bool match_vif_raw = false;
uint16_t vif_raw {};
// Match any vif combinables.
std::set<VIFCombinable> vif_combinables;
std::set<uint16_t> vif_combinables_raw;
@ -438,6 +448,10 @@ struct FieldMatcher
vif_range = v;
match_vif_range = (v != VIFRange::Any);
return *this; }
FieldMatcher &set(VIFRaw v) {
vif_raw = v.value;
match_vif_raw = true;
return *this; }
FieldMatcher &add(VIFCombinable v) {
vif_combinables.insert(v);
return *this; }

Wyświetl plik

@ -1507,9 +1507,9 @@ string FieldInfo::renderJsonOnlyDefaultUnit(Meter *m)
return renderJson(m, NULL);
}
string FieldInfo::renderJsonText(Meter *m)
string FieldInfo::renderJsonText(Meter *m, DVEntry *dve)
{
return renderJson(m, NULL);
return renderJson(m, dve);
}
string FieldInfo::generateFieldNameNoUnit(DVEntry *dve)
@ -2319,7 +2319,7 @@ bool FieldInfo::extractString(Meter *m, Telegram *t, DVEntry *dve)
if (found)
{
m->setStringValue(this, translated_bits);
t->addMoreExplanation(dve->offset, renderJsonText(m));
t->addMoreExplanation(dve->offset, renderJsonText(m, dve));
}
}
else if (matcher_.vif_range == VIFRange::DateTime)
@ -2338,7 +2338,7 @@ bool FieldInfo::extractString(Meter *m, Telegram *t, DVEntry *dve)
extracted_device_date_time = strdatetime(&datetime);
}
m->setStringValue(this, extracted_device_date_time);
t->addMoreExplanation(dve->offset, renderJsonText(m));
t->addMoreExplanation(dve->offset, renderJsonText(m, dve));
found = true;
}
else if (matcher_.vif_range == VIFRange::Date)
@ -2347,7 +2347,7 @@ bool FieldInfo::extractString(Meter *m, Telegram *t, DVEntry *dve)
dve->extractDate(&date);
string extracted_device_date = strdate(&date);
m->setStringValue(this, extracted_device_date);
t->addMoreExplanation(dve->offset, renderJsonText(m));
t->addMoreExplanation(dve->offset, renderJsonText(m, dve));
found = true;
}
else if (matcher_.vif_range == VIFRange::Any ||
@ -2365,7 +2365,7 @@ bool FieldInfo::extractString(Meter *m, Telegram *t, DVEntry *dve)
string extracted_id;
dve->extractReadableString(&extracted_id);
m->setStringValue(this, extracted_id);
t->addMoreExplanation(dve->offset, renderJsonText(m));
t->addMoreExplanation(dve->offset, renderJsonText(m, dve));
found = true;
}
else

Wyświetl plik

@ -317,7 +317,7 @@ struct FieldInfo
string renderJsonOnlyDefaultUnit(Meter *m);
string renderJson(Meter *m, DVEntry *dve);
string renderJsonText(Meter *m);
string renderJsonText(Meter *m, DVEntry *dve);
// Render the field name based on the actual field from the telegram.
// A FieldInfo can be declared to handle any number of storage fields of a certain range.
// The vname is then a pattern total_at_month_{storage_counter} that gets translated into