This repository has been archived by the owner on Nov 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnode-red-example2.json
1 lines (1 loc) · 12.3 KB
/
node-red-example2.json
1
[{"id":"abd033f5.78c24","type":"http response","z":"45713e9d.6607c","name":"http response","statusCode":"","headers":{},"x":991,"y":75,"wires":[]},{"id":"724d7b54.5e8ee4","type":"http in","z":"45713e9d.6607c","name":"","url":"/windspeed","method":"get","upload":false,"swaggerDoc":"","x":111,"y":78,"wires":[["4492d7dd.4e0a18"]]},{"id":"14ce7f19.c52c81","type":"http in","z":"45713e9d.6607c","name":"","url":"/_dash-layout","method":"get","upload":false,"swaggerDoc":"","x":120,"y":118,"wires":[["9707cf45.c8f5"]]},{"id":"b5cbb71f.b47c58","type":"http in","z":"45713e9d.6607c","name":"","url":"/_dash-dependencies","method":"get","upload":false,"swaggerDoc":"","x":140,"y":157,"wires":[["33bb202e.b7161"]]},{"id":"d9f8406c.523ba","type":"http in","z":"45713e9d.6607c","name":"","url":"/_dash-update-component","method":"post","upload":false,"swaggerDoc":"","x":161,"y":199,"wires":[["e35efd1b.00605"]]},{"id":"5597ab59.f5c374","type":"change","z":"45713e9d.6607c","name":"Set Headers","rules":[{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"headers.content-type","pt":"msg","to":"application/json","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":756,"y":142,"wires":[["abd033f5.78c24","d012aba6.cc3678"]]},{"id":"9707cf45.c8f5","type":"template","z":"45713e9d.6607c","name":"_dash-layout","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"type\": \"Div\", \"namespace\": \"dash_html_components\", \"props\": {\"style\": {\"padding\": \"0px 10px 10px 10px\", \"width\": \"1000px\", \"marginLeft\": \"auto\", \"boxShadow\": \"0px 0px 5px 5px rgba(204,204,204,0.4)\", \"marginRight\": \"auto\"}, \"children\": [{\"type\": \"Div\", \"namespace\": \"dash_html_components\", \"props\": {\"className\": \"banner\", \"children\": [{\"type\": \"H2\", \"namespace\": \"dash_html_components\", \"props\": {\"children\": \"Wind Speed Monitor\"}}, {\"type\": \"Img\", \"namespace\": \"dash_html_components\", \"props\": {\"src\": \"https://s3-us-west-1.amazonaws.com/plotly-tutorials/logo/new-branding/dash-logo-by-plotly-stripe-inverted.png\", \"children\": null}}]}}, {\"type\": \"Div\", \"namespace\": \"dash_html_components\", \"props\": {\"className\": \"row wind-histo-polar\", \"children\": [{\"type\": \"Div\", \"namespace\": \"dash_html_components\", \"props\": {\"className\": \"seven columns wind-histogram\", \"children\": [{\"type\": \"Div\", \"namespace\": \"dash_html_components\", \"props\": {\"className\": \"Title\", \"children\": [{\"type\": \"H3\", \"namespace\": \"dash_html_components\", \"props\": {\"children\": \"WIND SPEED (mph)\"}}]}}, {\"type\": \"Div\", \"namespace\": \"dash_html_components\", \"props\": {\"className\": \"twelve columns wind-speed\", \"children\": [{\"type\": \"Graph\", \"namespace\": \"dash_core_components\", \"props\": {\"id\": \"wind-speed\"}}]}}, {\"type\": \"Interval\", \"namespace\": \"dash_core_components\", \"props\": {\"interval\": 3000, \"id\": \"wind-speed-update\", \"n_intervals\": 0}}]}}, {\"type\": \"Div\", \"namespace\": \"dash_html_components\", \"props\": {\"className\": \"five columns wind-polar\", \"children\": [{\"type\": \"Div\", \"namespace\": \"dash_html_components\", \"props\": {\"className\": \"Title\", \"children\": [{\"type\": \"H3\", \"namespace\": \"dash_html_components\", \"props\": {\"children\": \"WIND DIRECTION\"}}]}}, {\"type\": \"Graph\", \"namespace\": \"dash_core_components\", \"props\": {\"id\": \"wind-direction\"}}]}}]}}]}}","output":"json","x":343,"y":116,"wires":[["5597ab59.f5c374"]]},{"id":"33bb202e.b7161","type":"template","z":"45713e9d.6607c","name":"_dash-dependencies","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"[{\"events\":[],\"inputs\":[{\"id\":\"wind-speed-update\",\"property\":\"n_intervals\"}],\"output\":{\"id\":\"wind-direction\",\"property\":\"figure\"},\"state\":[]},{\"events\":[],\"inputs\":[{\"id\":\"wind-speed-update\",\"property\":\"n_intervals\"}],\"output\":{\"id\":\"wind-speed\",\"property\":\"figure\"},\"state\":[]}]","output":"json","x":375,"y":156,"wires":[["5597ab59.f5c374"]]},{"id":"4492d7dd.4e0a18","type":"template","z":"45713e9d.6607c","name":"index.html","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<!DOCTYPE html>\n<html>\n <head>\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n <meta charset=\"UTF-8\">\n <title>Dash</title>\n <link href=\"/_favicon.ico\" type=\"image/x-icon\" rel=\"icon\">\n <link rel=\"stylesheet\" href=\"https://unpkg.com/[email protected]/dist/react-select.min.css\">\n<link rel=\"stylesheet\" href=\"https://unpkg.com/[email protected]/styles.css\">\n<link rel=\"stylesheet\" href=\"https://unpkg.com/[email protected]/styles.css\">\n<link rel=\"stylesheet\" href=\"https://unpkg.com/[email protected]/assets/index.css\">\n<link rel=\"stylesheet\" href=\"https://unpkg.com/[email protected]/dash_core_components/[email protected]\">\n<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css\">\n<link rel=\"stylesheet\" href=\"https://cdn.rawgit.com/plotly/dash-app-stylesheets/737dc4ab11f7a1a8d6b5645d26f69133d97062ae/dash-wind-streaming.css\">\n<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css?family=Raleway:400,400i,700,700i\">\n<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css?family=Product+Sans:400,400i,700,700i\">\n </head>\n <body>\n \n<div id=\"react-entry-point\">\n <div class=\"_dash-loading\">\n Loading...\n </div>\n</div>\n\n <footer>\n <script id=\"_dash-config\" type=\"application/json\">{\"requests_pathname_prefix\": \"/\", \"url_base_pathname\": null}</script>\n <script src=\"https://unpkg.com/[email protected]/dist/react.min.js\"></script>\n<script src=\"https://unpkg.com/[email protected]/dist/react-dom.min.js\"></script>\n<script src=\"https://unpkg.com/[email protected]/dash_html_components/dash_html_components.min.js\"></script>\n<script src=\"https://cdn.plot.ly/plotly-1.41.3.min.js\"></script>\n<script src=\"https://unpkg.com/[email protected]/dash_core_components/dash_core_components.min.js\"></script>\n<script src=\"https://unpkg.com/[email protected]/dash_renderer/dash_renderer.min.js\"></script>\n </footer>\n </body>\n</html>","output":"str","x":343,"y":78,"wires":[["abd033f5.78c24"]]},{"id":"d012aba6.cc3678","type":"debug","z":"45713e9d.6607c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":988,"y":145,"wires":[]},{"id":"4d075b6f.4ea444","type":"sqlite","z":"45713e9d.6607c","mydb":"2cb5f431.931bbc","sqlquery":"msg.topic","sql":"","name":"wind-data","x":531,"y":308,"wires":[["f68e1095.d69e1"]]},{"id":"a1c579f3.fcb158","type":"function","z":"45713e9d.6607c","name":"Query time-series data","func":"var start = new Date();\n\nvar hour = start.getHours();\nvar minute = start.getMinutes();\nvar sec = start.getSeconds();\n\nvar total_time = hour * 3600 + minute * 60 + sec;\n\nmsg.topic = \"SELECT Speed, SpeedError, Direction from Wind where rowid > \"+ (total_time-100) +\" AND rowid <= \"+total_time;\n\nreturn msg;","outputs":1,"noerr":0,"x":438,"y":245,"wires":[["4d075b6f.4ea444"]]},{"id":"f68e1095.d69e1","type":"function","z":"45713e9d.6607c","name":"Wind Speed Measurement","func":"var records = msg.payload;\n\nvar wind = { \"Speed\" : [], \"SpeedError\" : [], \"Direction\" : [] };\n\nfor (var i =0; i < records.length; i++) {\n wind.Speed.push( records[i].Speed ); \n wind.SpeedError.push( records[i].SpeedError ); \n wind.Direction.push( records[i].Direction ); \n}\n\nvar Speed = { y : wind.Speed , \n mode : 'lines', \n line : {color: \"#42C4F7\"}, \n type : \"scatter\",\n hoverinfo : \"skip\",\n error_y : { type : 'data',\n array : wind.SpeedError,\n thickness : 1.5,\n width : 2,\n color : '#B4E8FC'\n }\n};\n\nvar Layout = { \"height\": 500, \n \"margin\": {\"r\": 50, \"l\": 50, \"t\": 45}, \n \"xaxis\": {\"title\": \"Time Elapsed (sec)\", \n \"showgrid\": false, \n \"range\": [0, 100], \n \"fixedrange\": true, \n \"zeroline\": false, \n \"showline\": false, \n \"ticktext\": [\"100\", \"75\", \"50\", \"25\", \"0\"], \n \"tickvals\": [0, 25, 50, 75, 100]}, \n \"yaxis\": {\"zeroline\": false, \n \"showline\": false, \n \"nticks\": Math.max(6, Math.floor( wind.Speed[99]/10 ) ) , \n \"range\": [0, 60], \n \"fixedrange\": true}\n}\n\nmsg.payload = { response: {props: {figure: { data : [Speed] , layout : Layout }}}};\n \nreturn msg;","outputs":1,"noerr":0,"x":735,"y":307,"wires":[["5597ab59.f5c374"]]},{"id":"e35efd1b.00605","type":"switch","z":"45713e9d.6607c","name":"speed or direction","property":"payload.output.id","propertyType":"msg","rules":[{"t":"eq","v":"wind-speed","vt":"str"},{"t":"eq","v":"wind-direction","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":203,"y":317,"wires":[["a1c579f3.fcb158"],["3bded41c.098e7c"]]},{"id":"3bded41c.098e7c","type":"function","z":"45713e9d.6607c","name":"Query time-series data","func":"var start = new Date();\n\nvar hour = start.getHours();\nvar minute = start.getMinutes();\nvar sec = start.getSeconds();\n\nvar total_time = hour * 3600 + minute * 60 + sec;\n\nmsg.topic = \"SELECT Speed, SpeedError, Direction from Wind where rowid > \"+ (total_time-100) +\" AND rowid <= \"+total_time;\n\nreturn msg;","outputs":1,"noerr":0,"x":445,"y":417,"wires":[["881a1f9d.303fe"]]},{"id":"881a1f9d.303fe","type":"sqlite","z":"45713e9d.6607c","mydb":"2cb5f431.931bbc","sqlquery":"msg.topic","sql":"","name":"wind-data","x":533,"y":357,"wires":[["c899a505.ab47c8"]]},{"id":"c899a505.ab47c8","type":"function","z":"45713e9d.6607c","name":"Wind Direction Measurement","func":"//var Plotly = require(\"plotly.js-dist\");\nvar records = msg.payload;\n\nvar wind = { \"Speed\" : [], \"SpeedError\" : [], \"Direction\" : [] };\n\nfor (var i =0; i < records.length; i++) {\n wind.Speed.push( records[i].Speed ); \n wind.SpeedError.push( records[i].SpeedError ); \n wind.Direction.push( records[i].Direction ); \n}\n\n\nvar lastSpeed = wind.Speed[99]; \nvar direction = [0, (wind.Direction[0]-20), (wind.Direction[0]+20), 0];\n \nvar trace = { \n r : [0, lastSpeed , lastSpeed, 0],\n fill : \"toself\", \n fillcolor : \"rgb(242, 196, 247)\", \n line : {color: \"rgba(32, 32, 32, .6)\", width : 1 }, \n mode : \"lines\",\n theta : direction,\n type : \"scatterpolar\"\n};\n\nvar trace1 = { \n r : [0, lastSpeed * 0.65 , lastSpeed * 0.65, 0],\n fill : \"toself\", \n fillcolor : \"#F6D7F9\", \n line : {color: \"rgba(32, 32, 32, .6)\", width : 1 }, \n mode : \"lines\",\n theta : direction,\n type : \"scatterpolar\"\n};\n\nvar trace2 = { \n r : [0, lastSpeed * 0.3 , lastSpeed * 0.3, 0],\n fill : \"toself\", \n fillcolor : \"#FAEBFC\", \n line : {color: \"rgba(32, 32, 32, .6)\", width : 1 }, \n mode : \"lines\",\n theta : direction,\n type : \"scatterpolar\"\n};\n\nvar Layout = { \"polar\": {\n \"radialaxis\": { \"range\": [0, 45], \"angle\": 45, \"dtick\": 10}, \n \"bgcolor\": \"#F2F2F2\", \n \"angularaxis\": {\"showline\": false, \"tickcolor\": \"white\"}\n }, \n \"autosize\": true, \n \"margin\": {\"r\": 30, \"b\": 10, \"l\": 40, \"t\": 10}, \n \"showlegend\": false, \n \"width\": 275\n}\n\nmsg.payload = { response: {props: {figure: { data : [trace, trace1, trace2] , layout : Layout }}}};\n \nreturn msg;","outputs":1,"noerr":0,"x":743,"y":356,"wires":[["5597ab59.f5c374"]]},{"id":"2cb5f431.931bbc","type":"sqlitedb","z":"","db":"C:\\Users\\sphyun\\.node-red\\wind-data.db","mode":"RWC"}]