carte esclave pompe 2020 V1

Dependencies:   mbed ident_crac

Revision:
21:42d6cead9cc2
Parent:
20:677dcf689523
Child:
22:f104afbecb98
--- a/main.cpp	Fri Mar 06 08:17:17 2020 +0000
+++ b/main.cpp	Sat Mar 07 17:40:59 2020 +0000
@@ -1,4 +1,5 @@
 #include "extern.h"
+#include "Asservissement.h"
 #define SIZE_FIFO 50
 
 
@@ -59,7 +60,7 @@
         switch(identifiant)
         {
             
-            /*case HACHEUR_GET_ATOM:
+            case HACHEUR_GET_ATOM:
                 BRAS = msgRxBuffer[FIFO_lecture].data[0];
                 ventouse[BRAS]->action(1);
                 break;
@@ -82,26 +83,54 @@
                 can.write(CANMessage(HACHEUR_ETAT_CONTACTS,&contacts_tmp,1));
                 break;*/
                 
-            case TEST_ELECTROV_1:
-                ventouse[AR_GAUCHE]->action(1);
-                ventouse[AR_CENTRE]->action(1);
+            case TEST_VENT_1_ON:
+                ventouse[AV_DROIT]->action(1);
+                break;
+                
+            case TEST_VENT_2_ON:
+                ventouse[AV_CENTRE]->action(1);
+                break;
+                
+            case TEST_VENT_3_ON:
+                ventouse[AV_GAUCHE]->action(1);
+                break;
+                
+            case TEST_VENT_4_ON:
                 ventouse[AR_DROIT]->action(1);
                 break;
                 
-            case TEST_ELECTROV_2:
-                ventouse[AV_GAUCHE]->action(1);
-                ventouse[AV_CENTRE]->action(1);
-                ventouse[AV_DROIT]->action(1);
+            case TEST_VENT_5_ON:
+                ventouse[AR_CENTRE]->action(1);
+                break;
+                
+            case TEST_VENT_6_ON:
+                ventouse[AR_GAUCHE]->action(1);
+                break;
+            
+            case TEST_VENT_1_OFF:
+                ventouse[AV_GAUCHE]->action(0);
+                break;
+                
+            case TEST_VENT_2_OFF:
+                ventouse[AV_CENTRE]->action(0);
                 break;
                 
-            case TEST_ELECTROV_3:
+            case TEST_VENT_3_OFF:
+                ventouse[AV_DROIT]->action(0);
+                break;
+                
+            case TEST_VENT_4_OFF:
                 ventouse[AR_GAUCHE]->action(0);
+                break;
+                
+            case TEST_VENT_5_OFF:
                 ventouse[AR_CENTRE]->action(0);
+                break;
+                
+            case TEST_VENT_6_OFF:
                 ventouse[AR_DROIT]->action(0);
-                ventouse[AV_GAUCHE]->action(0);
-                ventouse[AV_CENTRE]->action(0);
-                ventouse[AV_DROIT]->action(0);
-                break;        
+                break;
+                      
             }
         FIFO_lecture=(FIFO_lecture+1)%SIZE_FIFO;
     }
@@ -113,16 +142,23 @@
     wait(1);
     
     pc.printf("\nPetit robot\n\n");
-    ventouse[AV_GAUCHE] = new Ventouse(PB_7, PB_6, PC_0, AV_GAUCHE);
+    ventouse[AR_DROIT] = new Ventouse(PB_7, PB_6, PC_0, AV_DROIT);
     ventouse[AR_CENTRE] = new Ventouse(PC_9, PA_8, PB_0, AR_CENTRE);
-    ventouse[AR_DROIT] = new Ventouse(PA_9, PA_10,  PB_1, AR_DROIT);
+    ventouse[AR_GAUCHE] = new Ventouse(PA_9, PA_10,  PB_1, AR_GAUCHE);
     
     ventouse[AV_DROIT] = new Ventouse(PA_0, PA_1, PA_4, AV_DROIT);
-    ventouse[AV_CENTRE] = new Ventouse(PC_7,PC_8 , PC_5, AV_CENTRE);
-    ventouse[AR_GAUCHE] = new Ventouse(PB_10, PB_2, PC_4, AR_GAUCHE);
+    ventouse[AV_GAUCHE] = new Ventouse(PC_7,PC_8 , PC_5, AV_GAUCHE);
+    ventouse[AV_CENTRE] = new Ventouse(PB_10, PB_2, PC_4, AR_CENTRE);
     
     pc.printf("LAUNCHED");
-    while(1) {
+    ventouse[AV_DROIT]->action(0);
+    ventouse[AV_CENTRE]->action(0);
+    ventouse[AV_GAUCHE]->action(0);
+    ventouse[AR_DROIT]->action(0);
+    ventouse[AR_CENTRE]->action(0);
+    ventouse[AR_GAUCHE]->action(0);
+    while(1) 
+    {
         canProcessRx();
         for(int i=0; i<NB_VENTOUSES; i++){
             ventouse[i]->automate();
@@ -147,14 +183,14 @@
     if(contacts != prev_contacts)
     {
         prev_contacts = contacts;
-        can.write(CANMessage(HACHEUR_ETAT_CONTACTS,&prev_contacts,1));
+        //can.write(CANMessage(HACHEUR_ETAT_CONTACTS,&prev_contacts,1));
     }
 }
 
 void get_etat_ventouses()
 {   
     CANMessage etat_ventouses = CANMessage();
-    etat_ventouses.id=HACHEUR_STATUT_VENTOUSES;      
+    //tat_ventouses.id=HACHEUR_STATUT_VENTOUSES;      
     etat_ventouses.len=2;
     etat_ventouses.format=CANStandard;
     etat_ventouses.type=CANData;