with Assert ;
with Gada.Text_IO ;
with Avion_Sol, INSA_Air ;
with Train, Tour, Pilote_Automatique, Carburant ;
procedure Mission2C is
package Txt renames GAda.Text_IO ;
package IA renames INSA_Air ;
package AS renames Avion_Sol ;
package PA renames Pilote_Automatique ;
procedure Rouler_KA is
begin
Tour.Attendre_Autorisation_Roulage ;
AS.Rouler_Vers ( Dest => 'L') ;
AS.Rouler_Vers ( Dest => 'M') ;
AS.Rouler_Vers ( Dest => 'E') ;
AS.Rouler_Vers ( Dest => 'A') ;
end Rouler_KA ;
procedure Rouler_DK is
begin
AS.Rouler_Vers ( Dest => 'N') ;
AS.Rouler_Vers ( Dest => 'P') ;
AS.Rouler_Vers ( Dest => 'M') ;
AS.Rouler_Vers ( Dest => 'L') ;
AS.Rouler_Vers ( Dest => 'K') ;
AS.Freiner ;
end Rouler_DK ;
Angle_Tour : constant Float := 360.0 ;
Demi_Tour : constant Float := Angle_Tour / 2.0 ;
function Delta_Cap (Cap_Actuel : Float ; Cap_Voulu : Float) return Float is
Resultat : Float ;
begin
Resultat := Cap_Voulu - Cap_Actuel ;
if Resultat > Demi_Tour then Resultat := Resultat - Angle_Tour ;
elsif Resultat < - Demi_Tour then Resultat := Resultat + Angle_Tour ;
end if ;
return Resultat ;
end Delta_Cap ;
procedure Tester_Delta_Cap (CapA : Float ; CapV : Float) is
begin
Txt.Put_Line (Aff => "Delta_Cap " & Float'Image( CapA ) & ", " &
Float'Image( CapV ) & " = " &
Float'Image( Delta_Cap(Cap_Actuel => CapA, Cap_Voulu => CapV)) ) ;
end Tester_Delta_Cap ;
function Caps_Egaux (Cap1 : Float ; Cap2 : Float) return Boolean is
Tolerance : constant Float := 5.0 ;
begin
return abs (Delta_Cap ( Cap_Actuel => Cap1, Cap_Voulu => Cap2)) < Tolerance ;
end Caps_Egaux ;
procedure Tester_Caps_Egaux (Cap1, Cap2 : Float) is
begin
Txt.Put (Aff => "Les caps " & Float'Image(Cap1) & " et " &
Float'Image(Cap2) & " ") ;
if Caps_Egaux(Cap1, Cap2) then
Txt.Put_Line (Aff => " sont égaux (à 5 degrés près).") ;
else
Txt.Put_Line (Aff => " ne sont pas égaux (à 5 degrés près).") ;
end if ;
end Tester_Caps_Egaux ;
procedure Orienter_En_Vol (Cible : Float) is
begin
Assert.Failif (Cond => Cible < 0.0 or Cible > Angle_Tour,
Message => "Orienter_En_Vol : cap incorrect = " & Float'Image(Cible)) ;
while not (Caps_Egaux (Cap1 => Cible, Cap2 => IA.Cap_Courant)) loop
if Delta_Cap (Cap_Actuel => IA.Cap_Courant, Cap_Voulu => Cible) < 0.0 then
INSA_Air.Positionner_Gouverne_A_Gauche ;
else
INSA_Air.Positionner_Gouverne_A_Droite ;
end if ;
end loop ;
INSA_Air.Positionner_Gouverne_A_Zero ;
end Orienter_En_Vol ;
procedure Vol_Demo is
Cap_Aller : constant Float := 295.0 ;
Cap_Retour : constant Float := 115.0 ;
Temps_Aller : constant Float := 20.0 * 60.0 ;
Temps_Retour : constant Float := 15.0 * 60.0 ;
Reacteur_Decollage : constant Integer := 8 ;
Reacteur_Vol_Croisiere : constant Integer := 6 ;
Reacteur_Atterrissage : constant Integer := 3 ;
begin
Carburant.Faire_Le_Plein ;
IA.Donner_Nom_Compagnie(Nom => "Kako-Air") ;
Rouler_KA ;
Tour.Attendre_Autorisation_Decollage ;
IA.Regler_Reacteur (Force => Reacteur_Decollage) ;
PA.Decoller ;
IA.Regler_Reacteur (Force => Reacteur_Vol_Croisiere) ;
Train.Deplacer_Train (Sens => False) ;
Orienter_En_Vol (Cible => Cap_Aller) ;
IA.Attendre(Sec => Temps_aller) ;
Orienter_En_Vol (Cible => Cap_Retour) ;
IA.Attendre(Sec => Temps_Retour) ;
IA.Regler_Reacteur (Force => Reacteur_Atterrissage) ;
Train.Deplacer_Train (Sens => True) ;
Tour.Attendre_Autorisation_Atterrissage ;
PA.Atterrir ;
Rouler_DK ;
end Vol_Demo ;
begin
Vol_Demo ;
end Mission2C ;