[ { "id": "ac317896.5b37c8", "type": "exec", "z": "abb501ba.74f3a", "command": "", "addpay": true, "append": "", "useSpawn": "false", "timer": "", "oldrc": false, "name": "", "x": 290, "y": 100, "wires": [ [ "19415122.78943f", "c5df9bb4.1eb138" ], [ "e3ec582e.319148" ], [ "536e7aa9.85c384", "c485ba49.5407a8" ] ] }, { "id": "e610fb59.50cca8", "type": "inject", "z": "abb501ba.74f3a", "name": "Atura stats.py", "topic": "", "payload": "ps aux | grep stats.py | grep -v grep", "payloadType": "str", "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "x": 110, "y": 100, "wires": [ [ "ac317896.5b37c8" ] ] }, { "id": "19415122.78943f", "type": "debug", "z": "abb501ba.74f3a", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 470, "y": 40, "wires": [] }, { "id": "e3ec582e.319148", "type": "debug", "z": "abb501ba.74f3a", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 470, "y": 100, "wires": [] }, { "id": "536e7aa9.85c384", "type": "debug", "z": "abb501ba.74f3a", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 470, "y": 160, "wires": [] }, { "id": "51366cc1.7b8a54", "type": "debug", "z": "abb501ba.74f3a", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 550, "y": 460, "wires": [] }, { "id": "c5df9bb4.1eb138", "type": "function", "z": "abb501ba.74f3a", "name": "PID's stats.py seeker", "func": "var str = msg.payload;\nvar szCadena = \"\";\nvar i = 0;\nvar bNumeroDetectat = false;\nglobal.set(\"customCommand\",\"\");\n\nif(str.length > 0){\n while(i < msg.payload.length){\n if(bNumeroDetectat && !(str[i] >= '0' && str[i] <= '9'))\n \tbreak;\n if(str[i] >= '0' && str[i] <= '9'){\n \tbNumeroDetectat = true;\n \tszCadena += str[i];\n }\n i++;\n }\n msg.payload = \"sudo kill \" + szCadena;\n global.set(\"customCommand\",msg.payload);\n} \nreturn msg;", "outputs": 1, "noerr": 0, "x": 700, "y": 60, "wires": [ [] ] }, { "id": "f3468574.40c248", "type": "delay", "z": "abb501ba.74f3a", "name": "", "pauseType": "delay", "timeout": "0.5", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "x": 370, "y": 220, "wires": [ [ "e01cc68.01d7638" ] ] }, { "id": "c485ba49.5407a8", "type": "switch", "z": "abb501ba.74f3a", "name": "msg.payload.code", "property": "payload.code", "propertyType": "msg", "rules": [ { "t": "eq", "v": " 0", "vt": "str" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 150, "y": 280, "wires": [ [ "f3468574.40c248" ], [ "70e93567.8d85ec" ] ] }, { "id": "70e93567.8d85ec", "type": "function", "z": "abb501ba.74f3a", "name": "", "func": "msg.payload = \"El procés no està actiu\"\nreturn msg;", "outputs": 1, "noerr": 0, "x": 350, "y": 320, "wires": [ [ "51366cc1.7b8a54" ] ] }, { "id": "e01cc68.01d7638", "type": "function", "z": "abb501ba.74f3a", "name": "kill stats.py", "func": "msg.payload = global.get(\"customCommand\");\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 550, "y": 220, "wires": [ [ "51366cc1.7b8a54", "40167fc9.2aaca8" ] ] }, { "id": "40167fc9.2aaca8", "type": "exec", "z": "abb501ba.74f3a", "command": "", "addpay": true, "append": "", "useSpawn": "false", "timer": "", "oldrc": false, "name": "", "x": 750, "y": 220, "wires": [ [], [], [ "cdd2c220.b88ce8" ] ] }, { "id": "cdd2c220.b88ce8", "type": "switch", "z": "abb501ba.74f3a", "name": "msg.payload.code", "property": "payload.code", "propertyType": "msg", "rules": [ { "t": "eq", "v": "0", "vt": "str" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 570, "y": 340, "wires": [ [ "d2c3eb28.3bffb8" ], [ "c9e2832a.3adb38" ] ] }, { "id": "d2c3eb28.3bffb8", "type": "function", "z": "abb501ba.74f3a", "name": "", "func": "msg.payload = \"S'ha aturat stats.py amb èxit\";\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 750, "y": 300, "wires": [ [ "51366cc1.7b8a54" ] ] }, { "id": "c9e2832a.3adb38", "type": "function", "z": "abb501ba.74f3a", "name": "", "func": "msg.payload = \"No s'ha pogut aturar stats.py\\nEstava en marxa?\";\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 750, "y": 380, "wires": [ [ "51366cc1.7b8a54" ] ] }, { "id": "314105f8.cc1fd2", "type": "inject", "z": "abb501ba.74f3a", "name": "Engega stats.py", "topic": "", "payload": "python3 /home/pi/code/Adafruit_Python_SSD1306/examples/stats.py &", "payloadType": "str", "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "x": 120, "y": 440, "wires": [ [ "1a0616b2.b39e29" ] ] }, { "id": "1a0616b2.b39e29", "type": "exec", "z": "abb501ba.74f3a", "command": "", "addpay": true, "append": "", "useSpawn": "false", "timer": "", "oldrc": false, "name": "", "x": 290, "y": 440, "wires": [ [ "51366cc1.7b8a54" ], [ "51366cc1.7b8a54" ], [ "51366cc1.7b8a54" ] ] } ]