|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 28672 (0x7000)
Types: Ada Source
Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Summary, package body Unit_Error_Recording, seg_0046a5
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
└─⟦5a81ac88f⟧ »Space Info Vol 1«
└─⟦this⟧
with Bounded_String;
with Sequential;
with Table_Formatter;
with Directory_Tools;
with String_Utilities;
package body Unit_Error_Recording is
package Object renames Directory_Tools.Object;
package Naming renames Directory_Tools.Naming;
package Data_Io is new Pio.Operations (Error_Data);
package Pipe_Io is new Pipe.Type_Specific_Operations (Error_Data);
package Names renames Sequential.Names;
function Make (Label : Item;
Kind : Error_Kind := Error;
In_Unit : String;
Line_Number : Natural) return Error_Data is
D : Error_Data;
begin
D.Label := Label;
D.Kind := Kind;
D.Line_Number := Line_Number;
Bounded_String.Copy (D.Unit, In_Unit);
return D;
end Make;
function Kind (Of_Data : Error_Data) return Error_Kind is
begin
return Of_Data.Kind;
end Kind;
procedure Write (To_File : Pio.File_Type; D : Error_Data) is
begin
Data_Io.Write (File => To_File, Item => D);
end Write;
procedure Read (From_File : Pio.File_Type; D : out Error_Data) is
begin
Data_Io.Read (File => From_File, Item => D);
end Read;
procedure Write (To_Pipe : in out Pipe.Handle;
D : Error_Data;
Wait : Duration) is
begin
Pipe_Io.Write (Pipe => To_Pipe, Message => D, Max_Wait => Wait);
end Write;
procedure Read (From_Pipe : Pipe.Handle;
Wait : Duration;
D : out Error_Data;
Timeout_Expired : out Boolean) is
Null_Data : Error_Data;
begin
loop
begin
D := Pipe_Io.Read (Pipe => From_Pipe, Max_Wait => Wait);
Timeout_Expired := False;
exit;
exception
when Pipe.Use_Error =>
D := Null_Data;
Timeout_Expired := True;
exit;
when Pipe.End_Error =>
null; -- ignore end_error
end;
end loop;
end Read;
procedure Init (From_Files : String; Iter : in out Entry_Iterator) is
Head, The_List : Data_List.List := Data_List.Nil;
Files : Object.Iterator := Naming.Resolution (From_Files);
procedure Append_To_List (D : Error_Data) is
Local : Data_List.List := Data_List.Make (D, Data_List.Nil);
begin
if Data_List.Is_Empty (The_List) then
The_List := Local;
Head := Local;
else
Data_List.Set_Rest (The_List, Local);
The_List := Local;
end if;
end Append_To_List;
begin
if Object.Is_Bad (Files) then
return;
end if;
while not Object.Done (Files) loop
declare
Handle : Pio.File_Type;
D : Error_Data;
begin
Pio.Open (File => Handle,
Mode => Pio.In_File,
Name => Naming.Unique_Full_Name
(Object.Value (Files)),
Form => "");
while not Pio.End_Of_File (Handle) loop
Data_Io.Read (Handle, D);
Append_To_List (D);
end loop;
exception
when Pio.Use_Error =>
null; -- skip locked files
-- one file (the file currently being written
-- will always be locked
end;
Object.Next (Files);
end loop;
-- Initialize the iterator and current data value
Data_List.Init (Iter.List_Iter, Head);
if not Data_List.Done (Iter.List_Iter) then
Iter.Current_Data := Data_List.Value (Iter.List_Iter);
end if;
end Init;
function Done (Iter : Entry_Iterator) return Boolean is
begin
return Data_List.Done (Iter.List_Iter);
end Done;
procedure Next (Iter : in out Entry_Iterator) is
begin
Data_List.Next (Iter.List_Iter);
if not Data_List.Done (Iter.List_Iter) then
Iter.Current_Data := Data_List.Value (Iter.List_Iter);
end if;
end Next;
function User_Name (Iter : Entry_Iterator) return String is
begin
return Bounded_String.Image (Iter.Current_Data.User);
end User_Name;
function Date (Iter : Entry_Iterator) return Time_Utilities.Time is
begin
return Iter.Current_Data.Date;
end Date;
function Label (Iter : Entry_Iterator) return Item is
begin
return Iter.Current_Data.Label;
end Label;
function Kind (Iter : Entry_Iterator) return Error_Kind is
begin
return Iter.Current_Data.Kind;
end Kind;
function Unit (Iter : Entry_Iterator) return String is
begin
return Bounded_String.Image (Iter.Current_Data.Unit);
end Unit;
function Line_Number (Iter : Entry_Iterator) return Natural is
begin
return Iter.Current_Data.Line_Number;
end Line_Number;
function Image (Name : Column_Name) return String is
begin
case Name is
when User =>
return "User Name";
when Date =>
return "Date";
when Incompatibility =>
return "Check";
when Error_Designation =>
return "Error Kind";
when Unit_Name =>
return "Unit Name (Ref #)";
when Line_Number =>
return "Line";
end case;
end Image;
procedure Generate_Report (From_Files : String;
To_File : Io.File_Type := Io.Standard_Output) is
package Table is new Table_Formatter (Included_Columns'Length);
Sort_Fields : Table.Field_List
(Included_Columns'First .. Included_Columns'Last);
Name_Map : Names.Map;
Unit_Name_Max : constant := 25;
Entry_Iter : Entry_Iterator;
The_Summary : Summary.Summary_Data;
function Include_Column (Name : Column_Name; Iter : Entry_Iterator)
return Boolean is
begin
case Name is
when User =>
return Include (User_Name (Iter));
-- calls to generic formals to test for inclusion
when Date =>
return Include (Date (Iter));
when Incompatibility =>
return Include (Label (Iter));
when Error_Designation =>
return Include (Kind (Iter));
when Unit_Name =>
return Include_Unit (Unit (Iter));
when Line_Number =>
return True;
end case;
end Include_Column;
function Included (Columns : Column_List; Iter : Entry_Iterator)
return Boolean is
begin
for I in Columns'Range loop
if not Include_Column (Columns (I), Iter) then
return False;
end if;
end loop;
return True;
end Included;
function Data_Value (Column : Column_Name; Iter : Entry_Iterator)
return String is
begin
case Column is
when User =>
return User_Name (Iter);
when Date =>
return Time_Utilities.Image
(Date (Iter),
Contents => Time_Utilities.Date_Only);
when Incompatibility =>
return Image (Label (Iter));
when Error_Designation =>
return Error_Kind'Image (Kind (Iter));
when Unit_Name =>
declare
Name : constant String := Unit (Iter);
Simple_Name : constant String :=
Naming.Simple_Name (Name);
Unit_Name : Sequential.Var_String;
begin
Bounded_String.Copy (Unit_Name, Name);
Names.Add (Unit_Name, To => Name_Map);
if Simple_Name'Length < Unit_Name_Max then
return
Simple_Name & " (" &
String_Utilities.Strip
(Integer'Image
(Names.Index (Unit_Name, Name_Map))) &
")";
else
return
Simple_Name
(Simple_Name'First ..
Simple_Name'First + Unit_Name_Max - 1) &
" (" &
String_Utilities.Strip
(Integer'Image
(Names.Index (Unit_Name, Name_Map))) &
")";
end if;
end;
when Line_Number =>
return Natural'Image (Line_Number (Iter));
end case;
end Data_Value;
begin
for I in Included_Columns'Range loop
Sort_Fields (I) := Integer (I);
Table.Header (Image (Included_Columns (I)));
end loop;
Names.Initialize (Name_Map);
Init (From_Files, Entry_Iter);
Summary.Initialize (The_Summary);
while not Done (Entry_Iter) loop
if Included (Included_Columns, Entry_Iter) then
Summary.Add (Entry_Iter.Current_Data, The_Summary);
for Column in Included_Columns'Range loop
Table.Item (Data_Value
(Included_Columns (Column), Entry_Iter));
end loop;
end if;
Next (Entry_Iter);
end loop;
Names.Display (Name_Map, To_File);
Io.New_Line (To_File);
Table.Sort (Sort_Fields);
Table.Display (To_File);
Io.New_Line (To_File);
Io.Put_Line ("SUMMARY REPORT:");
Io.New_Line (To_File);
Summary.Display (The_Summary, To_File);
end Generate_Report;
procedure Display_Summary (Of_Entries : in out Entry_Iterator;
To_File : Io.File_Type) is
The_Summary : Summary.Summary_Data;
begin
Summary.Initialize (The_Summary);
while not Done (Of_Entries) loop
Summary.Add (Of_Entries.Current_Data, The_Summary);
Next (Of_Entries);
end loop;
Summary.Display (The_Summary, To_File);
end Display_Summary;
package body Summary is
subtype Real_Errors is Error_Kind range Error .. Batch_Warning;
Prefix_Length : constant := 8;
Longest_Item : constant Integer := Item'Width;
Item_Blanks : constant String (1 .. Longest_Item + Prefix_Length) :=
(others => ' ');
Item_Line : constant String (1 .. Longest_Item + Prefix_Length) :=
(others => '-');
Longest_Error : constant Integer := Real_Errors'Width;
Error_Blanks : constant String (1 .. Longest_Error) := (others => ' ');
Error_Line : constant String (1 .. Longest_Error) := (others => '-');
procedure Initialize (Summary : in out Summary_Data) is
begin
Summary.Total_Count := 0;
Summary.Item_Counts := (others => 0);
Summary.Error_Counts := (others => 0);
Name_Map.Initialize (Summary.Unit_Map);
Name_Map.Initialize (Summary.User_Map);
Name_Map.Initialize (Summary.Date_Map);
end Initialize;
procedure Add (To : in out Name_Map.Map; Name : String) is
Value : Natural;
begin
Value := Name_Map.Eval (To, Name);
Value := Value + 1;
Name_Map.Define (To, Name, Value);
exception
when Name_Map.Undefined =>
Name_Map.Define (To, Name, 1);
end Add;
procedure Add (D : Error_Data; To_Summary : in out Summary_Data) is
begin
To_Summary.Total_Count := To_Summary.Total_Count + 1;
To_Summary.Item_Counts (D.Label) :=
To_Summary.Item_Counts (D.Label) + 1;
To_Summary.Error_Counts (D.Kind) :=
To_Summary.Error_Counts (D.Kind) + 1;
Add (To_Summary.Unit_Map, Bounded_String.Image (D.Unit));
Add (To_Summary.User_Map, Bounded_String.Image (D.User));
Add (To_Summary.Date_Map,
Time_Utilities.Image (D.Date,
Contents => Time_Utilities.Date_Only));
end Add;
function Item_Image (I : Item) return String is
Imag : constant String := Image (I) & " : " & Item'Image (I);
Pad : constant String (1 .. Longest_Item + Prefix_Length -
Imag'Length + 1) := (others => ' ');
begin
return Imag & Pad; end Item_Image;
function Image (E : Error_Kind) return String is
Imag : constant String := Error_Kind'Image (E);
Pad : constant String (1 .. Longest_Error - Imag'Length + 1) :=
(others => ' ');
begin
return Imag & Pad;
end Image;
function Pad_For_Items (S : String) return String is
Pad : constant String (1 .. Longest_Item + Prefix_Length -
S'Length + 1) := (others => ' ');
begin
return S & Pad;
end Pad_For_Items;
function Pad_For_Errors (S : String) return String is
Pad : constant String (1 .. Longest_Error - S'Length + 1) :=
(others => ' ');
begin
return S & Pad;
end Pad_For_Errors;
function Average (Map : Name_Map.Map) return Natural is
Total, Number : Natural := 0;
Iter : Name_Map.Iterator;
begin
Name_Map.Init (Iter, Map);
while not Name_Map.Done (Iter) loop
Total := Total + Name_Map.Eval (Map, Name_Map.Value (Iter));
Number := Number + 1;
Name_Map.Next (Iter);
end loop;
if Number > 0 then
return Total / Number;
else
return 0;
end if;
end Average;
procedure Display (Summary : Summary_Data; To : Io.File_Type) is
begin
Io.Put_Line (To, "INCOMPATIBILITY TOTALS:");
for I in Item loop
Io.Put_Line (To, " " & Item_Image (I) & ": " &
Natural'Image (Summary.Item_Counts (I)));
end loop;
Io.Put_Line (To, " " & Item_Line);
Io.Put_Line (To, " " & Pad_For_Items ("TOTAL") & ": " &
Natural'Image (Summary.Total_Count))
Io.New_Line (To);
Io.Put_Line (To, "ERROR KIND TOTALS:");
for E in Real_Errors loop
Io.Put_Line (To, " " & Image (E) & ": " &
Natural'Image (Summary.Error_Counts (E)));
end loop;
Io.Put_Line (To, " " & Error_Line);
Io.Put_Line (To, " " & Pad_For_Errors ("TOTAL") & ": " &
Natural'Image (Summary.Total_Count));
Io.New_Line (To);
Io.Put_Line (To, "AVERAGE ERRORS PER Unit: " &
Natural'Image (Average (Summary.Unit_Map)));
Io.Put_Line (To, "AVERAGE ERRORS PER User: " &
Natural'Image (Average (Summary.User_Map)));
Io.Put_Line (To, "AVERAGE ERRORS PER Day : " &
Natural'Image (Average (Summary.Date_Map)));
end Display;
end Summary;
end Unit_Error_Recording;
nblk1=1b
nid=0
hdr6=36
[0x00] rec0=21 rec1=00 rec2=01 rec3=00e
[0x01] rec0=00 rec1=00 rec2=1b rec3=01a
[0x02] rec0=1c rec1=00 rec2=02 rec3=01c
[0x03] rec0=1d rec1=00 rec2=03 rec3=020
[0x04] rec0=01 rec1=00 rec2=1a rec3=008
[0x05] rec0=1e rec1=00 rec2=04 rec3=05a
[0x06] rec0=00 rec1=00 rec2=19 rec3=00a
[0x07] rec0=1f rec1=00 rec2=05 rec3=012
[0x08] rec0=21 rec1=00 rec2=06 rec3=032
[0x09] rec0=1e rec1=00 rec2=07 rec3=004
[0x0a] rec0=1c rec1=00 rec2=08 rec3=01c
[0x0b] rec0=13 rec1=00 rec2=09 rec3=066
[0x0c] rec0=01 rec1=00 rec2=18 rec3=012
[0x0d] rec0=18 rec1=00 rec2=0a rec3=04e
[0x0e] rec0=21 rec1=00 rec2=0b rec3=016
[0x0f] rec0=19 rec1=00 rec2=0c rec3=044
[0x10] rec0=00 rec1=00 rec2=17 rec3=00e
[0x11] rec0=19 rec1=00 rec2=0d rec3=030
[0x12] rec0=00 rec1=00 rec2=16 rec3=00c
[0x13] rec0=13 rec1=00 rec2=0e rec3=02c
[0x14] rec0=01 rec1=00 rec2=15 rec3=002
[0x15] rec0=1a rec1=00 rec2=0f rec3=036
[0x16] rec0=00 rec1=00 rec2=14 rec3=014
[0x17] rec0=19 rec1=00 rec2=10 rec3=088
[0x18] rec0=00 rec1=00 rec2=13 rec3=002
[0x19] rec0=18 rec1=00 rec2=11 rec3=02a
[0x1a] rec0=01 rec1=00 rec2=12 rec3=000
tail 0x215004854815c66bb0540 0x42a00088462061e03