Skip to content

Instantly share code, notes, and snippets.

@rappch1
Last active September 15, 2017 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rappch1/61215e8280f75f511cb19eba1e3ce033 to your computer and use it in GitHub Desktop.
Save rappch1/61215e8280f75f511cb19eba1e3ce033 to your computer and use it in GitHub Desktop.
WhatTheData 2017: Real SICK Data
[
{
"id": "d7e5835.77c61",
"type": "subflow",
"name": "Subflow 1",
"info": "",
"in": [
{
"x": 187,
"y": 181,
"wires": [
{
"id": "6e23e30a.83f5bc"
}
]
}
],
"out": [
{
"x": 801,
"y": 184,
"wires": [
{
"id": "637e0f8b.eded2",
"port": 0
}
]
}
]
},
{
"id": "6ffa90fa.0b1848",
"type": "split",
"z": "d7e5835.77c61",
"name": "",
"splt": "\\n",
"x": 454,
"y": 182,
"wires": [
[
"637e0f8b.eded2"
]
]
},
{
"id": "637e0f8b.eded2",
"type": "function",
"z": "d7e5835.77c61",
"name": "format output msg",
"func": "// old payload\nlet data = msg.payload;\n\n// new topic and payload\nmsg.topic = 'field ' + data.field;\nmsg.payload = 100- data.value;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 631,
"y": 184,
"wires": [
[]
]
},
{
"id": "6e23e30a.83f5bc",
"type": "json",
"z": "d7e5835.77c61",
"name": "",
"pretty": false,
"x": 317,
"y": 181,
"wires": [
[
"6ffa90fa.0b1848"
]
]
},
{
"id": "9eca6b2d.0cda7",
"type": "tab",
"label": "3 - LMS5xx",
"disabled": false,
"info": ""
},
{
"id": "52e46bf1.59875c",
"type": "mqtt in",
"z": "9eca6b2d.0cda7",
"name": "contamination",
"topic": "io/cybus/energie-campus/sick/3/laserscanner/og/flur/contamination",
"qos": "0",
"broker": "10e889ef.451a0e",
"x": 105,
"y": 241,
"wires": [
[
"5283d74b.188a88"
]
]
},
{
"id": "19bc53cb.76370c",
"type": "debug",
"z": "9eca6b2d.0cda7",
"name": "",
"active": false,
"console": "false",
"complete": "false",
"x": 615,
"y": 125,
"wires": []
},
{
"id": "d46fdd6c.f88ea8",
"type": "mqtt in",
"z": "9eca6b2d.0cda7",
"name": "scan",
"topic": "io/cybus/energie-campus/sick/3/laserscanner/og/flur/scan",
"qos": "0",
"broker": "10e889ef.451a0e",
"x": 108,
"y": 125,
"wires": [
[
"bd49a03d.276578"
]
]
},
{
"id": "9ca359a9.dd6a88",
"type": "ui_template",
"z": "9eca6b2d.0cda7",
"group": "ce138537.945878",
"name": "ScanVisualization",
"order": 1,
"width": "20",
"height": "20",
"format": "<!--<div ng-bind-html=\"msg.payload\"></div>-->\n<canvas style=\"position: absolute; top: 0; left: 0;\" id=\"canvasLayerGrid\" width=\"1070\" height=\"1070\"></canvas>\n<canvas style=\"position: absolute; top: 0; left: 0;\" id=\"canvasLayerWarning\" width=\"1070\" height=\"1070\"></canvas>\n<canvas style=\"position: absolute; top: 0; left: 0;\" id=\"canvasLayerProtective\" width=\"1070\" height=\"1070\"></canvas>\n<canvas style=\"position: absolute; top: 0; left: 0;\" id=\"canvasLayerScan\" width=\"1070\" height=\"1070\"></canvas>\n\n<script>\n var scale = 0.1;\n var everyNthScanPoint = 1;\n var i = 0;\n var j = 0;\n \n function clear(canvas)\n {\n var context = canvas.getContext('2d');\n context.clearRect(0, 0, canvas.width, canvas.height);\n }\n\n function drawScanPoint(canvas, x, y, color)\n {\n var context = canvas.getContext('2d');\n var radius = 5;\n var centerX = canvas.width / 2;\n var centerY = canvas.height / 2;\n \n context.beginPath();\n context.arc(centerX + x, centerY + y, radius, 0, 2 * Math.PI, false);\n context.fillStyle = color;\n context.fill();\n context.lineWidth = 1;\n context.strokeStyle = '#333333';\n context.stroke();\n }\n \n function drawScanRay(canvas, x, y, color)\n {\n var context = canvas.getContext('2d');\n var centerX = canvas.width / 2;\n var centerY = canvas.height / 2;\n context.beginPath();\n context.moveTo(centerX, centerY);\n context.lineTo(centerX + x, centerY + y);\n context.lineWidth = 1;\n context.strokeStyle = color;\n context.stroke();\n }\n \n function drawLine(canvas, firstPos, secondPos, color)\n {\n var context = canvas.getContext('2d');\n var centerX = canvas.width / 2;\n var centerY = canvas.height / 2;\n context.beginPath();\n context.moveTo(centerX + firstPos[0], centerY + firstPos[1]);\n context.lineTo(centerX + secondPos[0], centerY + secondPos[1]);\n context.lineWidth = 2;\n context.strokeStyle = color;\n context.stroke();\n }\n \n function drawGrid(canvas)\n {\n clear(canvas);\n var gridSize = 50;\n var span = 10;\n var absBorder = gridSize * span;\n for (i = -span; i <= span; i++)\n {\n drawLine(canvas, [-absBorder, i*gridSize], [absBorder, i*gridSize], '#AAAAAA');\n drawLine(canvas, [i*gridSize, -absBorder], [i*gridSize, absBorder], '#AAAAAA');\n }\n }\n \n function drawText(canvas, text)\n {\n var context = canvas.getContext(\"2d\");\n context.font = \"30px Arial\";\n context.fillText(text,100,100); \n }\n \n function toRad(angleDeg)\n {\n return angleDeg * Math.PI / 180.0;\n }\n \n function calcPos(angle, distance, rotation, scale)\n {\n var x = scale * Math.sin(angle + rotation) * distance;\n var y = scale * Math.cos(angle + rotation) * distance;\n return [x,y];\n }\n \n function drawScan(canvas, parsedData, color)\n {\n clear(canvas);\n var angles = parsedData.angles;\n var distances = parsedData.distances;\n var numPoints = angles.length;\n \n var rotation = toRad(90.0);\n for (j = 0; j < numPoints; j+=everyNthScanPoint)\n { \n if (distances[j] == 0)\n {\n continue;\n }\n var pos = calcPos(angles[j], distances[j], rotation, scale);\n drawScanRay(canvas, pos[0], pos[1], color);\n drawScanPoint(canvas, pos[0], pos[1], color);\n }\n }\n \n function msgIsOfType(msgString, typeString)\n {\n return(msgString.indexOf(typeString) == 2)\n }\n\n var canvasGrid = document.getElementById('canvasLayerGrid');\n drawGrid(canvasGrid);\n \n (function(scope) {\n scope.$watch('msg.payload', function(msg) {\n //var parsedData = JSON.parse(msg);\n var canvas = document.getElementById('canvasLayerScan');\n drawScan(canvas, msg, 'red');\n return;\n });\n })(scope);\n</script>",
"storeOutMessages": true,
"fwdInMessages": true,
"templateScope": "local",
"x": 423,
"y": 125,
"wires": [
[
"19bc53cb.76370c"
]
]
},
{
"id": "de0b436.c9e2ec",
"type": "ui_chart",
"z": "9eca6b2d.0cda7",
"name": "",
"group": "5f812a9d.4faa8c",
"order": 0,
"width": 0,
"height": 0,
"label": "",
"chartType": "bar",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "0",
"ymax": "100",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"x": 714,
"y": 245,
"wires": [
[],
[]
]
},
{
"id": "bd49a03d.276578",
"type": "json",
"z": "9eca6b2d.0cda7",
"name": "",
"pretty": false,
"x": 245,
"y": 125,
"wires": [
[
"9ca359a9.dd6a88"
]
]
},
{
"id": "5283d74b.188a88",
"type": "subflow:d7e5835.77c61",
"z": "9eca6b2d.0cda7",
"name": "preprocessContaminationForVisualization",
"x": 419,
"y": 242,
"wires": [
[
"de0b436.c9e2ec"
]
]
},
{
"id": "10e889ef.451a0e",
"type": "mqtt-broker",
"z": "",
"broker": "energie-campus.cybus.io",
"port": "1883",
"clientid": "",
"usetls": false,
"verifyservercert": true,
"compatmode": true,
"keepalive": "15",
"cleansession": true,
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": ""
},
{
"id": "ce138537.945878",
"type": "ui_group",
"z": "",
"name": "Scan",
"tab": "debf32b8.eaa258",
"order": 1,
"disp": true,
"width": "20"
},
{
"id": "5f812a9d.4faa8c",
"type": "ui_group",
"z": "",
"name": "Contamination",
"tab": "debf32b8.eaa258",
"order": 2,
"disp": true,
"width": "12"
},
{
"id": "debf32b8.eaa258",
"type": "ui_tab",
"z": "",
"name": "3 - LMS5xx",
"icon": "dashboard",
"order": 3
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment