subflows for check modbus reading done or reading fail
The principle of use is If Status has the message "reading done", set it to be able to read data from Modbus. Other messages than this and no "reading done" message arrived at the specified time. It is assumed that data cannot be read from Modbus.
contact me or follow me : https://www.facebook.com/profile.php?id=61550015338310
[{"id":"d54760571f46d290","type":"subflow","name":"getCommuDone","info":"","category":"","in":[{"x":100,"y":120,"wires":[{"id":"f2723931f83b134d"}]}],"out":[{"x":700,"y":120,"wires":[{"id":"1cda5d91e9df4663","port":0},{"id":"f2723931f83b134d","port":1}]}],"env":[{"name":"setDelay","type":"num","value":"2000"}],"meta":{},"color":"#DDAA99","status":{"x":420,"y":180,"wires":[{"id":"63c167839a625ddc","port":0}]}},{"id":"f2723931f83b134d","type":"function","z":"d54760571f46d290","name":"getCommuDone","func":"let status = msg.payload || msg.status.text;\nlet delay = env.get(\"setDelay\");\nlet topic = msg.topic || '';\nlet commuOK;\nlet commuFail;\n\nif (status === 'done' || status === 'reading done') {\n commuOK = { payload: 1, delay: delay, topic: topic + '_commu' };\n} else {\n commuFail = { payload: 0, delay: delay, topic: topic + '_commu' };\n}\n\nreturn [commuFail, commuOK];","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":120,"wires":[["1cda5d91e9df4663"],["1cda5d91e9df4663"]]},{"id":"1cda5d91e9df4663","type":"trigger","z":"d54760571f46d290","name":"","op1":"","op2":"0","op1type":"nul","op2type":"num","duration":"1","extend":false,"overrideDelay":true,"units":"s","reset":"1","bytopic":"all","topic":"topic","outputs":1,"x":520,"y":80,"wires":[[]]},{"id":"63c167839a625ddc","type":"status","z":"d54760571f46d290","name":"","scope":["1cda5d91e9df4663"],"x":280,"y":180,"wires":[[]]},{"id":"4020736609838681","type":"subflow:d54760571f46d290","z":"155ee02bc198cf10","name":"","env":[{"name":"setDelay","value":"3000","type":"num"},{"name":"dd","value":"5000","type":"num"}],"x":1040,"y":320,"wires":[["e819a30b843ba25c"]],"inputLabels":["status"],"outputLabels":["communication"]},{"id":"e819a30b843ba25c","type":"debug","z":"155ee02bc198cf10","name":"debug 58","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1240,"y":320,"wires":[]},{"id":"f1bb531bf4ac32d1","type":"status","z":"155ee02bc198cf10","name":"","scope":["0344095cc3608092"],"x":820,"y":320,"wires":[["4020736609838681","1bde64a1b84fbcd4"]]},{"id":"1bde64a1b84fbcd4","type":"debug","z":"155ee02bc198cf10","name":"status.text","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"status.text","targetType":"msg","statusVal":"","statusType":"auto","x":1030,"y":380,"wires":[]},{"id":"0344095cc3608092","type":"modbus-read","z":"155ee02bc198cf10","name":"","topic":"","showStatusActivities":true,"logIOActivities":false,"showErrors":false,"showWarnings":true,"unitid":"1","dataType":"HoldingRegister","adr":"0","quantity":"100","rate":"2","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"64cd1b72167c3369","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":1050,"y":240,"wires":[[],[]]},{"id":"64cd1b72167c3369","type":"modbus-client","name":"127.0.0.1","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":true,"queueLogEnabled":false,"failureLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"1","commandDelay":"1","clientTimeout":"3000","reconnectOnTimeout":true,"reconnectTimeout":"5000","parallelUnitIdsAllowed":true,"showErrors":false,"showWarnings":true,"showLogs":true}]