使用nodered Dashboad圖表節點繪製隨機值的圖形
實現生成的隨機值以供Web API使用
[{"id":"fc080395.c9026","type":"inject","z":"89b5e167.6b055","name":"2s","topic":"","payload":"","payloadType":"date","repeat":"2","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":100,"wires":[["f9937848.c26178","8609b435.7c3808"]]},{"id":"f9937848.c26178","type":"function","z":"89b5e167.6b055","name":"random1","func":"ran = parseInt(Math.random() * 10);\nmsg.topic = \"Random1\";\nmsg.payload = ran;\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":100,"wires":[["651ba2c1.9c9c2c"]]},{"id":"651ba2c1.9c9c2c","type":"ui_chart","z":"89b5e167.6b055","name":"","group":"172c72a3.c05a7d","order":0,"width":"6","height":"5","label":"20s(10 points)","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"20","removeOlderPoints":"","removeOlderUnit":"1","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":540,"y":100,"wires":[["d2e5e919.d5cec8","87c2df48.37139"],[]]},{"id":"8609b435.7c3808","type":"function","z":"89b5e167.6b055","name":"random2","func":"ran = parseInt(Math.random() * 10);\nmsg.topic = \"Random2\";\nmsg.payload = ran;\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":140,"wires":[["651ba2c1.9c9c2c","bb63789f.53c338"]]},{"id":"1f543df9.6d6102","type":"inject","z":"89b5e167.6b055","name":"Flush","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":180,"wires":[["4165a1b1.2f64"]]},{"id":"4165a1b1.2f64","type":"function","z":"89b5e167.6b055","name":"Flush","func":"msg.payload = [];\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":180,"wires":[["651ba2c1.9c9c2c"]]},{"id":"d2e5e919.d5cec8","type":"function","z":"89b5e167.6b055","name":"Save","func":"flow.set(\"chartarray\",msg.payload);","outputs":1,"noerr":0,"x":710,"y":100,"wires":[[]]},{"id":"461195ab.dd184c","type":"inject","z":"89b5e167.6b055","name":"Reload","topic":"","payload":"","payloadType":"date","repeat":"3600","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":220,"wires":[["d795bc86.eb7ef"]]},{"id":"d795bc86.eb7ef","type":"function","z":"89b5e167.6b055","name":"Reload","func":"msg.payload = flow.get(\"chartarray\");\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":220,"wires":[["651ba2c1.9c9c2c"]]},{"id":"a68ffe6e.70af6","type":"comment","z":"89b5e167.6b055","name":"Dashboard Chart Node","info":"","x":190,"y":40,"wires":[]},{"id":"cd7a8378.f477e","type":"http in","z":"89b5e167.6b055","name":"","url":"/random","method":"get","upload":false,"swaggerDoc":"","x":150,"y":380,"wires":[["4a7a68bf.ff1e08"]]},{"id":"963bc9fc.06c678","type":"http response","z":"89b5e167.6b055","name":"","statusCode":"","headers":{},"x":730,"y":380,"wires":[]},{"id":"83e567b1.c41bf8","type":"comment","z":"89b5e167.6b055","name":"Random http://127.0.0.1:1880/random","info":"","x":210,"y":340,"wires":[]},{"id":"4a7a68bf.ff1e08","type":"function","z":"89b5e167.6b055","name":"http in","func":"rnum=parseInt(msg.req.query.rnum);\ncount=parseInt(msg.req.query.count);\n\nif (rnum <= 2 && count <= 10) {\n msg.rnum = rnum;\n msg.count = count;\n msg.payload=\"OK\";\n return msg; \n}else{\n msg.payload=\"Error!\";\n return msg; \n} ","outputs":1,"noerr":0,"x":310,"y":380,"wires":[["882cde83.df3dc","fb76b907.6ad8a8"]]},{"id":"882cde83.df3dc","type":"function","z":"89b5e167.6b055","name":"Ok","func":"pay=msg.payload;\nif (pay == \"OK\"){\n return msg;\n}","outputs":1,"noerr":0,"x":450,"y":380,"wires":[["ac3178dd.232e58"]]},{"id":"ac3178dd.232e58","type":"function","z":"89b5e167.6b055","name":"Output","func":"var temp=[];\nvar tempmsg = flow.get(\"chartarray\");\nrnum=msg.rnum;\ncount=msg.count;\n\ntemp = \"[\";\nfor(var i = 0; i < rnum; i++){\n temp = temp + \"[\"; \n for(var j = 0; j < count; j++){\n var j2=9-j;\n temp = temp + '{ \"time\" : \"';\n temp = temp + tempmsg[0].data[i][j2].x;\n temp = temp + '\" , \"val\" : \"';\n temp = temp + tempmsg[0].data[i][j2].y;\n temp = temp + '\" }';\n if (j < count-1){ temp = temp + \",\";}\n }\n temp = temp + \"]\";\n if (i < rnum-1){ temp = temp + \",\";}\n}\ntemp = temp + \"]\";\n\nmsg.payload = temp;\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":380,"wires":[["963bc9fc.06c678"]]},{"id":"87c2df48.37139","type":"debug","z":"89b5e167.6b055","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":140,"wires":[]},{"id":"ff077da9.ea985","type":"http response","z":"89b5e167.6b055","name":"","statusCode":"","headers":{},"x":730,"y":440,"wires":[]},{"id":"fb76b907.6ad8a8","type":"function","z":"89b5e167.6b055","name":"Error","func":"pay=msg.payload;\nif (pay == \"Error!\"){\n return msg;\n}","outputs":1,"noerr":0,"x":450,"y":440,"wires":[["f93d53fa.9fed5"]]},{"id":"f93d53fa.9fed5","type":"template","z":"89b5e167.6b055","name":"web","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n <head></head>\n <body>\n <h1>{{payload}}</h1>\n </body>\n</html>","output":"str","x":590,"y":440,"wires":[["ff077da9.ea985"]]},{"id":"75730aee.fc4f04","type":"inject","z":"89b5e167.6b055","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":520,"wires":[["577880db.b6353"]]},{"id":"4f8d4188.37301","type":"debug","z":"89b5e167.6b055","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":520,"wires":[]},{"id":"577880db.b6353","type":"http request","z":"89b5e167.6b055","name":"exchange","method":"GET","ret":"obj","url":"http://earthquake.kr/exchange/","tls":"","x":350,"y":520,"wires":[["4f8d4188.37301"]]},{"id":"c16e19b3.763ae8","type":"inject","z":"89b5e167.6b055","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":580,"wires":[["9e0b566b.77b098"]]},{"id":"6aefc7fa.873b88","type":"debug","z":"89b5e167.6b055","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":580,"wires":[]},{"id":"9e0b566b.77b098","type":"http request","z":"89b5e167.6b055","name":"random","method":"GET","ret":"obj","url":"http://localhost:1880/random?rnum=2&count=5","tls":"","x":350,"y":580,"wires":[["6aefc7fa.873b88"]]},{"id":"bb63789f.53c338","type":"ui_template","z":"89b5e167.6b055","group":"172c72a3.c05a7d","name":"","order":0,"width":0,"height":0,"format":"<div layout=\"row\" layout-align=\"space-between\">\n<p>The random 1 number is</p>\n<p ng-style=\"{color: (msg.payload || 0) % 2 === 0 ? 'green' : 'red'}\">\n {{(msg.payload || 0) % 2 === 0 ? 'even' : 'odd'}}\n</p>\n</div>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":540,"y":160,"wires":[[]]},{"id":"172c72a3.c05a7d","type":"ui_group","name":"Group 1","tab":"21c6ef7f.9ca0f","order":1,"disp":true,"width":6},{"id":"21c6ef7f.9ca0f","type":"ui_tab","name":"Tab 3","icon":"dashboard","order":1}]
訂閱:
張貼留言 (Atom)
WOKWI DHT22 & LED , Node-Red + SQLite database
WOKWI DHT22 & LED , Node-Red + SQLite database Node-Red程式 [{"id":"6f0240353e534bbd","type":"comment&...
-
python pip 不是内部或外部命令 -- 解決方法 要安裝 Pyqt5 1. 首先,開啟命令提示字元。 2. 輸入 pip3 install pyqt5 好像不能執行 ! ! 錯誤顯示 : ‘ pip3 ’ 不是內部或外部命令、可執行的程式或批...
-
課程講義 下載 11/20 1) PPT 下載 + 程式下載 http://www.mediafire.com/file/cru4py7e8pptfda/106%E5%8B%A4%E7%9B%8A2-1.rar 11/27 2) PPT 下載...
-
• 認 識 PreFix、InFix、PostFix PreFix(前序式):* + 1 2 + 3 4 InFix(中序式): (1+2)*(3+4) PostFix(後序式):1 2 + 3 4 + * 後 序式的運算 例如: 運算時由 後序式的...
沒有留言:
張貼留言