[{"id":"74aaac64.2ab074","type":"mqtt in","z":"8cba288e.042798","name":"","topic":"node/infragrid-sensor:0/buffer/-/data","qos":"2","datatype":"auto","broker":"e649966c.8c2af8","x":520,"y":460,"wires":[["78e1325c.52b5cc"]]},{"id":"85d0868f.0344e8","type":"function","z":"8cba288e.042798","name":"Temperature format","func":"function decompress(input)\n{\n var output = [];\n var bit = 0;\n\n for(var i = 0; i < 64; i++)\n {\n b = Math.floor(bit / 8);\n offset = bit % 8;\n\n if(offset > 2)\n {\n val = input[b] >> offset | input[b+1] << (8-offset);\n }\n else\n {\n val = input[b] >> offset;\n }\n output[i] = val & 0x3F\n bit += 6;\n }\n\n return output;\n}\n\nmsg.payload = decompress(msg.payload);\n\nreturn msg;","outputs":1,"noerr":0,"x":930,"y":460,"wires":[["3ca7e109.d42e6e"]]},{"id":"4e738869.b0e458","type":"ui_template","z":"8cba288e.042798","group":"27d52812.4e0d88","name":"","order":0,"width":"12","height":"12","format":"<table style=\"border-spacing:0\">\n<tr ng-repeat=\"row in msg.payload track by $index\">\n <td style=\"width:20px;height:20px;display:block;float:left\" ng-repeat=\"col in row track by $index\" ng-style=\"{'background-color': col}\">\n \n </td>\n</tr>\n</table>\n \n ","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":1280,"y":460,"wires":[[]]},{"id":"78e1325c.52b5cc","type":"json","z":"8cba288e.042798","name":"","property":"payload","action":"","pretty":false,"x":770,"y":460,"wires":[["85d0868f.0344e8"]]},{"id":"3ca7e109.d42e6e","type":"function","z":"8cba288e.042798","name":"Array slicer","func":"var inputArray = [];\nvar array = [];\nvar outputArray = [];\n\nvar min = 400;\nvar max = -5;\n\nvar temperature;\n\nvar colorMap = [\"#480078\", \"#400078\", \"#400078\", \"#400078\", \"#400080\", \"#380080\", \"#380080\", \"#380080\", \"#380080\", \"#300080\", \"#300080\", \"#300080\", \"#280080\", \"#280080\", \"#280080\", \"#280080\", \"#200080\", \"#200080\", \"#200080\", \"#180080\", \"#180080\", \"#180088\", \"#180088\", \"#100088\", \"#100088\", \"#100088\", \"#080088\", \"#080088\", \"#080088\", \"#000088\", \"#000088\", \"#000088\", \"#000088\", \"#000088\", \"#000488\", \"#000488\", \"#000888\", \"#000C90\", \"#000C90\", \"#001090\", \"#001490\", \"#001490\", \"#001890\", \"#001C90\", \"#001C90\", \"#002090\", \"#002490\", \"#002890\", \"#002890\", \"#002C90\", \"#003090\", \"#003090\", \"#003490\", \"#003890\", \"#003C98\", \"#003C98\", \"#004098\", \"#004498\", \"#004898\", \"#004898\", \"#004C98\", \"#005098\", \"#005498\", \"#005898\", \"#005898\", \"#005C98\", \"#006098\", \"#006498\", \"#006498\", \"#006898\", \"#006C98\", \"#0070A0\", \"#0074A0\", \"#0078A0\", \"#0078A0\", \"#007CA0\", \"#0080A0\", \"#0084A0\", \"#0088A0\", \"#008CA0\", \"#008CA0\", \"#0090A0\", \"#0094A0\", \"#0098A0\", \"#009CA0\", \"#00A0A0\", \"#00A4A0\", \"#00A4A0\", \"#00A8A0\", \"#00A8A0\", \"#00ACA0\", \"#00ACA0\", \"#00AC98\", \"#00AC98\", \"#00AC98\", \"#00AC90\", \"#00AC90\", \"#00AC90\", \"#00AC88\", \"#00B088\", \"#00B088\", \"#00B080\", \"#00B080\", \"#00B078\", \"#00B078\", \"#00B078\", \"#00B070\", \"#00B470\", \"#00B470\", \"#00B468\", \"#00B468\", \"#00B468\", \"#00B460\", \"#00B460\", \"#00B458\", \"#00B858\", \"#00B858\", \"#00B850\", \"#00B850\", \"#00B850\", \"#00B848\", \"#00B848\", \"#00B840\", \"#00BC40\", \"#00BC40\", \"#00BC38\", \"#00BC38\", \"#00BC30\", \"#00BC30\", \"#00BC30\", \"#00BC28\", \"#00BC28\", \"#00C020\", \"#00C020\", \"#00C020\", \"#00C018\", \"#00C018\", \"#00C010\", \"#00C010\", \"#00C008\", \"#00C408\", \"#00C408\", \"#00C400\", \"#00C400\", \"#00C400\", \"#00C400\", \"#08C400\", \"#08C400\", \"#08C800\", \"#10C800\", \"#10C800\", \"#18C800\", \"#18C800\", \"#20C800\", \"#20C800\", \"#28C800\", \"#28CC00\", \"#30CC00\", \"#30CC00\", \"#38CC00\", \"#38CC00\", \"#38CC00\", \"#40CC00\", \"#40CC00\", \"#48CC00\", \"#48D000\", \"#50D000\", \"#50D000\", \"#58D000\", \"#58D000\", \"#60D000\", \"#60D000\", \"#68D000\", \"#68D400\", \"#70D400\", \"#70D400\", \"#78D400\", \"#78D400\", \"#80D400\", \"#80D400\", \"#88D400\", \"#88D800\", \"#90D800\", \"#90D800\", \"#98D800\", \"#98D800\", \"#A0D800\", \"#A8D800\", \"#A8D800\", \"#B0DC00\", \"#B0DC00\", \"#B8DC00\", \"#B8DC00\", \"#C0DC00\", \"#C0DC00\", \"#C8DC00\", \"#C8DC00\", \"#D0DC00\", \"#D0E000\", \"#D8E000\", \"#D8DC00\", \"#D8D800\", \"#D8D400\", \"#D8D000\", \"#D8D000\", \"#E0CC00\", \"#E0C800\", \"#E0C400\", \"#E0C000\", \"#E0BC00\", \"#E0B800\", \"#E0B400\", \"#E0B000\", \"#E0AC00\", \"#E0A800\", \"#E0A400\", \"#E0A000\", \"#E09C00\", \"#E09800\", \"#E09400\", \"#E09000\", \"#E08C00\", \"#E88800\", \"#E88400\", \"#E88000\", \"#E87C00\", \"#E87800\", \"#E87400\", \"#E87000\", \"#E86C00\", \"#E86800\", \"#E86400\", \"#E86000\", \"#E85C00\", \"#E85800\", \"#E85400\", \"#E85000\", \"#E84C00\", \"#E84800\", \"#F04400\", \"#F04000\", \"#F03C00\", \"#F03800\", \"#F03400\", \"#F03000\", \"#F02C00\", \"#F02800\", \"#F02000\", \"#F01C00\", \"#F01800\", \"#F01400\", \"#F01000\", \"#F00C00\", \"#F00800\", \"#F00400\", \"#F80000\"];\nvar outputColor = [];\n\nfor(var i = 0; i < 8; i++)\n{\n inputArray[i] = msg.payload.slice(i * 8, i * 8 + 8);\n min = Math.min(min,...inputArray[i]);\n max = Math.max(max,...inputArray[i]);\n}\n\narray = inputArray;\n\nfor(var row = 0; row < 15; row++)\n{\n outputArray[row] = [];\n for(var col = 0; col < 15; col++)\n {\n var row2 = Math.floor(row / 2);\n var col2 = Math.floor(col / 2);\n if (((col % 2) == 0) && ((row % 2) == 0))\n {\n temperature = array[row2][col2];\n }\n else if (((row % 2) == 1) && ((col % 2) == 0))\n {\n temperature = (array[row2][col2] + array[row2 + 1][col2]) / 2;\n }\n else \n {\n temperature = (array[row2][col2] + array[row2][col2 + 1]) / 2;\n }\n colorIndex = Math.floor(map(Number(temperature), min, max, 0, 255));\n outputArray[row][col] = colorMap[colorIndex];\n }\n}\n\nmsg.payload = outputArray;\nreturn msg;\n\nfunction map(x, in_min, in_max, out_min, out_max)\n{\n var val = (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;\n if (val > out_max)\n {\n val = out_max;\n }\n if (val < out_min)\n {\n val = out_min;\n }\n return val;\n}","outputs":1,"noerr":0,"x":1110,"y":460,"wires":[["4e738869.b0e458"]]},{"id":"e649966c.8c2af8","type":"mqtt-broker","z":"","name":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"27d52812.4e0d88","type":"ui_group","z":"","name":"Demo","tab":"785a9973.fe5a58","disp":true,"width":"12","collapse":false},{"id":"785a9973.fe5a58","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]
Comments