From 4d8f2e05c3c816f0d4804708c9483fda0cbb5949 Mon Sep 17 00:00:00 2001 From: medina5 Date: Sat, 10 Jan 2026 07:29:55 +0100 Subject: [PATCH] Exercice 4 --- .devcontainer/nodered/flows.json | 1569 +++++++++++++++++++++++++++++- autom.cpp | 29 + 2 files changed, 1581 insertions(+), 17 deletions(-) diff --git a/.devcontainer/nodered/flows.json b/.devcontainer/nodered/flows.json index 221f637..707477f 100644 --- a/.devcontainer/nodered/flows.json +++ b/.devcontainer/nodered/flows.json @@ -177,7 +177,7 @@ "correl": "", "expiry": "", "broker": "5bf949eb0a1b50a7", - "x": 1810, + "x": 110, "y": 100, "wires": [] }, @@ -339,8 +339,8 @@ "rap": true, "rh": 0, "inputs": 0, - "x": 130, - "y": 1140, + "x": 170, + "y": 1480, "wires": [ [ "9ef1bb67f51b254c" @@ -432,7 +432,7 @@ "finalize": "", "libs": [], "x": 380, - "y": 1140, + "y": 1480, "wires": [ [ "9dad44eccec1d282", @@ -446,7 +446,22 @@ "be011ad2f6f6421d", "99ccef7cde8a92e9", "782e8b8cc5e195e4", - "9f7680a2a2de021a" + "9f7680a2a2de021a", + "2559321f70cd5908", + "12ee9490cfd0c2cb", + "a016dc35c575f406", + "e94f13f0f1acc44c", + "92b7b19f3a84b610", + "cd6ccfdf8cc29b04", + "e694653f29c5c6c3", + "b25a525c97f6ca68", + "f88ed6b89e2793cf", + "41f6c23afe13dda4", + "ca27afe33c09b23a", + "227354827c5b2a9e", + "79e82ef03466071e", + "f55fa882f44af78e", + "02cfaae4ac4028fa" ] ] }, @@ -735,7 +750,7 @@ "type": "function", "z": "41526b8c80d5a5f7", "name": "reset", - "func": "flow.set(\"i0\", 0);\nflow.set(\"i1\", 0);\nflow.set(\"i2\", 0);\nflow.set(\"i3\", 0);\nflow.set(\"i4\", 0);\nflow.set(\"i5\", 0);\nflow.set(\"i6\", 0);\nflow.set(\"i7\", 0);\n\nflow.set(\"m0\", 0);\nflow.set(\"m1\", 0);\nflow.set(\"m2\", 0);\nflow.set(\"m3\", 0);\n\nflow.set(\"p0\", 0);\nflow.set(\"v0\", 0);\n\nreturn msg;", + "func": "flow.set(\"i0\", 0);\nflow.set(\"i1\", 0);\nflow.set(\"i2\", 0);\nflow.set(\"i3\", 0);\nflow.set(\"i4\", 0);\nflow.set(\"i5\", 0);\nflow.set(\"i6\", 0);\nflow.set(\"i7\", 0);\n\nflow.set(\"a0\", 0);\nflow.set(\"a1\", 0);\nflow.set(\"a2\", 0);\nflow.set(\"a3\", 0);\nflow.set(\"a4\", 0);\nflow.set(\"a5\", 0);\nflow.set(\"a6\", 0);\nflow.set(\"a7\", 0);\n\nflow.set(\"m0\", 0);\nflow.set(\"m1\", 0);\nflow.set(\"m2\", 0);\nflow.set(\"m3\", 0);\n\nflow.set(\"p0\", 0);\nflow.set(\"v0\", 0);\n\nflow.set(\"c0\", 1);\nflow.set(\"c1\", 0);\nflow.set(\"c2\", 0);\nflow.set(\"c3\", 0);\nflow.set(\"c4\", 0);\nflow.set(\"c5\", 0);\nflow.set(\"c6\", 0);\nflow.set(\"c7\", 0);\n\nflow.set(\"flag0\", 0);\n\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, @@ -1084,7 +1099,7 @@ "type": "function", "z": "41526b8c80d5a5f7", "name": "format mqtt", - "func": "let i0 = Number(flow.get(\"i0\")) || 0;\nlet i1 = Number(flow.get(\"i1\")) || 0;\nlet i2 = Number(flow.get(\"i2\")) || 0;\nlet i3 = Number(flow.get(\"i3\")) || 0;\nlet i4 = Number(flow.get(\"i4\")) || 0;\nlet i5 = Number(flow.get(\"i5\")) || 0;\nlet i6 = Number(flow.get(\"i6\")) || 0;\nlet i7 = Number(flow.get(\"i7\")) || 0;\n\nlet v0 = Number(flow.get(\"v0\")) || 0;\n\nif (typeof msg.payload[\"arret\"] === 'undefined') msg.payload[\"arret\"] = 1;\nif (typeof msg.payload[\"marche\"] === 'undefined') msg.payload[\"marche\"] = 0;\n\nif (typeof msg.payload[\"b0\"] === 'undefined') msg.payload[\"b0\"] = 0;\nif (typeof msg.payload[\"b1\"] === 'undefined') msg.payload[\"b1\"] = 0;\nif (typeof msg.payload[\"b2\"] === 'undefined') msg.payload[\"b2\"] = 0;\nif (typeof msg.payload[\"b3\"] === 'undefined') msg.payload[\"b3\"] = 0;\nif (typeof msg.payload[\"b4\"] === 'undefined') msg.payload[\"b4\"] = 0;\nif (typeof msg.payload[\"b5\"] === 'undefined') msg.payload[\"b5\"] = 0;\nif (typeof msg.payload[\"b6\"] === 'undefined') msg.payload[\"b6\"] = 0;\nif (typeof msg.payload[\"b7\"] === 'undefined') msg.payload[\"b7\"] = 0;\n\nmsg.payload[\"i0\"] = i0;\nmsg.payload[\"i1\"] = i1;\nmsg.payload[\"i2\"] = i2;\nmsg.payload[\"i3\"] = i3;\nmsg.payload[\"i4\"] = i4;\nmsg.payload[\"i5\"] = i5;\nmsg.payload[\"i6\"] = i6;\nmsg.payload[\"i7\"] = i7;\nmsg.payload[\"v0\"] = v0;\n\nreturn msg;", + "func": "let i0 = Number(flow.get(\"i0\")) || 0;\nlet i1 = Number(flow.get(\"i1\")) || 0;\nlet i2 = Number(flow.get(\"i2\")) || 0;\nlet i3 = Number(flow.get(\"i3\")) || 0;\nlet i4 = Number(flow.get(\"i4\")) || 0;\nlet i5 = Number(flow.get(\"i5\")) || 0;\nlet i6 = Number(flow.get(\"i6\")) || 0;\nlet i7 = Number(flow.get(\"i7\")) || 0;\n\nlet v0 = Number(flow.get(\"v0\")) || 0;\n\nif (typeof msg.payload[\"arret\"] === 'undefined') msg.payload[\"arret\"] = 1;\nif (typeof msg.payload[\"marche\"] === 'undefined') msg.payload[\"marche\"] = 0;\n\nif (typeof msg.payload[\"b0\"] === 'undefined') msg.payload[\"b0\"] = 0;\nif (typeof msg.payload[\"b1\"] === 'undefined') msg.payload[\"b1\"] = 0;\nif (typeof msg.payload[\"b2\"] === 'undefined') msg.payload[\"b2\"] = 0;\nif (typeof msg.payload[\"b3\"] === 'undefined') msg.payload[\"b3\"] = 0;\nif (typeof msg.payload[\"b4\"] === 'undefined') msg.payload[\"b4\"] = 0;\nif (typeof msg.payload[\"b5\"] === 'undefined') msg.payload[\"b5\"] = 0;\nif (typeof msg.payload[\"b6\"] === 'undefined') msg.payload[\"b6\"] = 0;\nif (typeof msg.payload[\"b7\"] === 'undefined') msg.payload[\"b7\"] = 0;\n\nmsg.payload[\"i0\"] = i0;\nmsg.payload[\"i1\"] = i1;\nmsg.payload[\"i2\"] = i2;\nmsg.payload[\"i3\"] = i3;\nmsg.payload[\"i4\"] = i4;\nmsg.payload[\"i5\"] = i5;\nmsg.payload[\"i6\"] = i6;\nmsg.payload[\"i7\"] = i7;\n\nlet c0 = Number(flow.get(\"c0\")) || 0;\nlet c1 = Number(flow.get(\"c1\")) || 0;\nlet c2 = Number(flow.get(\"c2\")) || 0;\nlet c3 = Number(flow.get(\"c3\")) || 0;\nlet c4 = Number(flow.get(\"c4\")) || 0;\nlet c5 = Number(flow.get(\"c5\")) || 0;\nlet c6 = Number(flow.get(\"c6\")) || 0;\nlet c7 = Number(flow.get(\"c7\")) || 0;\n\nmsg.payload[\"c0\"] = c0;\nmsg.payload[\"c1\"] = c1;\nmsg.payload[\"c2\"] = c2;\nmsg.payload[\"c3\"] = c3;\nmsg.payload[\"c4\"] = c4;\nmsg.payload[\"c5\"] = c5;\nmsg.payload[\"c6\"] = c6;\nmsg.payload[\"c7\"] = c7;\n\nmsg.payload[\"v0\"] = v0;\n\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, @@ -1652,7 +1667,7 @@ "type": "function", "z": "41526b8c80d5a5f7", "name": "m0", - "func": "flow.set(\"m0\", Number(msg.payload.m0));\nreturn msg;", + "func": "flow.set(\"m0\", Number(msg.payload.m0));\nmsg.payload = msg.payload.m0 * 10;\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, @@ -1662,7 +1677,9 @@ "x": 690, "y": 1440, "wires": [ - [] + [ + "7ac9d8c8e18dc044" + ] ] }, { @@ -1670,7 +1687,7 @@ "type": "function", "z": "41526b8c80d5a5f7", "name": "m1", - "func": "flow.set(\"m1\", Number(msg.payload.m1));\nreturn msg;", + "func": "flow.set(\"m1\", Number(msg.payload.m1));\nmsg.payload = msg.payload.m1 * 10;\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, @@ -1680,7 +1697,9 @@ "x": 690, "y": 1480, "wires": [ - [] + [ + "84fa844178c49edf" + ] ] }, { @@ -1688,7 +1707,7 @@ "type": "function", "z": "41526b8c80d5a5f7", "name": "m2", - "func": "flow.set(\"m2\", Number(msg.payload.m2));\nreturn msg;", + "func": "flow.set(\"m2\", Number(msg.payload.m2));\nmsg.payload = msg.payload.m2 * 10;\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, @@ -1698,7 +1717,9 @@ "x": 690, "y": 1520, "wires": [ - [] + [ + "47017a2a936e5072" + ] ] }, { @@ -1706,7 +1727,7 @@ "type": "function", "z": "41526b8c80d5a5f7", "name": "m3", - "func": "flow.set(\"m3\", Number(msg.payload.m3));\nreturn msg;", + "func": "flow.set(\"m3\", Number(msg.payload.m3));\nmsg.payload = msg.payload.m3 * 10;\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, @@ -1716,7 +1737,9 @@ "x": 690, "y": 1560, "wires": [ - [] + [ + "5ce2b9a4e220b5ea" + ] ] }, { @@ -1757,6 +1780,1504 @@ [] ] }, + { + "id": "7bd24ffe89bf6013", + "type": "ui-text", + "z": "41526b8c80d5a5f7", + "group": "02fab8cbf37e2bb7", + "order": 5, + "width": 0, + "height": 0, + "name": "", + "label": "", + "format": "{{msg.payload}}", + "layout": "row-right", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 850, + "y": 1740, + "wires": [] + }, + { + "id": "6d94aa7b17d6bedd", + "type": "ui-text", + "z": "41526b8c80d5a5f7", + "group": "02fab8cbf37e2bb7", + "order": 4, + "width": 0, + "height": 0, + "name": "", + "label": "", + "format": "{{msg.payload}}", + "layout": "row-spread", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 850, + "y": 1700, + "wires": [] + }, + { + "id": "309e25e7e1f603d5", + "type": "ui-text", + "z": "41526b8c80d5a5f7", + "group": "02fab8cbf37e2bb7", + "order": 3, + "width": 0, + "height": 0, + "name": "", + "label": "", + "format": "{{msg.payload}}", + "layout": "row-spread", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 850, + "y": 1660, + "wires": [] + }, + { + "id": "2559321f70cd5908", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "l1", + "func": "msg.payload = Number(msg.payload.light) == 1 ? \"🟢\" : \"⚪\";\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 690, + "y": 1740, + "wires": [ + [ + "7bd24ffe89bf6013" + ] + ] + }, + { + "id": "12ee9490cfd0c2cb", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "l2", + "func": "msg.payload = Number(msg.payload.light) == 2 ? \"🟠\" : \"⚪\";\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 690, + "y": 1700, + "wires": [ + [ + "6d94aa7b17d6bedd" + ] + ] + }, + { + "id": "a016dc35c575f406", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "l3", + "func": "msg.payload = Number(msg.payload.light) == 3 ? \"🔴\" : \"⚪\";\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 690, + "y": 1660, + "wires": [ + [ + "309e25e7e1f603d5" + ] + ] + }, + { + "id": "7ac9d8c8e18dc044", + "type": "ui-gauge", + "z": "41526b8c80d5a5f7", + "name": "", + "group": "6b44d4b22cd7b3dc", + "order": 1, + "value": "payload", + "valueType": "msg", + "width": "2", + "height": "2", + "gtype": "gauge-half", + "gstyle": "needle", + "title": "gauge", + "alwaysShowTitle": false, + "floatingTitlePosition": "top-left", + "units": "units", + "icon": "", + "prefix": "", + "suffix": "", + "segments": [ + { + "from": "0", + "color": "#5cd65c", + "text": "", + "textType": "label" + }, + { + "from": "4", + "color": "#ffc800", + "text": "", + "textType": "label" + }, + { + "from": "7", + "color": "#ea5353", + "text": "", + "textType": "label" + } + ], + "min": 0, + "max": 10, + "sizeThickness": 16, + "sizeGap": 4, + "sizeKeyThickness": 8, + "styleRounded": true, + "styleGlow": false, + "className": "", + "x": 870, + "y": 1440, + "wires": [ + [] + ] + }, + { + "id": "84fa844178c49edf", + "type": "ui-gauge", + "z": "41526b8c80d5a5f7", + "name": "", + "group": "6b44d4b22cd7b3dc", + "order": 2, + "value": "payload", + "valueType": "msg", + "width": "2", + "height": "2", + "gtype": "gauge-half", + "gstyle": "needle", + "title": "gauge", + "alwaysShowTitle": false, + "floatingTitlePosition": "top-left", + "units": "units", + "icon": "", + "prefix": "", + "suffix": "", + "segments": [ + { + "from": "0", + "color": "#5cd65c", + "text": "", + "textType": "label" + }, + { + "from": "4", + "color": "#ffc800", + "text": "", + "textType": "label" + }, + { + "from": "7", + "color": "#ea5353", + "text": "", + "textType": "label" + } + ], + "min": 0, + "max": 10, + "sizeThickness": 16, + "sizeGap": 4, + "sizeKeyThickness": 8, + "styleRounded": true, + "styleGlow": false, + "className": "", + "x": 870, + "y": 1480, + "wires": [ + [] + ] + }, + { + "id": "47017a2a936e5072", + "type": "ui-gauge", + "z": "41526b8c80d5a5f7", + "name": "", + "group": "6b44d4b22cd7b3dc", + "order": 3, + "value": "payload", + "valueType": "msg", + "width": "2", + "height": "2", + "gtype": "gauge-half", + "gstyle": "needle", + "title": "gauge", + "alwaysShowTitle": false, + "floatingTitlePosition": "top-left", + "units": "units", + "icon": "", + "prefix": "", + "suffix": "", + "segments": [ + { + "from": "0", + "color": "#5cd65c", + "text": "", + "textType": "label" + }, + { + "from": "4", + "color": "#ffc800", + "text": "", + "textType": "label" + }, + { + "from": "7", + "color": "#ea5353", + "text": "", + "textType": "label" + } + ], + "min": 0, + "max": 10, + "sizeThickness": 16, + "sizeGap": 4, + "sizeKeyThickness": 8, + "styleRounded": true, + "styleGlow": false, + "className": "", + "x": 870, + "y": 1520, + "wires": [ + [] + ] + }, + { + "id": "5ce2b9a4e220b5ea", + "type": "ui-gauge", + "z": "41526b8c80d5a5f7", + "name": "", + "group": "6b44d4b22cd7b3dc", + "order": 4, + "value": "payload", + "valueType": "msg", + "width": "2", + "height": "2", + "gtype": "gauge-half", + "gstyle": "needle", + "title": "gauge", + "alwaysShowTitle": false, + "floatingTitlePosition": "top-left", + "units": "units", + "icon": "", + "prefix": "", + "suffix": "", + "segments": [ + { + "from": "0", + "color": "#5cd65c", + "text": "", + "textType": "label" + }, + { + "from": "4", + "color": "#ffc800", + "text": "", + "textType": "label" + }, + { + "from": "7", + "color": "#ea5353", + "text": "", + "textType": "label" + } + ], + "min": 0, + "max": 10, + "sizeThickness": 16, + "sizeGap": 4, + "sizeKeyThickness": 8, + "styleRounded": true, + "styleGlow": false, + "className": "", + "x": 870, + "y": 1560, + "wires": [ + [] + ] + }, + { + "id": "e94f13f0f1acc44c", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "a0", + "func": "flow.set(\"a0\", Number(msg.payload.a0));\nmsg.payload = msg.payload.a0;\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 690, + "y": 1820, + "wires": [ + [ + "3f4307ae68dbfe24" + ] + ] + }, + { + "id": "3f4307ae68dbfe24", + "type": "rbe", + "z": "41526b8c80d5a5f7", + "name": "", + "func": "rbe", + "gap": "", + "start": "", + "inout": "out", + "septopics": false, + "property": "payload", + "topi": "topic", + "x": 850, + "y": 1820, + "wires": [ + [ + "4eb3133716e74df9" + ] + ] + }, + { + "id": "6e41db0b430f9a91", + "type": "delay", + "z": "41526b8c80d5a5f7", + "name": "sortie verrin", + "pauseType": "delay", + "timeout": "800", + "timeoutUnits": "milliseconds", + "rate": "1", + "nbRateUnits": "1", + "rateUnits": "second", + "randomFirst": "1", + "randomLast": "5", + "randomUnits": "seconds", + "drop": false, + "allowrate": false, + "outputs": 1, + "x": 1210, + "y": 1900, + "wires": [ + [ + "9df81d32815e49cf" + ] + ] + }, + { + "id": "9df81d32815e49cf", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c6 = 1", + "func": "flow.set(\"c6\", 1);\nflow.set(\"flag0\", 1);\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1390, + "y": 1900, + "wires": [ + [] + ] + }, + { + "id": "4eb3133716e74df9", + "type": "switch", + "z": "41526b8c80d5a5f7", + "name": "", + "property": "payload", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "0", + "vt": "num" + }, + { + "t": "eq", + "v": "1", + "vt": "num" + } + ], + "checkall": "false", + "repair": false, + "outputs": 2, + "x": 1000, + "y": 1820, + "wires": [ + [ + "38a0783404eca7e6" + ], + [ + "8dbfe82b3d93a51f", + "6e41db0b430f9a91" + ] + ] + }, + { + "id": "8dbfe82b3d93a51f", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c0 = 0", + "func": "flow.set(\"c0\", 0);\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1190, + "y": 1860, + "wires": [ + [] + ] + }, + { + "id": "38a0783404eca7e6", + "type": "delay", + "z": "41526b8c80d5a5f7", + "name": "retour verrin", + "pauseType": "delay", + "timeout": "1200", + "timeoutUnits": "milliseconds", + "rate": "1", + "nbRateUnits": "1", + "rateUnits": "second", + "randomFirst": "1", + "randomLast": "5", + "randomUnits": "seconds", + "drop": false, + "allowrate": false, + "outputs": 1, + "x": 1210, + "y": 1800, + "wires": [ + [ + "bfedc09f6f707609" + ] + ] + }, + { + "id": "bfedc09f6f707609", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c0 = 1", + "func": "flow.set(\"c0\", 1);\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1390, + "y": 1800, + "wires": [ + [] + ] + }, + { + "id": "92b7b19f3a84b610", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "a1", + "func": "flow.set(\"a1\", Number(msg.payload.a1));\nmsg.payload = msg.payload.a1;\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 690, + "y": 2040, + "wires": [ + [ + "0b52465d023a6934" + ] + ] + }, + { + "id": "0b52465d023a6934", + "type": "rbe", + "z": "41526b8c80d5a5f7", + "name": "", + "func": "rbe", + "gap": "", + "start": "", + "inout": "out", + "septopics": true, + "property": "payload", + "topi": "topic", + "x": 850, + "y": 2040, + "wires": [ + [ + "e0b6603acc4ecf87" + ] + ] + }, + { + "id": "e0b6603acc4ecf87", + "type": "switch", + "z": "41526b8c80d5a5f7", + "name": "", + "property": "payload", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "0", + "vt": "num" + }, + { + "t": "eq", + "v": "1", + "vt": "num" + } + ], + "checkall": "false", + "repair": false, + "outputs": 2, + "x": 1000, + "y": 2040, + "wires": [ + [ + "255aa585d23062e3", + "af93bf8a3513b407" + ], + [ + "36306be30feaf7f0", + "0d6e71b58cc1cc38" + ] + ] + }, + { + "id": "af93bf8a3513b407", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c2 = 0", + "func": "flow.set(\"c2\", 0);\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1170, + "y": 1980, + "wires": [ + [] + ] + }, + { + "id": "36306be30feaf7f0", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c1 = 0", + "func": "flow.set(\"c1\", 0);\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1170, + "y": 2100, + "wires": [ + [] + ] + }, + { + "id": "0d6e71b58cc1cc38", + "type": "delay", + "z": "41526b8c80d5a5f7", + "name": "sortie verrin", + "pauseType": "delay", + "timeout": "800", + "timeoutUnits": "milliseconds", + "rate": "1", + "nbRateUnits": "1", + "rateUnits": "second", + "randomFirst": "1", + "randomLast": "5", + "randomUnits": "seconds", + "drop": false, + "allowrate": false, + "outputs": 1, + "x": 1190, + "y": 2140, + "wires": [ + [ + "3cc44c740230f02a" + ] + ] + }, + { + "id": "3cc44c740230f02a", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c2 = 1", + "func": "flow.set(\"c2\", 1);\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1370, + "y": 2140, + "wires": [ + [] + ] + }, + { + "id": "255aa585d23062e3", + "type": "delay", + "z": "41526b8c80d5a5f7", + "name": "retour verrin", + "pauseType": "delay", + "timeout": "1200", + "timeoutUnits": "milliseconds", + "rate": "1", + "nbRateUnits": "1", + "rateUnits": "second", + "randomFirst": "1", + "randomLast": "5", + "randomUnits": "seconds", + "drop": false, + "allowrate": false, + "outputs": 1, + "x": 1190, + "y": 2020, + "wires": [ + [ + "2f9031a86b4a023b" + ] + ] + }, + { + "id": "2f9031a86b4a023b", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c1 = 1", + "func": "flow.set(\"c1\", 1);\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1350, + "y": 2020, + "wires": [ + [] + ] + }, + { + "id": "7febe9e39b9c4b6d", + "type": "ui-text", + "z": "41526b8c80d5a5f7", + "group": "6b44d4b22cd7b3dc", + "order": 5, + "width": "2", + "height": "1", + "name": "", + "label": "c0", + "format": "{{msg.payload}}", + "layout": "row-spread", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 1230, + "y": 1120, + "wires": [] + }, + { + "id": "462e542c5786e330", + "type": "ui-text", + "z": "41526b8c80d5a5f7", + "group": "6b44d4b22cd7b3dc", + "order": 6, + "width": "2", + "height": "1", + "name": "", + "label": "c1", + "format": "{{msg.payload}}", + "layout": "row-spread", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 1230, + "y": 1160, + "wires": [] + }, + { + "id": "c7e569b7027aa3ce", + "type": "ui-text", + "z": "41526b8c80d5a5f7", + "group": "6b44d4b22cd7b3dc", + "order": 7, + "width": "2", + "height": "1", + "name": "", + "label": "c2", + "format": "{{msg.payload}}", + "layout": "row-spread", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 1230, + "y": 1200, + "wires": [] + }, + { + "id": "cd6ccfdf8cc29b04", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c0", + "func": "msg.payload = Number(msg.payload.c0) ? \"🟩\" : \"🟥\";\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1050, + "y": 1120, + "wires": [ + [ + "7febe9e39b9c4b6d" + ] + ] + }, + { + "id": "e694653f29c5c6c3", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c1", + "func": "msg.payload = Number(msg.payload.c1) ? \"🟩\" : \"🟥\";\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1050, + "y": 1160, + "wires": [ + [ + "462e542c5786e330" + ] + ] + }, + { + "id": "b25a525c97f6ca68", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c2", + "func": "msg.payload = Number(msg.payload.c2) ? \"🟩\" : \"🟥\";\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1050, + "y": 1200, + "wires": [ + [ + "c7e569b7027aa3ce" + ] + ] + }, + { + "id": "36c7c76a5e1740ba", + "type": "ui-text", + "z": "41526b8c80d5a5f7", + "group": "6b44d4b22cd7b3dc", + "order": 8, + "width": "2", + "height": "1", + "name": "", + "label": "c3", + "format": "{{msg.payload}}", + "layout": "row-spread", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 1230, + "y": 1240, + "wires": [] + }, + { + "id": "e3cc796a4ae84c36", + "type": "ui-text", + "z": "41526b8c80d5a5f7", + "group": "6b44d4b22cd7b3dc", + "order": 9, + "width": "2", + "height": "1", + "name": "", + "label": "c4", + "format": "{{msg.payload}}", + "layout": "row-spread", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 1230, + "y": 1280, + "wires": [] + }, + { + "id": "0f4fcd7d4ea77704", + "type": "ui-text", + "z": "41526b8c80d5a5f7", + "group": "6b44d4b22cd7b3dc", + "order": 10, + "width": "2", + "height": "1", + "name": "", + "label": "c5", + "format": "{{msg.payload}}", + "layout": "row-spread", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 1230, + "y": 1320, + "wires": [] + }, + { + "id": "d19105b55c934446", + "type": "ui-text", + "z": "41526b8c80d5a5f7", + "group": "6b44d4b22cd7b3dc", + "order": 11, + "width": "2", + "height": "1", + "name": "", + "label": "c6", + "format": "{{msg.payload}}", + "layout": "row-spread", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 1230, + "y": 1360, + "wires": [] + }, + { + "id": "9f668e45418ca62a", + "type": "ui-text", + "z": "41526b8c80d5a5f7", + "group": "6b44d4b22cd7b3dc", + "order": 12, + "width": "2", + "height": "1", + "name": "", + "label": "c7", + "format": "{{msg.payload}}", + "layout": "row-spread", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 1230, + "y": 1400, + "wires": [] + }, + { + "id": "f88ed6b89e2793cf", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c3", + "func": "msg.payload = Number(msg.payload.c3) ? \"🟩\" : \"🟥\";\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1050, + "y": 1240, + "wires": [ + [ + "36c7c76a5e1740ba" + ] + ] + }, + { + "id": "41f6c23afe13dda4", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c4", + "func": "msg.payload = Number(msg.payload.c4) ? \"🟩\" : \"🟥\";\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1050, + "y": 1280, + "wires": [ + [ + "e3cc796a4ae84c36" + ] + ] + }, + { + "id": "ca27afe33c09b23a", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c5", + "func": "msg.payload = Number(msg.payload.c5) ? \"🟩\" : \"🟥\";\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1050, + "y": 1320, + "wires": [ + [ + "0f4fcd7d4ea77704" + ] + ] + }, + { + "id": "227354827c5b2a9e", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c6", + "func": "msg.payload = Number(msg.payload.c6) ? \"🟩\" : \"🟥\";\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1050, + "y": 1360, + "wires": [ + [ + "d19105b55c934446" + ] + ] + }, + { + "id": "79e82ef03466071e", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c7", + "func": "msg.payload = Number(msg.payload.c7) ? \"🟩\" : \"🟥\";\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1050, + "y": 1400, + "wires": [ + [ + "9f668e45418ca62a" + ] + ] + }, + { + "id": "f55fa882f44af78e", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "a2", + "func": "flow.set(\"a2\", Number(msg.payload.a2));\nmsg.payload = msg.payload.a2;\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 690, + "y": 2240, + "wires": [ + [ + "c2cdd0cec8c60f7b" + ] + ] + }, + { + "id": "c2cdd0cec8c60f7b", + "type": "rbe", + "z": "41526b8c80d5a5f7", + "name": "", + "func": "rbe", + "gap": "", + "start": "", + "inout": "out", + "septopics": true, + "property": "payload", + "topi": "topic", + "x": 834, + "y": 2229, + "wires": [ + [ + "4f208fbc27e6ba22" + ] + ] + }, + { + "id": "4f208fbc27e6ba22", + "type": "switch", + "z": "41526b8c80d5a5f7", + "name": "", + "property": "payload", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "0", + "vt": "num" + }, + { + "t": "eq", + "v": "1", + "vt": "num" + } + ], + "checkall": "false", + "repair": false, + "outputs": 2, + "x": 1000, + "y": 2240, + "wires": [ + [ + "66ea059b7d73dd94" + ], + [ + "119a37cc13969294" + ] + ] + }, + { + "id": "119a37cc13969294", + "type": "delay", + "z": "41526b8c80d5a5f7", + "name": "sortie verrin", + "pauseType": "delay", + "timeout": "800", + "timeoutUnits": "milliseconds", + "rate": "1", + "nbRateUnits": "1", + "rateUnits": "second", + "randomFirst": "1", + "randomLast": "5", + "randomUnits": "seconds", + "drop": false, + "allowrate": false, + "outputs": 1, + "x": 1170, + "y": 2280, + "wires": [ + [ + "f4829f8e643d0c3e" + ] + ] + }, + { + "id": "f4829f8e643d0c3e", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c3 = 1", + "func": "flow.set(\"c3\", 1);\nflow.set(\"c6\", 0);\n\nif (Number(flow.get(\"flag0\")) == 1) {\n flow.set(\"flag0\", 0);\n flow.set(\"c5\", 1);\n}\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1330, + "y": 2280, + "wires": [ + [] + ] + }, + { + "id": "66ea059b7d73dd94", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c3 = 0", + "func": "flow.set(\"c3\", 0);\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1170, + "y": 2220, + "wires": [ + [] + ] + }, + { + "id": "02cfaae4ac4028fa", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "a3", + "func": "flow.set(\"a3\", Number(msg.payload.a3));\nmsg.payload = msg.payload.a3;\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 690, + "y": 2360, + "wires": [ + [ + "0ae317ffe38bf575" + ] + ] + }, + { + "id": "0ae317ffe38bf575", + "type": "rbe", + "z": "41526b8c80d5a5f7", + "name": "", + "func": "rbe", + "gap": "", + "start": "", + "inout": "out", + "septopics": true, + "property": "payload", + "topi": "topic", + "x": 830, + "y": 2360, + "wires": [ + [ + "a50f4b5dfa9eade9" + ] + ] + }, + { + "id": "a50f4b5dfa9eade9", + "type": "switch", + "z": "41526b8c80d5a5f7", + "name": "", + "property": "payload", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "0", + "vt": "num" + }, + { + "t": "eq", + "v": "1", + "vt": "num" + } + ], + "checkall": "false", + "repair": false, + "outputs": 2, + "x": 980, + "y": 2360, + "wires": [ + [], + [ + "fc150d9fc55ebcc5" + ] + ] + }, + { + "id": "fc150d9fc55ebcc5", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "c5 = 0", + "func": "flow.set(\"c5\", 0);\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1150, + "y": 2380, + "wires": [ + [] + ] + }, + { + "id": "97c3bdd3022c06a2", + "type": "inject", + "z": "41526b8c80d5a5f7", + "name": "sortie a0", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"a0\":1}", + "payloadType": "json", + "x": 400, + "y": 1800, + "wires": [ + [ + "e94f13f0f1acc44c" + ] + ] + }, + { + "id": "32a0178413458831", + "type": "inject", + "z": "41526b8c80d5a5f7", + "name": "retour a0", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"a0\":0}", + "payloadType": "json", + "x": 400, + "y": 1840, + "wires": [ + [ + "e94f13f0f1acc44c" + ] + ] + }, + { + "id": "55b870902eafb7d6", + "type": "inject", + "z": "41526b8c80d5a5f7", + "name": "sortie a1", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"a1\":1}", + "payloadType": "json", + "x": 420, + "y": 2020, + "wires": [ + [ + "92b7b19f3a84b610" + ] + ] + }, + { + "id": "9613b1d12607eb78", + "type": "inject", + "z": "41526b8c80d5a5f7", + "name": "retour a1", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"a1\":0}", + "payloadType": "json", + "x": 420, + "y": 2060, + "wires": [ + [ + "92b7b19f3a84b610" + ] + ] + }, + { + "id": "e2ee6d24c361265a", + "type": "inject", + "z": "41526b8c80d5a5f7", + "name": "retour a2", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"a2\":0}", + "payloadType": "json", + "x": 420, + "y": 2240, + "wires": [ + [ + "f55fa882f44af78e" + ] + ] + }, + { + "id": "3f3795eb65e0bc06", + "type": "inject", + "z": "41526b8c80d5a5f7", + "name": "retour a3", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"a3\":0}", + "payloadType": "json", + "x": 440, + "y": 2380, + "wires": [ + [ + "02cfaae4ac4028fa" + ] + ] + }, + { + "id": "7806cff293d6b133", + "type": "inject", + "z": "41526b8c80d5a5f7", + "name": "sortie a2", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"a2\":1}", + "payloadType": "json", + "x": 420, + "y": 2200, + "wires": [ + [ + "f55fa882f44af78e" + ] + ] + }, + { + "id": "b96e4ea91c42c3de", + "type": "inject", + "z": "41526b8c80d5a5f7", + "name": "sortie a3", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"a3\":1}", + "payloadType": "json", + "x": 440, + "y": 2340, + "wires": [ + [ + "02cfaae4ac4028fa" + ] + ] + }, { "id": "5fe915fcd26e78ae", "type": "ui-group", @@ -1851,6 +3372,20 @@ "page": "bb436fe040268d40", "width": "8", "height": 1, + "order": 6, + "showTitle": true, + "className": "", + "visible": "true", + "disabled": "false", + "groupType": "default" + }, + { + "id": "6b44d4b22cd7b3dc", + "type": "ui-group", + "name": "Moteurs", + "page": "bb436fe040268d40", + "width": "4", + "height": 1, "order": 5, "showTitle": true, "className": "", @@ -1934,11 +3469,11 @@ } }, { - "id": "3dc18e328806e2f6", + "id": "72fb79817cf41c66", "type": "global-config", "env": [], "modules": { - "@flowfuse/node-red-dashboard": "1.30.1" + "@flowfuse/node-red-dashboard": "1.29.0" } } ] \ No newline at end of file diff --git a/autom.cpp b/autom.cpp index 547a822..bda73e9 100644 --- a/autom.cpp +++ b/autom.cpp @@ -56,6 +56,9 @@ int s0, s1, s2, s3, s4, s5, s6, s7; int m0, m1, m2, m3; int v0; +int a0, a1, a2, a3, a4, a5, a6, a7; +int c0, c1, c2, c3, c4, c5, c6, c7; + void process(); /* ******************************************************** @@ -120,6 +123,23 @@ public: if (j.contains("i6")) i6 = j["i6"].get(); if (j.contains("i7")) i7 = j["i7"].get(); + if (j.contains("c0")) + c0 = j["c0"].get(); + if (j.contains("c1")) + c1 = j["c1"].get(); + if (j.contains("c2")) + c2 = j["c2"].get(); + if (j.contains("c3")) + c3 = j["c3"].get(); + if (j.contains("c4")) + c4 = j["c4"].get(); + if (j.contains("c5")) + c5 = j["c5"].get(); + if (j.contains("c6")) + c6 = j["c6"].get(); + if (j.contains("c7")) + c7 = j["c7"].get(); + if (j.contains("v0") && j["v0"].is_number()) v0 = j["v0"].get(); process(); @@ -165,6 +185,15 @@ void mqtt_send(mqtt::async_client *client) {"m1", m1}, {"m2", m2}, {"m3", m3}, + {"a0", a0}, + {"a1", a1}, + {"a2", a2}, + {"a3", a3}, + {"a4", a4}, + {"a5", a5}, + {"a6", a6}, + {"a7", a7}, + {"light", 0}, }; std::string payload = obj.dump();