diff --git a/.devcontainer/nodered/flows.json b/.devcontainer/nodered/flows.json index 9701ef3..9b969de 100644 --- a/.devcontainer/nodered/flows.json +++ b/.devcontainer/nodered/flows.json @@ -4034,6 +4034,7 @@ "id": "e5da08ba69fe6fb8", "type": "link in", "z": "b5e17af18ea9731a", + "d": true, "name": "link in 1", "links": [ "397735dd2560f7cf" @@ -4221,7 +4222,6 @@ "id": "ed71da98200376bd", "type": "link in", "z": "93dc5b41180d0746", - "d": true, "name": "link in 3", "links": [ "c613454bd48662e1" @@ -4238,8 +4238,8 @@ "id": "24ee793574d63484", "type": "function", "z": "93dc5b41180d0746", - "name": "function 2", - "func": "let p0 = Number(global.get(\"p0\")) || 0;\nlet v0 = Number(global.get(\"v0\")) || 0;\n\nif (global.get(\"m0\")) {\n p0 += 0.3;\n}\n\nif (global.get(\"m2\")) {\n p0 += 0.3;\n}\n\nif (global.get(\"m3\")) {\n p0 += 0.3;\n}\n\nif (global.get(\"m4\")) {\n p0 += 0.3;\n}\n\np0 = p0 - v0 / 100;\n\nif (p0 > 100) p0 = 100;\nif (p0 < 0) p0 = 0;\nglobal.set(\"p0\", p0);\nmsg.payload = p0;\n\nreturn msg;", + "name": "réservoir", + "func": "let p0 = Number(global.get(\"p0\")) || 0;\nlet v0 = Number(global.get(\"v0\")) || 0;\n\nif (global.get(\"m0\")) {\n p0 += 0.3;\n}\n\nif (global.get(\"m2\")) {\n p0 += 0.3;\n}\n\nif (global.get(\"m3\")) {\n p0 += 0.3;\n}\n\nif (global.get(\"m4\")) {\n p0 += 0.3;\n}\n\np0 = p0 - v0 / 100;\n\nif (p0 > 100) p0 = 100;\nif (p0 < 0) p0 = 0;\nglobal.set(\"p0\", p0);\nmsg.payload = p0;\n\nglobal.set(\"c0\", p0 > 15);\nglobal.set(\"c1\", p0 > 40);\nglobal.set(\"c2\", p0 > 60);\nglobal.set(\"c3\", p0 > 75);\n\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, diff --git a/18.md b/18.md index fb78b9a..194bbc9 100644 --- a/18.md +++ b/18.md @@ -1,12 +1,69 @@ + c7_frontdescendant = capteur[7] < c7_precedent; + + ci = (capteur[0] == 1 && capteur[2] == 1 && capteur[3] == 0 && capteur[5] == 0 && capteur[6] == 0 && capteur[7] == 0); + + if (ci == 1 && marche_frontmontant == 1) + { + mode_auto = 1; + etape = 1; + } + + if (etape == 1 && capteur[0] == 0 && capteur[6] == 1 && (bouton_frontmontant[0] || !interrupteur[0])) + { + etape = 2; + } + + if (etape == 2 && capteur[3] == 1) + { + etape = 3; + } + + if (etape == 3 && tempo == 0) + { + tempo = millis(); + } + + if (etape == 3 && millis() > tempo + 3000) + { + etape = 4; + tempo = 0; + } + + if (etape == 4 && capteur[2] == 1 && (bouton_frontmontant[0] || !interrupteur[0])) + { + etape = 5; + } + + if (etape == 5 && capteur[5] == 1 && (bouton_frontmontant[0] || !interrupteur[0])) + { + etape = 6; + } + + if (etape == 6 && c7_frontdescendant == 1) + { + etape = 7; + } + + if (etape == 7 && (bouton_frontmontant[0] || !interrupteur[0])) + { + etape = 1; + } + + sortie[10] = etape; + sortie[11] = ci; + + actionneur[0] = (etape == 1); + actionneur[1] = (etape == 2 || etape == 3); + actionneur[2] = (etape == 5); + actionneur[3] = (etape == 6); +/* ************************************************************************ if (arret_frontdescedant == 1) { mode_auto = 0; } - - s0 = mode_auto == 1; if (ci && mode_auto == 0) { diff --git a/exercice1.txt b/exercice1.txt new file mode 100644 index 0000000..47a8a49 --- /dev/null +++ b/exercice1.txt @@ -0,0 +1,83 @@ +ci = (c0 == 1 && c1 == 1 && c2 == 0 && c3 == 0 && c5 == 0 && c6 == 0); + + if (marche_frontmontant == 1 && ci == 1) + { + mode_auto = 1; + etape = 1; + } + + if (i0 = 1) { + mode_manu = 1; + mode_auto = 0; + } + + if (arret_frontdescedant == 1) + { + mode_auto = 0; + } + + if (etape == 1 && c6 == 1 && ((b0_frontmontant && mode_manu) || mode_auto)) + { + etape = 2; + } + + if (etape == 2 && c2 == 1 && b0_frontmontant) + { + etape = 3; + } + + if (etape == 3 && tempo == 0 && b0_frontmontant) + { + tempo = millis(); + } + + if (etape == 3 && millis() > tempo + 3000) + { + etape = 4; + tempo = 0; + } + + if (etape == 4 && c1 == 1 && b0_frontmontant) + { + etape = 5; + } + + if (etape == 5 && c3 == 1 && b0_frontmontant == 1) + { + etape = 6; + } + + if (etape == 6 && c5_frontdescendant == 1) + { + etape = 7; + } + + if (etape == 7 && b0_frontmontant == 1) { + etape = 1; + } + + s0 = mode_auto == 1; + + if (ci && mode_auto == 0) + { + s8 = 1; + } + else if (ci && mode_auto == 1) + { + s8 = 2; + } + else if (mode_auto) + { + s8 = 3; + } + else + { + s8 = 0; + } + + s10 = etape; + + a0 = (etape == 1); + a1 = (etape == 2 || etape == 3); + a2 = (etape == 5); + a3 = (etape == 6); diff --git a/main.cpp b/main.cpp index 007d7ee..a46e1f2 100644 --- a/main.cpp +++ b/main.cpp @@ -58,59 +58,11 @@ void process() { /* **************************************************************** **************************************************************** */ - c7_frontdescendant = capteur[7] < c7_precedent; - ci = (capteur[0] == 1 && capteur[2] == 1 && capteur[3] == 0 && capteur[5] == 0 && capteur[6] == 0 && capteur[7] == 0); - - if (ci == 1 && marche_frontmontant == 1) - { - mode_auto = 1; - etape = 1; - } - - if (etape == 1 && capteur[0] == 0 && capteur[6] == 1) - { - etape = 2; - } - - if (etape == 2 && capteur[3] == 1) - { - etape = 3; - } - - if (etape == 3 && tempo == 0) - { - tempo = millis(); - } - - if (etape == 3 && millis() > tempo + 3000) - { - etape = 4; - tempo = 0; - } - - if (etape == 4 && capteur[2] == 1) - { - etape = 5; - } - - if (etape == 5 && capteur[5] == 1) - { - etape = 6; - } - - if (etape == 6 && c7_frontdescendant == 1) - { - etape = 1; - } - - sortie[10] = etape; - sortie[11] = ci; - - actionneur[0] = (etape == 1); - actionneur[1] = (etape == 2 || etape == 3); - actionneur[2] = (etape == 5); - actionneur[3] = (etape == 6); + m0 = i0; + m1 = i1; + m2 = i2; + m3 = i3; // Prêt pour un nouveau cycle // L'état courant devient l'état précédent