Price config

This commit is contained in:
Gunnar Skjold
2023-12-25 14:47:28 +01:00
parent fa87cfaa61
commit fffd95dcf2
25 changed files with 515 additions and 99 deletions

View File

@@ -188,9 +188,9 @@ struct PriceServiceConfig {
char entsoeToken[37];
char area[17];
char currency[4];
uint32_t multiplier;
uint32_t unused1;
bool enabled;
uint16_t fixedPrice;
uint16_t unused2;
}; // 64
struct EnergyAccountingConfig {

View File

@@ -18,5 +18,6 @@
#define FILE_ENERGYACCOUNTING "/energyaccounting.bin"
#define FILE_CFG "/configfile.cfg"
#define FILE_PRICE_CONF "/priceconf.bin"
#endif

View File

@@ -593,9 +593,7 @@ bool AmsConfiguration::setPriceServiceConfig(PriceServiceConfig& config) {
priceChanged |= strcmp(config.entsoeToken, existing.entsoeToken) != 0;
priceChanged |= strcmp(config.area, existing.area) != 0;
priceChanged |= strcmp(config.currency, existing.currency) != 0;
priceChanged |= config.multiplier != existing.multiplier;
priceChanged |= config.enabled != existing.enabled;
priceChanged |= config.fixedPrice != existing.fixedPrice;
} else {
priceChanged = true;
}
@@ -615,9 +613,9 @@ void AmsConfiguration::clearPriceServiceConfig(PriceServiceConfig& config) {
strcpy(config.entsoeToken, "");
strcpy(config.area, "");
strcpy(config.currency, "");
config.multiplier = 1000;
config.unused1 = 1000;
config.enabled = false;
config.fixedPrice = 0;
config.unused2 = 0;
}
bool AmsConfiguration::isPriceServiceChanged() {
@@ -972,7 +970,7 @@ bool AmsConfiguration::relocateConfig102() {
PriceServiceConfig entsoe;
EEPROM.get(CONFIG_ENTSOE_START_103, entsoe);
entsoe.fixedPrice = 0;
entsoe.unused2 = 0;
EEPROM.put(CONFIG_ENTSOE_START_103, entsoe);
EEPROM.put(EEPROM_CONFIG_ADDRESS, 103);
@@ -1240,7 +1238,6 @@ void AmsConfiguration::print(Print* debugger)
debugger->println(F("--Price configuration--"));
debugger->printf_P(PSTR("Area: %s\r\n"), price.area);
debugger->printf_P(PSTR("Currency: %s\r\n"), price.currency);
debugger->printf_P(PSTR("Multiplier: %f\r\n"), price.multiplier / 1000.0);
debugger->printf_P(PSTR("ENTSO-E Token: %s\r\n"), price.entsoeToken);
}
debugger->println(F(""));