mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-21 02:17:56 +00:00
Fixed segfault when enabling verbose debug with fixed price
This commit is contained in:
parent
d729d0c5bd
commit
eea1782280
@ -81,7 +81,7 @@ public:
|
||||
EnergyAccountingData getData();
|
||||
void setData(EnergyAccountingData&);
|
||||
|
||||
void setFixedPrice(float price);
|
||||
void setFixedPrice(float price, String currency);
|
||||
float getPriceForHour(uint8_t h);
|
||||
|
||||
private:
|
||||
@ -97,6 +97,7 @@ private:
|
||||
float produce = 0, incomeHour = 0, incomeDay = 0;
|
||||
EnergyAccountingData data = { 0, 0, 0, 0, 0, 0 };
|
||||
float fixedPrice = 0;
|
||||
String currency = "";
|
||||
|
||||
void calcDayCost();
|
||||
bool updateMax(uint16_t val, uint8_t day);
|
||||
|
||||
@ -132,7 +132,7 @@ bool EnergyAccounting::update(AmsData* amsData) {
|
||||
use += kwhi;
|
||||
if(price != ENTSOE_NO_VALUE) {
|
||||
float cost = price * kwhi;
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) and %.4f %s\n"), cost / 100.0, eapi->getCurrency());
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) and %.4f %s\n"), cost / 100.0, currency.c_str());
|
||||
costHour += cost;
|
||||
costDay += cost;
|
||||
}
|
||||
@ -142,7 +142,7 @@ bool EnergyAccounting::update(AmsData* amsData) {
|
||||
produce += kwhe;
|
||||
if(price != ENTSOE_NO_VALUE) {
|
||||
float income = price * kwhe;
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) and %.4f %s\n"), income / 100.0, eapi->getCurrency());
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) and %.4f %s\n"), income / 100.0, currency.c_str());
|
||||
incomeHour += income;
|
||||
incomeDay += income;
|
||||
}
|
||||
@ -499,8 +499,9 @@ bool EnergyAccounting::updateMax(uint16_t val, uint8_t day) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void EnergyAccounting::setFixedPrice(float price) {
|
||||
void EnergyAccounting::setFixedPrice(float price, String currency) {
|
||||
this->fixedPrice = price;
|
||||
this->currency = currency;
|
||||
}
|
||||
|
||||
float EnergyAccounting::getPriceForHour(uint8_t h) {
|
||||
|
||||
@ -186,7 +186,7 @@ void setup() {
|
||||
ws.setEntsoeApi(eapi);
|
||||
}
|
||||
ws.setPriceSettings(entsoe.area, entsoe.currency);
|
||||
ea.setFixedPrice(entsoe.fixedPrice / 1000.0);
|
||||
ea.setFixedPrice(entsoe.fixedPrice / 1000.0, entsoe.currency);
|
||||
bool shared = false;
|
||||
config.getMeterConfig(meterConfig);
|
||||
Serial.flush();
|
||||
@ -655,7 +655,7 @@ void handlePriceApi(unsigned long now) {
|
||||
}
|
||||
ws.setPriceSettings(entsoe.area, entsoe.currency);
|
||||
config.ackEntsoeChange();
|
||||
ea.setFixedPrice(entsoe.fixedPrice / 1000.0);
|
||||
ea.setFixedPrice(entsoe.fixedPrice / 1000.0, entsoe.currency);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user