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

⟦f503ed3f4⟧ TextFile

    Length: 4901 (0x1325)
    Types: TextFile
    Names: »B«

Derivation

└─⟦149519bd4⟧ Bits:30000546 8mm tape, Rational 1000, !projects 93-07-13
    └─ ⟦124ff5788⟧ »DATA« 
        └─⟦this⟧ 

TextFile

with Agent;
with Behavior_Defs;
with Calendar;
with Identifier;
with Message;
with Message_Transport;
with Method;
with Parameter;
with Time_Utilities;


with Text_Io;
use Text_Io;
package body Daemon is

    Count : Integer := 0;


    procedure Publish (Self : Identifier.Object) is
        Status : Message_Transport.Status_Code;
    begin
        Behavior_Defs.Send_Message
           (Message => Message.Create
                          (Class => Message.Publication,
                           Addressee => Identifier.Hash
                                           (Id => Identifier.Broker),
                           Sender => Identifier.Hash (Id => Self),
                           Method => "count",
                           Parameter_Name => "count",
                           Parameter_Class => "string",
                           Parameter_Value => Parameter.Void),
            Status => Status);
    end Publish;


    procedure Process_Message
                 (Message : Standard.Message.Object; Handled : out Boolean);


    package A is new Agent (Publish, Process_Message);


    procedure Actor is
        Status : Message_Transport.Status_Code;
        Mes : Message.Object;
        Expired : Boolean;

        use Calendar;

        Interval : constant Duration := 10.0;
        Next_Time : Time := Clock + Interval;
    begin
        loop
            Put_Line ("actor: we delay");
            delay Next_Time - Clock;

            Put_Line ("actor: delay is over");

            Behavior_Defs.Send_Message
               (Message => Message.Create
                              (Class => Message.Request,
                               Addressee => Identifier.Hash
                                               (Id => Identifier.Broker),
                               Sender => Identifier.Hash (Id => A.Get_Identity),
                               Method => "date",
                               Parameter_Name => "date",
                               Parameter_Class => "string",
                               Parameter_Value => Parameter.Void),
                Status => Status);

            Put_Line ("actor: request sent, we wait for reply");
            A.Wait_For_Reply
               (Message => Mes, Time_Out => 5.0, Expired => Expired);

            Put_Line ("actor: we do no more wait");
            if not Expired then
                Put_Line ("actor: received reply => " & Message.Image (Mes));

                Behavior_Defs.Send_Message
                   (Message =>
                       Message.Create
                          (Class => Message.Request,
                           Addressee =>
                              Identifier.Hash (Id => Identifier.Broker),
                           Sender => Identifier.Hash (Id => A.Get_Identity),
                           Method => "log_line",
                           Parameter1_Name => "display",
                           Parameter1_Class => "string",
                           Parameter1_Value => "grenouille:0",
                           Parameter2_Name => "message",
                           Parameter2_Class => "string",
                           Parameter2_Value => Parameter.Void),
                    Status => Status);

            else
                Put_Line ("actor: time_out has expired");
            end if;

            Next_Time := Next_Time + Interval;

        end loop;
    end Actor;



    package Core is new A.Core (Actor);


    procedure Process_Message
                 (Message : Standard.Message.Object; Handled : out Boolean) is

        Status : Message_Transport.Status_Code;

        use Message_Transport;
    begin
        if Method.Get_Name (Standard.Message.Get_Method (Message)) =
           "count" then
            New_Line;
            Put_Line ("+++ satisfying request for count");
            Behavior_Defs.Send_Message
               (Message => Standard.Message.Create
                              (Class => Standard.Message.Forward,
                               Addressee =>
                                  Standard.Message.Get_Sender (Message),
                               Sender => Identifier.Hash (A.Get_Identity),
                               Method => "count",
                               Parameter_Name => "count",
                               Parameter_Class => "string",
                               Parameter_Value => Integer'Image (Count)),
                Status => Status);
            if Status = Ok then
                Put_Line ("--- asking broker to forward");
            else
                Put_Line ("*** failed asking broker to forward");
            end if;

            Handled := True;
        else

            Handled := False;
        end if;

    end Process_Message;


    procedure Start is
    begin
        Put_Line ("+++ Starting Daemon ");
        Core.Start;
    end Start;

end Daemon;