Browse Source

ZE optimize Log, Bugfixes

pull/1581/head
Patrick Amrhein 10 months ago
parent
commit
afd211035c
  1. 89
      src/plugins/zeroExport/zeroExport.h

89
src/plugins/zeroExport/zeroExport.h

@ -284,7 +284,7 @@ class ZeroExport {
unsigned long bTsp = millis(); unsigned long bTsp = millis();
mLog["g"] = group; mLog["g"] = group;
mLog["s"] = (100 + (uint8_t)zeroExportState::SETLIMIT); mLog["s"] = (uint8_t)zeroExportState::SETLIMIT;
if (mCfg->debug) mLog["t"] = "eventAckSetLimit"; if (mCfg->debug) mLog["t"] = "eventAckSetLimit";
JsonArray logArr = mLog.createNestedArray("ix"); JsonArray logArr = mLog.createNestedArray("ix");
@ -294,7 +294,7 @@ class ZeroExport {
JsonObject logObj = logArr.createNestedObject(); JsonObject logObj = logArr.createNestedObject();
logObj["i"] = inv; logObj["i"] = inv;
logObj["id"] = iv->id; if (mCfg->debug) logObj["id"] = iv->id;
mCfg->groups[group].inverters[inv].waitAckSetLimit = 0; mCfg->groups[group].inverters[inv].waitAckSetLimit = 0;
logObj["wL"] = mCfg->groups[group].inverters[inv].waitAckSetLimit; logObj["wL"] = mCfg->groups[group].inverters[inv].waitAckSetLimit;
@ -328,7 +328,7 @@ class ZeroExport {
unsigned long bTsp = millis(); unsigned long bTsp = millis();
mLog["g"] = group; mLog["g"] = group;
mLog["s"] = (100 + (uint8_t)zeroExportState::SETPOWER); mLog["s"] = (uint8_t)zeroExportState::SETPOWER;
if (mCfg->debug) mLog["t"] = "eventAckSetPower"; if (mCfg->debug) mLog["t"] = "eventAckSetPower";
JsonArray logArr = mLog.createNestedArray("ix"); JsonArray logArr = mLog.createNestedArray("ix");
@ -372,7 +372,7 @@ class ZeroExport {
unsigned long bTsp = millis(); unsigned long bTsp = millis();
mLog["g"] = group; mLog["g"] = group;
mLog["s"] = (100 + (uint8_t)zeroExportState::SETREBOOT); mLog["s"] = (uint8_t)zeroExportState::SETREBOOT;
if (mCfg->debug) mLog["t"] = "eventAckSetReboot"; if (mCfg->debug) mLog["t"] = "eventAckSetReboot";
JsonArray logArr = mLog.createNestedArray("ix"); JsonArray logArr = mLog.createNestedArray("ix");
@ -689,6 +689,7 @@ class ZeroExport {
*/ */
bool groupGetInverterData(uint8_t group, unsigned long *tsp, bool *doLog) { bool groupGetInverterData(uint8_t group, unsigned long *tsp, bool *doLog) {
zeroExportGroup_t *cfgGroup = &mCfg->groups[group]; zeroExportGroup_t *cfgGroup = &mCfg->groups[group];
bool result = true;
cfgGroup->lastRun = *tsp; cfgGroup->lastRun = *tsp;
@ -697,9 +698,6 @@ class ZeroExport {
*doLog = true; *doLog = true;
} }
// Init data
cfgGroup->power = 0;
// Get Data // Get Data
JsonArray logArr = mLog.createNestedArray("ix"); JsonArray logArr = mLog.createNestedArray("ix");
int32_t power = 0; int32_t power = 0;
@ -713,7 +711,10 @@ class ZeroExport {
// Inverter not enabled or not selected -> ignore // Inverter not enabled or not selected -> ignore
if (NotEnabledOrNotSelected(group, inv)) continue; if (NotEnabledOrNotSelected(group, inv)) continue;
if (!mIv[group][inv]->isAvailable()) continue; if (!mIv[group][inv]->isAvailable()) {
result = false;
continue;
}
record_t<> *rec; record_t<> *rec;
rec = mIv[group][inv]->getRecordStruct(RealTimeRunData_Debug); rec = mIv[group][inv]->getRecordStruct(RealTimeRunData_Debug);
@ -724,14 +725,22 @@ class ZeroExport {
power += cfgGroupInv->power; power += cfgGroupInv->power;
// Get dcVoltage // Get dcVoltage
cfgGroupInv->dcVoltage = mIv[group][inv]->getChannelFieldValue(CH1, FLD_UDC, rec); float U = mIv[group][inv]->getChannelFieldValue(CH1, FLD_UDC, rec);
if (U == 0) {
result = false;
continue;
}
cfgGroupInv->dcVoltage = U;
logObj["U"] = cfgGroupInv->dcVoltage; logObj["U"] = cfgGroupInv->dcVoltage;
} }
cfgGroup->power = power; cfgGroup->power = power;
mLog["P"] = cfgGroup->power; mLog["P"] = cfgGroup->power;
return true; if ((cfgGroup->battEnabled) && (cfgGroup->power > 0))
cfgGroup->battSwitch = true;
return result;
} }
/** groupBatteryprotection /** groupBatteryprotection
@ -779,24 +788,37 @@ class ZeroExport {
return false; return false;
} }
bool switchOn = true; // Check
bool switchOff = false; JsonArray logArr = mLog.createNestedArray("ix");
for (uint8_t inv = 0; inv < ZEROEXPORT_GROUP_MAX_INVERTERS; inv++) {
// Inverter not enabled or not selected -> ignore
if (NotEnabledOrNotSelected(group, inv)) continue;
if (cfgGroup->inverters[inv].dcVoltage < cfgGroup->battVoltageOn) switchOn = false; if (!cfgGroup->battSwitch) {
if (cfgGroup->inverters[inv].dcVoltage < cfgGroup->battVoltageOff) switchOff = true; // is off turn on
} for (uint8_t inv = 0; inv < ZEROEXPORT_GROUP_MAX_INVERTERS; inv++) {
// Inverter not enabled or not selected -> ignore
if (NotEnabledOrNotSelected(group, inv)) continue;
if (switchOff == true) { JsonObject logObj = logArr.createNestedObject();
cfgGroup->battSwitch = false; logObj["i"] = inv;
*doLog = true; logObj["U"] = cfgGroup->inverters[inv].dcVoltage;
} else {
if (switchOn == true) { if (cfgGroup->inverters[inv].dcVoltage < cfgGroup->battVoltageOn) continue;
cfgGroup->battSwitch = true; cfgGroup->battSwitch = true;
*doLog = true; *doLog = true;
} }
} else {
// is on turn off
for (uint8_t inv = 0; inv < ZEROEXPORT_GROUP_MAX_INVERTERS; inv++) {
// Inverter not enabled or not selected -> ignore
if (NotEnabledOrNotSelected(group, inv)) continue;
JsonObject logObj = logArr.createNestedObject();
logObj["i"] = inv;
logObj["U"] = cfgGroup->inverters[inv].dcVoltage;
if (cfgGroup->inverters[inv].dcVoltage > cfgGroup->battVoltageOff) continue;
cfgGroup->battSwitch = false;
*doLog = true;
}
} }
} else { } else {
mLog["en"] = false; mLog["en"] = false;
@ -1085,9 +1107,9 @@ class ZeroExport {
// Inverter not enabled or not selected -> ignore // Inverter not enabled or not selected -> ignore
if (NotEnabledOrNotSelected(group, inv)) continue; if (NotEnabledOrNotSelected(group, inv)) continue;
/// record_t<> *rec; /// record_t<> *rec;
/// rec = mIv[group][inv]->getRecordStruct(RealTimeRunData_Debug); /// rec = mIv[group][inv]->getRecordStruct(RealTimeRunData_Debug);
/// cfgGroupInv->power = mIv[group][inv]->getChannelFieldValue(CH0, FLD_PAC, rec); /// cfgGroupInv->power = mIv[group][inv]->getChannelFieldValue(CH0, FLD_PAC, rec);
if ((cfgGroupInv->power < ivPmin[cfgGroupInv->target]) && (cfgGroupInv->limit < cfgGroupInv->powerMax) && (cfgGroupInv->limit < mIv[group][inv]->getMaxPower())) { if ((cfgGroupInv->power < ivPmin[cfgGroupInv->target]) && (cfgGroupInv->limit < cfgGroupInv->powerMax) && (cfgGroupInv->limit < mIv[group][inv]->getMaxPower())) {
grpTarget[cfgGroupInv->target] = true; grpTarget[cfgGroupInv->target] = true;
@ -1216,6 +1238,7 @@ class ZeroExport {
if (mCfg->debug) { if (mCfg->debug) {
logObj["dR"] = cfgGroupInv->doReboot; logObj["dR"] = cfgGroupInv->doReboot;
logObj["wR"] = cfgGroupInv->waitAckSetReboot; logObj["wR"] = cfgGroupInv->waitAckSetReboot;
*doLog = true;
} }
// Wait // Wait
@ -1402,9 +1425,9 @@ class ZeroExport {
continue; continue;
} }
logObj["wL"] = cfgGroupInv->waitAckSetLimit;
if (mCfg->debug) { if (mCfg->debug) {
logObj["dL"] = cfgGroupInv->doLimit; logObj["dL"] = cfgGroupInv->doLimit;
logObj["wL"] = cfgGroupInv->waitAckSetLimit;
logObj["L"] = cfgGroupInv->limit; logObj["L"] = cfgGroupInv->limit;
} }
@ -1660,18 +1683,6 @@ class ZeroExport {
* Sendet den LogSpeicher über Webserial und/oder MQTT * Sendet den LogSpeicher über Webserial und/oder MQTT
*/ */
void sendLog(void) { void sendLog(void) {
//if (mLog["s"] == 1) return;
//if (mLog["s"] == 2) return;
//if (mLog["s"] == 3) return;
if (mLog["s"] == 4) return;
//if (mLog["s"] == 5) return;
//if (mLog["s"] == 6) return;
//if (mLog["s"] == 7) return;
//if (mLog["s"] == 8) return;
//if (mLog["s"] == 9) return;
//if (mLog["s"] == 10) return;
// Log over Webserial // Log over Webserial
if (mCfg->log_over_webserial) { if (mCfg->log_over_webserial) {
DPRINTLN(DBG_INFO, String("ze: ") + mDocLog.as<String>()); DPRINTLN(DBG_INFO, String("ze: ") + mDocLog.as<String>());

Loading…
Cancel
Save