hi evryone can anyone help me with this :
i wana simulate code can control a system {pump-low start and stop by switch after pump-low start the pump-décolorant and pump-scalaut starting after 2 sec also pump-high start after 6 sec when switch is false all pump stoped}
but i get northing in debug any advise
here is the code :
<
// Declare variables for the pumps
let pumpLow;
let pumpDecolorant;
let pumpScalaut;
let pumpHigh;
// Declare a variable to track the status of the pumps
let pumpStatus = "off";
// This function is called when the switch is flipped
function startPumps(msg) {
// Check the value of the switch
if (msg.payload === true) {
// If the switch is turned on, start the pump-low
pumpLow = setInterval(function () {
console.log("pump-low started");
}, 1000); // Run the function every second
// Set a timeout to start the pump-decolorant and pump-scalaut after 2 seconds
setTimeout(function () {
pumpDecolorant = setInterval(function () {
console.log("pump-decolorant started");
}, 1000); // Run the function every second
pumpScalaut = setInterval(function () {
console.log("pump-scalaut started");
}, 1000); // Run the function every second
}, 2000);
// Set a timeout to start the pump-high after 6 seconds
setTimeout(function () {
pumpHigh = setInterval(function () {
console.log("pump-high started");
}, 1000); // Run the function every second
}, 6000);
// Update the pump status
pumpStatus = "on";
} else {
// If the switch is turned off, stop all pumps
stopPumps();
}
}
// This function stops all pumps
function stopPumps() {
clearInterval(pumpLow);
clearInterval(pumpDecolorant);
clearInterval(pumpScalaut);
clearInterval(pumpHigh);
console.log("all pumps stopped");
pumpStatus = "off";
}
// Send the pump status to the output
return {
payload: pumpStatus
};
//