* added option for no powerlimit (setup)

* moved function showLiveData to web.cpp
* improved debug messages
* cleaned some code
This commit is contained in:
lumapu 2022-08-26 16:34:10 +02:00
parent fec8758de7
commit ae968d618a
7 changed files with 152 additions and 191 deletions

View file

@ -18,6 +18,7 @@
const uint16_t pwrLimitOptionValues[] {
NoPowerLimit,
AbsolutNonPersistent,
AbsolutPersistent,
RelativNonPersistent,
@ -25,6 +26,7 @@ const uint16_t pwrLimitOptionValues[] {
};
const char* const pwrLimitOptions[] {
"no power limit",
"absolute in Watt non persistent",
"absolute in Watt persistent",
"relativ in percent non persistent",
@ -216,7 +218,7 @@ void web::showSetup(void) {
inv += F("<label for=\"inv") + String(i) + F("ActivePowerLimitConType\">Active Power Limit Control Type</label>");
inv += F("<select name=\"inv") + String(i) + F("PowerLimitControl\">");
for(uint8_t j = 0; j < 4; j++) {
for(uint8_t j = 0; j < 5; j++) {
inv += F("<option value=\"") + String(pwrLimitOptionValues[j]) + F("\"");
if(NULL != iv) {
if(iv->powerLimit[1] == pwrLimitOptionValues[j])
@ -330,13 +332,14 @@ void web::showSave(void) {
iv->powerLimit[1] = actPwrLimitControl;
iv->devControlCmd = ActivePowerContr;
iv->devControlRequest = true;
if (iv->powerLimit[1] & 0x0001)
if ((iv->powerLimit[1] & 0x0001) == 0x0001)
DPRINTLN(DBG_INFO, F("Power limit for inverter ") + String(iv->id) + F(" set to ") + String(iv->powerLimit[0]) + F("%") );
else
else {
DPRINTLN(DBG_INFO, F("Power limit for inverter ") + String(iv->id) + F(" set to ") + String(iv->powerLimit[0]) + F("W") );
DPRINTLN(DBG_INFO, F("Power Limit Control Setting ") + String(iv->powerLimit[1]));
}
}
if (actPwrLimit == 0xffff){ // set to 100%
if (actPwrLimit == 0xffff) { // set to 100%
iv->powerLimit[0] = 100;
iv->powerLimit[1] = RelativPersistent;
iv->devControlCmd = ActivePowerContr;
@ -431,7 +434,84 @@ void web::showVisualization(void) {
//-----------------------------------------------------------------------------
void web::showLiveData(void) {
DPRINTLN(DBG_VERBOSE, F("web::showLiveData"));
mWeb->send(200, F("text/html"), mMain->getLiveData());
String modHtml;
for (uint8_t id = 0; id < mMain->mSys->getNumInverters(); id++) {
Inverter<> *iv = mMain->mSys->getInverterByPos(id);
if (NULL != iv) {
#ifdef LIVEDATA_VISUALIZED
uint8_t modNum, pos;
switch (iv->type) {
default:
case INV_TYPE_1CH: modNum = 1; break;
case INV_TYPE_2CH: modNum = 2; break;
case INV_TYPE_4CH: modNum = 4; break;
}
modHtml += F("<div class=\"iv\">"
"<div class=\"ch-iv\"><span class=\"head\">")
+ String(iv->name) + F(" Limit ")
+ String(iv->actPowerLimit) + F("%");
if(NoPowerLimit == iv->powerLimit[1])
modHtml += F(" (not controlled)");
modHtml += F(" | last Alarm: ") + iv->lastAlarmMsg + F("</span>");
uint8_t list[] = {FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_PCT, FLD_T, FLD_YT, FLD_YD, FLD_PDC, FLD_EFF, FLD_PRA, FLD_ALARM_MES_ID};
for (uint8_t fld = 0; fld < 11; fld++) {
pos = (iv->getPosByChFld(CH0, list[fld]));
if (0xff != pos) {
modHtml += F("<div class=\"subgrp\">");
modHtml += F("<span class=\"value\">") + String(iv->getValue(pos));
modHtml += F("<span class=\"unit\">") + String(iv->getUnit(pos)) + F("</span></span>");
modHtml += F("<span class=\"info\">") + String(iv->getFieldName(pos)) + F("</span>");
modHtml += F("</div>");
}
}
modHtml += "</div>";
for (uint8_t ch = 1; ch <= modNum; ch++) {
modHtml += F("<div class=\"ch\"><span class=\"head\">");
if (iv->chName[ch - 1][0] == 0)
modHtml += F("CHANNEL ") + String(ch);
else
modHtml += String(iv->chName[ch - 1]);
modHtml += F("</span>");
for (uint8_t j = 0; j < 6; j++) {
switch (j) {
default: pos = (iv->getPosByChFld(ch, FLD_UDC)); break;
case 1: pos = (iv->getPosByChFld(ch, FLD_IDC)); break;
case 2: pos = (iv->getPosByChFld(ch, FLD_PDC)); break;
case 3: pos = (iv->getPosByChFld(ch, FLD_YD)); break;
case 4: pos = (iv->getPosByChFld(ch, FLD_YT)); break;
case 5: pos = (iv->getPosByChFld(ch, FLD_IRR)); break;
}
if (0xff != pos) {
modHtml += F("<span class=\"value\">") + String(iv->getValue(pos));
modHtml += F("<span class=\"unit\">") + String(iv->getUnit(pos)) + F("</span></span>");
modHtml += F("<span class=\"info\">") + String(iv->getFieldName(pos)) + F("</span>");
}
}
modHtml += "</div>";
yield();
}
modHtml += F("<div class=\"ts\">Last received data requested at: ") + mMain->getDateTimeStr(iv->ts) + F("</div>");
modHtml += F("</div>");
#else
// dump all data to web frontend
modHtml = F("<pre>");
char topic[30], val[10];
for (uint8_t i = 0; i < iv->listLen; i++) {
snprintf(topic, 30, "%s/ch%d/%s", iv->name, iv->assign[i].ch, iv->getFieldName(i));
snprintf(val, 10, "%.3f %s", iv->getValue(i), iv->getUnit(i));
modHtml += String(topic) + ": " + String(val) + "\n";
}
modHtml += F("</pre>");
#endif
}
}
mWeb->send(200, F("text/html"), modHtml);
}