1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-16 07:23:07 +01:00

make the counter display and the channel names dynamic in the UI

This commit is contained in:
andreas
2023-08-31 12:24:21 +02:00
parent 019fb8ff6a
commit cb98324604
5 changed files with 109 additions and 54 deletions

View File

@@ -57,7 +57,7 @@ GwChannel::GwChannel(GwLog *logger,
this->logger = logger;
this->name=name;
this->sourceId=sourceId;
this->maxSourceId=sourceId;
this->maxSourceId=maxSourceId;
this->countIn=new GwCounter<String>(String("count")+name+String("in"));
this->countOut=new GwCounter<String>(String("count")+name+String("out"));
this->impl=NULL;
@@ -146,12 +146,15 @@ bool GwChannel::canReceive(const char *buffer){
}
int GwChannel::getJsonSize(){
int rt=2;
int rt=JSON_OBJECT_SIZE(6);
if (countIn) rt+=countIn->getJsonSize();
if (countOut) rt+=countOut->getJsonSize();
return rt;
}
void GwChannel::toJson(GwJsonDocument &doc){
JsonObject jo=doc.createNestedObject("ch"+name);
jo["id"]=sourceId;
jo["max"]=maxSourceId;
if (countOut) countOut->toJson(doc);
if (countIn) countIn->toJson(doc);
}