Skip to content

Commit

Permalink
Renaming due to on<event> name changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoudwijma committed Jun 26, 2024
1 parent e3cb8b6 commit 595770f
Show file tree
Hide file tree
Showing 11 changed files with 1,214 additions and 1,214 deletions.
18 changes: 9 additions & 9 deletions data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function makeWS() {
gId("vApp").value = appName(); //tbd: should be set by server

//send request for onUI
flushUIFunCommands();
flushOnUICommands();
}
else
console.log("html of module already generated", json);
Expand Down Expand Up @@ -544,7 +544,7 @@ function createHTML(json, parentNode = null, rowNr = UINT8_MAX) {
if (variable.fun >= 0) { //>=0 as element in var
onUICommands.push(variable.id);
if (onUICommands.length > 4) { //every 4 vars (to respect responseDoc size) check WS_EVT_DATA info
flushUIFunCommands();
flushOnUICommands();
}
variable.fun = -1; //requested
}
Expand Down Expand Up @@ -587,7 +587,7 @@ function genTableRowHTML(json, parentNode = null, rowNr = UINT8_MAX) {
tdNode.appendChild(buttonNode);
trNode.appendChild(tdNode);
}
flushUIFunCommands();
flushOnUICommands();
if (variable.id == "insTbl")
setInstanceTableColumns();
}
Expand Down Expand Up @@ -631,7 +631,7 @@ function receiveData(json) {
let variable = value.var;
let rowNr = value.rowNr == null?UINT8_MAX:value.rowNr;
let nodeId = variable.id + ((rowNr != UINT8_MAX)?"#" + rowNr:"");
//if var object with .n, create .n (e.g. see fx.onChange (setEffect) and fixtureGenChFun, tbd: )
//if var object with .n, create .n (e.g. see fx.onChange (setEffect) and fixtureGenonChange, tbd: )
ppf("receiveData details", key, variable.id, nodeId, rowNr);
if (gId(nodeId + "_n")) gId(nodeId + "_n").remove(); //remove old ndiv

Expand All @@ -646,7 +646,7 @@ function receiveData(json) {
gId(nodeId).parentNode.appendChild(ndivNode);
createHTML(modelVar.n, ndivNode, rowNr);
}
flushUIFunCommands(); //make sure onUIs of new elements are called
flushOnUICommands(); //make sure onUIs of new elements are called
}
else if (key == "addRow") { //update the row of a table
ppf("receiveData", key, value);
Expand Down Expand Up @@ -912,7 +912,7 @@ function changeHTML(variable, commandJson, rowNr = UINT8_MAX) {
newRowNr++;
}

flushUIFunCommands(); //make sure onUIs of new elements are called
flushOnUICommands(); //make sure onUIs of new elements are called

if (variable.id == "insTbl")
setInstanceTableColumns();
Expand Down Expand Up @@ -958,7 +958,7 @@ function changeHTML(variable, commandJson, rowNr = UINT8_MAX) {
changeHTML(variable, {"value":null, "chk":"column"}, newRowNr); //new row cell has no value
}

flushUIFunCommands(); //make sure onUIs of new elements are called
flushOnUICommands(); //make sure onUIs of new elements are called

}
else if (node.parentNode.parentNode.nodeName.toLocaleLowerCase() == "td" && Array.isArray(commandJson.value)) { //table column, called for each column cell!!!
Expand Down Expand Up @@ -1171,11 +1171,11 @@ function changeHTML(variable, commandJson, rowNr = UINT8_MAX) {
}
} //changeHTML

function flushUIFunCommands() {
function flushOnUICommands() {
if (onUICommands.length > 0) { //if something to flush
var command = {};
command.onUI = onUICommands; //ask to run onUI for vars (to add the options)
// console.log("flushUIFunCommands", command);
// console.log("flushOnUICommands", command);
requestJson(command);
onUICommands = [];
}
Expand Down
18 changes: 9 additions & 9 deletions src/App/LedModEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ class LedModEffects:public SysModule {
return true;
case onAddRow: {
rowNr = fixture.listOfLeds.size();
// ppf("chFun addRow %s[%d]\n", mdl->varID(var), rowNr);
// ppf("fxTbl addRow %s[%d]\n", mdl->varID(var), rowNr);

web->getResponseObject()["addRow"]["rowNr"] = rowNr;

if (rowNr >= fixture.listOfLeds.size())
fixture.listOfLeds.push_back(new Leds(fixture));
return true; }
case onDeleteRow: {
// ppf("chFun delrow %s[%d]\n", mdl->varID(var), rowNr);
// ppf("fxTbl delrow %s[%d]\n", mdl->varID(var), rowNr);
//tbd: fade to black
if (rowNr <fixture.listOfLeds.size()) {
Leds *leds = fixture.listOfLeds[rowNr];
Expand Down Expand Up @@ -251,7 +251,7 @@ class LedModEffects:public SysModule {
projection->controls(*leds, var);
mdl->varPostDetails(var, rowNr);
}
// ppf("chFun pro[%d] <- %d (%d)\n", rowNr, proValue, fixture.listOfLeds.size());
// ppf("onChange pro[%d] <- %d (%d)\n", rowNr, proValue, fixture.listOfLeds.size());

fixture.doMap = true;
}
Expand All @@ -275,14 +275,14 @@ class LedModEffects:public SysModule {
if (rowNr < fixture.listOfLeds.size()) {
fixture.listOfLeds[rowNr]->startPos = mdl->getValue(var, rowNr).as<Coord3D>();

ppf("fxStart[%d] chFun %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->startPos.x, fixture.listOfLeds[rowNr]->startPos.y, fixture.listOfLeds[rowNr]->startPos.z);
ppf("fxStart[%d] onChange %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->startPos.x, fixture.listOfLeds[rowNr]->startPos.y, fixture.listOfLeds[rowNr]->startPos.z);

fixture.listOfLeds[rowNr]->fadeToBlackBy();
fixture.listOfLeds[rowNr]->doMap = true;
fixture.doMap = true;
}
else {
ppf("fxStart[%d] chfun rownr not in range > %d\n", rowNr, fixture.listOfLeds.size());
ppf("fxStart[%d] onChange rownr not in range > %d\n", rowNr, fixture.listOfLeds.size());
}
return true;
default: return false;
Expand All @@ -303,14 +303,14 @@ class LedModEffects:public SysModule {
if (rowNr < fixture.listOfLeds.size()) {
fixture.listOfLeds[rowNr]->midPos = mdl->getValue(var, rowNr).as<Coord3D>();

ppf("fxStart[%d] chFun %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->midPos.x, fixture.listOfLeds[rowNr]->midPos.y, fixture.listOfLeds[rowNr]->midPos.z);
ppf("fxStart[%d] onChange %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->midPos.x, fixture.listOfLeds[rowNr]->midPos.y, fixture.listOfLeds[rowNr]->midPos.z);

fixture.listOfLeds[rowNr]->fadeToBlackBy();
fixture.listOfLeds[rowNr]->doMap = true;
fixture.doMap = true;
}
else {
ppf("fxStart[%d] chfun rownr not in range > %d\n", rowNr, fixture.listOfLeds.size());
ppf("fxStart[%d] onChange rownr not in range > %d\n", rowNr, fixture.listOfLeds.size());
}
return true;
default: return false;
Expand All @@ -331,14 +331,14 @@ class LedModEffects:public SysModule {
if (rowNr < fixture.listOfLeds.size()) {
fixture.listOfLeds[rowNr]->endPos = mdl->getValue(var, rowNr).as<Coord3D>();

ppf("fxEnd[%d] chFun %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->endPos.x, fixture.listOfLeds[rowNr]->endPos.y, fixture.listOfLeds[rowNr]->endPos.z);
ppf("fxEnd[%d] onChange %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->endPos.x, fixture.listOfLeds[rowNr]->endPos.y, fixture.listOfLeds[rowNr]->endPos.z);

fixture.listOfLeds[rowNr]->fadeToBlackBy();
fixture.listOfLeds[rowNr]->doMap = true;
fixture.doMap = true;
}
else {
ppf("fxEnd[%d] chfun rownr not in range > %d\n", rowNr, fixture.listOfLeds.size());
ppf("fxEnd[%d] onChange rownr not in range > %d\n", rowNr, fixture.listOfLeds.size());
}
return true;
default: return false;
Expand Down
8 changes: 4 additions & 4 deletions src/App/LedModFixtureGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ class LedModFixtureGen:public SysModule {
// print->printJson("OPTIONS", options1);
return true; }
case onChange:
this->fixtureVarChFun();
this->fixtureVarOnChange();
return true;
default: return false;
}}); //fixtureVar
Expand Down Expand Up @@ -591,7 +591,7 @@ class LedModFixtureGen:public SysModule {
}

//generate dynamic html for fixture controls
void fixtureVarChFun() {
void fixtureVarOnChange() {

JsonObject fixtureVar = mdl->findVar("fixtureVar");

Expand Down Expand Up @@ -656,7 +656,7 @@ class LedModFixtureGen:public SysModule {
case onChange: {

char fileName[32];
generateChFun(var, fileName);
generateOnChange(var, fileName);

//set fixture in fixture module
ui->callVarFun("fixture", UINT8_MAX, onUI); //rebuild options
Expand Down Expand Up @@ -910,7 +910,7 @@ class LedModFixtureGen:public SysModule {
}

//generate the F-ixture.json file
void generateChFun(JsonObject var, char * fileName) {
void generateOnChange(JsonObject var, char * fileName) {

JsonObject fixtureVar = mdl->findVar("fixtureVar");
stackUnsigned8 fgValue = fixtureVar["value"];
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void SysModFiles::setup() {
case onDeleteRow:
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("fileTbl delRow %s[%d] = %s %s\n", mdl->varID(var), rowNr, var["value"].as<String>().c_str(), fileName);
this->removeFiles(fileName, false);

// print->printVar(var);
Expand Down
8 changes: 4 additions & 4 deletions src/Sys/SysModInstances.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ class SysModInstances:public SysModule {
strcat(columnVarID, var["id"]);
JsonObject insVar; // = ui->cloneVar(var, columnVarID, [this, var](JsonObject insVar){});

//create a var of the same type. InitVar is not calling chFun which is good in this situation!
//create a var of the same type. InitVar is not calling onChange which is good in this situation!
insVar = ui->initVar(tableVar, columnVarID, var["type"], false, [this, var](JsonObject insVar, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onSetValue:
//should not trigger chFun
//should not trigger onChange
for (forUnsigned8 rowNrL = 0; rowNrL < instances.size() && (rowNr == UINT8_MAX || rowNrL == rowNr); rowNrL++) {
// ppf("initVar dash %s[%d]\n", mdl->varID(insVar), rowNrL);
//do what setValue is doing except calling onChange
Expand Down Expand Up @@ -328,7 +328,7 @@ class SysModInstances:public SysModule {
instances.clear();

//not needed here as there is no connection
// ui->processUiFun("insTbl");
// ui->processOnUI("insTbl");

//udp off ??
}
Expand Down Expand Up @@ -811,7 +811,7 @@ class SysModInstances:public SysModule {
ui->callVarFun("ddpInst", UINT8_MAX, onUI); //rebuild options
ui->callVarFun("artInst", UINT8_MAX, onUI); //rebuild options

// ui->processUiFun("insTbl");
// ui->processOnUI("insTbl");
//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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModPins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void SysModPins::setup() {
case onChange: {
bool pinValue = var["value"];

ppf("chFun pin19 %s:=%d\n", mdl->varID(var), pinValue);
ppf("onChange pin19 %s:=%d\n", mdl->varID(var), pinValue);

// softhack007: writing these pins on S3/C3/S2 may cause major problems (crashes included)
digitalWrite(19, pinValue?HIGH:LOW);
Expand Down
6 changes: 3 additions & 3 deletions src/Sys/SysModUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class SysModUI: public SysModule {
}
}
else { //do onChange on existing value
//no call of chFun for buttons otherwise all buttons will be fired which is highly undesirable
//no call of onChange for buttons otherwise all buttons will be fired which is highly undesirable
if (strcmp(type,"button") != 0 && varFun ) { //!isPointer because 0 is also a value then && (!isPointer || value)
bool onChangeExists = false;
if (var["value"].is<JsonArray>()) {
Expand All @@ -212,7 +212,7 @@ class SysModUI: public SysModule {
}

if (onChangeExists)
ppf("initVarAndUpdate chFun init %s[x] <- %s\n", mdl->varID(var), var["value"].as<String>().c_str());
ppf("initVarAndUpdate onChange init %s[x] <- %s\n", mdl->varID(var), var["value"].as<String>().c_str());
}
}

Expand Down Expand Up @@ -283,7 +283,7 @@ class SysModUI: public SysModule {
void processJson(JsonVariant json); //must be Variant, not object for jsonhandler

//called to rebuild selects and tables (tbd: also label and comments is done again, that is not needed)
// void processUiFun(const char * id);
// void processOnUI(const char * id);

void setLabel(JsonObject var, const char * text) {
web->addResponse(var["id"], "label", text);
Expand Down
4 changes: 2 additions & 2 deletions src/Sys/SysModWeb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,11 @@ void SysModWeb::wsEvent(WebSocket * ws, WebClient * client, AwsEventType type, v
ppf("wsEvent deserializeJson failed with code %s\n", error.c_str());
client->text("{\"success\":true}"); // we have to send something back otherwise WS connection closes
} else {
bool isUiFun = !responseObject["onUI"].isNull();
bool isOnUI = !responseObject["onUI"].isNull();
ui->processJson(responseObject); //adds to responseDoc / responseObject

if (responseObject.size()) {
sendResponseObject(isUiFun?client:nullptr); //onUI only send to requesting client async response
sendResponseObject(isOnUI?client:nullptr); //onUI only send to requesting client async response
}
else {
ppf("WS_EVT_DATA no responseDoc\n");
Expand Down
Loading

0 comments on commit 595770f

Please sign in to comment.