[
{
"id": "2c912723.4f0338",
"type": "http in",
"z": "57519a9b.8fba94",
"name": "",
"url": "sensor4",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 70,
"y": 100,
"wires": [
[
"94c3393a.020d68"
]
]
},
{
"id": "94c3393a.020d68",
"type": "template",
"z": "57519a9b.8fba94",
"name": "HTML",
"field": "payload",
"fieldType": "msg",
"format": "html",
"syntax": "mustache",
"template": "<!DOCTYPE html>\n<html lang=\"ja\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n<title>加速度検出</title>\n</head>\n \n<body>\n<div id=\"datatxt\">データの表示</div> \n \n<script>\n var encrypted = \"{{{req.connection.encrypted}}}\";\n if (encrypted === \"true\") {\n var wsUri = \"wss://{{{req.hostname}}}:{{{req.connection.localPort}}}/accl1\";\n }\n else {\n var wsUri = \"ws://{{{req.hostname}}}:{{{req.connection.localPort}}}/accl1\";\n }\n var ws = new WebSocket(wsUri);\n\n var accx = null;\n var accy = null;\n var accz = null;\n\n function sendMessage() {\n // 画面書き換え\n var txt = \"wsUri:\" + wsUri + \"<br>\";\n txt += \"x:\" + accx + \"<br>\";\n txt += \"y:\" + accy + \"<br>\";\n txt += \"z:\" + accz + \"<br>\";\n\n var datatxt = document.getElementById(\"datatxt\");\n datatxt.innerHTML = txt;\n\n // WebSocket送信\n var payload = {\n 'accx': accx,\n 'accy': accy,\n 'accz': accz,\n };\n ws.send(JSON.stringify(payload));\n }\n\n function handleMotionEvent(evt) {\n //加速度\n accx = evt.acceleration.x;\n accy = evt.acceleration.y;\n accz = evt.acceleration.z;\n }\n\n window.addEventListener(\"devicemotion\", handleMotionEvent, true); //情報変更ごとにイベント発生\n window.setInterval(sendMessage, 500); // 500msごとにイベント発生\n\n</script>\n</body>\n</html>",
"output": "str",
"x": 317.00000762939453,
"y": 100.00000286102295,
"wires": [
[
"c9b732b9.d5df9"
]
]
},
{
"id": "c9b732b9.d5df9",
"type": "http response",
"z": "57519a9b.8fba94",
"name": "",
"statusCode": "",
"headers": {},
"x": 541.0000152587891,
"y": 100.00000190734863,
"wires": []
},
{
"id": "af4fa6f9.139f88",
"type": "websocket in",
"z": "57519a9b.8fba94",
"name": "",
"server": "250c9625.e420aa",
"client": "",
"x": 60,
"y": 220,
"wires": [
[
"1c16e58e.096d5a"
]
]
},
{
"id": "1c16e58e.096d5a",
"type": "json",
"z": "57519a9b.8fba94",
"name": "加速度をjson形式に変換",
"property": "payload",
"action": "",
"pretty": false,
"x": 310,
"y": 320,
"wires": [
[
"b50a0d6c.0c67a",
"10eecadd.b9fbe5",
"1c843637.566a8a"
]
]
},
{
"id": "b50a0d6c.0c67a",
"type": "switch",
"z": "57519a9b.8fba94",
"name": "加速度判定",
"property": "payload.accz",
"propertyType": "msg",
"rules": [
{
"t": "gt",
"v": "10",
"vt": "num"
},
{
"t": "btwn",
"v": "6",
"vt": "num",
"v2": "10",
"v2t": "num"
},
{
"t": "lte",
"v": "5",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 533.0000152587891,
"y": 312.0000088214874,
"wires": [
[
"326dd035.413f1"
],
[
"dddabb62.392ea8"
],
[
"7c53f99b.cba9e8"
]
]
},
{
"id": "ec7a3c72.a1361",
"type": "debug",
"z": "57519a9b.8fba94",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 1110,
"y": 320,
"wires": []
},
{
"id": "d1c70b54.eb01d8",
"type": "comment",
"z": "57519a9b.8fba94",
"name": "加速度を出力",
"info": "",
"x": 70,
"y": 60,
"wires": []
},
{
"id": "10eecadd.b9fbe5",
"type": "mqtt out",
"z": "57519a9b.8fba94",
"name": "/NefryBT/SOLE",
"topic": "/NefryBT/SOLE",
"qos": "",
"retain": "",
"broker": "f9299578.86bcb8",
"x": 470.0000915527344,
"y": 530.0000152587891,
"wires": []
},
{
"id": "1c843637.566a8a",
"type": "debug",
"z": "57519a9b.8fba94",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 311.00004959106445,
"y": 583.0000152587891,
"wires": []
},
{
"id": "326dd035.413f1",
"type": "change",
"z": "57519a9b.8fba94",
"name": "accz > 10 のときの文字列「large」",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "large",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 818.000020980835,
"y": 274.00000762939453,
"wires": [
[
"ec7a3c72.a1361"
]
]
},
{
"id": "dddabb62.392ea8",
"type": "change",
"z": "57519a9b.8fba94",
"name": "accz:6~10 のときの文字列「medium」",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "medium",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 840,
"y": 320,
"wires": [
[
"ec7a3c72.a1361"
]
]
},
{
"id": "7c53f99b.cba9e8",
"type": "change",
"z": "57519a9b.8fba94",
"name": "accz <= 5 のときの文字列「small」",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "small",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 820,
"y": 360,
"wires": [
[
"ec7a3c72.a1361"
]
]
},
{
"id": "53d3ea65.523574",
"type": "comment",
"z": "57519a9b.8fba94",
"name": "加速度を受信して橋渡し",
"info": "",
"x": 110,
"y": 180,
"wires": []
},
{
"id": "422cdf71.4a17e",
"type": "comment",
"z": "57519a9b.8fba94",
"name": "MQTTで加速度をjson形式で送信",
"info": "",
"x": 520.0000152587891,
"y": 490.00001430511475,
"wires": []
},
{
"id": "d24b4e1f.58b25",
"type": "comment",
"z": "57519a9b.8fba94",
"name": "デバック画面に加速度の具合を表示させる部分",
"info": "",
"x": 641.0000152587891,
"y": 226.00000667572021,
"wires": []
},
{
"id": "250c9625.e420aa",
"type": "websocket-listener",
"z": "",
"path": "/accl1",
"wholemsg": "false"
},
{
"id": "f9299578.86bcb8",
"type": "mqtt-broker",
"z": "",
"name": "",
"broker": "http://test.mosquitto.org/",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]