Anais La M et Bruno La M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mission2c.adb 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. with GAda.Text_IO ;
  2. with INSA_Air;
  3. with Train;
  4. with Avion_Sol;
  5. with Assert;
  6. with Carburant;
  7. with Pilote_Automatique;
  8. with Tour;
  9. procedure Mission2c is
  10. --
  11. -- Mission 2, partie 1 : fonction Delta_Cap
  12. --
  13. -- Cette fonction Delta_Cap est incorrecte.
  14. -- À vous de corriger son algorithme.
  15. --
  16. function Delta_Cap(Cap_Actuel : Float ; Cap_Voulu : Float) return Float is
  17. Ecart_Angle : Float ;
  18. begin
  19. Ecart_Angle := Cap_Voulu - Cap_Actuel ;
  20. if Ecart_Angle < -180.0 then
  21. Ecart_Angle := Ecart_Angle + 360.0 ;
  22. end if ;
  23. if Ecart_Angle > 180.0 then
  24. Ecart_Angle := Ecart_Angle -360.0;
  25. end if;
  26. return Ecart_Angle ;
  27. end Delta_Cap ;
  28. --
  29. -- Mission 2, partie 1 : procédure de test de Delta_Cap
  30. --
  31. -- Cette procédure est incomplète, à vous de la rendre utile.
  32. --
  33. procedure Tester_Delta_Cap(CapA : Float ; CapV : Float) is
  34. Ecart_Angle: Float;
  35. begin
  36. Ecart_Angle := Delta_Cap(Cap_Actuel => CapA, Cap_Voulu => CapV);
  37. GAda.Text_IO.Put_Line (Aff => "Le cap actuel vaut" & Float'Image(CapA) & " Le cap Voulut vaut:" & Float'Image(CapV) & " Delta Cap vaut:" & Float'Image(Ecart_Angle)) ;
  38. end Tester_Delta_Cap ;
  39. --
  40. -- Mission 2, partie 2 : fonction Caps_Egaux
  41. function Caps_Egaux(Cap1:Float; Cap2:Float) return Boolean is
  42. Dif_Cap: Float;
  43. begin
  44. Dif_Cap:= abs((Delta_Cap(Cap1 , Cap2)));
  45. return Dif_Cap <= 5.0;
  46. end Caps_Egaux;
  47. --
  48. -- Mission 2, partie 2 : procédure de test de Caps_Egaux
  49. procedure Tester_Caps_Egaux(Cap1: Float; Cap2: Float) is
  50. Rep: Boolean;
  51. begin
  52. Rep := Caps_Egaux(Cap1 , Cap2);
  53. GAda.Text_IO.Put_Line(Aff => "Ecart:" & Boolean'Image(Rep));
  54. end Tester_Caps_Egaux;
  55. --
  56. -- Mission 2, parties 1 et 2 : réalisation de plusieurs tests
  57. --
  58. procedure Tests_Unitaires is
  59. begin
  60. Tester_Delta_Cap (CapA => 0.0, CapV => 45.0) ;
  61. Tester_Delta_Cap (CapA => 45.0, CapV => 0.0) ;
  62. Tester_Delta_Cap (CapA => 350.0, CapV => 10.0) ;
  63. Tester_Delta_Cap (CapA => 10.0, CapV => 350.0) ;
  64. Tester_Delta_Cap (CapA => 30.0, CapV => 285.0) ;
  65. Tester_Delta_Cap (CapA => 178.0, CapV => 182.0) ;
  66. Tester_Caps_Egaux(Cap1 => 0.0, Cap2 => 5.0) ;
  67. Tester_Caps_Egaux(Cap1 => 2.0, Cap2 => 359.0) ;
  68. Tester_Caps_Egaux(Cap1 => 350.0, Cap2 => 10.0) ;
  69. Tester_Caps_Egaux(Cap1 => 10.0, Cap2 => 350.0) ;
  70. Tester_Caps_Egaux(Cap1 => 178.0, Cap2 => 182.0) ;
  71. -- Ajouter vos propres tests unitaires
  72. end Tests_Unitaires ;
  73. --
  74. -- Mission 2, partie 3 : procédure Orienter_au_sol
  75. procedure Orienter_Au_Sol(Cap: Float) is
  76. Cap_Bon: Boolean;
  77. Delt_Cap: Float;
  78. begin
  79. Cap_Bon:= (Cap < 0.0) or (Cap > 360.0);
  80. Assert.Failif(Cap_Bon , "Le cap demandé ne correspond pas aux attentes");
  81. INSA_Air.Regler_Reacteur(1);
  82. while not Caps_Egaux(Cap , INSA_Air.Cap_Courant) loop
  83. Delt_Cap:= Delta_Cap(INSA_Air.Cap_Courant , Cap);
  84. if Delt_Cap <0.0 then
  85. Train.Positionner_A_Gauche;
  86. elsif Delt_Cap = 0.0 then
  87. Train.Positionner_A_Zero;
  88. else
  89. Train.Positionner_A_Droite;
  90. end if;
  91. INSA_Air.Attendre(0.05);
  92. end loop;
  93. Avion_Sol.Freiner;
  94. end Orienter_Au_Sol;
  95. --
  96. --
  97. -- Mission 2, partie 3 : procédure Tester_Cap
  98. --
  99. procedure Tester_Cap is
  100. begin
  101. Avion_Sol.Rouler_Vers('L');
  102. Avion_Sol.Rouler_Vers('M');
  103. Avion_Sol.Freiner;
  104. Avion_Sol.Attendre_Entree;
  105. Mission2c.Orienter_Au_Sol(0.0);
  106. Avion_Sol.Attendre_Entree;
  107. Mission2c.Orienter_Au_Sol(90.0);
  108. Avion_Sol.Attendre_Entree;
  109. Mission2c.Orienter_Au_Sol(270.0);
  110. Avion_Sol.Attendre_Entree;
  111. Mission2c.Orienter_Au_Sol(180.0);
  112. Avion_Sol.Attendre_Entree;
  113. Avion_Sol.Rouler_Vers('L');
  114. Avion_Sol.Rouler_Vers('K');
  115. end Tester_Cap;
  116. --
  117. -- Mission 2, partie 4 : procédure Orienter_en_vol
  118. --
  119. procedure Orienter_En_Vol(Cap: Float) is
  120. Cap_Bon: Boolean;
  121. Delt_Cap: Float;
  122. begin
  123. Cap_Bon:= (Cap < 0.0) or (Cap > 360.0);
  124. Assert.Failif(Cap_Bon , "Le cap demandé ne correspond pas aux attentes");
  125. while not Caps_Egaux(Cap , INSA_Air.Cap_Courant) loop
  126. Delt_Cap:= Delta_Cap(INSA_Air.Cap_Courant , Cap);
  127. if Delt_Cap <0.0 then
  128. INSA_Air.Positionner_Gouverne_A_Gauche;
  129. elsif Delt_Cap = 0.0 then
  130. INSA_Air.Positionner_Gouverne_A_Zero;
  131. else
  132. INSA_Air.Positionner_Gouverne_A_Droite;
  133. end if;
  134. INSA_Air.Attendre(0.1);
  135. end loop;
  136. INSA_Air.Positionner_Gouverne_A_Zero;
  137. end Orienter_En_Vol;
  138. --
  139. -- Mission 2, partie 4 : procédure Realiser_Vol_Demo
  140. --
  141. procedure Realiser_Vol_Demo is
  142. begin
  143. Carburant.Faire_Le_Plein;
  144. Tour.Attendre_Autorisation_Roulage;
  145. Avion_Sol.Rouler_Vers('L');
  146. Avion_Sol.Rouler_Vers('M');
  147. Avion_Sol.Rouler_Vers('E');
  148. Avion_Sol.Rouler_Vers('A');
  149. Tour.Attendre_Autorisation_Decollage;
  150. INSA_Air.Regler_Reacteur(8);
  151. Pilote_Automatique.Decoller;
  152. INSA_Air.Regler_Reacteur(6);
  153. Train.Deplacer_Train(FALSE);
  154. Mission2c.Orienter_En_Vol(295.0);
  155. INSA_Air.Attendre(1200.0);
  156. Mission2c.Orienter_En_Vol(115.0);
  157. INSA_Air.Attendre(900.0);
  158. INSA_Air.Regler_Reacteur(3);
  159. Train.Deplacer_Train(True);
  160. Tour.Attendre_Autorisation_Atterrissage;
  161. Pilote_Automatique.Atterrir;
  162. Avion_Sol.Rouler_Vers('N');
  163. Avion_Sol.Rouler_Vers('M');
  164. Avion_Sol.Rouler_Vers('L');
  165. Avion_Sol.Rouler_Vers('K');
  166. end Realiser_Vol_Demo;
  167. begin
  168. -- Effectuer tous les tests unitaires de Delta_Cap et Caps_Egaux
  169. Tests_Unitaires ;
  170. Realiser_Vol_Demo;
  171. end Mission2c ;