DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦787dabc2f⟧ Ada Source

    Length: 16384 (0x4000)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, procedure Superviseur, seg_04ccbe, seg_04cd99

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« 
        └─⟦this⟧ 

E3 Source Code



with Carte;
with Cl35;
with Cl35_Message;
with Date;
with Evenement;
with Evenements;
with Groupe;
with Io;
with Lecteur;
with L_Groupes;
with L_Lecteurs;
with L_Plages_Horaires;
with L_Zones;
with L_P_Access;
with Machine_Io;
with My_Types;
with Parametres;
with Plage;
with Plage_Horaire;
with Porte;
with Porteur;
with P_Acces;  
with Syntaxic;
with Text_Io;
with Time_Utilities;
with Zone;


-- Pour prevenir les autres, ou pour voir qui a deja le lecteur.
-- A supprimer en exploitation "normale"
with Message;
with What;

procedure Superviseur is

    package Mt renames My_Types;
    package Tio renames Text_Io;
    package Tu renames Time_Utilities;

    Fichier_Journal : constant String := "journal";
    Le_Lecteur : Cl35.Object;
    Le_Journal : Io.File_Type;

    procedure Imprime (Affichage : in String) is
    begin
        Tio.Put_Line (Item => "++" & Ascii.Lf & Affichage & Ascii.Lf);
        Io.Put_Line (File => Le_Journal,
                     Item => "++" & Ascii.Lf & Affichage & Ascii.Lf);
        Io.Save (File => Le_Journal);
    end Imprime;

    function Identifie (Numero_De_Carte : Carte.Object) return String is

        Un_Porteur : Porteur.Object;
        Un_Groupe : Groupe.Object;

    begin

        L_Groupes.Search (Les_Groupes => Syntaxic.Liste_G,
                          Numero_Carte => Numero_De_Carte,
                          Le_Groupe => Un_Groupe,
                          Le_Porteur => Un_Porteur);
        -- Ajout 23 Mars 1995. CST
        if Porteur.Get (Le_Porteur => Un_Porteur) = Carte.Zero then
            return String'("Porteur inconnu !");
        end if;

        return String'("Groupe : " & Groupe.Image (Le_Groupe => Un_Groupe) &
                       ". " & Porteur.Image (Le_Porteur => Un_Porteur));

    end Identifie;

    function Localise return String is

        Une_Porte : Porte.Object;
        Une_Zone : Zone.Object;

    begin

        L_Zones.Search (Les_Zones => Syntaxic.Liste_Zone,
                        Numero_Lecteur => Cl35.Address (Le_Lecteur),
                        La_Zone => Une_Zone,
                        La_Porte => Une_Porte);
        return String'("Zone : " & Zone.Image (Une_Zone) &
                       ". " & Porte.Image (Une_Porte));

    end Localise;

    procedure Conf_Plages is

        Une_Zone : Zone.Object;  
        Iterateur : L_Zones.Liste.Iterator;

    begin

        L_Zones.Liste.Init (Iterateur, Syntaxic.Liste_Zone);
        loop
            exit when L_Zones.Liste.Done (Iterateur);
            Une_Zone := L_Zones.Liste.Value (Iterateur);
            declare
                Iterateur : Zone.Liste_Portes.Iterator;
                Les_Portes : Zone.Liste_Portes.List;
                Une_Plage : Plage.Object;
            begin
                Les_Portes := Zone.Liste (La_Zone => Une_Zone);
                Zone.Liste_Portes.Init (Iterateur, Les_Portes);
                loop
                    exit when Zone.Liste_Portes.Done (Iterateur);

                    Le_Lecteur := Cl35.Address
                                     (Porte.Get (La_Porte =>
                                                    Zone.Liste_Portes.Value
                                                       (Iter => Iterateur)));

                    for I in Plage.Num_Plage'First ..
                                Plage.Num_Plage'Last - 1 loop  
                        Une_Plage :=
                           Plage_Horaire.Get_Plage
                              (Une_Plage_Horaire =>
                                  L_Plages_Horaires.Search
                                     (Les_P_H => Syntaxic.List_P_H,
                                      N_Zone => Zone.Image
                                                   (La_Zone => Une_Zone),
                                      Der_Car_Zone =>
                                         Zone.Longueur_Name (Une_Zone),
                                      Numero_P_H => I));
                        Cl35.Transmission_Plage
                           (Le_Lecteur => Le_Lecteur, La_Plage => Une_Plage);
                    end loop;

                    Zone.Liste_Portes.Next (Iterateur);
                end loop;
            end;
            L_Zones.Liste.Next (Iterateur);
        end loop;

    end Conf_Plages;

    procedure Conf_Cartes is

        Un_Acces : P_Acces.Object;  
        Iterateur : L_P_Access.Liste.Iterator;

    begin
        L_P_Access.Liste.Init (Iterateur, Syntaxic.Liste_L_A);
        loop
            exit when L_P_Access.Liste.Done (Iterateur);
            Un_Acces := L_P_Access.Liste.Value (Iterateur);
            declare
                Numero_Plage : Plage.Num_Plage;
                Une_Zone : Zone.Object;
                Iterateur : Zone.Liste_Portes.Iterator;
                Les_Portes : Zone.Liste_Portes.List;
            begin
                Numero_Plage := P_Acces.Get_Num_Plage (Un_Acces => Un_Acces);
                L_Zones.Search (Les_Zones => Syntaxic.Liste_Zone,
                                Nom_De_Zone => P_Acces.Get_Nom_Zone
                                                  (Un_Acces => Un_Acces),
                                La_Zone => Une_Zone);
                Les_Portes := Zone.Liste (La_Zone => Une_Zone);
                Zone.Liste_Portes.Init (Iterateur, Les_Portes);
                loop
                    exit when Zone.Liste_Portes.Done (Iterateur);

                    Le_Lecteur := Cl35.Address
                                     (Porte.Get (La_Porte =>
                                                    Zone.Liste_Portes.Value
                                                       (Iter => Iterateur)));
                    declare
                        Un_Groupe : Groupe.Object;
                        Les_Porteurs : Groupe.Liste_Porteurs.List;
                        Iterateur : Groupe.Liste_Porteurs.Iterator;
                        Un_Porteur : Porteur.Object;
                        Une_Carte : Carte.Object;

                    begin
                        L_Groupes.Search
                           (Les_Groupes => Syntaxic.Liste_G,
                            Nom_De_Groupe => P_Acces.Get_Nom_Groupe (Un_Acces),
                            Le_Groupe => Un_Groupe);
                        Les_Porteurs := Groupe.Liste (Le_Groupe => Un_Groupe);
                        Groupe.Liste_Porteurs.Init
                           (Iter => Iterateur, L => Les_Porteurs);

                        loop
                            exit when Groupe.Liste_Porteurs.Done (Iterateur);
                            Un_Porteur := Groupe.Liste_Porteurs.Value
                                             (Iter => Iterateur);
                            Une_Carte := Porteur.Get (Le_Porteur => Un_Porteur);
                            Cl35.Valide_Carte (Le_Lecteur => Le_Lecteur,
                                               La_Carte => Une_Carte,
                                               Pour_La_Plage => Numero_Plage);

                            Groupe.Liste_Porteurs.Next (Iterateur);
                        end loop;
                    end;  
                    Zone.Liste_Portes.Next (Iterateur);
                end loop;
            end;
            L_P_Access.Liste.Next (Iterateur);
        end loop;
    end Conf_Cartes;


    procedure Conf_Parms is

        Parms : Parametres.Object;
        Num_Cl35 : Natural;  
        Une_Date : Date.Object;
        Type_Cl35 : String (1 .. 30);  
        Iterateur : L_Lecteurs.Liste.Iterator;

    begin

        L_Lecteurs.Liste.Init (Iterateur, Syntaxic.Liste_Lect);
        loop
            exit when L_Lecteurs.Liste.Done (Iterateur);
            Lecteur.Get (Un_Lecteur => L_Lecteurs.Liste.Value (Iterateur),
                         Type_Lecteur => Type_Cl35,
                         Numero => Num_Cl35,
                         Les_Para => Parms);

            Une_Date := Date.System_Date;
            Le_Lecteur := Cl35.Address (Address => Num_Cl35);
            Cl35.Mise_A_L_Heure (Le_Lecteur => Le_Lecteur,
                                 Date_Lecteur => Une_Date);

            Cl35.Reglage_Parametres (Le_Lecteur => Le_Lecteur,
                                     Params_Lecteur => Parms);
            Cl35.Set_Site (Le_Lecteur => Cl35.Address (Address => Num_Cl35),
                           Le_Code => Syntaxic.Le_Site);


            -- invalidation de toutes les cartes
            Cl35.Invalide_Carte (Le_Lecteur => Le_Lecteur,
                                 De_La_Carte => 1,
                                 A_La_Carte => Carte.Object'Last);


            L_Lecteurs.Liste.Next (Iterateur);
        end loop;

    end Conf_Parms;

    procedure Init_Date (Le_Lecteur : in Cl35.Object) is

        Date_Systeme : Date.Object;

    begin

        Date_Systeme := Date.System_Date;
        Cl35.Mise_A_L_Heure (Le_Lecteur, Date_Lecteur => Date_Systeme);  
        Imprime (Date.Image (The_Date => Date_Systeme) & ", " &
                 "Mise a l'heure du lecteur" & Ascii.Lf & Localise);
    end Init_Date;

    function Check_Evt (Le_Lecteur : in Cl35.Object) return Boolean is

        package File_Evt renames Evenements.Evt_Queue;
        package Message_Lu is new Cl35_Message (Mt.Response);
        File_Rapport : File_Evt.Queue;
        Rapport : Evenement.Object;
        Iterateur : File_Evt.Iterator;
        Power_Off : Boolean := False;
        Une_Carte : Carte.Object;

    begin
        Cl35.Init;
        Cl35.Rapport_Evenements (Le_Lecteur => Le_Lecteur,
                                 Le_Rapport => File_Rapport);
        File_Evt.Init (Iter => Iterateur, Q => File_Rapport);

        loop
            exit when File_Evt.Done (Iter => Iterateur);
            Rapport := File_Evt.Value (Iter => Iterateur);
            if Evenement.Was_Power_Off (Rapport) then
                Power_Off := True;
            end if;
            Une_Carte := Evenement.Get (Rapport);
            if (Une_Carte /= Carte.Zero) then
                Imprime (Evenement.Image (Rapport => Rapport) &
                         Ascii.Lf & Localise & Ascii.Lf &
                         Identifie (Numero_De_Carte => Une_Carte));
            else
                Imprime (Evenement.Image (Rapport => Rapport) &
                         Ascii.Lf & Localise);
            end if;  
            File_Evt.Next (Iter => Iterateur);
        end loop;
        File_Evt.Make_Empty (Q => File_Rapport);
        return Power_Off;

    exception

        when Message_Lu.Bad_Ack =>
            Imprime (Date.Image (The_Date => Date.System_Date) & ": " &
                     "ne repond pas correctement => mauvais aquittement !" &
                     Ascii.Lf & Localise);
            return False;

        when Message_Lu.Bad_Header | Message_Lu.Bad_Trailer =>
            Imprime (Date.Image (The_Date => Date.System_Date) & ": " &
                     "ne repond pas correctement => erreur de trame !" &
                     Ascii.Lf & Localise);
            return False;

        when Machine_Io.Open_Error =>
            Imprime (Date.Image (The_Date => Date.System_Date) & ": " &
                     "n'est pas accessible => erreur a l'ouverture !" &
                     Ascii.Lf & Localise);
            return False;

        when Machine_Io.Read_Timeout =>
            Imprime (Date.Image (The_Date => Date.System_Date) &
                     ": " & "ne repond pas !" & Ascii.Lf & Localise);
            return False;

    end Check_Evt;

    procedure Demon is

        Parms : Parametres.Object;
        Num_Cl35 : Natural;  
        Type_Cl35 : String (1 .. 30);
        Iterateur : L_Lecteurs.Liste.Iterator;

    begin

        Machine_Io.Set (Timeout => 1.0);
        Main:
            loop

                L_Lecteurs.Liste.Init (Iterateur, Syntaxic.Liste_Lect);
                loop
                    exit when L_Lecteurs.Liste.Done (Iterateur);
                    Lecteur.Get (Un_Lecteur =>
                                    L_Lecteurs.Liste.Value (Iterateur),
                                 Type_Lecteur => Type_Cl35,
                                 Numero => Num_Cl35,
                                 Les_Para => Parms);
                    Le_Lecteur := Cl35.Address (Address => Num_Cl35);
                    if Check_Evt (Le_Lecteur => Le_Lecteur) then
                        Init_Date (Le_Lecteur => Le_Lecteur);
                    end if;
                    L_Lecteurs.Liste.Next (Iterateur);

                end loop;
                delay 10.0;
            end loop Main;

    end Demon;

begin

    Syntaxic.Charge_Config;
    Tio.Put ("Initialisation des lecteurs ");
    Conf_Parms;
    Conf_Plages;
    Conf_Cartes;
    Tio.Put_Line ("terminee");
    Io.Create (File => Le_Journal,
               Mode => Io.Out_File,
               Name => Fichier_Journal,
               Form => "");
    Imprime (Affichage =>
                Tu.Image (Date => Tu.Get_Time,
                          Date_Style => Tu.Day_Month_Year,
                          Time_Style => Tu.Short,
                          Contents => Tu.Both) &
                " Debut de supervision sur port " & Machine_Io.Io_Port);
    -- A supprimer si on est seul.
    -- Message.Send_All("Je prends le controle des lecteurs pour ~ 1 minute. Merci, Claude.");
    --
    Demon;

exception

    when Syntaxic.Syntax_Error =>
        Tio.Put_Line
           ("Erreur detectee a la lecture du fichier de configuration");

    when others =>
        Tio.Put_Line (Ascii.Lf & Localise & " : " & "Erreur d'acces");
        raise;

        -- A supprimer si on est seul.
        What.Locks (Name => Machine_Io.Io_Port);
        --


end Superviseur;

E3 Meta Data

    nblk1=f
    nid=0
    hdr6=1e
        [0x00] rec0=30 rec1=00 rec2=01 rec3=024
        [0x01] rec0=1d rec1=00 rec2=02 rec3=022
        [0x02] rec0=1e rec1=00 rec2=03 rec3=022
        [0x03] rec0=13 rec1=00 rec2=04 rec3=012
        [0x04] rec0=1c rec1=00 rec2=05 rec3=024
        [0x05] rec0=12 rec1=00 rec2=06 rec3=03e
        [0x06] rec0=12 rec1=00 rec2=07 rec3=08e
        [0x07] rec0=1d rec1=00 rec2=08 rec3=066
        [0x08] rec0=19 rec1=00 rec2=09 rec3=026
        [0x09] rec0=1c rec1=00 rec2=0a rec3=07a
        [0x0a] rec0=1a rec1=00 rec2=0b rec3=03a
        [0x0b] rec0=1b rec1=00 rec2=0c rec3=008
        [0x0c] rec0=19 rec1=00 rec2=0d rec3=02e
        [0x0d] rec0=22 rec1=00 rec2=0e rec3=01e
        [0x0e] rec0=09 rec1=00 rec2=0f rec3=000
    tail 0x217540d36874f6ea11bd4 0x42a00088462060003