[{"id":"8c8c02f4.24678","type":"tab","label":"Sous-marin","disabled":false,"info":""},{"id":"eab98ec3.ea2098","type":"ui_template","z":"8c8c02f4.24678","group":"79349489.b4ad8c","name":"Vidéo","order":6,"width":11,"height":11,"format":"","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":530,"y":120,"wires":[[]]},{"id":"3752b40a.fe6bfc","type":"ui_text_input","z":"8c8c02f4.24678","name":"","label":"Entrez l'IP de la Raspberry","tooltip":"","group":"79349489.b4ad8c","order":1,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":160,"y":120,"wires":[["eab98ec3.ea2098"]]},{"id":"6b80bd53.52fe7c","type":"mqtt out","z":"8c8c02f4.24678","name":"","topic":"command","qos":"","retain":"","broker":"689464b0.a805ac","x":1260,"y":360,"wires":[]},{"id":"b1e48555.b4215","type":"ui_slider","z":"8c8c02f4.24678","name":"","label":"Rotation [-90→90]","tooltip":"","group":"b9b5484a.f2403","order":4,"width":0,"height":0,"passthru":true,"outs":"end","topic":"rotation","min":"-90","max":"90","step":"10","x":190,"y":360,"wires":[["e762e6b6.7a073","57118207.53a0e4"]]},{"id":"e762e6b6.7a073","type":"ui_gauge","z":"8c8c02f4.24678","name":"Rotation","group":"e6234fd3.0d98f8","order":1,"width":6,"height":4,"gtype":"gage","title":"Rotation","label":"[°]","format":"{{value}}","min":"-90","max":"90","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":540,"y":360,"wires":[]},{"id":"951c83d.1b1c5","type":"ui_slider","z":"8c8c02f4.24678","name":"","label":"Speed [0→100]","tooltip":"","group":"b9b5484a.f2403","order":5,"width":0,"height":0,"passthru":true,"outs":"all","topic":"speed","min":0,"max":"100","step":"10","x":200,"y":320,"wires":[["c73900a5.30fc","57118207.53a0e4"]]},{"id":"c73900a5.30fc","type":"ui_text","z":"8c8c02f4.24678","group":"e6234fd3.0d98f8","order":2,"width":3,"height":1,"name":"","label":"Speed [%]","format":"{{msg.payload}}","layout":"row-spread","x":550,"y":320,"wires":[]},{"id":"ce0b54fb.2a36f","type":"function","z":"8c8c02f4.24678","name":"Depth","func":"var depth = msg.payload\n\nvar previous = flow.get(\"previous_depth\")||0;\n\nvar unit_time = 0.78431372549019607843137254901961\nvar time = unit_time*depth\nnode.warn(\"previous\")\nnode.warn(previous)\n\nvar oldtime = unit_time*previous\ntime = String(time);\noldtime = String(oldtime);\n\nvar part1 = ''\nvar part2 = ''\nvar part3 = ''\n\nfunction round (time)\n{\n if (time.includes('.'))\n {\n if (time.charAt(1) == '.' && time.charAt(0) == '0')\n {\n part1 = time.charAt(0)\n part2 = '0'\n part3 = time.charAt(2)\n //part2 = time.slice(2-time.length,4-time.length)\n if (Number(time.slice(3-time.length,5-time.length)) > 50)\n {\n part3 = Number(part3)\n part3 = part3+1\n part3 = String(part3)\n }\n time = part1+part2+part3;\n }\n else if (time.charAt(1) == '.' && time.charAt(0) !== '0')\n {\n part1 = '0'\n part2 = time.charAt(0)\n part3 = time.charAt(2)\n //part2 = time.slice(2-time.length,4-time.length)\n if (Number(time.slice(3-time.length,5-time.length)) > 50)\n {\n part3 = Number(part3)\n part3 = part3+1\n part3 = String(part3)\n }\n time = part1+part2+part3;\n }\n else if (time.charAt(2) == '.')\n {\n part1 = time.charAt(0)\n part2 = time.charAt(1)\n part3 = time.charAt(3)\n //part1 = time.slice(0,1)\n //part2 = time.slice(3-time.length,4-time.length)\n if (Number(time.slice(3-time.length,5-time.length)) > 50)\n {\n part3 = Number(part3)\n part3 = part3+1\n part3 = String(part3)\n }\n time = part1+part2+part3;\n }\n else\n {\n time = time + '0'\n }\n }\n while (time.length < 3)\n {\n time = time + '0'\n }\n return time\n}\n\n//time = round(time);\n//oldtime = round(oldtime);\n\n//time = '0' + time\n\nvar speed = '255'\n\nvar stop = '0'\nvar empty = '1'\nvar fill = '2'\n\nvar str1 = 'B'\nvar speed_D = speed\nvar time_D = time\nvar speed_G = speed\nvar time_G = time\nvar rotation_D = ''\nvar rotation_G = ''\n\nif (previous > depth)\n{\n node.warn(\"previous>depth\")\n //time_D = parseInt(previous*unit_time) - parseInt(depth*unit_time)\n //time_G = time_D\n node.warn(oldtime)\n node.warn(time)\n \n time_D = round(String(oldtime-time))\n //time_D = Number(oldtime) - Number(time)\n node.warn(time_D)\n \n if (time == '0')\n {\n time_D = '500'\n }\n \n time_G = time_D\n \n rotation_D = empty\n rotation_G = empty\n}\nelse\n{\n node.warn(\"previous 0 && rotation < 0)\n{\n speed_D = speed-(rotation/2)\n \n speed_G = speed+(rotation/2)\n if (speed_G < 0)\n {\n speed_G = 0\n }\n \n if (rotation == -90)\n {\n speed_G = 0\n speed_D = speed\n }\n}\nelse if (speed > 0 && rotation > 0)\n{\n speed_G = speed+(rotation/2)\n \n speed_D = speed-(rotation/2)\n if (speed_D < 0)\n {\n speed_D = 0\n }\n \n if (rotation == 90)\n {\n speed_D = 0\n speed_G = speed\n }\n}\n\nspeed_G = String(speed_G)\nwhile (speed_G.length < 3)\n{\n speed_G = '0' + speed_G\n}\n\nspeed_D = String(speed_D)\nwhile (speed_D.length < 3)\n{\n speed_D = '0' + speed_D\n}\n\nmsg.payload = str1+speed_D+time+speed_G+time\nif (msg.payload.length > 15)\n{\n speed_D = '000'\n speed_G = '000'\n}\nmsg.payload = str1+speed_D+time_D+speed_G+time_G+str2\n\nif (msg.payload.length == 15)\n{\n return msg;\n}","outputs":1,"noerr":0,"x":750,"y":340,"wires":[["6b80bd53.52fe7c"]]},{"id":"812c2c5b.db5748","type":"mqtt in","z":"8c8c02f4.24678","name":"depth","topic":"depth","qos":"2","datatype":"auto","broker":"689464b0.a805ac","x":230,"y":560,"wires":[["3772497.7a4b6b6"]]},{"id":"3772497.7a4b6b6","type":"ui_text","z":"8c8c02f4.24678","group":"553b1c7d.0cc66c","order":3,"width":3,"height":1,"name":"","label":"Depth [cm]","format":"{{msg.payload}}","layout":"row-spread","x":550,"y":560,"wires":[]},{"id":"52fe868b.07a4b8","type":"mqtt out","z":"8c8c02f4.24678","name":"","topic":"servo","qos":"","retain":"","broker":"689464b0.a805ac","x":1250,"y":120,"wires":[]},{"id":"652694ce.dd2abc","type":"function","z":"8c8c02f4.24678","name":"camY","func":"var camY = msg.payload\n\nmsg.payload = \"17:\"+camY\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":180,"wires":[["52fe868b.07a4b8"]]},{"id":"d638d077.16a22","type":"function","z":"8c8c02f4.24678","name":"camX","func":"var camX = msg.payload\n\nmsg.payload = \"27:\"+camX\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":60,"wires":[["52fe868b.07a4b8"]]},{"id":"db1c72ca.ae179","type":"ui_button","z":"8c8c02f4.24678","name":"","group":"79349489.b4ad8c","order":13,"width":1,"height":5,"passthru":false,"label":"→","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"decrement","x":750,"y":200,"wires":[[]]},{"id":"c21827de.71e568","type":"ui_button","z":"8c8c02f4.24678","name":"","group":"79349489.b4ad8c","order":12,"width":1,"height":5,"passthru":false,"label":"←","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"increment","x":750,"y":160,"wires":[[]]},{"id":"2046968.1ebbd6a","type":"ui_button","z":"8c8c02f4.24678","name":"","group":"79349489.b4ad8c","order":3,"width":5,"height":1,"passthru":false,"label":"↑","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"increment","x":750,"y":40,"wires":[["fe6b134b.142da8"]]},{"id":"524910e8.b54da","type":"ui_button","z":"8c8c02f4.24678","name":"","group":"79349489.b4ad8c","order":21,"width":5,"height":1,"passthru":false,"label":"↓","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"decrement","x":750,"y":80,"wires":[["fe6b134b.142da8"]]},{"id":"fe6b134b.142da8","type":"function","z":"8c8c02f4.24678","name":"counter","func":"\nvar count = flow.get(\"count\")||8;\n\nif (msg.topic === \"init\") {\n count = msg.payload;\n \n} else if ((msg.topic === \"increment\") && (count< 12.5)) {\n count = count + 0.5;\n} else if ((msg.topic === \"decrement\") && (count > 5)) {\n count = count - 0.5;\n}\n\nflow.set('count',count);\n\nmsg.payload = count;\nreturn msg;","outputs":1,"noerr":0,"x":940,"y":60,"wires":[["d638d077.16a22"]]},{"id":"dcf48cce.38c568","type":"function","z":"8c8c02f4.24678","name":"counter","func":"\nvar count = flow.get(\"countY\")||8;\n\nif (msg.topic === \"init\") {\n count = msg.payload;\n \n} else if ((msg.topic === \"increment\") && (count< 12.5)) {\n count = count + 0.5;\n} else if ((msg.topic === \"decrement\") && (count > 5)) {\n count = count - 0.5;\n}\n\nflow.set('countY',count);\n\nmsg.payload = count;\nreturn msg;","outputs":1,"noerr":0,"x":940,"y":180,"wires":[["652694ce.dd2abc"]]},{"id":"83ba1f62.d7058","type":"ui_gauge","z":"8c8c02f4.24678","name":"","group":"553b1c7d.0cc66c","order":5,"width":6,"height":4,"gtype":"gage","title":"Deviation","label":"[°]","format":"{{value}}","min":"-90","max":"90","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":540,"y":660,"wires":[]},{"id":"4a532cfc.bca844","type":"function","z":"8c8c02f4.24678","name":"Interpretation","func":"msg.payload = Math.round(msg.payload*100)\nmsg.payload -= (2*msg.payload)\nreturn msg;","outputs":1,"noerr":0,"x":380,"y":660,"wires":[["83ba1f62.d7058","6c7ec4f7.2cbee4","56de56ad.4f9a5"]]},{"id":"170f6710.88ecd9","type":"mqtt in","z":"8c8c02f4.24678","name":"acceleration","topic":"acceleration","qos":"2","datatype":"auto","broker":"689464b0.a805ac","x":210,"y":660,"wires":[["4a532cfc.bca844"]]},{"id":"4ecd4414.56a5a4","type":"mqtt in","z":"8c8c02f4.24678","name":"Sonar","topic":"chatter","qos":"2","datatype":"auto","broker":"689464b0.a805ac","x":230,"y":500,"wires":[["bfded6e4.bb672"]]},{"id":"bfded6e4.bb672","type":"ui_text","z":"8c8c02f4.24678","group":"553b1c7d.0cc66c","order":4,"width":3,"height":1,"name":"","label":"Sonar [m]","format":"{{msg.payload}}","layout":"row-spread","x":540,"y":500,"wires":[]},{"id":"6c7ec4f7.2cbee4","type":"function","z":"8c8c02f4.24678","name":"PID","func":"var speed = '255'\n\nvar stop = '0'\nvar empty = '1'\nvar fill = '2'\n\nvar str1 = 'B'\nvar speed_D = speed\nvar time_D = '003'\nvar speed_G = speed\nvar time_G = '003'\nvar rotation_D = ''\nvar rotation_G = ''\n\nif (Math.abs(msg.payload) > 25)\n{\n if (msg.payload < -25)\n {\n rotation_D = fill\n rotation_G = empty\n }\n else if (msg.payload > 25)\n {\n rotation_D = empty\n rotation_G = fill\n }\n msg.payload = str1+speed_D+time_D+speed_G+time_G+rotation_D+rotation_G\n\n return msg;\n}","outputs":1,"noerr":0,"x":750,"y":560,"wires":[["6b80bd53.52fe7c"]]},{"id":"2085d241.3e2d2e","type":"mqtt in","z":"8c8c02f4.24678","name":"battery","topic":"battery","qos":"2","datatype":"auto","broker":"689464b0.a805ac","x":230,"y":440,"wires":[["3866b896.e172c","460998b4.03fee"]]},{"id":"3866b896.e172c","type":"ui_text","z":"8c8c02f4.24678","group":"553b1c7d.0cc66c","order":1,"width":3,"height":1,"name":"Battery [%]","label":"Battery [%]","format":"{{msg.payload}}","layout":"row-spread","x":550,"y":420,"wires":[]},{"id":"d4d243c6.3f5088","type":"ui_button","z":"8c8c02f4.24678","name":"↑","group":"b9b5484a.f2403","order":1,"width":0,"height":0,"passthru":false,"label":"↑ Surface ↑","tooltip":"","color":"","bgcolor":"","icon":"","payload":"B25550025550011","payloadType":"str","topic":"","x":230,"y":180,"wires":[["6b80bd53.52fe7c"]]},{"id":"acee070a.ed7c1","type":"ui_button","z":"8c8c02f4.24678","name":"↓","group":"b9b5484a.f2403","order":3,"width":0,"height":0,"passthru":false,"label":"↓ Dive ↓","tooltip":"","color":"","bgcolor":"","icon":"","payload":"B25550025550022","payloadType":"str","topic":"","x":230,"y":260,"wires":[["6b80bd53.52fe7c"]]},{"id":"fc51f4ef.e3a45","type":"ui_button","z":"8c8c02f4.24678","name":"","group":"b9b5484a.f2403","order":2,"width":0,"height":0,"passthru":false,"label":"X STOP X","tooltip":"","color":"","bgcolor":"","icon":"","payload":"B00000000000011","payloadType":"str","topic":"","x":220,"y":220,"wires":[["6b80bd53.52fe7c"]]},{"id":"4533ff48.af2b","type":"ui_text","z":"8c8c02f4.24678","group":"553b1c7d.0cc66c","order":6,"width":0,"height":0,"name":"Alert","label":"","format":"{{msg.payload}}","layout":"col-center","x":1250,"y":600,"wires":[]},{"id":"56de56ad.4f9a5","type":"function","z":"8c8c02f4.24678","name":"Alert","func":"if (Math.abs(msg.payload) > 25)\n{\n msg.payload = \"Self-Regulation !\"\n}\nelse\n{\n msg.payload = \"\"\n}\nreturn msg;","outputs":1,"noerr":0,"x":750,"y":600,"wires":[["4533ff48.af2b"]]},{"id":"460998b4.03fee","type":"function","z":"8c8c02f4.24678","name":"Retreat","func":"if (msg.payload < 20)\n{\n msg.payload = \"B25550025550011\";\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":460,"wires":[["6b80bd53.52fe7c","58cc9b6a.6cbc44"]]},{"id":"c04957b3.3f6be","type":"ui_text","z":"8c8c02f4.24678","group":"553b1c7d.0cc66c","order":2,"width":3,"height":1,"name":"Alert","label":"","format":"{{msg.payload}}","layout":"col-center","x":1250,"y":460,"wires":[]},{"id":"58cc9b6a.6cbc44","type":"function","z":"8c8c02f4.24678","name":"Alert","func":"if (msg.payload == \"B25550025550011\")\n{\n msg.payload = \"Retreat !\"\n}\nelse\n{\n msg.payload = \"\"\n}\nreturn msg;","outputs":1,"noerr":0,"x":1010,"y":460,"wires":[["c04957b3.3f6be"]]},{"id":"ae8beccb.298c88","type":"mqtt in","z":"8c8c02f4.24678","name":"","topic":"water","qos":"2","datatype":"auto","broker":"9294f5fe.8ec238","x":230,"y":740,"wires":[["61e5aab8.8ddac4"]]},{"id":"664aace3.a46ecc","type":"ui_text","z":"8c8c02f4.24678","group":"553b1c7d.0cc66c","order":6,"width":0,"height":0,"name":"Alert","label":"","format":"{{msg.payload}}","layout":"col-center","x":1250,"y":740,"wires":[]},{"id":"61e5aab8.8ddac4","type":"function","z":"8c8c02f4.24678","name":"Alert","func":"if (msg.payload == 1)\n{\n msg.payload = \"Water inside, Retreat !\";\n}\nelse\n{\n msg.payload = \"\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":750,"y":740,"wires":[["664aace3.a46ecc"]]},{"id":"79349489.b4ad8c","type":"ui_group","z":"","name":"Vidéo","tab":"813366e1.1b52","order":2,"disp":true,"width":13,"collapse":false},{"id":"689464b0.a805ac","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"b9b5484a.f2403","type":"ui_group","z":"","name":"Commandes","tab":"813366e1.1b52","order":3,"disp":true,"width":"6","collapse":false},{"id":"e6234fd3.0d98f8","type":"ui_group","z":"","name":"Dashboard","tab":"813366e1.1b52","order":4,"disp":true,"width":"6","collapse":false},{"id":"553b1c7d.0cc66c","type":"ui_group","z":"","name":"Data","tab":"813366e1.1b52","order":1,"disp":true,"width":"6","collapse":false},{"id":"9294f5fe.8ec238","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"813366e1.1b52","type":"ui_tab","z":"","name":"Sous-marin","icon":"dashboard","disabled":false,"hidden":false}]