このFlowは疑似的に温度・湿度のデータを生成して、LoopEdge上で簡易に可視化(チャートグラフやゲージ)させるサンプルです。
各ノードの説明
(1)Start Temp/Humi(inject node)
一定間隔で当該フローを実行するためのノードです。
手動で実行したい場合や一定間隔で当該フローを実行したい場合に使用するノードですので、PLC機器からのデータが接続されるような場合は不要です。
15秒間隔で実行するように設定しています。
(2)Create:Temp/Humi(funcion node)
Demo動作用の温度/湿度のダミーデータを作成するためのノードです。
PLC機器からのデータが接続されるような場合は不要です。
温度と湿度のダミーデータを作成するコードを記述しています。
(3)Chart Graph(chart node)
Create:Temp/Humiノードにて作成した温度のダミーデータをチャートグラフ表示させるためのノードです。チャートグラフを表示するダッシュボードの指定やグラフの種類などを設定しています。
(4)Gauge(gauge node)
Create:Temp/Humiノードにて作成した湿度のダミーデータをゲージ表示させるためのノードです。ゲージを表示するダッシュボードの指定やゲージの種類などを設定しています。
(5)Dump:Temp/Humi(debug node)
受け取ったデータをdebug tabに出力します。
フロー設定
[{"id":"1278b126.530fbf","type":"tab","label":"Demo : Temp/Humi"},{"id":"29c1c13f.71220e","type":"inject","z":"1278b126.530fbf","name":"Start Temp/Humi","topic":"","payload":"","payloadType":"date","repeat":"15","crontab":"","once":true,"x":120,"y":140,"wires":[["804023fb.bd1348"]]},{"id":"804023fb.bd1348","type":"function","z":"1278b126.530fbf","name":"Create : Temp/Humi","func":"// temperature\ntemp_max = 28;\ntemp_min = 26;\ntemp = Math.random() * (temp_max - temp_min) + temp_min;\nmsg.payload = Math.floor(temp * 100) / 100;\n\n// humidity\nvar humidt = {};\nhumi_max = 50;\nhumi_min = 38;\nhumi = Math.random() * (humi_max - humi_min) + humi_min; \nhumidt.payload = Math.floor(humi * 100) / 100;\n\nreturn [msg, humidt];\n","outputs":"2","noerr":0,"x":225,"y":140,"wires":[["b6beacab.133fd8","3bf34f22.058ac"],["3795e938.d4ca66","3bf34f22.058ac"]]},{"id":"b6beacab.133fd8","type":"ui_chart","z":"1278b126.530fbf","name":"Chart Graph","group":"18784aaf.af48dd","order":0,"width":"6","height":"6","label":"Temperature (Sample)","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"Temperature (Sample)","dot":true,"ymin":"20","ymax":"40","removeOlder":"10","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#31b0cc","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":true,"x":340,"y":80,"wires":[[],[]]},{"id":"3bf34f22.058ac","type":"debug","z":"1278b126.530fbf","name":"Dump : Temp/Humi","active":true,"console":"false","complete":"payload","x":440,"y":140,"wires":[]},{"id":"3795e938.d4ca66","type":"ui_gauge","z":"1278b126.530fbf","name":"Gauge ","group":"18784aaf.af48dd","order":0,"width":"6","height":"6","gtype":"gage","title":"Humidity (Sample)","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":340,"y":200,"wires":[]},{"id":"18784aaf.af48dd","type":"ui_group","z":"","name":"Dashboard Group","tab":"e0eeb339.b8c5c8","order":1,"disp":true,"width":"12","collapse":false},{"id":"e0eeb339.b8c5c8","type":"ui_tab","z":"","name":"Sample Dashboard","icon":"dashboard","order":1}]