web modBus instrumentation

more details see : http://www.rgot.org/instrumentation-modbus/

[{"id":"56b42b3e.51b8d4","type":"tab","label":"Instrumentation Web modBus"},{"id":"f6195580.c4f1c8","type":"function","z":"56b42b3e.51b8d4","name":"data2obj","func":"/* \n\n╔═════════╦════════════════╦══════════╦═════════╦═════╦═════╦════════════╦═════════╗\n║  index  ║       0        ║    1     ║    2    ║  3  ║  4  ║     5      ║    6    ║\n╠═════════╬════════════════╬══════════╬═════════╬═════╬═════╬════════════╬═════════╣\n║ trame   ║ id_appareil    ║ id_unite ║ id_type ║ min ║ max ║ valEntiere ║ valDeci ║\n╠═════════╬════════════════╬══════════╬═════════╬═════╬═════╬════════════╬═════════╣\n║ exemple ║ 51966 (0xCAFE) ║ 9        ║ 3       ║ 5   ║ 95  ║ 33         ║ 90      ║\n╚═════════╩════════════════╩══════════╩═════════╩═════╩═════╩════════════╩═════════╝\n\ntableau des unité :\n╔═══════╦══════╦═════╦══════╦═══╦════╦═══╦═══╦═════════╦═══════════╦════╗\n║ index ║  0   ║  1  ║  2   ║ 3 ║ 4  ║ 5 ║ 6 ║    7    ║     8     ║ 9  ║\n╠═══════╬══════╬═════╬══════╬═══╬════╬═══╬═══╬═════════╬═══════════╬════╣\n║ unité ║ sans ║ m/s ║ Km/h ║ m ║ km ║ s ║ h ║ Tours/s ║ Tours/min ║ °C ║\n╚═══════╩══════╩═════╩══════╩═══╩════╩═══╩═══╩═════════╩═══════════╩════╝\ntableau des types :\n╔═══════╦══════╦══════╦═════╦═════════╗\n║ index ║  0   ║  1   ║  2  ║    3    ║\n╠═══════╬══════╬══════╬═════╬═════════╣\n║ Type  ║ Char ║ Byte ║ Int ║ decimal ║\n╚═══════╩══════╩══════╩═════╩═════════╝\npar exemple data = [ 51966, 9, 3, 5, 95, 33, 90 ]\nid = 51966 = 0xCAFE\nunité = 9 => °C\ntype = 3 => decimal\nmin = 5 => minimum indiqué sur la gauge\nmax = 95 => max indiqué sur la gauge\nvalEntiere = 33 et vaDeci = 90 => tempétature = 33.90°C\n\nformat de l'objet de sortie :\n4 propriétés : unite, valeur, min et max \n{ \"unite\": \"°C\", \"valeur\": 33.9, \"min\": 5, \"max\": 95 }\n*/\nvar data = msg.payload;\nvar obj={};\nvar unite = ['','m/s','km/h','m','km','s','h','tours/s','tours/min','°C'];\n\nif(data[0]==0xCAFE)\n{\n    obj.unite=unite[data[1]];\n    if(data[2]==3){\n        obj.valeur= (data[5]*100 + data[6])/100.0;\n    }\n    obj.min=data[3];\n    obj.max=data[4];\n}\nflow.set('message',obj);\nmsg.payload=obj;\nreturn msg;","outputs":1,"noerr":0,"x":474.20001220703125,"y":163.1999969482422,"wires":[["68a86d4c.b1218c"]]},{"id":"a617b638.702bc","type":"debug","z":"56b42b3e.51b8d4","name":"","active":false,"console":"false","complete":"false","x":596.2000122070312,"y":276.9999694824219,"wires":[]},{"id":"6e23cf4d.41762","type":"function","z":"56b42b3e.51b8d4","name":"getJson","func":"msg.payload=flow.get('message');\nreturn msg;","outputs":1,"noerr":0,"x":370.20001220703125,"y":325.9999694824219,"wires":[["a617b638.702bc","d8f2bd76.52e0f8"]]},{"id":"88f3daae.cb51e","type":"debug","z":"56b42b3e.51b8d4","name":"","active":false,"console":"false","complete":"payload","x":490.70001220703125,"y":98.39999389648438,"wires":[]},{"id":"343e5a41.dfd98e","type":"modbus-read","z":"56b42b3e.51b8d4","name":"add1","showStatusActivities":false,"showErrors":false,"unitid":"2","dataType":"HoldingRegister","adr":"0","quantity":"7","rate":"1","rateUnit":"s","server":"ec1c5eaa.182f58","x":207.70001220703125,"y":121.39999389648438,"wires":[["f6195580.c4f1c8","88f3daae.cb51e"],[]]},{"id":"e2ddbd0e.ccf4e8","type":"template","z":"56b42b3e.51b8d4","name":"script","field":"script","fieldType":"msg","format":"javascript","syntax":"mustache","template":"\n/**\n * Sonic Gauge jQuery Plugin v0.3.0\n * jQuery plugin to create and display SVG gauges using RaphaelJS\n * \n * Copyright (c) 2013 Andy Burton (http://andyburton.co.uk)\n * GitHub https://github.com/andyburton/Sonic-Gauge\n * \n * Licensed under the MIT license (http://andyburton.co.uk/license/mit.txt)\n */\n\n(function($){\n\t\n\tvar methods\t= {\n\t\t\n\t\t/**\n\t\t * Initialise object\n\t\t */\n\t\t\n\t\tinit : function (options)\n\t\t{\n\t\t\t\n\t\t\tif (!this.length)\n\t\t\t{\n\t\t\t\treturn this;\n\t\t\t}\n\t\t\t\n\t\t\tthis.options\t= $.extend (true, {}, $.fn.SonicGauge.defaultOptions);\n\t\t\tthis.settings\t= {};\n\t\t\t\n\t\t\tthis.SonicGauge ('setOptions', options);\n\t\t\t//this.SonicGauge ('draw');\n\t\t\t\n\t\t\treturn this;\n\t\t\t\n\t\t},\n\t\t\n\t\t/**\n\t\t * Set options\n\t\t */\n\t\t\n\t\tsetOptions : function (options)\n\t\t{\n\t\t\t\n\t\t\tif (options)\n\t\t\t{\n\t\t\t\t$.extend (true, this.options, options);\n\t\t\t}\n\t\t\t\n\t\t\tthis.settings.canvas_d\t= this.options.diameter;\n\t\t\tthis.settings.canvas_r\t= this.settings.canvas_d / 2;\n\t\t\tthis.settings.speedo_d\t= this.settings.canvas_d - this.options.margin * 2;\n\t\t\tthis.settings.speedo_r\t= this.settings.speedo_d / 2;\n\t\t\tthis.settings.increment\t= (this.options.end.angle - this.options.start.angle) / (this.options.end.num - this.options.start.num);\n\t\t\t\n\t\t\treturn this;\n\t\t\t\n\t\t},\n\t\t\n\t\t/**\n\t\t * Draw gauge\n\t\t */\n\n\t\tdraw : function ()\n\t\t{\n\t\t\t\n\t\t\t// Reference scope\n\t\t\t\n\t\t\tvar p\t= this;\n\t\t\t\n\t\t\t// Set element size\n\t\t\t// This fixes the firefox issue causing the digital dial position to be incorrect\n\t\t\t// As the raphael canvas still hasnt rendered causing incorrect width/height\n\t\t\t\n\t\t\tthis.width (this.settings.canvas_d);\n\t\t\tthis.height (this.settings.canvas_d);\n\t\t\t\n\t\t\t// Init Raphael element\n\t\t\t\n\t\t\tthis.gauge\t\t= Raphael (this.attr ('id'), this.settings.canvas_d, this.settings.canvas_d);\n\t\t\t\n\t\t\t// Set gauge outline\n\t\t\t\n\t\t\tvar outline\t\t= this.gauge.circle (this.settings.canvas_r, this.settings.canvas_r, this.settings.speedo_r).attr (this.options.style.outline);\n\t\t\t\n\t\t\t// Gauge label\n\t\t\t\n\t\t\tvar label_x\t= this.settings.canvas_r;\n\t\t\tvar label_y\t= this.settings.canvas_r - (this.settings.canvas_r / 4);\n\t\t\t\n\t\t\tif (typeof this.options.label == \"object\")\n\t\t\t{\n\t\t\t\t\n\t\t\t\tif (this.options.label.margin_x)\n\t\t\t\t{\n\t\t\t\t\tlabel_x += this.options.label.margin_x;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (this.options.label.margin_y)\n\t\t\t\t{\n\t\t\t\t\tlabel_y += this.options.label.margin_y;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\telse if (typeof this.options.label == \"string\")\n\t\t\t{\n\t\t\t\tthis.options.label\t= {value: this.options.label};\n\t\t\t}\n\t\t\t\n\t\t\tif (this.options.label)\n\t\t\t{\n\t\t\t\tvar label\t= this.gauge.text (label_x, label_y, this.options.label.value).attr (this.options.style.label);\n\t\t\t}\n\t\t\t\n\t\t\t// Draw sectors\n\t\t\t// Thanks to Thomas M aka Arctic SnowSky\n\n\t\t\tthis.sectors\t= [];\n\n\t\t\t$.each (this.options.sectors, function (i) {\n\t\t\t\t\n\t\t\t\tthis.style = $.extend (true, p.options.style.sector, this.style);\n\n\t\t\t\tif (!(isNaN (this.start) || isNaN (this.end)))\n\t\t\t\t{\n\t\t\t\t\t\n\t\t\t\t\tvar startAngle\t= p.settings.increment * (this.start - p.options.start.num) + p.options.start.angle;\n\t\t\t\t\tvar endAngle\t= p.settings.increment * (this.end - p.options.start.num) + p.options.start.angle;\n\t\t\t\t\t\n\t\t\t\t\tvar r\t\t\t= this.radius? this.radius : p.settings.speedo_r;\n\t\t\t\t\tvar rad\t\t\t= Math.PI / 180;\n\t\t\t\t\t\n\t\t\t\t\tvar x1 = p.settings.canvas_r + r * Math.cos (startAngle * rad),\n\t\t\t\t\t\tx2 = p.settings.canvas_r + r * Math.cos (endAngle * rad),\n\t\t\t\t\t\ty1 = p.settings.canvas_r + r * Math.sin (startAngle * rad),\n\t\t\t\t\t\ty2 = p.settings.canvas_r + r * Math.sin (endAngle * rad);\n\n\t\t\t\t\tvar sect = p.gauge.path ([\n\t\t\t\t\t\t\"M\", p.settings.canvas_r, p.settings.canvas_r,\n\t\t\t\t\t\t\"L\", x2, y2,\n\t\t\t\t\t\t\"A\", r, r, 0, + (endAngle - startAngle > 180),\n\t\t\t\t\t\t0, x1, y1, \"z\"]).attr (this.style);\n\n\t\t\t\t\tp.sectors.push (sect);\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t});\n\t\t\t\n\t\t\t// Generate markers\n\t\t\t\n\t\t\tvar markers\t\t= [];\n\n\t\t\t$.each (this.options.markers, function () {\n\t\t\t\t\n\t\t\t\tif (this.line)\n\t\t\t\t{\n\t\t\t\t\t\n\t\t\t\t\tif (!this.line.width)\n\t\t\t\t\t{\n\t\t\t\t\t\tthis.line.width = 10;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (!this.line.height)\n\t\t\t\t\t{\n\t\t\t\t\t\tthis.line.height = 1;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tvar line\t= p.gauge.rect (p.settings.canvas_r + p.settings.speedo_r - this.line.width, p.settings.canvas_r - Math.floor (this.line.height / 2)).attr (this.line).hide ();\n\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Work around JS precision problems with marker gaps < 1\n\t\t\t\t\n\t\t\t\tvar divide\t= 1;\n\t\t\t\t\n\t\t\t\twhile (this.gap < 1)\n\t\t\t\t{\n\t\t\t\t\tdivide *= 10;\n\t\t\t\t\tthis.gap *= 10;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvar start\t= p.options.start.num * divide;\n\t\t\t\tvar end\t\t= p.options.end.num * divide;\n\t\t\t\t\n\t\t\t\t// Add marker points\n\t\t\t\t\n\t\t\t\tfor (var count = start; count <= end; count += this.gap)\n\t\t\t\t{\n\t\t\t\t\t\n\t\t\t\t\tvar val\t= divide > 1? count / divide : count;\n\t\t\t\t\t\n\t\t\t\t\tif (this.toFixed)\n\t\t\t\t\t{\n\t\t\t\t\t\tval = val.toFixed (this.toFixed);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (this.toPrecision)\n\t\t\t\t\t{\n\t\t\t\t\t\tval = val.toPrecision (this.toPrecision);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t// Work out angle of rotation for value\n\t\t\t\t\t\n\t\t\t\t\tvar a\t= p.settings.increment * (val - start) + p.options.start.angle;\n\t\t\t\t\t\n\t\t\t\t\t// Work out relative to complete 360 rotation\n\t\t\t\t\t\n\t\t\t\t\tif (a + Math.abs (p.options.start.angle) >= 360)\n\t\t\t\t\t{\n\t\t\t\t\t\ta = (a + Math.abs (p.options.start.angle)) % 360 + p.options.start.angle;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t// Dont place multiple markers in the same location\n\t\t\t\t\t\n\t\t\t\t\tif ($.inArray (a, markers) >= 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tmarkers.push (a);\n\t\t\t\t\t\n\t\t\t\t\t// Marker line\n\t\t\t\t\t\n\t\t\t\t\tif (this.line)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar speed_marker = line.clone ().rotate (a, p.settings.canvas_r, p.settings.canvas_r);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t// Marker text\n\t\t\t\t\t\n\t\t\t\t\tif (this.text)\n\t\t\t\t\t{\n\n\t\t\t\t\t\tif (!this.text.space)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthis.text.space = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tvar txt\t= val;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (typeof this.value == \"object\")\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (this.value.divide)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttxt /= this.value.divide;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (this.value.multiply)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttxt *= this.value.multiply;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tvar rad\t\t= a.toRadians ();\n\t\t\t\t\t\tvar x\t\t= p.settings.canvas_r + (this.text.space + p.settings.speedo_r) * Math.cos (rad);\n\t\t\t\t\t\tvar y\t\t= p.settings.canvas_r + (this.text.space + p.settings.speedo_r) * Math.sin (rad);\n\t\t\t\t\t\tvar text\t= p.gauge.text (x, y, txt).attr (this.text);\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif (this.line)\n\t\t\t\t{\n\t\t\t\t\tline.remove ();\n\t\t\t\t}\n\n\t\t\t});\n\t\t\t\n\t\t\t// Create digital display\n\t\t\t\n\t\t\tif (this.options.digital)\n\t\t\t{\n\t\t\t\tthis.digital\t= $('<div>').addClass ('digital').css ({\n\t\t\t\t\t\"margin-top\"\t\t: Math.ceil (this.settings.speedo_r / 2),\n\t\t\t\t\t\"width\"\t\t\t\t: \"20%\",\n\t\t\t\t\t\"font-family\"\t\t: \"Arial\",\n\t\t\t\t\t\"font-size\"\t\t\t: 20,\n\t\t\t\t\t\"color\"\t\t\t\t: '#fff',\n\t\t\t\t\t\"text-align\"\t\t: \"center\",\n\t\t\t\t\t\"border\"\t\t\t: \"2px solid #777\",\n\t\t\t\t\t\"border-radius\"\t\t: 10,\n\t\t\t\t\t\"padding\"\t\t\t: 5,\n\t\t\t\t\t\"background-color\"\t: \"#111\"\n\t\t\t\t}).css (this.options.digital).text (this.options.default_num).appendTo (this).center ();\n\t\t\t}\n\t\t\t\n\t\t\t// Create needle indicators\n\t\t\t\n\t\t\tthis.needles\t= [];\n\t\t\t\n\t\t\t$.each (this.options.needles, function (i) {\n\t\t\t\t\n\t\t\t\tif (!this.default_num)\n\t\t\t\t{\n\t\t\t\t\tthis.default_num = p.options.default_num;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tthis.style = $.extend (true, p.options.style.needle, this.style);\n\t\t\t\t\n\t\t\t\tvar val\t= this.default_num - p.options.start.num;\n\t\t\t\t\n\t\t\t\tif (typeof this.value == \"object\")\n\t\t\t\t{\n\t\t\t\t\t\n\t\t\t\t\tif (this.value.divide)\n\t\t\t\t\t{\n\t\t\t\t\t\tval /= this.value.divide;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.value.multiply)\n\t\t\t\t\t{\n\t\t\t\t\t\tval *= this.value.multiply;\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvar rotate\t= p.settings.increment * val + p.options.start.angle;\n\t\t\t\t\n\t\t\t\tvar needle\t= p.gauge.rect (p.settings.canvas_r, p.settings.canvas_r, p.settings.speedo_r).attr (this.style)\n\t\t\t\t\t.transform (\"r\" + rotate + \",\" + p.settings.canvas_r + \",\" + p.settings.canvas_r);\n\t\t\t\t\n\t\t\t\tp.needles.push (needle);\n\t\t\t\t\n\t\t\t});\n\t\t\t\n\t\t\t// Set marker center point\n\t\t\t\n\t\t\tif (typeof this.options.style.center == \"object\")\n\t\t\t{\n\t\t\t\tvar center\t\t= this.gauge.circle (this.settings.canvas_r, this.settings.canvas_r, this.options.style.center.diameter).attr (this.options.style.center);\n\t\t\t}\n\t\t\t\n\t\t\tthis.trigger ('drawn');\n\t\t\t\n\t\t\treturn this;\n\t\t\t\n\t\t},\n\n\t\t/**\n\t\t * Set gauge value\n\t\t */\n\n\t\tval : function (val)\n\t\t{\n\t\t\t\n\t\t\tif (this.digital)\n\t\t\t{\n\t\t\t\tvar txt\t= val;\n\t\t\t\t\n\t\t\t\tif (this.options.digital_toFixed)\n\t\t\t\t{\n\t\t\t\t\ttxt = txt.toFixed (this.options.digital_toFixed);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (this.options.digital_toPrecision)\n\t\t\t\t{\n\t\t\t\t\ttxt = txt.toPrecision (this.options.digital_toPrecision);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tthis.digital.text (txt);\n\t\t\t}\n\t\t\t\n\t\t\tvar p = this;\n\t\t\t\n\t\t\t$.each (this.needles, function (i) {\n\t\t\t\t\n\t\t\t\tvar new_val = val;\n\t\t\t\t\n\t\t\t\tif (typeof p.options.needles[i].value == \"object\")\n\t\t\t\t{\n\t\t\t\t\t\n\t\t\t\t\tvar val_modify\t= p.options.needles[i].value;\n\t\t\t\t\t\n\t\t\t\t\tif (val_modify.divide)\n\t\t\t\t\t{\n\t\t\t\t\t\tnew_val /= val_modify.divide;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (val_modify.multiply)\n\t\t\t\t\t{\n\t\t\t\t\t\tnew_val *= val_modify.multiply;\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tthis.animate ({transform: \"r\" + (p.settings.increment * (new_val - p.options.start.num) + p.options.start.angle) + \",\" + p.settings.canvas_r + \",\" + p.settings.canvas_r}, p.options.animation_speed);\n\t\t\t\n\t\t\t});\n\t\t\t\n\t\t\tthis.trigger ('update', val);\n\t\t\t\n\t\t\treturn this;\n\t\t\t\n\t\t}\n\t\t\n\t};\n\t\n\t/**\n\t * Constructor\n\t */\n\t\n\t$.fn.SonicGauge = function (method) {\n\t\t\n\t\t// Call method and set options\n\n\t\tif (methods[method]){\n\t\t\treturn methods[method].apply (this, Array.prototype.slice.call (arguments, 1));\n\t\t} else if (typeof method === 'object' || !method) {\n\t\t\treturn methods.init.apply (this, arguments);\n\t\t} else {\n\t\t\t$.error ('Method ' +  method + ' does not exist on jQuery.SonicGauge');\n\t\t}\n\t\t\n\t};\n\t\n\t/**\n\t * Default options\n\t */\n\t\n\t$.fn.SonicGauge.defaultOptions = {\n\t\tmargin\t\t\t: 35,\n\t\tdiameter\t\t: 350,\n\t\tstart\t\t\t: {angle: -225, num: 0},\n\t\tend\t\t\t\t: {angle: 45, num: 100},\n\t\tdefault_num\t\t: 0,\n\t\tanimation_speed\t: 1000,\n\t\tdigital\t\t\t: {},\n\t\tdigital_toFixed\t: 0,\n\t\tneedles\t\t\t: [{}],\n\t\tsectors\t\t\t: [{}],\n\t\tmarkers\t\t\t: [\n\t\t\t{\n\t\t\t\tgap: 10,\n\t\t\t\tline: {\"width\": 20, \"stroke\": \"none\", \"fill\": \"#eeeeee\"},\n\t\t\t\ttext: {\"space\": 22, \"text-anchor\": \"middle\", \"fill\": \"#333333\", \"font-size\": 18}\n\t\t\t},{\n\t\t\t\tgap: 5, \n\t\t\t\tline: {\"width\": 8, \"stroke\": \"none\", \"fill\": \"#999999\"}\n\t\t\t}\n\t\t],\n\t\tstyle\t\t\t: {\n\t\t\t\"outline\"\t: {\"fill\": \"#333333\", \"stroke\": \"#555555\", \"stroke-width\": 8},\n\t\t\t\"center\"\t: {\"fill\": \"#eeeeee\", \"diameter\": 10},\n\t\t\t\"needle\"\t: {\"height\": 1, \"stroke\": \"none\", \"fill\": \"#cc0000\"},\n\t\t\t\"label\"\t\t: {\"text-anchor\": \"middle\", \"fill\": \"#fff\", \"font-size\": 16}\n\t\t}\n\t};\n\t\n})(jQuery);\n\n/**\n * Convert decimal to radians\n */\n\nif (typeof (Number.prototype.toRadians) === \"undefined\") {\n\tNumber.prototype.toRadians = function () {\n\t\treturn this * Math.PI / 180;\n\t}\n}\n\n/**\n * Number of decimal places\n */\n\nif (typeof (Number.prototype.decimalPlaces) === \"undefined\") {\n\tNumber.prototype.decimalPlaces = function () {\n\t\treturn (this.toFixed (20)).replace (/^-?\\d*\\.?|0+$/g, '').length;\n\t}\n}\n\n/**\n * Center element position\n */\n\nif (typeof (jQuery.fn.center) === \"undefined\") {\n\tjQuery.fn.center = function (p) {\n\t\t\n\t\tif (typeof p === \"undefined\")\n\t\t{\n\t\t\tp = this.parent ();\n\t\t}\n\t\t\n\t\tp.css (\"position\", \"relative\");\n\t\t\n\t\treturn this.css (\"position\", \"absolute\").css ({\n\t\t\ttop\t\t: Math.max (0, ((p.height () - this.outerHeight ()) / 2) + p.scrollTop ()),\n\t\t\tleft\t: Math.max (0, ((p.width () - this.outerWidth ()) / 2) + p.scrollLeft ())\n\t\t});\n\t\t\n\t}\n}","x":367.70001220703125,"y":401.3999938964844,"wires":[["cd90dda3.b2b5f"]]},{"id":"cd90dda3.b2b5f","type":"template","z":"56b42b3e.51b8d4","name":"html","field":"payload","fieldType":"msg","format":"javascript","syntax":"mustache","template":"<script src=\"http://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.0/jquery.min.js\"></script>\n<script src=\"http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js\"></script>\n<script>{{{script}}}</script>\n<div id='thermometre' class=\"gauge\"></div>\n<script>\n    var thermometre= $('#thermometre').SonicGauge();\n    \n\t$.getJSON(\n    \"/data\",\n    function(data){\n        var options ={};\n        options.label= data.unite;\n        options.start = {angle: -225, num: data.min};\n\t\toptions.end\t\t= {angle: 45, num: data.max};\n        thermometre.SonicGauge('setOptions', options);\n        thermometre.SonicGauge ('draw');\n    });\n\t\t        \n\t\t        \nsetInterval(function () {\n$.getJSON(\n    \"/data\",\n    function(data){\n        thermometre.SonicGauge('val',data.valeur);\n    });\n},200);\n\n\n</script>","x":572.7000122070312,"y":401.3999938964844,"wires":[["1d547897.2b2ba7"]]},{"id":"55689dae.34a29c","type":"http in","z":"56b42b3e.51b8d4","name":"","url":"/mesure","method":"get","swaggerDoc":"","x":176.70001220703125,"y":402.3999938964844,"wires":[["e2ddbd0e.ccf4e8"]]},{"id":"1d547897.2b2ba7","type":"http response","z":"56b42b3e.51b8d4","name":"","x":786.7000122070312,"y":401.3999938964844,"wires":[]},{"id":"c0eed921.936008","type":"http in","z":"56b42b3e.51b8d4","name":"","url":"/data","method":"get","swaggerDoc":"","x":167.70001220703125,"y":327.3999938964844,"wires":[["6e23cf4d.41762"]]},{"id":"d8f2bd76.52e0f8","type":"http response","z":"56b42b3e.51b8d4","name":"","x":579.7000122070312,"y":326.3999938964844,"wires":[]},{"id":"68a86d4c.b1218c","type":"debug","z":"56b42b3e.51b8d4","name":"","active":false,"console":"false","complete":"false","x":670.7000122070312,"y":142.39999389648438,"wires":[]},{"id":"ec1c5eaa.182f58","type":"modbus-client","z":"","name":"arduino","clienttype":"simpleser","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","serialPort":"/dev/ttyACM0","serialType":"RTU-BUFFERD","serialBaudrate":"19200","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":1,"commandDelay":1,"clientTimeout":1000,"reconnectTimeout":2000}]

Flow Info

Created 8 years, 3 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • debug (x3)
  • function (x2)
  • http in (x2)
  • http response (x2)
  • template (x2)
Other
  • modbus-client (x1)
  • modbus-read (x1)
  • tab (x1)

Tags

  • modBus
  • Arduino
  • sonicGauge
  • html
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option