Skip to content

Instantly share code, notes, and snippets.

@rappch1 rappch1/7 - LMS5xx
Last active Sep 15, 2017

Embed
What would you like to do?
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": "2d29bbfb.d719f4",
"type": "tab",
"label": "7 - LMS5xx",
"disabled": false,
"info": ""
},
{
"id": "4393ad68.1b1b0c",
"type": "mqtt in",
"z": "2d29bbfb.d719f4",
"name": "contamination",
"topic": "io/cybus/energie-campus/sick/7/laserscanner/eg/halle/contamination",
"qos": "0",
"broker": "10e889ef.451a0e",
"x": 130,
"y": 180,
"wires": [
[
"78399992.3bef88"
]
]
},
{
"id": "a90a7d29.01ab5",
"type": "ui_chart",
"z": "2d29bbfb.d719f4",
"name": "",
"group": "f42bddad.9a095",
"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": 694,
"y": 179,
"wires": [
[],
[]
]
},
{
"id": "3b223d2b.f0506a",
"type": "mqtt in",
"z": "2d29bbfb.d719f4",
"name": "scan",
"topic": "io/cybus/energie-campus/sick/7/laserscanner/eg/halle/scan",
"qos": "0",
"broker": "10e889ef.451a0e",
"x": 130,
"y": 80,
"wires": [
[
"3a3db5a3.eee262"
]
]
},
{
"id": "d08f436c.2fd5f",
"type": "ui_template",
"z": "2d29bbfb.d719f4",
"group": "e85fa909.7ee8",
"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": 437,
"y": 80,
"wires": [
[]
]
},
{
"id": "3a3db5a3.eee262",
"type": "json",
"z": "2d29bbfb.d719f4",
"name": "",
"pretty": false,
"x": 263,
"y": 79,
"wires": [
[
"d08f436c.2fd5f"
]
]
},
{
"id": "78399992.3bef88",
"type": "subflow:d7e5835.77c61",
"z": "2d29bbfb.d719f4",
"name": "preprocessContaminationForVisualization",
"x": 428,
"y": 178.5,
"wires": [
[
"a90a7d29.01ab5"
]
]
},
{
"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": "f42bddad.9a095",
"type": "ui_group",
"z": "",
"name": "Contamination",
"tab": "de880ba1.394a6",
"order": 2,
"disp": true,
"width": "12"
},
{
"id": "e85fa909.7ee8",
"type": "ui_group",
"z": "",
"name": "Scan",
"tab": "de880ba1.394a6",
"order": 1,
"disp": true,
"width": "20"
},
{
"id": "de880ba1.394a6",
"type": "ui_tab",
"z": "",
"name": "7 - LMS5xx",
"icon": "dashboard",
"order": 7
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.