Added last comments

This commit is contained in:
Raphael Lacroix 2020-05-31 22:33:10 +02:00
parent 64df900239
commit a6281aafa1

View file

@ -76,8 +76,8 @@ procedure td is
Good : Boolean := True; -- if it stays good all along then it's good else it's not Good : Boolean := True; -- if it stays good all along then it's good else it's not
begin begin
for I in 1 .. Fiche.NB_Palanquees loop for I in 1 .. Fiche.NB_Palanquees loop
if Fiche.Tab_Palanquees(I).Duree_Reelle_Fond >= Fiche.Temps_Plongee_Max_Autorise then if Fiche.Tab_Palanquees(I).Duree_Reelle_Fond >= Fiche.Temps_Plongee_Max_Autorise then -- if the length of the plongee was greater than the authorized time we set good to false
Good := False; Good := False; -- therefore as soon as there is one palanquee that got past the limit it is and will remain false
end if; end if;
end loop; end loop;
return Good; return Good;
@ -85,14 +85,13 @@ procedure td is
function Profondeur_Max(Table: T_palanq) return Integer is function Profondeur_Max(Table: T_palanq) return Integer is
I : Integer := 0; I : Integer := 0; -- to go through the table
Max : Integer := 0; Max : Integer := 0; -- to be returned
NB_Max_Plongeurs: constant Integer := 10; -- Not explicitely given so I figured out I'll put it to be 10
begin begin
for I in 0 .. Max_Plongeurs loop for I in 0 .. Max_Plongeurs loop
if Table.Plongeurs(I).Profondeur_Max_Autorisee < Max then -- it's smaller than because if smone can't go further the it become the new max if Table.Plongeurs(I).Profondeur_Max_Autorisee < Max then -- it's smaller than because if smone can't go further it becomes the new maximum allowed
Max := Table.Plongeurs(I).Profondeur_Max_Autorisee; Max := Table.Plongeurs(I).Profondeur_Max_Autorisee;
end if; end if;
end loop; end loop;
@ -101,22 +100,24 @@ procedure td is
end Profondeur_Max; end Profondeur_Max;
function Profondeur_Fiche_OK(Fiche: T_Fiche_Secu) return Boolean is function Profondeur_Fiche_OK(Fiche: T_Fiche_Secu) return Boolean is
I : Integer := 1; I : Integer := 1; -- to go through the table
Good : Boolean := True; Good : Boolean := True; -- to be returned
begin begin
for I in 1 .. Fiche.NB_Palanquees loop for I in 1 .. Fiche.NB_Palanquees loop
if Fiche.Tab_Palanquees(I).Profondeur_Reelle >= Profondeur_Max(Fiche.Tab_Palanquees(I)) then if Fiche.Tab_Palanquees(I).Profondeur_Reelle >= Profondeur_Max(Fiche.Tab_Palanquees(I)) then -- if the length of the plongee was greater than the authorized time we set good to false
Good := False; Good := False; -- therefore as soon as there is one palanquee that got past the limit it is and will remain false
end if; end if;
end loop; end loop;
return Good; return Good;
end Profondeur_Fiche_OK; end Profondeur_Fiche_OK;
-- The answer to the question of the universe life and everything is ... 42
-- TD 3 -- TD 3
-- Q1: exmample of events: -- Q1: exmample of events:
--the race starts and the guys jumps
-- (Signal_Feu:32400.0) -- (Signal_Feu:32400.0)
-- (Plot,2,32400.8) -- (Plot,2,32400.8)
-- (Plot,3,32400.9) -- (Plot,3,32400.9)
@ -124,7 +125,7 @@ procedure td is
-- (Sud,3,32420.8) -- (Sud,3,32420.8)
-- (Sud,2,32421.8) -- (Sud,2,32421.8)
-- (Sud,2,32421.85) -- (Sud,2,32421.85) -- note there was an error here because of the capteur's bug
-- (Sud,2,32421.90) -- (Sud,2,32421.90)
-- (Sud,1,32423.8) -- (Sud,1,32423.8)
@ -143,15 +144,15 @@ procedure td is
procedure Course is procedure Course is
Temp: Float := 0.0; Temp: Float := 0.0; -- there to store a value
Rank: Integer := 0; Rank: Integer := 0;
Sorted: Boolean := False; Sorted: Boolean := False; -- there to store the state of sorting of the array at the end
J : Integer := 0; J : Integer := 0;-- there to increment
I : Integer := 0; I : Integer := 0;-- there to increment
NB_Swimmer: Integer :=8; -- could be more; NB_Swimmer: Integer :=8; -- could be more;
Running : Boolean:= True; Running : Boolean:= True;
Event : T_Evenement; Event : T_Evenement;
TDepart : Float := 0.0; TDepart : Float := 0.0; -- the time of the start of the race
type T_TableTime is array (1..NB_Swimmer, 1..4) of Float; --time of the nth swimmer at 1: Start, 2:50 m, 3 finish, 4, the last time it reached a Nord base type T_TableTime is array (1..NB_Swimmer, 1..4) of Float; --time of the nth swimmer at 1: Start, 2:50 m, 3 finish, 4, the last time it reached a Nord base
type T_TableNum is array (1..NB_Swimmer) of Integer; -- number of times the nth swimmer did a 50m type T_TableNum is array (1..NB_Swimmer) of Integer; -- number of times the nth swimmer did a 50m
type T_TableArr is array (1..NB_Swimmer) of Float; -- time at which the awimmer arrives type T_TableArr is array (1..NB_Swimmer) of Float; -- time at which the awimmer arrives
@ -164,19 +165,11 @@ procedure td is
while Running loop while Running loop
Event := Attend_Signal; Event := Attend_Signal;
-- I had done a case at first but we need to do something more complex
-- case Event.emmeteur is
-- when Capteur_Plot =>
-- when Capteur_Nord =>
-- when Capteur_Sud => null;
-- when Signal_Feu =>
-- when Bouton_Fin =>
-- end case;
if Event.Emetteur = Signal_Feu then if Event.Emetteur = Signal_Feu then
TDepart := Event.Date; -- We stock the first value to have the time of the swimmers TDepart := Event.Date; -- We stock the first value to have the time of the swimmers
elsif Event.Emetteur = Capteur_Plot then elsif Event.Emetteur = Capteur_Plot then
if Event.Date - TDepart < 0.1 then -- it is a false start https://en.wikipedia.org/wiki/False_start if Event.Date - TDepart < 0.1 then -- it is a false start: https://en.wikipedia.org/wiki/False_start
Running := False; Running := False; -- we stop the race
Put_Line("False start at line" & Integer'Image(Event.Num)); Put_Line("False start at line" & Integer'Image(Event.Num));
else else
TableTime(Event.Num,1) := Event.Date; -- starting value TableTime(Event.Num,1) := Event.Date; -- starting value
@ -184,17 +177,17 @@ procedure td is
end if; end if;
elsif (Event.Emetteur = Capteur_Nord and (Event.Date - TableTime(Event.Num,4)>5.0)) then -- it's hard to do 50m in less than 5 seconds elsif (Event.Emetteur = Capteur_Nord and (Event.Date - TableTime(Event.Num,4)>5.0)) then -- it's hard to do 50m in less than 5 seconds
if TableNum(Event.Num) = 0 then if TableNum(Event.Num) = 0 then
TableTime(Event.Num,2) := Event.Date; TableTime(Event.Num,2) := Event.Date; -- we store the value at the first 50 m
TableNum(Event.Num):=TableNum(Event.Num)+1; TableNum(Event.Num):=TableNum(Event.Num)+1; -- we increment the numer of runs
elsif TableNum(Event.Num) = 15 then -- it means he's finishing his last run
TableTime(Event.Num,3) := Event.Date; -- we store the arrival's date
end if; end if;
if TableNum(Event.Num) = 15 then elsif Event.Emetteur = Bouton_Fin then -- the director of the race stopped it (probably saw someone arrive)
TableTime(Event.Num,3) := Event.Date;
end if;
elsif Event.Emetteur = Bouton_Fin then
Running := False; Running := False;
end if; end if;
End loop; End loop;
-- we store the times of arrival
for I in 1 .. NB_Swimmer loop for I in 1 .. NB_Swimmer loop
Arrival(I) := TableTime(I,3); Arrival(I) := TableTime(I,3);
end loop; end loop;
@ -202,19 +195,21 @@ procedure td is
-- We order the table: -- We order the table:
while not Sorted loop while not Sorted loop
for I in 1 .. NB_Swimmer-1 loop for I in 1 .. NB_Swimmer-1 loop -- for every value if it is greater than the next one we swop them
if Arrival(I)>Arrival(I+1) then if Arrival(I)>Arrival(I+1) then
Temp := Arrival(I); Temp := Arrival(I); -- there to store a value
Arrival(I) := Arrival(I+1); Arrival(I) := Arrival(I+1);
Arrival(I+1) := Temp; Arrival(I+1) := Temp;
Temp :=0.0; Temp := 0.0; --reset
end if; end if;
end loop; end loop;
Sorted := True;
--here we check for if it's sorted (if not we give it another go)
Sorted := True; --it starts true
for I in 1 .. NB_Swimmer-1 loop for I in 1 .. NB_Swimmer-1 loop
if Arrival(I)>Arrival(I+1) then if Arrival(I)>Arrival(I+1) then -- if a value is greater than the next one (as it's not supposed to be)
Sorted := False; Sorted := False; -- we set the sorted value to false
end if; end if;
end loop; end loop;
end loop; end loop;
@ -243,3 +238,4 @@ begin
end td; end td;