Skip to content

Commit

Permalink
callVarFun and callVarOnChange -> Variable().triggerEvent, web->isBusy
Browse files Browse the repository at this point in the history
index.js and SysModWeb
- fileLoad, count in steps of 50.000

SysModModel
- move varFunctions , VarFun and eventTypes from SysModUI to SysModModel
- move Variable definitions to .cpp
- replace ui->callVarFun by Variable().triggerEvent
- - replace mdl->callVarOnChange by Variable().triggerEvent

SysModWeb
- add isBusy and set in serveUpload and serveUpdate
- board: check on web->isBusy
  • Loading branch information
ewowi committed Nov 6, 2024
1 parent 793e489 commit 64bcfb5
Show file tree
Hide file tree
Showing 12 changed files with 1,470 additions and 1,496 deletions.
2 changes: 1 addition & 1 deletion data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ function createHTML(json, parentNode = null, rowNr = UINT8_MAX) {
let file = fileNode.files[0];
let formData = new FormData();
console.log("fileUpload " + variable.id, file, formData, file.size);
fileNode.parentNode.querySelector("progress").max = Math.round(file.size / 10000); //set progress max in blocks of 10K
fileNode.parentNode.querySelector("progress").max = Math.round(file.size / 50000); //set progress max in blocks of 50K

formData.append("file", file);
fetch('/' + variable.id, {method: "POST", body: formData});
Expand Down
18 changes: 9 additions & 9 deletions src/Sys/SysModInstances.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class SysModInstances:public SysModule {
return true;
case onUI:
// call onUI of the base variable for the new variable
ui->varFunctions[var["fun"]](insVar, rowNr, onUI);
mdl->varFunctions[var["fun"]](insVar, rowNr, onUI);
return true;
case onChange: {
//do not set this initially!!!
Expand Down Expand Up @@ -428,7 +428,7 @@ class SysModInstances:public SysModule {

ppf("instances handleNotifications %d\n", notifierUdp.remoteIP()[3]);
for (JsonObject childVar: Variable(mdl->findVar("Instances", "instances")).children())
ui->callVarFun(childVar, UINT8_MAX, onSetValue); //set the value (WIP) ); //rowNr //instance - instances.begin()
Variable(childVar).triggerEvent(onSetValue); //set the value (WIP) ); //rowNr //instance - instances.begin()

web->recvUDPCounter++;
web->recvUDPBytes+=packetSize;
Expand Down Expand Up @@ -529,12 +529,12 @@ class SysModInstances:public SysModule {
if (erased) {
ppf("instances remove inactive instances\n");
for (JsonObject childVar: Variable(mdl->findVar("Instances", "instances")).children())
ui->callVarFun(childVar, UINT8_MAX, onSetValue); //set the value (WIP)); //no rowNr so all rows updated
Variable(childVar).triggerEvent(onSetValue); //set the value (WIP)); //no rowNr so all rows updated

//tbd: pubsub mechanism
//LEDs specific
ui->callVarFun("DDP", "instance", UINT8_MAX, onUI); //rebuild options
// ui->callVarFun("Artnet", "artInst", UINT8_MAX, onUI); //rebuild options
Variable(mdl->findVar("DDP", "instance")).triggerEvent(onUI); //rebuild options
// Variable(mdl->findVar("Artnet", "artInst")).triggerEvent(onUI); //rebuild options
}
}

Expand Down Expand Up @@ -802,7 +802,7 @@ class SysModInstances:public SysModule {
// ppf("updateInstance updRow\n");

for (JsonObject childVar: Variable(mdl->findVar("Instances", "instances")).children())
ui->callVarFun(childVar, UINT8_MAX, onSetValue); //set the value (WIP)); //rowNr instance - instances.begin()
Variable(childVar).triggerEvent(onSetValue); //set the value (WIP)); //rowNr instance - instances.begin()

//tbd: now done for all rows, should be done only for updated rows!
}
Expand All @@ -816,15 +816,15 @@ class SysModInstances:public SysModule {

//tbd: pubsub mechanism
//LEDs specific
ui->callVarFun("DDP", "instance", UINT8_MAX, onUI); //rebuild options
// ui->callVarFun("Artnet", "artInst", UINT8_MAX, onUI); //rebuild options
Variable(mdl->findVar("DDP", "instance")).triggerEvent(onUI); //rebuild options
// Variable(mdl->findVar(Artnet", "artInst")).triggerEvent(onUI); //rebuild options

// ui->processOnUI("instances");
//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: Variable(mdl->findVar("Instances", "instances")).children()) {
ui->callVarFun(childVar, UINT8_MAX, onSetValue); //set the value (WIP)); //no rowNr, update all
Variable(childVar).triggerEvent(onSetValue); //set the value (WIP)); //no rowNr, update all
}
// }
// }
Expand Down
Loading

0 comments on commit 64bcfb5

Please sign in to comment.