FizzBuzz
node-red
Node-REDDay 15

node-redでfizzbuzz

More than 3 years have passed since last update.


概要

node-redの勉強に「fizzbuzz」書いてみました。


写真

fizzbuzz.jpg


サンプルコード

[{"id":"a30e4aff.5cf1b8","type":"template","name":"i=1","field":"i","template":"1","x":138,"y":306,"z":"1e03b67a.e1fc4a","wires":[["9268b5c.f6d9748"]]},{"id":"9268b5c.f6d9748","type":"switch","name":"if (i<100)","property":"i","rules":[{"t":"lt","v":"100"},{"t":"else"}],"checkall":"true","outputs":2,"x":384,"y":286,"z":"1e03b67a.e1fc4a","wires":[["92e729b8.6d18d8"],["5724f18d.a8db1"]]},{"id":"7f30130a.80cfec","type":"function","name":"i++","func":"msg.i++;\nreturn msg;\n","outputs":1,"x":186,"y":804,"z":"1e03b67a.e1fc4a","wires":[["97a14a0b.685eb8"]]},{"id":"c924bdb7.36db4","type":"debug","name":"","active":true,"console":"false","complete":"payload","x":881,"y":280,"z":"1e03b67a.e1fc4a","wires":[]},{"id":"6875cacc.978a34","type":"debug","name":"","active":true,"console":"false","complete":"payload","x":901.3999633789062,"y":743.066650390625,"z":"1e03b67a.e1fc4a","wires":[]},{"id":"179c58b0.e863a7","type":"inject","name":"","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"","once":false,"x":118.89581298828125,"y":203.888916015625,"z":"1e03b67a.e1fc4a","wires":[["a30e4aff.5cf1b8"]]},{"id":"e9c5d296.163a3","type":"template","name":"i","field":"payload","template":"{{i}}","x":689.8958129882812,"y":743.888916015625,"z":"1e03b67a.e1fc4a","wires":[["7f30130a.80cfec","6875cacc.978a34"]]},{"id":"5724f18d.a8db1","type":"template","name":"終わり","field":"payload","template":"終わり","x":637.8958129882812,"y":271.888916015625,"z":"1e03b67a.e1fc4a","wires":[["c924bdb7.36db4"]]},{"id":"be22ade2.41dd5","type":"switch","name":"if (mod == 0)","property":"mod","rules":[{"t":"eq","v":"0"},{"t":"else"}],"checkall":"true","outputs":2,"x":526,"y":402,"z":"1e03b67a.e1fc4a","wires":[["24a7a065.db586"],["4bc1f144.b43e1"]]},{"id":"92e729b8.6d18d8","type":"function","name":"mod = i % 15","func":"msg.mod = msg.i % 15;\nreturn msg;","outputs":1,"x":342,"y":415,"z":"1e03b67a.e1fc4a","wires":[["be22ade2.41dd5"]]},{"id":"4bc1f144.b43e1","type":"function","name":"mod = i % 3","func":"msg.mod = msg.i % 3;\nreturn msg;","outputs":1,"x":319,"y":515,"z":"1e03b67a.e1fc4a","wires":[["7b584c6c.84a7b4"]]},{"id":"7b584c6c.84a7b4","type":"switch","name":"if (mod == 0)","property":"mod","rules":[{"t":"eq","v":"0"},{"t":"else"}],"checkall":"true","outputs":2,"x":513,"y":513,"z":"1e03b67a.e1fc4a","wires":[["7b785b01.8487a4"],["fe10e72c.01ef18"]]},{"id":"24a7a065.db586","type":"template","name":"fizzbuzz","field":"payload","template":"fizzbuzz","x":699,"y":406,"z":"1e03b67a.e1fc4a","wires":[["8bb1c489.744e38","7f30130a.80cfec"]]},{"id":"8bb1c489.744e38","type":"debug","name":"","active":true,"console":"false","complete":"false","x":893,"y":410,"z":"1e03b67a.e1fc4a","wires":[]},{"id":"762306ab.89dcf8","type":"debug","name":"","active":true,"console":"false","complete":"false","x":881,"y":530,"z":"1e03b67a.e1fc4a","wires":[]},{"id":"7b785b01.8487a4","type":"template","name":"fizz","field":"payload","template":"fizz","x":692,"y":523,"z":"1e03b67a.e1fc4a","wires":[["762306ab.89dcf8","7f30130a.80cfec"]]},{"id":"fe10e72c.01ef18","type":"function","name":"mod = i % 5","func":"msg.mod = msg.i % 5;\nreturn msg;","outputs":1,"x":308,"y":642,"z":"1e03b67a.e1fc4a","wires":[["acd7c461.532838"]]},{"id":"acd7c461.532838","type":"switch","name":"if (mod == 0)","property":"mod","rules":[{"t":"eq","v":"0"},{"t":"else"}],"checkall":"true","outputs":2,"x":512,"y":632,"z":"1e03b67a.e1fc4a","wires":[["54479e30.abb86"],["e9c5d296.163a3"]]},{"id":"54479e30.abb86","type":"template","name":"buzz","field":"payload","template":"buzz","x":693,"y":639,"z":"1e03b67a.e1fc4a","wires":[["d00f5077.2ff0b","7f30130a.80cfec"]]},{"id":"d00f5077.2ff0b","type":"debug","name":"","active":true,"console":"false","complete":"false","x":892,"y":633,"z":"1e03b67a.e1fc4a","wires":[]},{"id":"97a14a0b.685eb8","type":"delay","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":374,"y":819,"z":"1e03b67a.e1fc4a","wires":[["9268b5c.f6d9748"]]}]