2019年11月23日 星期六

function雙重條件使用範例。

function雙重條件使用範例。




這是自動(自動/手動)且大於等於125(120/130)時輸出操作的示例。



[{"id":"7c31a2ef.b3970c","type":"inject","z":"246f77ce.0477c8","name":"","topic":"自動","payload":"auto","payloadType":"str","repeat":"2","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":500,"wires":[["74d3e332.4c333c"]]},{"id":"da9ad0de.7eefe","type":"inject","z":"246f77ce.0477c8","name":"","topic":"手動","payload":" Manual","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":540,"wires":[["74d3e332.4c333c"]]},{"id":"ca994ed8.9a45c","type":"inject","z":"246f77ce.0477c8","name":"","topic":"","payload":"120","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":640,"wires":[["144e3c8d.5b0fa3"]]},{"id":"26aa586e.2cf258","type":"inject","z":"246f77ce.0477c8","name":"","topic":"","payload":"130","payloadType":"num","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":600,"wires":[["144e3c8d.5b0fa3"]]},{"id":"74d3e332.4c333c","type":"function","z":"246f77ce.0477c8","name":"自動/手動","func":"if(msg.payload === \"auto\"){\n    flow.set(\"autonum\",1);\n}else{\n    flow.set(\"autonum\",0);\n}\nreturn msg;","outputs":1,"noerr":0,"x":400,"y":500,"wires":[["28cdb891.77e108","c39e152d.0cbd28"]]},{"id":"144e3c8d.5b0fa3","type":"function","z":"246f77ce.0477c8","name":" 溫度範圍","func":"if(msg.payload > 125){\n    flow.set(\"tempnum\",1);\n}else{\n    flow.set(\"tempnum\",0);\n}\nreturn msg;","outputs":1,"noerr":0,"x":380,"y":620,"wires":[["28cdb891.77e108","6c374b78.858814"]]},{"id":"28cdb891.77e108","type":"function","z":"246f77ce.0477c8","name":"On/Off","func":"var autonum = flow.get(\"autonum\")||0;\nvar tempnum = flow.get(\"tempnum\")||0;\nvar num = autonum + tempnum;\n\nif(num >= 2){\n    msg.payload = \"運作\"+num ;\n}else{\n    msg.payload = \"停下\"+num ;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":500,"wires":[["b3d2c11e.eee3d"]]},{"id":"b3d2c11e.eee3d","type":"debug","z":"246f77ce.0477c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":750,"y":500,"wires":[]},{"id":"26686b7b.c85634","type":"comment","z":"246f77ce.0477c8","name":" 雙重條件表達式","info":"","x":200,"y":440,"wires":[]},{"id":"c39e152d.0cbd28","type":"debug","z":"246f77ce.0477c8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":590,"y":440,"wires":[]},{"id":"6c374b78.858814","type":"debug","z":"246f77ce.0477c8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":620,"wires":[]}]

沒有留言:

張貼留言

WOKWI DHT22 & LED , Node-Red + SQLite database

 WOKWI DHT22 & LED , Node-Red + SQLite database Node-Red程式 [{"id":"6f0240353e534bbd","type":"comment&...