carte esclave Petit Robot

Dependencies:   mbed Herkulex_Library_2019 actions_Gr ident_crac actions_Pr

Committer:
Artiom
Date:
Fri May 17 10:39:09 2019 +0000
Revision:
9:9833e788942b
Parent:
7:553f3f1c2c53
Child:
10:48c0d1b8aed9
timer sur DT meilleur echantillonage

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Artiom 0:bc74da1c502f 1 #include "mbed.h"
Artiom 0:bc74da1c502f 2 #include "ident_crac.h"
Artiom 0:bc74da1c502f 3 #include "Capteur.h"
Artiom 0:bc74da1c502f 4 #include "Actionneurs.h"
Artiom 0:bc74da1c502f 5 #include "fonctions_herkulex.h"
Artiom 1:568955af8c2b 6 #include "main.h"
Artiom 9:9833e788942b 7 #include "dt.h"
Artiom 0:bc74da1c502f 8
Artiom 0:bc74da1c502f 9 #define SIZE_FIFO 50
Artiom 0:bc74da1c502f 10
Artiom 0:bc74da1c502f 11 CAN can(PB_8,PB_9,1000000); // Rx&Tx pour le CAN
Artiom 0:bc74da1c502f 12
Artiom 0:bc74da1c502f 13
Artiom 0:bc74da1c502f 14 CANMessage msgRxBuffer[SIZE_FIFO];
Artiom 0:bc74da1c502f 15 unsigned char FIFO_ecriture=0; //Position du fifo pour la reception CAN
Artiom 0:bc74da1c502f 16 signed char FIFO_lecture=0;//Position du fifo de lecture des messages CAN
Artiom 0:bc74da1c502f 17 unsigned char EtatGameEnd=0;
Artiom 0:bc74da1c502f 18
Artiom 6:45f9cf44718a 19 char fpresentoir_avant=0, fpresentoir_arriere=0;
Artiom 6:45f9cf44718a 20 char fgoldenium_avant=0, fgoldenium_arriere=0;
Artiom 6:45f9cf44718a 21 char fsol_avant=0,fsol_arriere=0;
Artiom 7:553f3f1c2c53 22 char fsol_avant_relache=0,fsol_arriere_relache=0;
Artiom 4:4a79942713fa 23
Artiom 4:4a79942713fa 24 char status_pompe=0;
Artiom 4:4a79942713fa 25
Artiom 0:bc74da1c502f 26 void canRx_ISR (void);
Artiom 0:bc74da1c502f 27 void SendAck(unsigned short id, unsigned short from);
Artiom 0:bc74da1c502f 28 void SendRawId (unsigned short id);
Artiom 0:bc74da1c502f 29 void GoStraight (signed short distance,unsigned char recalage, unsigned short newValue, unsigned char isEnchainement);
Artiom 0:bc74da1c502f 30 void canProcessRx(void);
Artiom 6:45f9cf44718a 31
Artiom 4:4a79942713fa 32 void automate_ventouse_presentoir_avant(void);
Artiom 5:6e198cdd99ad 33 void automate_ventouse_presentoir_arriere (void);
Artiom 0:bc74da1c502f 34
Artiom 6:45f9cf44718a 35 void automate_ventouse_goldenium_avant (void);
Artiom 6:45f9cf44718a 36 void automate_ventouse_goldenium_arriere (void);
Artiom 6:45f9cf44718a 37
Artiom 6:45f9cf44718a 38 void automate_ventouse_sol_avant (void);
Artiom 6:45f9cf44718a 39 void automate_ventouse_sol_arriere(void);
Artiom 6:45f9cf44718a 40
Artiom 7:553f3f1c2c53 41 void automate_ventouse_sol_avant_relache(void);
Artiom 7:553f3f1c2c53 42 void automate_ventouse_sol_arriere_relache(void);
Artiom 0:bc74da1c502f 43 /*********************************************************************************************/
Artiom 0:bc74da1c502f 44 /* FUNCTION NAME: canRx_ISR */
Artiom 0:bc74da1c502f 45 /* DESCRIPTION : lit les messages sur le can et les stocke dans la FIFO */
Artiom 0:bc74da1c502f 46 /*********************************************************************************************/
Artiom 0:bc74da1c502f 47 void canRx_ISR (void)
Artiom 0:bc74da1c502f 48 {
Artiom 0:bc74da1c502f 49 if (can.read(msgRxBuffer[FIFO_ecriture])) {
Artiom 0:bc74da1c502f 50 if (msgRxBuffer[FIFO_ecriture].id==GLOBAL_GAME_END) {
Artiom 0:bc74da1c502f 51
Artiom 0:bc74da1c502f 52 }
Artiom 0:bc74da1c502f 53 FIFO_ecriture=(FIFO_ecriture+1)%SIZE_FIFO;
Artiom 0:bc74da1c502f 54
Artiom 0:bc74da1c502f 55 }
Artiom 0:bc74da1c502f 56
Artiom 0:bc74da1c502f 57 }
Artiom 0:bc74da1c502f 58 /*********************************************************************************************/
Artiom 0:bc74da1c502f 59 /* FUNCTION NAME: SendAck */
Artiom 0:bc74da1c502f 60 /* DESCRIPTION : */
Artiom 0:bc74da1c502f 61 /*********************************************************************************************/
Artiom 0:bc74da1c502f 62 void SendAck(unsigned short from, unsigned short id) //FROM et ID sont inversés pour convenir à la lecture d'ACK de la carte principale
Artiom 0:bc74da1c502f 63 {
Artiom 0:bc74da1c502f 64 CANMessage msgTx=CANMessage();
Artiom 0:bc74da1c502f 65 msgTx.id=from; //waitingAckFrom
Artiom 0:bc74da1c502f 66 msgTx.len=2;
Artiom 0:bc74da1c502f 67 msgTx.format=CANStandard;
Artiom 0:bc74da1c502f 68 msgTx.type=CANData;
Artiom 0:bc74da1c502f 69 // from sur 2 octets
Artiom 0:bc74da1c502f 70 msgTx.data[0]=(unsigned char)id; //waitingAckID
Artiom 0:bc74da1c502f 71 msgTx.data[1]=(unsigned char)(id>>8);
Artiom 0:bc74da1c502f 72 can.write(msgTx);
Artiom 0:bc74da1c502f 73 }
Artiom 0:bc74da1c502f 74 /*********************************************************************************************/
Artiom 0:bc74da1c502f 75 /* FUNCTION NAME: SendRawId */
Artiom 0:bc74da1c502f 76 /* DESCRIPTION : */
Artiom 0:bc74da1c502f 77 /*********************************************************************************************/
Artiom 0:bc74da1c502f 78 void SendRawId (unsigned short id)
Artiom 0:bc74da1c502f 79 {
Artiom 0:bc74da1c502f 80 CANMessage msgTx=CANMessage();
Artiom 0:bc74da1c502f 81 msgTx.id=id;
Artiom 0:bc74da1c502f 82 msgTx.len=0;
Artiom 0:bc74da1c502f 83 can.write(msgTx); //carte esclave f446re
Artiom 0:bc74da1c502f 84 wait_us(200);
Artiom 0:bc74da1c502f 85 }
Artiom 0:bc74da1c502f 86
Artiom 0:bc74da1c502f 87 /*********************************************************************************************/
Artiom 0:bc74da1c502f 88 /* FUNCTION NAME: GoStraight */
Artiom 0:bc74da1c502f 89 /* DESCRIPTION : Transmission CAN correspondant à une ligne droite, avec ou sans recalage */
Artiom 0:bc74da1c502f 90 /* recalage : 0 => pas de recalage */
Artiom 0:bc74da1c502f 91 /* 1 => recalage en X */
Artiom 0:bc74da1c502f 92 /* 2 => Recalage en Y */
Artiom 0:bc74da1c502f 93 /* newValue : Uniquement en cas de recalage, indique la nouvelle valeur de l'odo */
Artiom 0:bc74da1c502f 94 /* isEnchainement : Indique si il faut executer l'instruction en enchainement */
Artiom 0:bc74da1c502f 95 /* 0 => non */
Artiom 0:bc74da1c502f 96 /* 1 => oui */
Artiom 0:bc74da1c502f 97 /* 2 => dernière instruction de l'enchainement */
Artiom 0:bc74da1c502f 98 /*********************************************************************************************/
Artiom 0:bc74da1c502f 99 void GoStraight (signed short distance,unsigned char recalage, unsigned short newValue, unsigned char isEnchainement)
Artiom 0:bc74da1c502f 100 {
Artiom 0:bc74da1c502f 101 CANMessage msgTx=CANMessage();
Artiom 0:bc74da1c502f 102 msgTx.id=ASSERVISSEMENT_RECALAGE;
Artiom 0:bc74da1c502f 103 msgTx.len=6;
Artiom 0:bc74da1c502f 104 msgTx.format=CANStandard;
Artiom 0:bc74da1c502f 105 msgTx.type=CANData;
Artiom 0:bc74da1c502f 106 // x sur 2 octets
Artiom 0:bc74da1c502f 107 msgTx.data[0]=(unsigned char)distance;
Artiom 0:bc74da1c502f 108 msgTx.data[1]=(unsigned char)(distance>>8);
Artiom 0:bc74da1c502f 109 //Recalage sur 1 octet
Artiom 0:bc74da1c502f 110 msgTx.data[2]=recalage;
Artiom 0:bc74da1c502f 111 //Valeur du recalage sur 2 octets
Artiom 0:bc74da1c502f 112 msgTx.data[3]=(unsigned char)newValue;
Artiom 0:bc74da1c502f 113 msgTx.data[4]=(unsigned char)(newValue>>8);
Artiom 0:bc74da1c502f 114 //Enchainement sur 1 octet
Artiom 0:bc74da1c502f 115 msgTx.data[5]=isEnchainement;
Artiom 0:bc74da1c502f 116
Artiom 0:bc74da1c502f 117 can.write(msgTx);
Artiom 0:bc74da1c502f 118 //wait_ms(500);
Artiom 0:bc74da1c502f 119 }
Artiom 0:bc74da1c502f 120
Artiom 0:bc74da1c502f 121 int main()
Artiom 0:bc74da1c502f 122 {
Artiom 0:bc74da1c502f 123 can.attach(&canRx_ISR); // création de l'interrupt attachée à la réception sur le CAN
Artiom 0:bc74da1c502f 124 servo_interrupt_en(); //permettre les interuptions
Artiom 0:bc74da1c502f 125 wait(1);//attente servo boot
Artiom 2:9e63099cca99 126 gabarit_petit_robot();
Artiom 0:bc74da1c502f 127
Artiom 0:bc74da1c502f 128 while(1) {
Artiom 0:bc74da1c502f 129 canProcessRx();
Artiom 9:9833e788942b 130 f_mesure();
Artiom 4:4a79942713fa 131 automate_ventouse_presentoir_avant();
Artiom 5:6e198cdd99ad 132 automate_ventouse_presentoir_arriere();
Artiom 7:553f3f1c2c53 133
Artiom 6:45f9cf44718a 134 automate_ventouse_goldenium_avant();
Artiom 6:45f9cf44718a 135 automate_ventouse_goldenium_arriere();
Artiom 7:553f3f1c2c53 136
Artiom 6:45f9cf44718a 137 automate_ventouse_sol_avant();
Artiom 7:553f3f1c2c53 138 automate_ventouse_sol_arriere();
Artiom 7:553f3f1c2c53 139
Artiom 0:bc74da1c502f 140 if(EtatGameEnd==1) {
Artiom 0:bc74da1c502f 141 while(1);
Artiom 0:bc74da1c502f 142 }
Artiom 0:bc74da1c502f 143
Artiom 0:bc74da1c502f 144 }
Artiom 0:bc74da1c502f 145 }
Artiom 0:bc74da1c502f 146
Artiom 0:bc74da1c502f 147 /****************************************************************************************/
Artiom 0:bc74da1c502f 148 /* FUNCTION NAME: canProcessRx */
Artiom 0:bc74da1c502f 149 /* DESCRIPTION : Fonction de traitement des messages CAN */
Artiom 0:bc74da1c502f 150 /****************************************************************************************/
Artiom 0:bc74da1c502f 151 void canProcessRx(void)
Artiom 0:bc74da1c502f 152 {
Artiom 0:bc74da1c502f 153 static signed char FIFO_occupation=0,FIFO_max_occupation=0;
Artiom 0:bc74da1c502f 154 CANMessage msgTx=CANMessage();
Artiom 0:bc74da1c502f 155 FIFO_occupation=FIFO_ecriture-FIFO_lecture;
Artiom 0:bc74da1c502f 156 if(FIFO_occupation<0)
Artiom 0:bc74da1c502f 157 FIFO_occupation=FIFO_occupation+SIZE_FIFO;
Artiom 0:bc74da1c502f 158 if(FIFO_max_occupation<FIFO_occupation)
Artiom 0:bc74da1c502f 159 FIFO_max_occupation=FIFO_occupation;
Artiom 0:bc74da1c502f 160 if(FIFO_occupation!=0) {
Artiom 0:bc74da1c502f 161 int identifiant=msgRxBuffer[FIFO_lecture].id;
Artiom 0:bc74da1c502f 162
Artiom 0:bc74da1c502f 163 switch(identifiant) {
Artiom 0:bc74da1c502f 164
Artiom 0:bc74da1c502f 165 case GLOBAL_GAME_END:
Artiom 0:bc74da1c502f 166 EtatGameEnd = 1;
Artiom 0:bc74da1c502f 167 break;
Artiom 0:bc74da1c502f 168
Artiom 0:bc74da1c502f 169 case DATA_TELEMETRE: //Lit le telemetre N°X suivant la data dans le CAN
Artiom 0:bc74da1c502f 170 char numero_telemetre=msgRxBuffer[FIFO_lecture].data[0];
Artiom 0:bc74da1c502f 171 short distance=lecture_telemetre(numero_telemetre);
Artiom 0:bc74da1c502f 172
Artiom 0:bc74da1c502f 173
Artiom 0:bc74da1c502f 174 msgTx.id=RECEPTION_DATA; // tx Valeur Telemetre1
Artiom 0:bc74da1c502f 175 msgTx.len=2;
Artiom 0:bc74da1c502f 176 msgTx.format=CANStandard;
Artiom 0:bc74da1c502f 177 msgTx.type=CANData;
Artiom 0:bc74da1c502f 178 // Rayon sur 2 octets
Artiom 0:bc74da1c502f 179 msgTx.data[0]=(unsigned char)distance;
Artiom 0:bc74da1c502f 180 msgTx.data[1]=(unsigned char)(distance>>8);
Artiom 0:bc74da1c502f 181
Artiom 0:bc74da1c502f 182 can.write(msgTx);
Artiom 0:bc74da1c502f 183 SendAck(ACKNOWLEDGE_TELEMETRE,RECEPTION_DATA);
Artiom 0:bc74da1c502f 184 break;
Artiom 0:bc74da1c502f 185
Artiom 0:bc74da1c502f 186 case DATA_RECALAGE:
Artiom 0:bc74da1c502f 187 short distance1=lecture_telemetre(1);
Artiom 0:bc74da1c502f 188 short distance2=lecture_telemetre(2);
Artiom 0:bc74da1c502f 189 short distance3=lecture_telemetre(3);
Artiom 0:bc74da1c502f 190 short distance4=lecture_telemetre(4);
Artiom 0:bc74da1c502f 191
Artiom 0:bc74da1c502f 192 msgTx.id=RECEPTION_RECALAGE; // tx Valeur Telemetre1
Artiom 0:bc74da1c502f 193 msgTx.len=8;
Artiom 0:bc74da1c502f 194 msgTx.format=CANStandard;
Artiom 0:bc74da1c502f 195 msgTx.type=CANData;
Artiom 0:bc74da1c502f 196 // Rayon sur 2 octets
Artiom 0:bc74da1c502f 197 msgTx.data[0]=(unsigned char)distance1;
Artiom 0:bc74da1c502f 198 msgTx.data[1]=(unsigned char)(distance1>>8);
Artiom 0:bc74da1c502f 199 msgTx.data[2]=(unsigned char)distance2;
Artiom 0:bc74da1c502f 200 msgTx.data[3]=(unsigned char)(distance2>>8);
Artiom 0:bc74da1c502f 201 msgTx.data[4]=(unsigned char)distance3;
Artiom 0:bc74da1c502f 202 msgTx.data[5]=(unsigned char)(distance3>>8);
Artiom 0:bc74da1c502f 203 msgTx.data[6]=(unsigned char)distance4;
Artiom 0:bc74da1c502f 204 msgTx.data[7]=(unsigned char)(distance4>>8);
Artiom 0:bc74da1c502f 205 can.write(msgTx);
Artiom 0:bc74da1c502f 206 SendAck(ACKNOWLEDGE_TELEMETRE,RECEPTION_RECALAGE);
Artiom 0:bc74da1c502f 207 break;
Artiom 0:bc74da1c502f 208
Artiom 0:bc74da1c502f 209 #ifdef ROBOT_SMALL
Artiom 4:4a79942713fa 210 //-------------------------------------------------------------------------Actions petit robot----------------------------------------------
Artiom 2:9e63099cca99 211 case GABARIT_PETIT_ROBOT:
Artiom 2:9e63099cca99 212 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 2:9e63099cca99 213 gabarit_petit_robot();
Artiom 2:9e63099cca99 214 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 0:bc74da1c502f 215 break;
Artiom 0:bc74da1c502f 216
Artiom 0:bc74da1c502f 217 case PRESENTOIR_AVANT:
Artiom 4:4a79942713fa 218 fpresentoir_avant=1;
Artiom 0:bc74da1c502f 219 break;
Artiom 0:bc74da1c502f 220
Artiom 0:bc74da1c502f 221 case PRESENTOIR_ARRIERE:
Artiom 5:6e198cdd99ad 222 fpresentoir_arriere=1;
Artiom 0:bc74da1c502f 223 break;
Artiom 0:bc74da1c502f 224
Artiom 0:bc74da1c502f 225 case BALANCE_AVANT:
Artiom 2:9e63099cca99 226 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 0:bc74da1c502f 227 balance_avant();
Artiom 2:9e63099cca99 228 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 0:bc74da1c502f 229 break;
Artiom 0:bc74da1c502f 230
Artiom 0:bc74da1c502f 231 case BALANCE_ARRIERE:
Artiom 2:9e63099cca99 232 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 0:bc74da1c502f 233 balance_arriere();
Artiom 2:9e63099cca99 234 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 2:9e63099cca99 235 break;
Artiom 2:9e63099cca99 236
Artiom 2:9e63099cca99 237 case ACCELERATEUR_AVANT:
Artiom 2:9e63099cca99 238 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 2:9e63099cca99 239 accelerateur_avant();
Artiom 2:9e63099cca99 240 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 2:9e63099cca99 241 break;
Artiom 2:9e63099cca99 242
Artiom 2:9e63099cca99 243 case ACCELERATEUR_ARRIERE:
Artiom 2:9e63099cca99 244 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 2:9e63099cca99 245 accelerateur_arriere();
Artiom 2:9e63099cca99 246 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 2:9e63099cca99 247 break;
Artiom 6:45f9cf44718a 248
Artiom 2:9e63099cca99 249 case GOLDENIUM_AVANT:
Artiom 6:45f9cf44718a 250 fgoldenium_avant=1;
Artiom 2:9e63099cca99 251 break;
Artiom 2:9e63099cca99 252
Artiom 2:9e63099cca99 253 case GOLDENIUM_ARRIERE:
Artiom 6:45f9cf44718a 254 fgoldenium_arriere=1;
Artiom 2:9e63099cca99 255 break;
Artiom 6:45f9cf44718a 256
Artiom 2:9e63099cca99 257 case SOL_AVANT:
Artiom 6:45f9cf44718a 258 fsol_avant=1;
Artiom 2:9e63099cca99 259 break;
Artiom 2:9e63099cca99 260
Artiom 2:9e63099cca99 261 case SOL_ARRIERE:
Artiom 6:45f9cf44718a 262 fsol_arriere=1;
Artiom 2:9e63099cca99 263 break;
Artiom 2:9e63099cca99 264
Artiom 2:9e63099cca99 265 case SOL_AVANT_RELACHE:
Artiom 7:553f3f1c2c53 266 fsol_avant_relache=1;
Artiom 2:9e63099cca99 267 break;
Artiom 2:9e63099cca99 268
Artiom 2:9e63099cca99 269 case SOL_ARRIERE_RELACHE:
Artiom 7:553f3f1c2c53 270 fsol_arriere_relache=1;
Artiom 0:bc74da1c502f 271 break;
Artiom 4:4a79942713fa 272 //--------------------------------------------------------------------------ACK carte pompe----------------------------------------------
Artiom 4:4a79942713fa 273
Artiom 4:4a79942713fa 274
Artiom 4:4a79942713fa 275 case HACHEUR_STATUT_VENTOUSES:
Artiom 4:4a79942713fa 276 status_pompe = msgRxBuffer[FIFO_lecture].data[1];
Artiom 5:6e198cdd99ad 277 //can.write(CANMessage(0x529, &status_pompe,1));
Artiom 4:4a79942713fa 278 break;
Artiom 4:4a79942713fa 279
Artiom 4:4a79942713fa 280 case HACHEUR_GET_ATOM_ACK:
Artiom 4:4a79942713fa 281 status_pompe |= (0x01 << msgRxBuffer[FIFO_lecture].data[0]);
Artiom 5:6e198cdd99ad 282 //can.write(CANMessage(0x529, &status_pompe,1));
Artiom 4:4a79942713fa 283 break;
Artiom 4:4a79942713fa 284
Artiom 4:4a79942713fa 285 case HACHEUR_RELEASE_ATOM_ACK :
Artiom 4:4a79942713fa 286 status_pompe &= ~(0x01 << msgRxBuffer[FIFO_lecture].data[0]);
Artiom 4:4a79942713fa 287 break;
Artiom 4:4a79942713fa 288 //-------------------------------------------------------------------------------------------------------------------------------------------
Artiom 4:4a79942713fa 289
Artiom 0:bc74da1c502f 290
Artiom 0:bc74da1c502f 291 #endif
Artiom 0:bc74da1c502f 292 #ifdef ROBOT_BIG
Artiom 0:bc74da1c502f 293 case 3:
Artiom 0:bc74da1c502f 294
Artiom 0:bc74da1c502f 295 break;
Artiom 0:bc74da1c502f 296
Artiom 0:bc74da1c502f 297 case 5:
Artiom 0:bc74da1c502f 298
Artiom 0:bc74da1c502f 299 break;
Artiom 0:bc74da1c502f 300
Artiom 0:bc74da1c502f 301 #endif
Artiom 0:bc74da1c502f 302 }
Artiom 0:bc74da1c502f 303 FIFO_lecture=(FIFO_lecture+1)%SIZE_FIFO;
Artiom 0:bc74da1c502f 304
Artiom 0:bc74da1c502f 305 }
Artiom 4:4a79942713fa 306
Artiom 4:4a79942713fa 307
Artiom 4:4a79942713fa 308 }
Artiom 4:4a79942713fa 309
Artiom 4:4a79942713fa 310 void automate_ventouse_presentoir_avant (void)
Artiom 4:4a79942713fa 311 {
Artiom 4:4a79942713fa 312
Artiom 4:4a79942713fa 313 typedef enum {init,envoi_instruction,attente_ack_ventouse} type_etat;
Artiom 4:4a79942713fa 314 static type_etat etat = init;
Artiom 4:4a79942713fa 315
Artiom 4:4a79942713fa 316 switch(etat) {
Artiom 4:4a79942713fa 317 case init: //attente d'initialisation
Artiom 4:4a79942713fa 318 if(fpresentoir_avant)
Artiom 4:4a79942713fa 319 etat=envoi_instruction;
Artiom 4:4a79942713fa 320 break;
Artiom 4:4a79942713fa 321
Artiom 4:4a79942713fa 322 case envoi_instruction://envoi instruction
Artiom 4:4a79942713fa 323 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 4:4a79942713fa 324 presentoir_avant();
Artiom 5:6e198cdd99ad 325 SendRawId(HACHEUR_STATUT_VENTOUSES);
Artiom 4:4a79942713fa 326 etat = attente_ack_ventouse;
Artiom 4:4a79942713fa 327 break;
Artiom 4:4a79942713fa 328
Artiom 4:4a79942713fa 329 case attente_ack_ventouse:
Artiom 5:6e198cdd99ad 330 if((status_pompe&MASK_PRESENTOIR_AV)==MASK_PRESENTOIR_AV) {
Artiom 4:4a79942713fa 331 fpresentoir_avant=0;
Artiom 5:6e198cdd99ad 332 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 4:4a79942713fa 333 etat = init;
Artiom 5:6e198cdd99ad 334 }
Artiom 5:6e198cdd99ad 335 break;
Artiom 5:6e198cdd99ad 336
Artiom 5:6e198cdd99ad 337 }
Artiom 5:6e198cdd99ad 338 }
Artiom 5:6e198cdd99ad 339 void automate_ventouse_presentoir_arriere (void)
Artiom 5:6e198cdd99ad 340 {
Artiom 5:6e198cdd99ad 341
Artiom 5:6e198cdd99ad 342 typedef enum {init,envoi_instruction,attente_ack_ventouse} type_etat;
Artiom 5:6e198cdd99ad 343 static type_etat etat = init;
Artiom 5:6e198cdd99ad 344
Artiom 5:6e198cdd99ad 345 switch(etat) {
Artiom 5:6e198cdd99ad 346 case init: //attente d'initialisation
Artiom 5:6e198cdd99ad 347 if(fpresentoir_arriere)
Artiom 5:6e198cdd99ad 348 etat=envoi_instruction;
Artiom 5:6e198cdd99ad 349 break;
Artiom 5:6e198cdd99ad 350
Artiom 5:6e198cdd99ad 351 case envoi_instruction://envoi instruction
Artiom 5:6e198cdd99ad 352 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 5:6e198cdd99ad 353 presentoir_arriere();
Artiom 5:6e198cdd99ad 354 SendRawId(HACHEUR_STATUT_VENTOUSES);
Artiom 5:6e198cdd99ad 355 etat = attente_ack_ventouse;
Artiom 5:6e198cdd99ad 356 break;
Artiom 5:6e198cdd99ad 357
Artiom 5:6e198cdd99ad 358 case attente_ack_ventouse:
Artiom 5:6e198cdd99ad 359 if((status_pompe&MASK_PRESENTOIR_AR)==MASK_PRESENTOIR_AR) {
Artiom 5:6e198cdd99ad 360 fpresentoir_arriere=0;
Artiom 5:6e198cdd99ad 361 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 5:6e198cdd99ad 362 etat = init;
Artiom 4:4a79942713fa 363 }
Artiom 4:4a79942713fa 364 break;
Artiom 4:4a79942713fa 365
Artiom 4:4a79942713fa 366 }
Artiom 6:45f9cf44718a 367 }
Artiom 6:45f9cf44718a 368 void automate_ventouse_goldenium_avant (void)
Artiom 6:45f9cf44718a 369 {
Artiom 4:4a79942713fa 370
Artiom 6:45f9cf44718a 371 typedef enum {init,envoi_instruction,attente_ack_ventouse} type_etat;
Artiom 6:45f9cf44718a 372 static type_etat etat = init;
Artiom 6:45f9cf44718a 373
Artiom 6:45f9cf44718a 374 switch(etat) {
Artiom 6:45f9cf44718a 375 case init: //attente d'initialisation
Artiom 6:45f9cf44718a 376 if(fgoldenium_avant)
Artiom 6:45f9cf44718a 377 etat=envoi_instruction;
Artiom 6:45f9cf44718a 378 break;
Artiom 6:45f9cf44718a 379
Artiom 6:45f9cf44718a 380 case envoi_instruction://envoi instruction
Artiom 6:45f9cf44718a 381 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 6:45f9cf44718a 382 goldenium_avant();
Artiom 6:45f9cf44718a 383 SendRawId(HACHEUR_STATUT_VENTOUSES);
Artiom 6:45f9cf44718a 384 etat = attente_ack_ventouse;
Artiom 6:45f9cf44718a 385 break;
Artiom 6:45f9cf44718a 386
Artiom 6:45f9cf44718a 387 case attente_ack_ventouse:
Artiom 6:45f9cf44718a 388 if((status_pompe&MASK_GOLDENIUM_AV)== MASK_GOLDENIUM_AV) {
Artiom 6:45f9cf44718a 389 fgoldenium_avant=0;
Artiom 6:45f9cf44718a 390 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 6:45f9cf44718a 391 etat = init;
Artiom 6:45f9cf44718a 392 }
Artiom 6:45f9cf44718a 393 break;
Artiom 6:45f9cf44718a 394
Artiom 6:45f9cf44718a 395 }
Artiom 6:45f9cf44718a 396 }
Artiom 6:45f9cf44718a 397
Artiom 6:45f9cf44718a 398 void automate_ventouse_goldenium_arriere (void)
Artiom 6:45f9cf44718a 399 {
Artiom 6:45f9cf44718a 400
Artiom 6:45f9cf44718a 401 typedef enum {init,envoi_instruction,attente_ack_ventouse} type_etat;
Artiom 6:45f9cf44718a 402 static type_etat etat = init;
Artiom 6:45f9cf44718a 403
Artiom 6:45f9cf44718a 404 switch(etat) {
Artiom 6:45f9cf44718a 405 case init: //attente d'initialisation
Artiom 6:45f9cf44718a 406 if(fgoldenium_arriere)
Artiom 6:45f9cf44718a 407 etat=envoi_instruction;
Artiom 6:45f9cf44718a 408 break;
Artiom 6:45f9cf44718a 409
Artiom 6:45f9cf44718a 410 case envoi_instruction://envoi instruction
Artiom 6:45f9cf44718a 411 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 6:45f9cf44718a 412 goldenium_arriere();
Artiom 6:45f9cf44718a 413 SendRawId(HACHEUR_STATUT_VENTOUSES);
Artiom 6:45f9cf44718a 414 etat = attente_ack_ventouse;
Artiom 6:45f9cf44718a 415 break;
Artiom 6:45f9cf44718a 416
Artiom 6:45f9cf44718a 417 case attente_ack_ventouse:
Artiom 6:45f9cf44718a 418 if((status_pompe&MASK_GOLDENIUM_AR)== MASK_GOLDENIUM_AR) {
Artiom 6:45f9cf44718a 419 fgoldenium_arriere=0;
Artiom 6:45f9cf44718a 420 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 6:45f9cf44718a 421 etat = init;
Artiom 6:45f9cf44718a 422 }
Artiom 6:45f9cf44718a 423 break;
Artiom 6:45f9cf44718a 424
Artiom 6:45f9cf44718a 425 }
Artiom 6:45f9cf44718a 426
Artiom 6:45f9cf44718a 427
Artiom 6:45f9cf44718a 428 }
Artiom 6:45f9cf44718a 429
Artiom 6:45f9cf44718a 430 void automate_ventouse_sol_avant (void)
Artiom 6:45f9cf44718a 431 {
Artiom 6:45f9cf44718a 432
Artiom 6:45f9cf44718a 433 typedef enum {init,envoi_instruction,attente_ack_ventouse} type_etat;
Artiom 6:45f9cf44718a 434 static type_etat etat = init;
Artiom 6:45f9cf44718a 435
Artiom 6:45f9cf44718a 436 switch(etat) {
Artiom 6:45f9cf44718a 437 case init: //attente d'initialisation
Artiom 6:45f9cf44718a 438 if(fsol_avant)
Artiom 6:45f9cf44718a 439 etat=envoi_instruction;
Artiom 6:45f9cf44718a 440 break;
Artiom 6:45f9cf44718a 441
Artiom 6:45f9cf44718a 442 case envoi_instruction://envoi instruction
Artiom 6:45f9cf44718a 443 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 6:45f9cf44718a 444 sol_avant_baisser();
Artiom 6:45f9cf44718a 445 SendRawId(HACHEUR_STATUT_VENTOUSES);
Artiom 6:45f9cf44718a 446 etat = attente_ack_ventouse;
Artiom 6:45f9cf44718a 447 break;
Artiom 6:45f9cf44718a 448
Artiom 6:45f9cf44718a 449 case attente_ack_ventouse:
Artiom 6:45f9cf44718a 450 if((status_pompe&MASK_SOL_AV)== MASK_SOL_AV) {
Artiom 6:45f9cf44718a 451 sol_avant_remonter();
Artiom 6:45f9cf44718a 452 fsol_avant=0;
Artiom 6:45f9cf44718a 453 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 6:45f9cf44718a 454 etat = init;
Artiom 6:45f9cf44718a 455 }
Artiom 6:45f9cf44718a 456 break;
Artiom 6:45f9cf44718a 457
Artiom 6:45f9cf44718a 458 }
Artiom 6:45f9cf44718a 459
Artiom 6:45f9cf44718a 460
Artiom 6:45f9cf44718a 461 }
Artiom 6:45f9cf44718a 462 void automate_ventouse_sol_arriere (void)
Artiom 6:45f9cf44718a 463 {
Artiom 6:45f9cf44718a 464
Artiom 6:45f9cf44718a 465 typedef enum {init,envoi_instruction,attente_ack_ventouse} type_etat;
Artiom 6:45f9cf44718a 466 static type_etat etat = init;
Artiom 6:45f9cf44718a 467
Artiom 6:45f9cf44718a 468 switch(etat) {
Artiom 6:45f9cf44718a 469 case init: //attente d'initialisation
Artiom 6:45f9cf44718a 470 if(fsol_arriere)
Artiom 6:45f9cf44718a 471 etat=envoi_instruction;
Artiom 6:45f9cf44718a 472 break;
Artiom 6:45f9cf44718a 473
Artiom 6:45f9cf44718a 474 case envoi_instruction://envoi instruction
Artiom 6:45f9cf44718a 475 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 6:45f9cf44718a 476 sol_arriere_baisser();
Artiom 6:45f9cf44718a 477 SendRawId(HACHEUR_STATUT_VENTOUSES);
Artiom 6:45f9cf44718a 478 etat = attente_ack_ventouse;
Artiom 6:45f9cf44718a 479 break;
Artiom 6:45f9cf44718a 480
Artiom 6:45f9cf44718a 481 case attente_ack_ventouse:
Artiom 6:45f9cf44718a 482 if((status_pompe&MASK_SOL_AR)== MASK_SOL_AR) {
Artiom 6:45f9cf44718a 483 sol_arriere_remonter();
Artiom 6:45f9cf44718a 484 fsol_arriere=0;
Artiom 6:45f9cf44718a 485 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 6:45f9cf44718a 486 etat = init;
Artiom 6:45f9cf44718a 487 }
Artiom 6:45f9cf44718a 488 break;
Artiom 6:45f9cf44718a 489
Artiom 6:45f9cf44718a 490 }
Artiom 4:4a79942713fa 491
Artiom 4:4a79942713fa 492
Artiom 0:bc74da1c502f 493 }