Skip to content

Commit

Permalink
rename varN function to varChildren
Browse files Browse the repository at this point in the history
  • Loading branch information
ewowi committed Mar 2, 2024
1 parent b08db57 commit e77f88b
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/App/AppModLeds.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class AppModLeds:public SysModule {

// ui->stageVarChanged = true;
// //rebuild the table
for (JsonObject childVar: mdl->varN("e131Tbl"))
for (JsonObject childVar: mdl->varChildren("e131Tbl"))
ui->callVarFun(childVar, UINT8_MAX, f_ValueFun);

// }
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void SysModFiles::loop() {

ui->callVarFun(mdl->findVar("drsize")); //valueFun

for (JsonObject childVar: mdl->varN("fileTbl"))
for (JsonObject childVar: mdl->varChildren("fileTbl"))
ui->callVarFun(childVar, UINT8_MAX, f_ValueFun);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Sys/SysModModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void SysModModel::cleanUpModel(JsonObject parent, bool oPos, bool ro) {
if (parent.isNull()) //no parent
vars = model->as<JsonArray>();
else
vars = varN(parent);
vars = varChildren(parent);

for (JsonArray::iterator varV=vars.begin(); varV!=vars.end(); ++varV) {
// for (JsonVariant varV : vars) {
Expand Down Expand Up @@ -140,7 +140,7 @@ void SysModModel::cleanUpModel(JsonObject parent, bool oPos, bool ro) {
}

//recursive call
if (!varN(var).isNull())
if (!varChildren(var).isNull())
cleanUpModel(var, oPos, ro);
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/Sys/SysModModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,15 @@ class SysModModel:public SysModule {
const char * varID(JsonObject var) {return var["id"];}
bool varRO(JsonObject var) {return var["ro"];}
void varRO(JsonObject var, bool value) {var["ro"] = value;}
JsonArray varN(const char * id) {return varN(findVar(id));}
JsonArray varN(JsonObject var) {return var["n"];}
JsonArray varChildren(const char * id) {return varChildren(findVar(id));}
JsonArray varChildren(JsonObject var) {return var["n"];}
JsonArray varValArray(JsonObject var) {if (var["value"].is<JsonArray>()) return var["value"]; else return JsonArray(); }
int varOrder(JsonObject var) {return var["o"];}
void varOrder(JsonObject var, int value) {var["o"] = value;}

//recursively remove all value[rowNr] from children of var
void varRemoveValuesForRow(JsonObject var, uint8_t rowNr) {
for (JsonObject childVar: varN(var)) {
for (JsonObject childVar: varChildren(var)) {
JsonArray valArray = varValArray(childVar);
if (!valArray.isNull()) {
valArray.remove(rowNr);
Expand All @@ -336,7 +336,7 @@ class SysModModel:public SysModule {
}

void varPreDetails(JsonObject var, uint8_t rowNr = UINT8_MAX) {
for (JsonObject var: varN(var)) { //for all controls
for (JsonObject var: varChildren(var)) { //for all controls
if (varOrder(var) >= 0) { //post init
varOrder(var, -varOrder(var)); // set all negative
}
Expand All @@ -354,7 +354,7 @@ class SysModModel:public SysModule {

//check if post init added: parent is already >=0
if (varOrder(var) >= 0) {
for (JsonArray::iterator childVar=varN(var).begin(); childVar!=varN(var).end(); ++childVar) { //use iterator to make .remove work!!!
for (JsonArray::iterator childVar=varChildren(var).begin(); childVar!=varChildren(var).end(); ++childVar) { //use iterator to make .remove work!!!
JsonArray valArray = varValArray(*childVar);
if (!valArray.isNull())
{
Expand All @@ -376,12 +376,12 @@ class SysModModel:public SysModule {
}
if (allNull) {
print->printJson("remove allnulls", *childVar);
varN(var).remove(childVar);
varChildren(var).remove(childVar);
}
}
else {
print->printJson("remove non valArray", *childVar);
varN(var).remove(childVar);
varChildren(var).remove(childVar);
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModPins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void SysModPins::loop1s() {
if (pinsChanged) {
pinsChanged = false;

for (JsonObject childVar: mdl->varN("pinTbl"))
for (JsonObject childVar: mdl->varChildren("pinTbl"))
ui->callVarFun(childVar, UINT8_MAX, f_ValueFun);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Sys/SysModWeb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ void SysModWeb::loop() {
clientsChanged = false;

USER_PRINTF("SysModWeb clientsChanged\n");
for (JsonObject childVar: mdl->varN("clTbl"))
for (JsonObject childVar: mdl->varChildren("clTbl"))
ui->callVarFun(childVar, UINT8_MAX, f_ValueFun);
}

}

void SysModWeb::loop1s() {
for (JsonObject childVar: mdl->varN("clTbl"))
for (JsonObject childVar: mdl->varChildren("clTbl"))
ui->callVarFun(childVar, UINT8_MAX, f_ValueFun);

mdl->setUIValueV("wsSend", "#: %d /s T: %d B/s B:%d B/s", sendWsCounter, sendWsTBytes, sendWsBBytes);
Expand Down
2 changes: 1 addition & 1 deletion src/User/UserModE131.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class UserModE131:public SysModule {
ui->setComment(var, "First channel");
return true;
case f_ChangeFun:
for (JsonObject childVar: mdl->varN("e131Tbl"))
for (JsonObject childVar: mdl->varChildren("e131Tbl"))
ui->callVarFun(childVar, UINT8_MAX, f_ValueFun);
return true;
default: return false;
Expand Down
8 changes: 4 additions & 4 deletions src/User/UserModInstances.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ class UserModInstances:public SysModule {
// Serial.println();

USER_PRINTF("insTbl handleNotifications %d\n", remoteIp[3]);
for (JsonObject childVar: mdl->varN("insTbl"))
for (JsonObject childVar: mdl->varChildren("insTbl"))
ui->callVarFun(childVar, UINT8_MAX, f_ValueFun); //rowNr //instance - instances.begin()

web->recvUDPCounter++;
Expand Down Expand Up @@ -501,7 +501,7 @@ class UserModInstances:public SysModule {
instance = instances.erase(instance);
USER_PRINTF("insTbl remove inactive instances %d\n", instance->ip[3]);

for (JsonObject childVar: mdl->varN("insTbl"))
for (JsonObject childVar: mdl->varChildren("insTbl"))
ui->callVarFun(childVar, UINT8_MAX, f_ValueFun); //no rowNr so all rows updated

ui->callVarFun("ddpInst", UINT8_MAX, f_UIFun);
Expand Down Expand Up @@ -670,7 +670,7 @@ class UserModInstances:public SysModule {

// USER_PRINTF("updateNode updRow[%d] %s\n", instance - instances.begin(), instances[instance - instances.begin()].name);

for (JsonObject childVar: mdl->varN("insTbl"))
for (JsonObject childVar: mdl->varChildren("insTbl"))
ui->callVarFun(childVar, UINT8_MAX, f_ValueFun); //rowNr instance - instances.begin()

//tbd: now done for all rows, should be done only for updated rows!
Expand All @@ -691,7 +691,7 @@ class UserModInstances:public SysModule {
//run though it sorted to find the right rowNr
// for (std::vector<InstanceInfo>::iterator instance=instances.begin(); instance!=instances.end(); ++instance) {
// if (instance->ip == messageIP) {
for (JsonObject childVar: mdl->varN("insTbl")) {
for (JsonObject childVar: mdl->varChildren("insTbl")) {
ui->callVarFun(childVar, UINT8_MAX, f_ValueFun); //no rowNr, update all
}
// }
Expand Down

0 comments on commit e77f88b

Please sign in to comment.