mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-04-17 09:10:52 +00:00
Some adjustments for real time calculation
This commit is contained in:
@@ -52,7 +52,7 @@ bool EnergyAccounting::update(AmsData* amsData) {
|
||||
calcDayCost();
|
||||
}
|
||||
|
||||
if(amsData->getListType() >= 3 && local.Hour != currentHour) {
|
||||
if(local.Hour != currentHour && (amsData->getListType() >= 3 || local.Minute == 1)) {
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EnergyAccounting) New local hour %d\n", local.Hour);
|
||||
|
||||
if(calcDayUse()) ret = true;
|
||||
@@ -102,14 +102,9 @@ bool EnergyAccounting::update(AmsData* amsData) {
|
||||
if(config != NULL) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(EnergyAccounting) calculating threshold, currently at %d\n", currentThresholdIdx);
|
||||
while(getMonthMax() > config->thresholds[currentThresholdIdx] && currentThresholdIdx < 10) currentThresholdIdx++;
|
||||
while(use > config->thresholds[currentThresholdIdx] && currentThresholdIdx < 10) currentThresholdIdx++;
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(EnergyAccounting) new threshold %d\n", currentThresholdIdx);
|
||||
}
|
||||
|
||||
if(use > data.maxHour) {
|
||||
data.maxHour = use; // Not really a good idea to use calculated value, but when you pass midnight and have the highest use at hour 23, it will not be included through 'calcDayUse'
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -207,6 +202,10 @@ uint8_t EnergyAccounting::getCurrentThreshold() {
|
||||
return config->thresholds[currentThresholdIdx];
|
||||
}
|
||||
|
||||
uint8_t EnergyAccounting::getCurrentHour() {
|
||||
return currentHour;
|
||||
}
|
||||
|
||||
float EnergyAccounting::getMonthMax() {
|
||||
return data.maxHour / 100.0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user