RESET
This commit is contained in:
@@ -320,7 +320,7 @@
|
|||||||
"group": "0b9ca135d0b7313a",
|
"group": "0b9ca135d0b7313a",
|
||||||
"name": "",
|
"name": "",
|
||||||
"label": "B0",
|
"label": "B0",
|
||||||
"order": 6,
|
"order": 7,
|
||||||
"width": 0,
|
"width": 0,
|
||||||
"height": 0,
|
"height": 0,
|
||||||
"emulateClick": false,
|
"emulateClick": false,
|
||||||
@@ -359,7 +359,7 @@
|
|||||||
"group": "0b9ca135d0b7313a",
|
"group": "0b9ca135d0b7313a",
|
||||||
"name": "",
|
"name": "",
|
||||||
"label": "B1",
|
"label": "B1",
|
||||||
"order": 7,
|
"order": 8,
|
||||||
"width": 0,
|
"width": 0,
|
||||||
"height": 0,
|
"height": 0,
|
||||||
"emulateClick": false,
|
"emulateClick": false,
|
||||||
@@ -398,7 +398,7 @@
|
|||||||
"group": "b7568fe107ccb2e6",
|
"group": "b7568fe107ccb2e6",
|
||||||
"name": "",
|
"name": "",
|
||||||
"label": "B2",
|
"label": "B2",
|
||||||
"order": 6,
|
"order": 7,
|
||||||
"width": 0,
|
"width": 0,
|
||||||
"height": 0,
|
"height": 0,
|
||||||
"emulateClick": false,
|
"emulateClick": false,
|
||||||
@@ -437,7 +437,7 @@
|
|||||||
"group": "b7568fe107ccb2e6",
|
"group": "b7568fe107ccb2e6",
|
||||||
"name": "",
|
"name": "",
|
||||||
"label": "B3",
|
"label": "B3",
|
||||||
"order": 7,
|
"order": 8,
|
||||||
"width": 0,
|
"width": 0,
|
||||||
"height": 0,
|
"height": 0,
|
||||||
"emulateClick": false,
|
"emulateClick": false,
|
||||||
@@ -657,10 +657,10 @@
|
|||||||
"id": "9a23c6f558ea0378",
|
"id": "9a23c6f558ea0378",
|
||||||
"type": "ui-text",
|
"type": "ui-text",
|
||||||
"z": "86a34ee77bf6db10",
|
"z": "86a34ee77bf6db10",
|
||||||
"group": "c3dd11d0778f9e67",
|
"group": "0b9ca135d0b7313a",
|
||||||
"order": 8,
|
"order": 6,
|
||||||
"width": 0,
|
"width": "1",
|
||||||
"height": 0,
|
"height": "1",
|
||||||
"name": "",
|
"name": "",
|
||||||
"label": "s0",
|
"label": "s0",
|
||||||
"format": "{{msg.payload}}",
|
"format": "{{msg.payload}}",
|
||||||
@@ -681,10 +681,10 @@
|
|||||||
"id": "a80fa1a313f076c8",
|
"id": "a80fa1a313f076c8",
|
||||||
"type": "ui-text",
|
"type": "ui-text",
|
||||||
"z": "86a34ee77bf6db10",
|
"z": "86a34ee77bf6db10",
|
||||||
"group": "c3dd11d0778f9e67",
|
"group": "b7568fe107ccb2e6",
|
||||||
"order": 7,
|
"order": 6,
|
||||||
"width": 0,
|
"width": "1",
|
||||||
"height": 0,
|
"height": "1",
|
||||||
"name": "",
|
"name": "",
|
||||||
"label": "s1",
|
"label": "s1",
|
||||||
"format": "{{msg.payload}}",
|
"format": "{{msg.payload}}",
|
||||||
@@ -705,10 +705,10 @@
|
|||||||
"id": "10e55237847991c9",
|
"id": "10e55237847991c9",
|
||||||
"type": "ui-text",
|
"type": "ui-text",
|
||||||
"z": "86a34ee77bf6db10",
|
"z": "86a34ee77bf6db10",
|
||||||
"group": "c3dd11d0778f9e67",
|
"group": "6ba51f61417860c1",
|
||||||
"order": 6,
|
"order": 6,
|
||||||
"width": 0,
|
"width": "1",
|
||||||
"height": 0,
|
"height": "1",
|
||||||
"name": "",
|
"name": "",
|
||||||
"label": "s2",
|
"label": "s2",
|
||||||
"format": "{{msg.payload}}",
|
"format": "{{msg.payload}}",
|
||||||
@@ -1041,7 +1041,7 @@
|
|||||||
"group": "6ba51f61417860c1",
|
"group": "6ba51f61417860c1",
|
||||||
"name": "",
|
"name": "",
|
||||||
"label": "B4",
|
"label": "B4",
|
||||||
"order": 6,
|
"order": 7,
|
||||||
"width": 0,
|
"width": 0,
|
||||||
"height": 0,
|
"height": 0,
|
||||||
"emulateClick": false,
|
"emulateClick": false,
|
||||||
@@ -1080,7 +1080,7 @@
|
|||||||
"group": "6ba51f61417860c1",
|
"group": "6ba51f61417860c1",
|
||||||
"name": "",
|
"name": "",
|
||||||
"label": "B5",
|
"label": "B5",
|
||||||
"order": 7,
|
"order": 8,
|
||||||
"width": 0,
|
"width": 0,
|
||||||
"height": 0,
|
"height": 0,
|
||||||
"emulateClick": false,
|
"emulateClick": false,
|
||||||
|
|||||||
37
autom.cpp
37
autom.cpp
@@ -88,6 +88,7 @@ const int CYCLE_MS = 100;
|
|||||||
|
|
||||||
mqtt::async_client client(ADDRESS, CLIENTID);
|
mqtt::async_client client(ADDRESS, CLIENTID);
|
||||||
|
|
||||||
|
void mqtt_start(mqtt::async_client *client);
|
||||||
void mqtt_send(mqtt::async_client *client);
|
void mqtt_send(mqtt::async_client *client);
|
||||||
|
|
||||||
// Réception des messages MQTT
|
// Réception des messages MQTT
|
||||||
@@ -111,10 +112,16 @@ public:
|
|||||||
if (j.empty())
|
if (j.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (j.contains("reset"))
|
||||||
|
{
|
||||||
|
reset = j["reset"].get<int>() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (j.contains("marche")) {
|
if (j.contains("marche")) {
|
||||||
marche = j["marche"].get<int>() != 0;
|
marche = j["marche"].get<int>() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (j.contains("arret")) {
|
if (j.contains("arret")) {
|
||||||
arret = j["arret"].get<int>() != 0;
|
arret = j["arret"].get<int>() != 0;
|
||||||
}
|
}
|
||||||
@@ -193,26 +200,19 @@ public:
|
|||||||
v0 = j["v0"].get<int>();
|
v0 = j["v0"].get<int>();
|
||||||
|
|
||||||
if (j.contains("p0") && j["p0"].is_number()) {
|
if (j.contains("p0") && j["p0"].is_number()) {
|
||||||
p0 = j["p0"].get<int>();
|
niveau[0] = p0 = j["p0"].get<int>();
|
||||||
niveau[0] = j["p0"].get<int>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j.contains("p1") && j["p1"].is_number())
|
if (j.contains("p1") && j["p1"].is_number()) {
|
||||||
{
|
niveau[1] = p1 = j["p1"].get<int>();
|
||||||
p1 = j["p1"].get<int>();
|
|
||||||
niveau[1] = j["p1"].get<int>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j.contains("p2") && j["p2"].is_number())
|
if (j.contains("p2") && j["p2"].is_number()) {
|
||||||
{
|
niveau[2] = p2 = j["p2"].get<int>();
|
||||||
p2 = j["p2"].get<int>();
|
|
||||||
niveau[2] = j["p2"].get<int>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j.contains("p3") && j["p3"].is_number())
|
if (j.contains("p3") && j["p3"].is_number()) {
|
||||||
{
|
niveau[3] = p3 = j["p3"].get<int>();
|
||||||
p3 = j["p3"].get<int>();
|
|
||||||
niveau[3] = j["p3"].get<int>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process();
|
process();
|
||||||
@@ -229,7 +229,6 @@ callback cb;
|
|||||||
|
|
||||||
void mqtt_open(mqtt::async_client *client)
|
void mqtt_open(mqtt::async_client *client)
|
||||||
{
|
{
|
||||||
|
|
||||||
client->set_callback(cb);
|
client->set_callback(cb);
|
||||||
mqtt::connect_options connOpts;
|
mqtt::connect_options connOpts;
|
||||||
connOpts.set_clean_session(true);
|
connOpts.set_clean_session(true);
|
||||||
@@ -240,6 +239,7 @@ void mqtt_open(mqtt::async_client *client)
|
|||||||
client->connect(connOpts)->wait();
|
client->connect(connOpts)->wait();
|
||||||
client->start_consuming();
|
client->start_consuming();
|
||||||
client->subscribe(TOPIC, QOS)->wait();
|
client->subscribe(TOPIC, QOS)->wait();
|
||||||
|
mqtt_start(client);
|
||||||
}
|
}
|
||||||
catch (const mqtt::exception &exc)
|
catch (const mqtt::exception &exc)
|
||||||
{
|
{
|
||||||
@@ -272,6 +272,13 @@ void mqtt_send(mqtt::async_client *client)
|
|||||||
client->publish(msg);
|
client->publish(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mqtt_start(mqtt::async_client *client)
|
||||||
|
{
|
||||||
|
auto msg = mqtt::make_message("geii/out", "reset");
|
||||||
|
msg->set_qos(2);
|
||||||
|
client->publish(msg);
|
||||||
|
}
|
||||||
|
|
||||||
void mqtt_close()
|
void mqtt_close()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
85
main.cpp
85
main.cpp
@@ -25,6 +25,7 @@ int mode_auto = 0;
|
|||||||
int mode_manu = 0;
|
int mode_manu = 0;
|
||||||
int etape = 0;
|
int etape = 0;
|
||||||
int etape_2 = 0;
|
int etape_2 = 0;
|
||||||
|
int etape_sauvegarde = 0;
|
||||||
|
|
||||||
int c7_frontdescendant = 0;
|
int c7_frontdescendant = 0;
|
||||||
int c7_precedent = 0;
|
int c7_precedent = 0;
|
||||||
@@ -47,6 +48,15 @@ int main()
|
|||||||
|
|
||||||
void process()
|
void process()
|
||||||
{
|
{
|
||||||
|
// Gestion du RESET
|
||||||
|
// ****************************************************************
|
||||||
|
if (reset == 1) {
|
||||||
|
std::cout << "RESET" << std::endl;
|
||||||
|
etape = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ****************************************************************
|
||||||
|
|
||||||
// Détection des fronts
|
// Détection des fronts
|
||||||
// front montant (état courant supérieur à l'état précédent)
|
// front montant (état courant supérieur à l'état précédent)
|
||||||
@@ -64,8 +74,79 @@ void process()
|
|||||||
/* ****************************************************************
|
/* ****************************************************************
|
||||||
VOTRE PROGRAMME COMMENCE ICI
|
VOTRE PROGRAMME COMMENCE ICI
|
||||||
**************************************************************** */
|
**************************************************************** */
|
||||||
|
if (etape == 0 && interrupteur[1] == 1 && capteur[1] == 1 && capteur[3] == 1 && capteur[5] == 1) {
|
||||||
|
etape = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (etape == 1 && !interrupteur[1]) {
|
||||||
|
etape = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (etape != 11 && interrupteur[2] && interrupteur[1] == 0 && (capteur[1]!=1 || capteur[3]!=1 || capteur[5]!=1))
|
||||||
|
{
|
||||||
|
etape = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (etape == 1 && marche_frontmontant) {
|
||||||
|
etape = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (etape == 2 && capteur[0]) {
|
||||||
|
etape = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (etape == 3 && capteur[2]) {
|
||||||
|
etape = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (etape == 4 && capteur[4]) {
|
||||||
|
etape = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arret_frontdescedant) {
|
||||||
|
etape_sauvegarde = etape;
|
||||||
|
etape = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (etape == 6 && marche_frontmontant) {
|
||||||
|
etape = etape_sauvegarde;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (etape == 10 && marche_frontmontant)
|
||||||
|
{
|
||||||
|
etape = 11;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (etape == 11 && capteur[1] && capteur[3] && capteur[5])
|
||||||
|
{
|
||||||
|
etape = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (etape == 1) {
|
||||||
|
sortie[8] = 1;
|
||||||
|
}
|
||||||
|
else if (etape == 5) {
|
||||||
|
sortie[8] = 3;
|
||||||
|
}
|
||||||
|
else if (etape > 1 && etape < 5) {
|
||||||
|
sortie[8] = 2;
|
||||||
|
}
|
||||||
|
else if (etape == 10)
|
||||||
|
{
|
||||||
|
sortie[8] = millis() / 500 % 2 ? 2 : 0;;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sortie[8] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
actionneur[0] = !capteur[0] && etape == 2;
|
||||||
|
actionneur[2] = !capteur[2] && etape == 3;
|
||||||
|
actionneur[4] = !capteur[4] && etape == 4;
|
||||||
|
|
||||||
|
actionneur[1] = !capteur[1] && etape == 11;
|
||||||
|
actionneur[3] = !capteur[3] && etape == 11;
|
||||||
|
actionneur[5] = !capteur[5] && etape == 11;
|
||||||
|
|
||||||
actionneur[0] = actionneur[2] = actionneur[4] = 1;
|
|
||||||
/* ****************************************************************
|
/* ****************************************************************
|
||||||
VOTRE PROGRAMME S'ARRETE ICI
|
VOTRE PROGRAMME S'ARRETE ICI
|
||||||
**************************************************************** */
|
**************************************************************** */
|
||||||
@@ -81,4 +162,4 @@ actionneur[0] = actionneur[2] = actionneur[4] = 1;
|
|||||||
bouton_precedent[i] = bouton[i];
|
bouton_precedent[i] = bouton[i];
|
||||||
}
|
}
|
||||||
c7_precedent = capteur[7];
|
c7_precedent = capteur[7];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user