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

⟦23106425e⟧ Ada Source

    Length: 5120 (0x1400)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Dispatch_Light_Commands, seg_00fd99

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 Client;
with Message_Types;
with Message_Dispatch;
with Message;
with Network;
with Light_Controls;
with Log_Writer;
with Lights;

pragma Elaborate (Client);

package body Dispatch_Light_Commands is

    function "+" (A, B : Lights.Light_Id) return Lights.Light_Id
        renames Lights."+";

    Lights_Id : Client.Id;  -- Client Id of the light manager.  This is the
    -- central controller module that handles management of cabin lighting.

    Emergency_Lighting_Id : Client.Id;  -- Id of handler for emergency msgs.


    procedure Start is
    begin
        null;  -- startup is done in the elaboration code.
    end Start;

    procedure Stop is
    begin
        null;  -- no shutdown is needed.
    end Stop;

    procedure Emergency is
    begin
        Emergency_Lighting_Id := Client.Register ("Emergency_Lighting");
        -- This function is not yet implemented
    end Emergency;


    task Dispatcher is
        entry Start;
        -- The Dispatcher task cannot be started until the elaboration code
        -- registers the Light_Controller client.  Then, the Dispatcher
        -- listens for requests to control lights.  Requests come from
        -- seat buttons and are routed to light controllers.
    end Dispatcher;


    task body Dispatcher is
        -- This packet is allocated by the Message_Dispatch package and
        -- must be freed by code here after use.
        Packet : Message.Packet;
    begin  
        accept Start;
        loop
            begin
                -- First, read a network message for this client
                Message_Dispatch.Get_Message (Lights_Id, Packet);

                -- Got a message.  Decode it.
                declare
                    Cmd : constant String := Message.Packet_Body (Packet);
                    Light : Light_Controls.Light_Id;
                begin
                    -- 1st char T => on F => off, rest of string is seat
                    -- number.
                    Light := Light_Controls.Light_Of
                                (Cmd (Cmd'First + 1 .. Cmd'Last));
                    case Cmd (Cmd'First) is
                        when 'T' =>
                            -- Turn on light
                            Light_Controls.On (Light);

                        when 'F' =>
                            -- Turn off light
                            Light_Controls.Off (Light);

                        when 'C' =>
                            -- Service agent call
                            Light_Controls.Toggle (Light + 100); -- offset to
                            -- service call light from seat light.  (bogus)

                        when others =>
                            Log_Writer.Log_Message
                               ("Cabin_Operations.Dispatch_light_commands",
                                "illegal message");
                    end case;
                    -- Release buffer packet.
                    Message_Dispatch.Free_Buffer (Packet);
                exception
                    when others =>
                        Log_Writer.Log_Message
                           ("Cabin_Operations.Dispatch_light_commands",
                            "exception");
                        delay 5.0;  -- avoid infinite busy loops
                end;
            end;
        end loop;
    end Dispatcher;
begin
    -- initialization: Register this client.    Then start the dispatcher task.
    Lights_Id := Client.Register ("Light_Manager");
    Dispatcher.Start;
end Dispatch_Light_Commands;

E3 Meta Data

    nblk1=4
    nid=0
    hdr6=8
        [0x00] rec0=2a rec1=00 rec2=01 rec3=00a
        [0x01] rec0=18 rec1=00 rec2=02 rec3=068
        [0x02] rec0=16 rec1=00 rec2=03 rec3=02c
        [0x03] rec0=12 rec1=00 rec2=04 rec3=000
    tail 0x2170c170a822f63009e0e 0x42a00088462060003