Hi @Colin,
See attached the flow part affected.
[{"id":"63bf743b57d7dad3","type":"ui_button","z":"6f0f171f.39d858","name":"","group":"b2147235.818","order":7,"width":0,"height":0,"passthru":false,"label":"Reset Bomba","tooltip":"","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"num","topic":"topic","topicType":"msg","x":320,"y":740,"wires":[["db50437ae9b45029"]]},{"id":"132dec09.2c9ce4","type":"modbus-flex-write","z":"6f0f171f.39d858","name":"","showStatusActivities":false,"showErrors":false,"server":"ca7a28d558d23b0a","emptyMsgOnFail":false,"keepMsgProperties":false,"x":870,"y":800,"wires":[["3be8578.b5476a8"],[]]},{"id":"3be8578.b5476a8","type":"debug","z":"6f0f171f.39d858","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1110,"y":800,"wires":[]},{"id":"db50437ae9b45029","type":"change","z":"6f0f171f.39d858","name":"","rules":[{"t":"set","p":"AuxRentadora.b0","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":740,"wires":[["bd5634d79c96b550"]]},{"id":"af960b1bccdb78b6","type":"function","z":"6f0f171f.39d858","name":"Bit a word AuxPLCRentadora","func":"function setBit(number, bitPosition) {\n return number | (1 << bitPosition);\n}\n\nvar xAuxPLCRentadorax0, wAuxPLCRentadora,word;\nxAuxPLCRentadorax0=global.get(\"AuxRentadora.b0\");\nwAuxPLCRentadora=setBit(xAuxPLCRentadorax0,0);\n\n\nif (xAuxPLCRentadorax0==1){\n word=1;\n global.set(\"AuxRentadora.Word\", 1);\n}\nelse{\n word=0;\n global.set(\"AuxRentadora.Word\", 0);\n}\n\n\nmsg.payload = {\n 'value': word,\n 'fc': 6,\n 'unitid': 1,\n 'address': 114,\n 'quantity': 1\n}\nmsg.topic = \"WriteAuxRentadora\";\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":800,"wires":[["132dec09.2c9ce4"]]},{"id":"4e0d07c757ea0a46","type":"inject","z":"6f0f171f.39d858","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":310,"y":800,"wires":[["af960b1bccdb78b6"]]},{"id":"bd5634d79c96b550","type":"delay","z":"6f0f171f.39d858","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":800,"y":740,"wires":[["47305e8466ee811a"]]},{"id":"0b42e813ff1b2e31","type":"debug","z":"6f0f171f.39d858","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1110,"y":740,"wires":[]},{"id":"47305e8466ee811a","type":"function","z":"6f0f171f.39d858","name":"Reset","func":"global.set(\"AuxRentadora.b0\", 0);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":950,"y":740,"wires":[["0b42e813ff1b2e31"]]},{"id":"b2147235.818","type":"ui_group","name":"Consums","tab":"aecc735e.171a1","order":2,"disp":true,"width":"6","collapse":false},{"id":"ca7a28d558d23b0a","type":"modbus-client","name":"M241Rentadora","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"10.10.5.31","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"aecc735e.171a1","type":"ui_tab","name":"Consums","icon":"dashboard","order":3,"disabled":false,"hidden":false}]
Function "Bit a word AuxPLCRentadora" was different previously:
function setBit(number, bitPosition) {
return number | (1 << bitPosition);
}
var xAuxPLCRentadorax0, wAuxPLCRentadora,word;
xAuxPLCRentadorax0=global.get("AuxRentadora.b0");
wAuxPLCRentadora=setBit(xAuxPLCRentadorax0,0);
global.set("wAuxPLCRentadora", wAuxPLCRentadora);
msg.payload = {
'value': wAuxPLCRentadora,
'fc': 6,
'unitid': 1,
'address': 114,
'quantity': 1
}
msg.topic = "WriteAuxRentadora";
return msg
The problem is that in context variable, bit turns false but word keeps in 1 value.
Thanks in advance!