Skip to content

Commit

Permalink
0.7.33
Browse files Browse the repository at this point in the history
* add alarms overview to WebGui #608
* fix webGui total values #1084
  • Loading branch information
lumapu committed Aug 15, 2023
1 parent 8544e86 commit 9b250c5
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Development Changes

## 0.7.33 - 2023-08-15
* add alarms overview to WebGui #608
* fix webGui total values #1084

## 0.7.32 - 2023-08-14
* fix colors of live view #1091

Expand Down
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 7
#define VERSION_PATCH 32
#define VERSION_PATCH 33

//-------------------------------------
typedef struct {
Expand Down
4 changes: 2 additions & 2 deletions src/hms/hmsRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ class CmtRadio {
initPacket(ivId, reqfld, ALL_FRAMES);
mTxBuf[10] = cmd;
CP_U32_LittleEndian(&mTxBuf[12], ts);
if (cmd == AlarmData ) { //cmd == RealTimeRunData_Debug ||
/*if (cmd == AlarmData ) { //cmd == RealTimeRunData_Debug ||
mTxBuf[18] = (alarmMesId >> 8) & 0xff;
mTxBuf[19] = (alarmMesId ) & 0xff;
}
}*/
sendPacket(24, isRetransmit);
}

Expand Down
6 changes: 4 additions & 2 deletions src/web/RestApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ class RestApi {
obj[F("ts_last_success")] = rec->ts;
obj[F("generation")] = iv->ivGen;
obj[F("status")] = (uint8_t)iv->status;
obj[F("alarm_cnt")] = iv->alarmCnt;

JsonArray ch = obj.createNestedArray("ch");

Expand Down Expand Up @@ -406,8 +407,9 @@ class RestApi {

record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug);

obj["cnt"] = iv->alarmCnt;
obj["last_id"] = iv->getChannelFieldValue(CH0, FLD_EVT, rec);
obj[F("iv_id")] = id;
obj[F("cnt")] = iv->alarmCnt;
obj[F("last_id")] = iv->getChannelFieldValue(CH0, FLD_EVT, rec);

JsonArray alarm = obj.createNestedArray(F("alarm"));
for(uint8_t i = 0; i < 10; i++) {
Expand Down
30 changes: 30 additions & 0 deletions src/web/html/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ function toIsoDateStr(d) {
return new Date(d.getTime() + (d.getTimezoneOffset() * -60000)).toISOString().substring(0, 19).replace('T', ', ');
}

function toIsoTimeStr(d) {
return new Date(d.getTime() + (d.getTimezoneOffset() * -60000)).toISOString().substring(11, 19).replace('T', ', ');
}

function setHide(id, hide) {
var elm = document.getElementById(id);
if(hide) {
Expand Down Expand Up @@ -272,3 +276,29 @@ function svg(data=null, w=24, h=24, cl=null, tooltip=null) {
}
return s;
}

function modal(title, body) {
if(null == document.getElementById("modal")) {
document.getElementById("wrapper").append(
ml("div", {id: "modal-wrapper", class: "modal", onclick: modalClose}),
ml("div", {id: "modal", class: "modal"},
ml("div", {class: "modal-content"}, [
ml("div", {class: "modal-header"}, [
ml("h5", {}, title),
ml("button", {class: "close", type: "button", onclick: modalClose}, "&times;")
]),
ml("div", {class: "modal-body"}, body)
]
)
)
);
}
}

function modalClose() {
var e = document.getElementById("modal");
if(null != e) {
e.remove();
document.getElementById("modal-wrapper").remove();
}
}
72 changes: 72 additions & 0 deletions src/web/html/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -651,3 +651,75 @@ div.hr {
margin-left: -5px;
transform: translate(0,0px);
}

#modal {
max-width: 700px;
margin: 1.75rem auto;
}

.modal {
position: fixed;
top: 0;
right: 0;
left: 0;
z-index: 1072;
display: block;
}

#modal-wrapper {
background-color: #000;
opacity: 0.5;
bottom: 0;
}

.modal-content {
border-radius: .3rem;
position: relative;
display: flex;
width: 100%;
background-color: var(--nav-active);
background-clip: padding-box;
border: 1px solid rgba(0,0,0,.2);
flex-direction: column;
}

.modal-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 1rem;
border-bottom: 1px solid #e9ecef;
}

.modal-header .close {
padding: 0.7rem;
margin: -1rem -1rem -1rem auto;
}

.modal-body {
padding: 1rem 1rem 2rem 1rem;
}

.close {
font-size: 2rem;
opacity: 0.5;
font-family: inherit;
cursor: pointer;
padding: 0;
}

button.close {
background-color: transparent;
border: 0;
}

h5 {
font-size: 1.25rem;
margin-top: 0;
margin-bottom: 0.5rem;
font-weight: 500;
}

.pointer {
cursor: pointer;
}
35 changes: 33 additions & 2 deletions src/web/html/visualization.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@
function ivHead(obj) {
if(0 != obj.status) { // only add totals if inverter is online
total[0] += obj.ch[0][2]; // P_AC
total[1] += obj.ch[0][7]; // YieldDay
total[2] += obj.ch[0][6]; // YieldTotal
total[3] += obj.ch[0][8]; // P_DC
total[4] += obj.ch[0][10]; // Q_AC
}
total[1] += obj.ch[0][7]; // YieldDay
total[2] += obj.ch[0][6]; // YieldTotal

var t = span("&nbsp;&deg;C");
var clh = (0 == obj.status) ? "iv-h-dis" : "iv-h";
var clbg = (0 == obj.status) ? "iv-bg-dis" : "iv-bg";
Expand All @@ -103,6 +104,9 @@
ml("div", {class: "row"}, [
ml("div", {class: "col mx-2 mx-md-1"}, obj.name),
ml("div", {class: "col a-c"}, "Power limit " + ((obj.power_limit_read == 65535) ? "n/a" : (obj.power_limit_read + "&nbsp;%"))),
ml("div", {class: "col a-c"}, ml("span", { class: "pointer", onclick: function() {
getAjax("/api/inverter/alarm/" + obj.id, parseIvAlarm);
}}, ("Alarms: " + obj.alarm_cnt))),
ml("div", {class: "col a-r mx-2 mx-md-1"}, String(obj.ch[0][5]) + t.innerText)
])
),
Expand Down Expand Up @@ -200,6 +204,7 @@
])
);


var last = true;
for(var i = obj.id + 1; i < ivEn.length; i++) {
if((i != ivEn.length) && ivEn[i]) {
Expand All @@ -215,6 +220,32 @@
}
}

function parseIvAlarm(obj) {
var html = [];
html.push(
ml("div", {class: "row"}, [
ml("div", {class: "col"}, ml("strong", {}, "String")),
ml("div", {class: "col"}, ml("strong", {}, "ID")),
ml("div", {class: "col"}, ml("strong", {}, "Start")),
ml("div", {class: "col"}, ml("strong", {}, "End"))
])
);

for(a of obj.alarm) {
if(a.code != 0) {
html.push(
ml("div", {class: "row"}, [
ml("div", {class: "col mt-3"}, String(a.str)),
ml("div", {class: "col mt-3"}, String(a.code)),
ml("div", {class: "col mt-3"}, String(toIsoTimeStr(new Date(a.start * 1000)))),
ml("div", {class: "col mt-3"}, String(toIsoTimeStr(new Date(a.end * 1000))))
])
);
}
}
modal("Alarms of inverter #" + obj.iv_id, ml("div", {}, html));
}

function parse(obj) {
if(null != obj) {
parseGeneric(obj["generic"]);
Expand Down

0 comments on commit 9b250c5

Please sign in to comment.