s1r-J / node-red-contrib-loop-processing

Node-RED nodes to help flow looping.
https://www.npmjs.com/package/node-red-contrib-loop-processing
Apache License 2.0
12 stars 21 forks source link

Nested loops #19

Open cdacruz opened 4 years ago

cdacruz commented 4 years ago

Hello,

I'm trying to use the array-loop imbricated, like a loop, in a loop. Do you confirm it does not work ? Thanks for your feedback.

.Christian

s1r-J commented 3 years ago

I did not try to create nested loop flow, So now I create that and check the behavior. To come to the point, the nested loop does not work. This is not intuitive. So I can't make any guarantees, but I try to update this module's nodes.

Here is nested loop flow.

[{"id":"f0666ea2.5935a","type":"inject","z":"cacee7e4.aa35c8","name":"set msg.alphabets","props":[{"p":"alphabets","v":"[\"A\",\"B\",\"C\"]","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":160,"y":440,"wires":[["c59c9ccd.08393"]]},{"id":"c59c9ccd.08393","type":"array-loop","z":"cacee7e4.aa35c8","name":"","key":"alc59c9ccd08393","keyType":"msg","reset":false,"resetValue":"value-null","array":"alphabets","arrayType":"msg","x":380,"y":440,"wires":[["81f298b4.852d98"],["13b65cd3.5c42b3"]]},{"id":"8b52b77d.c56cf8","type":"array-loop","z":"cacee7e4.aa35c8","name":"","key":"al8b52b77dc56cf8","keyType":"msg","reset":false,"resetValue":"value-null","array":"numbers","arrayType":"msg","x":520,"y":520,"wires":[["c59c9ccd.08393"],["48948416.e3cdac"]]},{"id":"81f298b4.852d98","type":"debug","z":"cacee7e4.aa35c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":640,"y":440,"wires":[]},{"id":"34f4ffcc.16c69","type":"delay","z":"cacee7e4.aa35c8","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":340,"y":520,"wires":[["8b52b77d.c56cf8"]]},{"id":"40273e02.e0be5","type":"delay","z":"cacee7e4.aa35c8","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":440,"y":620,"wires":[["8b52b77d.c56cf8"]]},{"id":"13b65cd3.5c42b3","type":"change","z":"cacee7e4.aa35c8","name":"","rules":[{"t":"set","p":"numbers","pt":"msg","to":"[1, 2, 3]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":150,"y":520,"wires":[["34f4ffcc.16c69"]]},{"id":"48948416.e3cdac","type":"function","z":"cacee7e4.aa35c8","name":"","func":"msg.payload = msg.alphabets[msg.alc59c9ccd08393] + msg.numbers[msg.al8b52b77dc56cf8];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":280,"y":620,"wires":[["40273e02.e0be5","dd3060c.99631a"]]},{"id":"dd3060c.99631a","type":"debug","z":"cacee7e4.aa35c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":450,"y":680,"wires":[]}]
s1r-J commented 3 years ago

@cdacruz I found a mistake in my flow, and you may be able to make nested loop. Use the option in edit dialog.

ss-nodered-nest

Here is a example flow. If you like, check this flow.

[{"id":"f0666ea2.5935a","type":"inject","z":"cacee7e4.aa35c8","name":"set msg.alphabets","props":[{"p":"alphabets","v":"[\"A\",\"B\",\"C\"]","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":160,"y":440,"wires":[["c59c9ccd.08393"]]},{"id":"c59c9ccd.08393","type":"array-loop","z":"cacee7e4.aa35c8","name":"","key":"alc59c9ccd08393","keyType":"msg","reset":false,"resetValue":"value-null","array":"alphabets","arrayType":"msg","x":380,"y":440,"wires":[["81f298b4.852d98"],["13b65cd3.5c42b3"]]},{"id":"8b52b77d.c56cf8","type":"array-loop","z":"cacee7e4.aa35c8","name":"","key":"al8b52b77dc56cf8","keyType":"msg","reset":true,"resetValue":"value-null","array":"numbers","arrayType":"msg","x":520,"y":520,"wires":[["c59c9ccd.08393"],["48948416.e3cdac"]]},{"id":"81f298b4.852d98","type":"debug","z":"cacee7e4.aa35c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":640,"y":440,"wires":[]},{"id":"34f4ffcc.16c69","type":"delay","z":"cacee7e4.aa35c8","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":340,"y":520,"wires":[["8b52b77d.c56cf8"]]},{"id":"40273e02.e0be5","type":"delay","z":"cacee7e4.aa35c8","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":440,"y":620,"wires":[["8b52b77d.c56cf8"]]},{"id":"13b65cd3.5c42b3","type":"change","z":"cacee7e4.aa35c8","name":"","rules":[{"t":"set","p":"numbers","pt":"msg","to":"[1, 2, 3]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":150,"y":520,"wires":[["34f4ffcc.16c69"]]},{"id":"48948416.e3cdac","type":"function","z":"cacee7e4.aa35c8","name":"","func":"msg.payload = msg.alphabets[msg.alc59c9ccd08393] + msg.numbers[msg.al8b52b77dc56cf8];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":280,"y":620,"wires":[["40273e02.e0be5","dd3060c.99631a"]]},{"id":"dd3060c.99631a","type":"debug","z":"cacee7e4.aa35c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":450,"y":680,"wires":[]}]