|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: B T
Length: 6517 (0x1975)
Types: TextFile
Names: »B«
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
└─⟦129cab021⟧ »DATA«
└─⟦this⟧
with Personnal_Array;
with Personnal_String;
with Element_De_Tri;
with Text_Io;
with Serial_Io;
package body Moteur is
type Pstring is access String;
type Tableau_D_Element_De_Tri is array (1 .. 1000) of Element_De_Tri.Object;
type Table_De_Tri is
record
The_Tab : Tableau_D_Element_De_Tri;
Size : Natural;
end record;
Time_Max : constant Duration := 86400.0;
The_File : Text_Io.File_Type;
Base : Duration;
The_Tab : Personnal_Array.Object;
procedure File_Open (The_Name : String; Mode : Text_Io.File_Mode) is
begin
Text_Io.Open
(File => The_File, Mode => Mode, Name => The_Name, Form => "");
end File_Open;
procedure File_Close is
begin
Text_Io.Close (The_File);
end File_Close;
procedure Start_Chrono is
begin
Base := 0.0;
end Start_Chrono;
function Current_Time_Is_Over (A_Time : Duration) return Boolean is
begin
delay A_Time - Base;
Base := A_Time;
return True;
end Current_Time_Is_Over;
function File_Time_Value (A_File : Text_Io.File_Type) return Duration is
A_String : Personnal_String.Object;
C : Character;
begin
Personnal_String.Raz (A_String);
if not Text_Io.End_Of_File (A_File) then
Text_Io.Get (A_File, C);
while C = ' ' loop
Text_Io.Get (A_File, C);
end loop;
while C in '0' .. '9' loop
Personnal_String.Put (A_String, C);
Text_Io.Get (A_File, C);
end loop;
return
Duration ((Integer'Value (Personnal_String.Value (A_String)))) /
10;
else
return Time_Max;
end if;
end File_Time_Value;
function File_Length (A_File : Text_Io.File_Type)
return Text_Io.Positive_Count is
C : Character;
begin
while not Text_Io.End_Of_File (A_File) loop
Text_Io.Get (A_File, C);
end loop;
return Text_Io.Line (A_File);
end File_Length;
procedure Line_Put (A_File : Text_Io.File_Type) is
C : Character;
A_String : Personnal_String.Object;
begin
Personnal_String.Raz (A_String);
while not Text_Io.End_Of_File (A_File) and
not Text_Io.End_Of_Line (A_File) loop
Text_Io.Get (A_File, C);
if C /= ' ' then
Personnal_String.Put (A_String, C);
end if;
end loop;
Personnal_Array.Put (The_Tab, A_String);
end Line_Put;
procedure Send_To_Serial_Io (The_String : String) is
begin
Serial_Io.Put (S => "D", Tty => "/dev/tty0");
Serial_Io.Put (S => The_String, Tty => "/dev/tty0");
Serial_Io.Put ("F", Tty => "/dev/tty0");
end Send_To_Serial_Io;
procedure Send is
begin
for I in 1 .. Personnal_Array.Last (The_Tab) loop
declare
Tmp : Pstring;
begin
Tmp := new String'(Personnal_Array.Value (The_Tab, I));
Send_To_Serial_Io (Tmp.all);
end;
end loop;
end Send;
procedure Copy_File_Into_Tab (A_File : Text_Io.File_Type;
Une_Table : in out Table_De_Tri) is
begin
for I in 1 .. Une_Table.Size loop
if not Text_Io.End_Of_File (A_File) then
Element_De_Tri.Affecter (Une_Table.The_Tab (I),
File_Time_Value (A_File));
Element_De_Tri.Affecter (Une_Table.The_Tab (I), A_File);
end if;
end loop;
end Copy_File_Into_Tab;
procedure Copy_Tab_Into_File (A_File : in out Text_Io.File_Type;
Une_Table : Table_De_Tri) is
begin
for I in 1 .. Une_Table.Size loop
Text_Io.Put
(A_File,
Integer'Image
(Integer
(Element_De_Tri.Temps_Value (Une_Table.The_Tab (I)) *
10)));
Text_Io.Put (A_File, " ");
Text_Io.Put_Line (A_File, Element_De_Tri.Contenu_Value
(Une_Table.The_Tab (I)));
end loop;
end Copy_Tab_Into_File;
procedure Tri_A_Bulle (Une_Table : in out Table_De_Tri) is
J : Integer;
Tmp : Element_De_Tri.Object;
begin
for I in 1 .. Une_Table.Size - 1 loop
J := Une_Table.Size;
while J >= I + 1 loop
if Element_De_Tri.Temps_Value (Une_Table.The_Tab (J)) <
Element_De_Tri.Temps_Value (Une_Table.The_Tab (J - 1)) then
Tmp := Une_Table.The_Tab (J);
Une_Table.The_Tab (J) := Une_Table.The_Tab (J - 1);
Une_Table.The_Tab (J - 1) := Tmp;
end if;
J := J - 1;
end loop;
end loop;
end Tri_A_Bulle;
function Trier (In_File : String) return String is
La_Table : Table_De_Tri;
begin
File_Open (In_File, Text_Io.In_File);
La_Table.Size := Positive (File_Length (The_File));
File_Close;
File_Open (In_File, Text_Io.In_File);
Copy_File_Into_Tab (The_File, La_Table);
File_Close;
Tri_A_Bulle (La_Table);
Text_Io.Create (File => The_File,
Mode => Text_Io.Out_File,
Name => In_File & ".tri",
Form => "");
Copy_Tab_Into_File (The_File, La_Table);
File_Close;
return In_File & ".tri";
end Trier;
procedure Run (Name : String) is
Current_File_Time, The_Time : Duration;
begin
File_Open (Name, Text_Io.In_File);
Start_Chrono;
Current_File_Time := File_Time_Value (The_File);
The_Time := Current_File_Time;
while not Text_Io.End_Of_File (The_File) loop
Personnal_Array.Raz (The_Tab);
while The_Time <= Current_File_Time loop
Line_Put (The_File);
Text_Io.Skip_Line (The_File);
The_Time := File_Time_Value (The_File);
end loop;
if Current_Time_Is_Over (Current_File_Time) then
Send;
Current_File_Time := The_Time;
end if;
end loop;
File_Close;
end Run;
end Moteur;