the code must start 2 actuator with delay 3 s in between en every actuator use 2 relays to change diriction
the problem that i can not reset the timeout to close or open the cleartimeout is not working any help plz
function init() {
function func_delay(myfunction,circuit,value,timer)
{
this.timer1 = setTimeout(function(){ this.timer2 = myfunction;
node.send({payload: cmd_build(circuit,value)}); }.bind(this), timer);
}
function stop()
{
node.warn(this.timer1);
node.warn(this.timer2);
clearTimeout(this.timer2);
clearTimeout(this.timer2);
}
function router(data ){
switch(data) {
case triggers["START_ZONE1"] :
node.warn("Zone 1 status Started ");
stop();
func_delay(func_delay(null,relays["zone1v2_open"],actions["on"],3000),relays["zone1v1_open"],actions["on"],1000);
node.send({payload: cmd_build(relays["zone1v1_close"],actions["off"])});
node.done();
node.send({payload: cmd_build(relays["zone1v2_close"],actions["off"])});
node.done();
msg={topic: "zone1/valves/opening",payload:{"notif":"notif_v1_stat", "message":"zone 1 started"}}
node.send(msg)
node.done();
// return [null,msg] ;
// }
// node.warn(msg);
break ;
case triggers["STOP_ZONE1"] :
stop();
func_delay(func_delay(null,relays["zone1v2_close"],actions["on"],3000) ,relays["zone1v1_close"],actions["on"],1000);
node.send({payload: cmd_build(relays["zone1v1_open"],actions["off"])});
node.done();
node.send({payload: cmd_build(relays["zone1v2_open"],actions["off"])});
node.done();
msg={topic: "zone1/valves/closing",payload:{"notif":"n1", "message":"Zone 1 stoped"}}
// return [null,msg] ;
node.send(msg)
node.done();
// }
break ;
default :
}
}
init();