Skip to content

Commit

Permalink
small bug fixes and ppf (printPrintF) changes
Browse files Browse the repository at this point in the history
General:
- changes in ppf output

SysModModel
- varPostDetails: use iterator instead of range-based-loop (does not work wiith & for some reason)

SysModPins: init pinObjects correctly

SysModPrint: pOut to UI per default
  • Loading branch information
ewoudwijma committed Apr 23, 2024
1 parent 6aadd03 commit f18e191
Show file tree
Hide file tree
Showing 7 changed files with 1,349 additions and 608 deletions.
6 changes: 4 additions & 2 deletions src/Sys/SysModFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ void SysModFiles::setup() {
case f_DelRow:
if (rowNr != UINT8_MAX && rowNr < fileList.size()) {
const char * fileName = fileList[rowNr].name;
ppf("chFun delRow %s[%d] = %s %s\n", mdl->varID(var), rowNr, var["value"].as<String>().c_str(), fileName);
// ppf("chFun delRow %s[%d] = %s %s\n", mdl->varID(var), rowNr, var["value"].as<String>().c_str(), fileName);
this->removeFiles(fileName, false);

// print->printVar(var);
// ppf("\n");
}
print->printJson(" ", var);
return true;
default: return false;
}});
Expand Down
16 changes: 8 additions & 8 deletions src/Sys/SysModModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,17 +391,17 @@ class SysModModel:public SysModule {

//check if post init added: parent is already >=0
if (varOrder(var) >= 0) {
// for (JsonArray::iterator childVar=varChildren(var).begin(); childVar!=varChildren(var).end(); ++childVar) { //use iterator to make .remove work!!!
for (JsonObject childVar: varChildren(var)) { //use iterator to make .remove work!!!
JsonArray valArray = varValArray(childVar);
for (JsonArray::iterator childVar=varChildren(var).begin(); childVar!=varChildren(var).end(); ++childVar) { //use iterator to make .remove work!!!
// for (JsonObject &childVar: varChildren(var)) { //use iterator to make .remove work!!!
JsonArray valArray = varValArray(*childVar);
if (!valArray.isNull())
{
if (varOrder(childVar) < 0) { //if not updated
if (varOrder(*childVar) < 0) { //if not updated
valArray[rowNr] = (char*)0; // set element in valArray to 0

ppf("varPostDetails %s.%s[%d] <- null\n", varID(var), varID(childVar), rowNr);
ppf("varPostDetails %s.%s[%d] <- null\n", varID(var), varID(*childVar), rowNr);
// setValue(var, -99, rowNr); //set value -99
varOrder(childVar, -varOrder(childVar)); //make positive again
varOrder(*childVar, -varOrder(*childVar)); //make positive again
//if some values in array are not -99
}

Expand All @@ -412,12 +412,12 @@ class SysModModel:public SysModule {
allNull = false;
}
if (allNull) {
print->printJson("remove allnulls", childVar);
print->printJson("remove allnulls", *childVar);
varChildren(var).remove(childVar);
}
}
else {
print->printJson("remove non valArray", childVar);
print->printJson("remove non valArray", *childVar);
varChildren(var).remove(childVar);
}

Expand Down
5 changes: 3 additions & 2 deletions src/Sys/SysModPins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

SysModPins::SysModPins() :SysModule("Pins") {
//start with no pins allocated
for (int i=0; i<NUM_DIGITAL_PINS; i++) {
deallocatePin(i, pinObjects[i].owner);
for (int pinNr=0; pinNr<NUM_DIGITAL_PINS; pinNr++) {
strcpy(pinObjects[pinNr].owner, "");
strcpy(pinObjects[pinNr].details, "");
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/Sys/SysModPrint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ void SysModPrint::setup() {

parentVar = ui->initSysMod(parentVar, name, 2302);

ui->initSelect(parentVar, "pOut", 1, false, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
//default to UI
ui->initSelect(parentVar, "pOut", 2, false, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case f_UIFun:
{
ui->setLabel(var, "Output");
Expand Down
4 changes: 2 additions & 2 deletions src/Sys/SysModUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ void SysModUI::processJson(JsonVariant json) {
JsonObject command = value;
JsonObject var = mdl->findVar(command["id"]);
stackUnsigned8 rowNr = command["rowNr"];
ppf("processJson %s - %s [%d]\n", key, value.as<String>().c_str(), rowNr);
ppf("processJson %s - %s[%d]\n", key, mdl->varID(var), rowNr);

//first remove the deleted row both on server and on client(s)
if (pair.key() == "delRow") {
ppf("delRow remove values\n");
mdl->varRemoveValuesForRow(var, rowNr);
print->printJson("deleted rows", var);
web->sendResponseObject(); //async response //trigger receiveData->delRow
}

Expand Down
Loading

0 comments on commit f18e191

Please sign in to comment.