DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

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 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ B T

⟦81b5e4422⟧ TextFile

    Length: 7002 (0x1b5a)
    Types: TextFile
    Names: »B«

Derivation

└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
    └─ ⟦129cab021⟧ »DATA« 
        └─⟦this⟧ 

TextFile

package body Role is
    package Int_Io is new Text_Io.Integer_Io (Num => Integer);


    Debut_Trame : constant Character := 'D';
    Fin_Trame : constant Character := 'F';


    function Creer_Role (Un_Acteur : Acteur) return P_Role is
        Result : P_Role;
    begin
        Result := new Cell_Role;
        Result.La_Duree := 0;
        Result.En_Cours := False;
        Result.L_Acteur := Un_Acteur;
        Result.L_Etape := Etape.Etape_Vide;  
        Result.L_Index := Etape.Etape_Vide;
        return Result;
    end Creer_Role;


    function Acteur_Du_Role (R : in P_Role) return Acteur is
    begin
        return R.L_Acteur;
    end Acteur_Du_Role;

    procedure Ajouter_Action_Ds_Role
                 (R : in out P_Role; T : in Etape.Temps; A : in Etape.Action) is
        Etape_Init : Etape.P_Etape;
    begin
        Etape_Init := R.L_Etape;
        if T > R.La_Duree then
            R.La_Duree := T;
        end if;
        Etape.Ajouter_Etape
           (E_Modifiee => Etape_Init, Temps_E => T, Action_E => A);
        R.L_Etape := Etape_Init;

    end Ajouter_Action_Ds_Role;


    function Lire_Un_Role (R : in P_Role; A : in Acteur) return P_Role is
        Un_Temps : Etape.Temps;
        Une_Action : Etape.Action;
        Un_Role : P_Role;
    begin  
        if Role_Est_Vide (R => R) then
            Un_Role := Creer_Role (Un_Acteur => A);
        else
            Un_Role := R;
        end if;
        Un_Temps := Intermediate_Code.Get;
        Une_Action.La_Valeur := Intermediate_Code.Get;
        if Intermediate_Code.End_Of_Line then
            Une_Action.La_Transition := 0;
        else
            Une_Action.La_Transition := Intermediate_Code.Get;
        end if;
        Ajouter_Action_Ds_Role (R => Un_Role, T => Un_Temps, A => Une_Action);
        Intermediate_Code.Skip_Line;
        return Un_Role;
    end Lire_Un_Role;



    procedure Affiche_Role (R : in P_Role) is
        E : Etape.P_Etape;
    begin
        E := R.L_Etape;
        Text_Io.Put ("affichage d'un role station : ");
        Int_Io.Put (R.L_Acteur.Num_Station);
        Text_Io.Put (" acteur : ");
        Int_Io.Put (R.L_Acteur.Num_Acteur);
        Text_Io.Put_Line ("");
        Etape.Affiche_Etape (E_Affichee => E);
        Text_Io.Put_Line ("fin de l'affichage du role");
    end Affiche_Role;

--    procedure Execute_Role (A : Acteur; Ac : Etape.Action) is
--    begin
--        Text_Io.Put ("execution de la station : ");
--        Int_Io.Put (A.Num_Station);
--        Text_Io.Put (" l'acteur : ");
--        Int_Io.Put (A.Num_Acteur);
--        Text_Io.Put ("  action : ");
--        Int_Io.Put (Ac);
--        Text_Io.Put_Line ("");
--    end Execute_Role;


    procedure Envoyer_Trame_10 (A : Acteur; Ac : Etape.Action) is
        Trame_10 : String (1 .. 10) := "0000000000";
        Inter : Integer;  
        String_2 : String (1 .. 2) := "00";
        String_4 : String (1 .. 4) := "0000";

    begin
        Trame_10 (1) := Debut_Trame;
        Trame_10 (10) := Fin_Trame;
        Inter := A.Num_Station;
        String_2 := String_Utilities.Number_To_String (Inter, 10, 2);
        Trame_10 (2 .. 3) := String_2;
        Inter := A.Num_Acteur;
        String_2 := String_Utilities.Number_To_String (Inter, 10, 2);
        Trame_10 (4 .. 5) := String_2;
        Inter := Ac.La_Valeur;
        String_4 := String_Utilities.Number_To_String (Inter, 10, 4);
        Trame_10 (6 .. 9) := String_4;
        for I in 1 .. 10 loop
            if Trame_10 (I) = ' ' then
                Trame_10 (I) := '0';
            end if;
        end loop;
        Serial_Io.Put (S => Trame_10, Tty => "/dev/tty0");

    end Envoyer_Trame_10;

    procedure Envoyer_Trame_14 (A : Acteur; Ac : Etape.Action) is
        Trame_14 : String (1 .. 14) := "00000000000000";
        Inter : Integer;
        String_2 : String (1 .. 2) := "00";
        String_4 : String (1 .. 4) := "0000";

    begin

        Trame_14 (1) := Debut_Trame;
        Trame_14 (14) := Fin_Trame;
        Inter := A.Num_Station;
        String_2 := String_Utilities.Number_To_String (Inter, 10, 2);
        Trame_14 (2 .. 3) := String_2;
        Inter := A.Num_Acteur;
        String_2 := String_Utilities.Number_To_String (Inter, 10, 2);
        Trame_14 (4 .. 5) := String_2;
        Inter := Ac.La_Valeur;
        String_4 := String_Utilities.Number_To_String (Inter, 10, 4);
        Trame_14 (6 .. 9) := String_4;
        Inter := Ac.La_Transition;
        String_4 := String_Utilities.Number_To_String (Inter, 10, 4);
        Trame_14 (10 .. 13) := String_4;
        for I in 1 .. 14 loop
            if Trame_14 (I) = ' ' then
                Trame_14 (I) := '0';
            end if;
        end loop;
        Serial_Io.Put (Trame_14, Tty => "/dev/tty0");

    end Envoyer_Trame_14;


    procedure Execute_Role (A : Acteur; Ac : Etape.Action) is
    begin
        if Ac.La_Transition = 0 then
            Envoyer_Trame_10 (A, Ac);
        else
            Envoyer_Trame_14 (A, Ac);
        end if;
    end Execute_Role;


    function Role_Est_Vide (R : in P_Role) return Boolean is
    begin
        return (R = Role_Vide);
    end Role_Est_Vide;

    function Role_En_Cours (R : in P_Role) return Boolean is
    begin
        return R.En_Cours;
    end Role_En_Cours;

    function Temps_Role (R : in P_Role) return Etape.Temps is
    begin
        return R.La_Duree;
    end Temps_Role;


    function Etapes_Du_Role (R : in P_Role) return Etape.P_Etape is
    begin
        return R.L_Etape;
    end Etapes_Du_Role;

    procedure Demarrer_Role (R : in out P_Role) is
    begin
        R.L_Index := Etapes_Du_Role (R => R);
        if not Etape.Etape_Est_Vide (E_Consultee => R.L_Index) then
            R.En_Cours := True;
        end if;
    end Demarrer_Role;

    procedure Arreter_Role (R : in out P_Role) is
    begin
        R.En_Cours := False;
    end Arreter_Role;

    procedure Solliciter_Role (R : in out P_Role;
                               Chrono : in Timer_Moteur.Objet) is

    begin
        if Role_En_Cours (R => R) then
            if Etape.Temps_Etape (E_Consultee => R.L_Index) <=
               Timer_Moteur.Temps_Moteur (Chrono) then
                Execute_Role (A => R.L_Acteur, Ac => R.L_Index.L_Action);
                R.L_Index := R.L_Index.Suivant;
                if Etape.Etape_Est_Vide (E_Consultee => R.L_Index) then
                    Arreter_Role (R => R);
                end if;
            end if;
        end if;
    end Solliciter_Role;


    procedure Jouer_Role (R : in P_Role) is
        Un_Role : P_Role := R;  
        Role_Chrono : Timer_Moteur.Objet;
    begin
        Demarrer_Role (R => Un_Role);
        Timer_Moteur.Init_Temps (Role_Chrono);
        Timer_Moteur.Reset_Temps (Role_Chrono);
        Timer_Moteur.Start_Temps (Role_Chrono);
        while Role_En_Cours (R => Un_Role) loop
            Solliciter_Role (R => Un_Role, Chrono => Role_Chrono);
        end loop;  
        Timer_Moteur.Stop_Temps (Role_Chrono);
    end Jouer_Role;
end Role;