[{"id":"61859b51.f7a28c","type":"http response","z":"deb0d57.1c46528","name":"/index.html","x":530,"y":1100,"wires":[]},{"id":"cbbcac0a.e5b73","type":"http in","z":"deb0d57.1c46528","name":"","url":"/index.html","method":"get","upload":false,"swaggerDoc":"","x":180,"y":1100,"wires":[["5cf1725f.a965c4"]]},{"id":"183e9b4e.3774a5","type":"http response","z":"deb0d57.1c46528","name":"/index.js","x":520,"y":1140,"wires":[]},{"id":"7446cf15.872f7","type":"http in","z":"deb0d57.1c46528","name":"","url":"/index.js","method":"get","swaggerDoc":"","x":190,"y":1140,"wires":[["60d4a32f.275244"]]},{"id":"a446256b.66b7f8","type":"websocket out","z":"deb0d57.1c46528","name":"","server":"5803f374.c349ec","client":"","x":520,"y":1260,"wires":[]},{"id":"3aa69389.4b13b4","type":"websocket in","z":"deb0d57.1c46528","name":"","server":"5803f374.c349ec","client":"","x":209,"y":1304,"wires":[["10fad5a.c91f32a"]]},{"id":"5cf1725f.a965c4","type":"template","z":"deb0d57.1c46528","name":"index.html","field":"payload","fieldType":"msg","format":"html","syntax":"plain","template":"\n\n \n Example\n \n \n\n \n\n\n
\n
Angle: ??°
\n","x":360,"y":1100,"wires":[["61859b51.f7a28c"]]},{"id":"60d4a32f.275244","type":"template","z":"deb0d57.1c46528","name":"index.js","field":"payload","fieldType":"msg","format":"text","syntax":"plain","template":"!function() {\n \"use strict\";\n\n var socket = new WebSocket('ws://' + window.location.host + '/data');\n socket.onmessage = function(e) {\n var item = JSON.parse(e.data);\n\n switch (item.topic) {\n case 'temperature':\n processTemp(item.data);\n break;\n case 'angle':\n processAngle(item.data);\n break;\n case 'predicted':\n processPredicted(item.data);\n break;\n }\n };\n\n /*\n * Temperature.\n */\n var actual = [{x: new Date}];\n var predicted = [];\n var $graph = document.querySelector('#graph');\n\n var chart = new CanvasJS.Chart($graph, {\n axisX: {title: \"Timeline\"},\n axisY: {title: \"Temperature\"},\n data: [{\n type: \"spline\",\n dataPoints: actual\n }, {\n type: \"line\",\n dataPoints: predicted,\n lineThickness: 1,\n lineDashType: 'dashDot'\n }]\n });\n\n chart.render();\n\n function processTemp(temp) {\n var now = new Date;\n\n if (+now - actual[0].x > 2 * 60 * 1000)\n actual.shift();\n\n var point = {x: now, y: temp};\n\n actual.push(point);\n predicted[0] = point;\n\n chart.render();\n }\n\n function processPredicted(temp) {\n predicted[1] = {\n x: new Date(Date.now() + 60 * 1000),\n y: temp\n };\n\n chart.render();\n }\n\n /*\n * Angle.\n */\n var $angle = document.querySelector('#angle');\n\n function processAngle(angle) {\n $angle.innerHTML = angle;\n }\n\n /*\n * Button.\n */\n var $button = document.querySelector('#turn-btn');\n $button.onclick = function() {\n socket.send(true);\n };\n\n}();","x":360,"y":1140,"wires":[["183e9b4e.3774a5"]]},{"id":"91e0ac73.63a57","type":"ibmiot in","z":"deb0d57.1c46528","authentication":"boundService","apiKey":"ec096bd5.03d408","inputType":"evt","deviceId":"b827eb79051a","applicationId":"","deviceType":"+","eventType":"+","commandType":"","format":"json","name":"raspi","service":"registered","allDevices":"","allApplications":"","allDeviceTypes":true,"allEvents":true,"allCommands":"","allFormats":"","qos":"0","x":210,"y":1260,"wires":[["b8a1c4c9.652d8"]]},{"id":"b8a1c4c9.652d8","type":"function","z":"deb0d57.1c46528","name":"transform","func":"return {\n payload: {\n topic: msg.eventType,\n data: msg.payload\n }\n};","outputs":1,"noerr":0,"x":360,"y":1260,"wires":[["a446256b.66b7f8"]]},{"id":"10fad5a.c91f32a","type":"ibmiot out","z":"deb0d57.1c46528","authentication":"boundService","apiKey":"ec096bd5.03d408","outputType":"cmd","deviceId":"b827eb79051a","deviceType":"bmstu001","eventCommandType":"button","format":"json","data":"null","name":"raspi","service":"registered","x":519,"y":1304,"wires":[]},{"id":"115237e3.51b47","type":"comment","z":"deb0d57.1c46528","name":"Статический сервер.","info":"","x":140,"y":1060,"wires":[]},{"id":"3dcb29d1.2977ce","type":"comment","z":"deb0d57.1c46528","name":"Получение и отправка сырых данных.","info":"","x":190,"y":1220,"wires":[]},{"id":"5803f374.c349ec","type":"websocket-listener","z":"deb0d57.1c46528","path":"/data","wholemsg":"false"},{"id":"ec096bd5.03d408","type":"ibmiot","z":"deb0d57.1c46528","name":"raspi"}]