Classes et code de la partie pompe du Robot 2021
Dependencies: mbed ident_crac
main.cpp@5:88ab89ab12ad, 2021-01-19 (annotated)
- Committer:
- smarecar
- Date:
- Tue Jan 19 07:11:38 2021 +0000
- Revision:
- 5:88ab89ab12ad
- Parent:
- 4:4bae30d48662
+com
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
goldmas | 0:253443d82cba | 1 | #include "bloc_8_pompe.h" |
goldmas | 4:4bae30d48662 | 2 | #include "ident_crac.h" |
goldmas | 0:253443d82cba | 3 | |
goldmas | 1:815ca6061e15 | 4 | //initialisations relatives au Bus CAN |
smarecar | 5:88ab89ab12ad | 5 | CAN bus_CAN(PB_8, PB_9, 1000000) ; //instanciation du bus CAN |
smarecar | 5:88ab89ab12ad | 6 | CANMessage commande_carte ; // creation d'une varaible de type CANMessage, instruction vennant de la carte maitre |
goldmas | 1:815ca6061e15 | 7 | int flag_reception_CAN = 0 ; |
smarecar | 5:88ab89ab12ad | 8 | //***************************************PROTOYPE DE FOCNTION************************************************ |
goldmas | 2:61ffa6e3eee5 | 9 | void interruption_reception(void) ; |
goldmas | 4:4bae30d48662 | 10 | void gestion_Message_CAN(void) ; |
goldmas | 4:4bae30d48662 | 11 | void Envoi_msg_test(void); |
goldmas | 1:815ca6061e15 | 12 | |
goldmas | 4:4bae30d48662 | 13 | //Fin de jeu |
goldmas | 4:4bae30d48662 | 14 | char end_game = 0; |
goldmas | 4:4bae30d48662 | 15 | |
smarecar | 5:88ab89ab12ad | 16 | ////instanciation du bloc_8_pompe en globale |
goldmas | 4:4bae30d48662 | 17 | bloc_8_pompe::bloc_8_pompe classe_pompe (PC_9, PA_8, PB_0, //bloc 1 |
goldmas | 0:253443d82cba | 18 | PA_9, PA_10, PB_1, //bloc 2 |
goldmas | 0:253443d82cba | 19 | PA_11, PA_15, PC_1, //bloc 3 |
goldmas | 0:253443d82cba | 20 | PB_7, PB_6, PC_0, //bloc 4 |
goldmas | 0:253443d82cba | 21 | PC_7, PC_8, PC_5, //bloc 5 |
goldmas | 0:253443d82cba | 22 | PB_10, PB_2, PC_4, //bloc 6 |
goldmas | 0:253443d82cba | 23 | PA_6, PA_5, PA_7, //bloc 7 |
goldmas | 0:253443d82cba | 24 | PA_0, PA_1, PA_4); //bloc 8 |
smarecar | 5:88ab89ab12ad | 25 | |
smarecar | 5:88ab89ab12ad | 26 | //**********************************************MAIN******************************************************** |
goldmas | 4:4bae30d48662 | 27 | |
goldmas | 4:4bae30d48662 | 28 | int main() |
goldmas | 4:4bae30d48662 | 29 | { |
goldmas | 4:4bae30d48662 | 30 | bus_CAN.attach(&interruption_reception) ; |
goldmas | 4:4bae30d48662 | 31 | |
goldmas | 1:815ca6061e15 | 32 | |
goldmas | 0:253443d82cba | 33 | |
goldmas | 0:253443d82cba | 34 | while(1) |
goldmas | 0:253443d82cba | 35 | { |
goldmas | 4:4bae30d48662 | 36 | bus_CAN(envoie); |
goldmas | 4:4bae30d48662 | 37 | //if(flag_reception_CAN) |
goldmas | 4:4bae30d48662 | 38 | // { |
goldmas | 4:4bae30d48662 | 39 | // gestion_Message_CAN() ; |
goldmas | 4:4bae30d48662 | 40 | // } |
goldmas | 4:4bae30d48662 | 41 | // |
goldmas | 4:4bae30d48662 | 42 | // if(end_game) |
goldmas | 4:4bae30d48662 | 43 | // { |
goldmas | 4:4bae30d48662 | 44 | // for (int i=0 ; i<8 ; i++) |
goldmas | 4:4bae30d48662 | 45 | // { |
goldmas | 4:4bae30d48662 | 46 | // classe_pompe.stop_pompe(i); |
goldmas | 4:4bae30d48662 | 47 | // wait_ms(10) ; |
goldmas | 4:4bae30d48662 | 48 | // } |
goldmas | 4:4bae30d48662 | 49 | // } |
goldmas | 4:4bae30d48662 | 50 | //for(int i=1 ; i<9 ; i++) |
goldmas | 4:4bae30d48662 | 51 | // { |
goldmas | 4:4bae30d48662 | 52 | classe_pompe.aspirer(2) ; |
goldmas | 4:4bae30d48662 | 53 | wait(1) ; |
goldmas | 4:4bae30d48662 | 54 | classe_pompe.relacher(2) ; |
goldmas | 4:4bae30d48662 | 55 | wait_ms(100) ; |
goldmas | 0:253443d82cba | 56 | //detrompeur_possession = classe_pompe.possession(2) ; |
goldmas | 4:4bae30d48662 | 57 | |
goldmas | 0:253443d82cba | 58 | //detrompeur_possession = classe_pompe.possession(2) ; |
goldmas | 0:253443d82cba | 59 | wait_ms(1000) ; |
goldmas | 4:4bae30d48662 | 60 | // } |
goldmas | 0:253443d82cba | 61 | |
goldmas | 0:253443d82cba | 62 | } |
goldmas | 0:253443d82cba | 63 | |
goldmas | 4:4bae30d48662 | 64 | } |
goldmas | 4:4bae30d48662 | 65 | |
smarecar | 5:88ab89ab12ad | 66 | // fonction d'interruption qui nous avertie de l'arriver d'un message via liaison bus CAN |
goldmas | 4:4bae30d48662 | 67 | void interruption_reception(void) |
goldmas | 4:4bae30d48662 | 68 | { |
goldmas | 4:4bae30d48662 | 69 | if (bus_CAN.read(commande_carte)) |
goldmas | 4:4bae30d48662 | 70 | flag_reception_CAN = 1 ; |
goldmas | 4:4bae30d48662 | 71 | } |
goldmas | 4:4bae30d48662 | 72 | |
smarecar | 5:88ab89ab12ad | 73 | // la fonction gestion_Message_CAN gere l'arriver de la consigne donner par la carte maitre et les appliques aux blocs concernes selon les identifiant recu |
goldmas | 4:4bae30d48662 | 74 | void gestion_Message_CAN(void) |
goldmas | 4:4bae30d48662 | 75 | { |
goldmas | 4:4bae30d48662 | 76 | int identifiant = commande_carte.id ; |
goldmas | 4:4bae30d48662 | 77 | char num_groupe = 1 ; |
goldmas | 4:4bae30d48662 | 78 | |
goldmas | 4:4bae30d48662 | 79 | switch (identifiant) |
goldmas | 4:4bae30d48662 | 80 | { |
goldmas | 4:4bae30d48662 | 81 | case VENT_AT: |
goldmas | 4:4bae30d48662 | 82 | num_groupe = commande_carte.data[0]; |
goldmas | 4:4bae30d48662 | 83 | classe_pompe.aspirer(num_groupe) ; |
goldmas | 4:4bae30d48662 | 84 | break; |
goldmas | 4:4bae30d48662 | 85 | |
goldmas | 4:4bae30d48662 | 86 | case VENT_RE: |
goldmas | 4:4bae30d48662 | 87 | num_groupe = commande_carte.data[0]; |
goldmas | 4:4bae30d48662 | 88 | classe_pompe.relacher(num_groupe) ; |
goldmas | 4:4bae30d48662 | 89 | break; |
goldmas | 4:4bae30d48662 | 90 | |
goldmas | 4:4bae30d48662 | 91 | case VENT_ETAT: |
goldmas | 4:4bae30d48662 | 92 | classe_pompe.etat_actuel(num_groupe) ; |
goldmas | 4:4bae30d48662 | 93 | break; |
goldmas | 4:4bae30d48662 | 94 | |
goldmas | 4:4bae30d48662 | 95 | case GLOBAL_GAME_END: |
goldmas | 4:4bae30d48662 | 96 | end_game = 1; |
goldmas | 4:4bae30d48662 | 97 | |
goldmas | 4:4bae30d48662 | 98 | break; |
goldmas | 4:4bae30d48662 | 99 | /* |
goldmas | 4:4bae30d48662 | 100 | |
goldmas | 4:4bae30d48662 | 101 | case TEST_VENT_1_ON: |
goldmas | 4:4bae30d48662 | 102 | classe_pompe[AV_DROIT]->action(1); |
goldmas | 4:4bae30d48662 | 103 | classe_pompe[AV_CENTRE]->action(1); |
goldmas | 4:4bae30d48662 | 104 | classe_pompe[AV_GAUCHE]->action(1); |
goldmas | 4:4bae30d48662 | 105 | classe_pompe[AR_DROIT]->action(1); |
goldmas | 4:4bae30d48662 | 106 | classe_pompe[AR_CENTRE]->action(1); |
goldmas | 4:4bae30d48662 | 107 | classe_pompe[AR_GAUCHE]->action(1); |
goldmas | 4:4bae30d48662 | 108 | break; |
goldmas | 4:4bae30d48662 | 109 | |
goldmas | 4:4bae30d48662 | 110 | case TEST_VENT_1_OFF: |
goldmas | 4:4bae30d48662 | 111 | classe_pompe[AV_CENTRE]->action(0); |
goldmas | 4:4bae30d48662 | 112 | classe_pompe[AV_GAUCHE]->action(0); |
goldmas | 4:4bae30d48662 | 113 | classe_pompe[AR_DROIT]->action(0); |
goldmas | 4:4bae30d48662 | 114 | classe_pompe[AR_CENTRE]->action(0); |
goldmas | 4:4bae30d48662 | 115 | classe_pompe[AR_GAUCHE]->action(0); |
goldmas | 4:4bae30d48662 | 116 | classe_pompe[AV_DROIT]->action(0); |
goldmas | 4:4bae30d48662 | 117 | break;*/ |
goldmas | 4:4bae30d48662 | 118 | default: |
goldmas | 4:4bae30d48662 | 119 | break; |
goldmas | 4:4bae30d48662 | 120 | } |
goldmas | 4:4bae30d48662 | 121 | |
goldmas | 4:4bae30d48662 | 122 | } |
smarecar | 5:88ab89ab12ad | 123 | //fonction test qui envoi un message test au bus can |
goldmas | 4:4bae30d48662 | 124 | void Envoi_msg_test(void) |
goldmas | 4:4bae30d48662 | 125 | { |
goldmas | 4:4bae30d48662 | 126 | CANMessage etat_ventouses; |
goldmas | 4:4bae30d48662 | 127 | etat_ventouses.len=2; |
goldmas | 4:4bae30d48662 | 128 | etat_ventouses.format=CANStandard; |
goldmas | 4:4bae30d48662 | 129 | etat_ventouses.type=CANData; |
goldmas | 4:4bae30d48662 | 130 | etat_ventouses.data[0]=0; |
goldmas | 4:4bae30d48662 | 131 | etat_ventouses.data[1]=1; |
goldmas | 4:4bae30d48662 | 132 | |
goldmas | 4:4bae30d48662 | 133 | can.write(etat_ventouses); |
goldmas | 0:253443d82cba | 134 | } |