diff --git a/src/CHANGES.md b/src/CHANGES.md index 23d17732..1cc2f00a 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,8 @@ # Development Changes +## 0.7.64 - 2023-10-02 +* moved active power control to modal in `live` view (per inverter) by click on current APC state + ## 0.7.63 - 2023-10-01 * fix NRF24 communication #1200 diff --git a/src/defines.h b/src/defines.h index 5938213a..ac96ff43 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 7 -#define VERSION_PATCH 63 +#define VERSION_PATCH 64 //------------------------------------- typedef struct { diff --git a/src/web/RestApi.h b/src/web/RestApi.h index a3a0384c..39c97532 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -105,6 +105,8 @@ class RestApi { getIvVersion(root, request->url().substring(22).toInt()); else if(path.substring(0, 19) == "inverter/radiostat/") getIvStatistis(root, request->url().substring(24).toInt()); + else if(path.substring(0, 16) == "inverter/pwrack/") + getIvPowerLimitAck(root, request->url().substring(21).toInt()); else getNotFound(root, F("http://") + request->host() + F("/api/")); } @@ -276,7 +278,7 @@ class RestApi { void getHtmlSystem(AsyncWebServerRequest *request, JsonObject obj) { getSysInfo(request, obj.createNestedObject(F("system"))); getGeneric(request, obj.createNestedObject(F("generic"))); - obj[F("html")] = F("Factory ResetReboot"); + obj[F("html")] = F("AhoyFactory ResetReboot"); } void getHtmlLogout(AsyncWebServerRequest *request, JsonObject obj) { @@ -322,6 +324,15 @@ class RestApi { obj[F("retransmits")] = iv->radioStatistics.retransmits; } + void getIvPowerLimitAck(JsonObject obj, uint8_t id) { + Inverter<> *iv = mSys->getInverterByPos(id); + if(NULL == iv) { + obj[F("error")] = F("inverter not found!"); + return; + } + obj["ack"] = (bool)iv->powerLimitAck; + } + void getInverterList(JsonObject obj) { JsonArray invArr = obj.createNestedArray(F("inverter")); @@ -389,10 +400,10 @@ class RestApi { ch0[fld] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; } } else { - for (uint8_t fld = 0; fld < sizeof(acList); fld++) { - pos = (iv->getPosByChFld(CH0, acList[fld], rec)); - ch0[fld] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; - } + for (uint8_t fld = 0; fld < sizeof(acList); fld++) { + pos = (iv->getPosByChFld(CH0, acList[fld], rec)); + ch0[fld] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; + } } // DC @@ -652,6 +663,7 @@ class RestApi { jsonOut[F("error")] = F("inverter index invalid: ") + jsonIn[F("id")].as(); return false; } + jsonOut[F("id")] = jsonIn[F("id")]; if(F("power") == jsonIn[F("cmd")]) accepted = iv->setDevControlRequest((jsonIn[F("val")] == 1) ? TurnOn : TurnOff); diff --git a/src/web/html/includes/nav.html b/src/web/html/includes/nav.html index 9d6b822c..91de5047 100644 --- a/src/web/html/includes/nav.html +++ b/src/web/html/includes/nav.html @@ -7,7 +7,7 @@ Live - Serial / Control + Webserial Settings Update diff --git a/src/web/html/serial.html b/src/web/html/serial.html index 442ba24a..10d1769e 100644 --- a/src/web/html/serial.html +++ b/src/web/html/serial.html @@ -12,53 +12,13 @@ - connected: + console active: Uptime: - + - - - Commands - - - Select Inverter - - - - Power Limit Command - - - select the unit and persistence - absolute non persistent [W] - relative non persistent [%] - absolute persistent [W] - relative persistent [%] - - - - - Power Limit Value - - - - - - - - Control Inverter - - - - - - - - Ctrl result - n/a - {#HTML_FOOTER} @@ -84,23 +44,11 @@ parseESP(obj); window.setInterval("getAjax('/api/generic', parseGeneric)", 10000); exeOnce = false; - getAjax("/api/inverter/list", parse); + setTimeOffset(); } } - function parse(root) { - select = document.getElementById('InvID'); - - if(null == root) return; - root = root.inverter; - for(var i = 0; i < root.length; i++) { - inv = root[i]; - var opt = document.createElement('option'); - opt.value = inv.id; - opt.innerHTML = inv.name; - select.appendChild(opt); - } - + function setTimeOffset() { // set time offset for serial console var obj = new Object(); obj.cmd = "serial_utc_offset"; @@ -119,12 +67,12 @@ if (!!window.EventSource) { var source = new EventSource('/events'); source.addEventListener('open', function(e) { - document.getElementById("connected").style.backgroundColor = "#0c0"; + document.getElementById("active").style.backgroundColor = "#0c0"; }, false); source.addEventListener('error', function(e) { if (e.target.readyState != EventSource.OPEN) { - document.getElementById("connected").style.backgroundColor = "#f00"; + document.getElementById("active").style.backgroundColor = "#f00"; } }, false); @@ -135,56 +83,6 @@ }, false); } - - function ctrlCb(obj) { - var e = document.getElementById("result"); - if(obj["success"]) - e.innerHTML = "ok"; - else - e.innerHTML = "Error: " + obj["error"]; - } - - function get_selected_iv() { - var e = document.getElementById("InvID"); - return parseInt(e.value); - } - - const wrapper = document.getElementById('power'); - - wrapper.addEventListener('click', (event) => { - var obj = new Object(); - obj.id = get_selected_iv(); - obj.cmd = "power"; - - switch (event.target.value) { - default: - case "Turn On": - obj.val = 1; - break; - case "Turn Off": - obj.val = 0; - break; - } - - getAjax("/api/ctrl", ctrlCb, "POST", JSON.stringify(obj)); - }); - - document.getElementById("sendpwrlim").addEventListener("click", function() { - var val = parseInt(document.getElementsByName('pwrlimval')[0].value); - var cmd = document.getElementsByName('pwrlimctrl')[0].value; - - if(isNaN(val)) { - document.getElementById("result").textContent = "value is missing"; - return; - } - - var obj = new Object(); - obj.id = get_selected_iv(); - obj.cmd = cmd; - obj.val = val; - getAjax("/api/ctrl", ctrlCb, "POST", JSON.stringify(obj)); - }); - getAjax("/api/generic", parseGeneric);