|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: B T
Length: 3310 (0xcee)
Types: TextFile
Names: »B«
└─⟦bfaa708f6⟧ Bits:30000531 8mm tape, Rational 1000, INSIGHT 1_3_0
└─⟦c51948655⟧ »DATA«
└─⟦266b31e86⟧
└─⟦this⟧
with Panel_Interface;
with Client;
with Message_Types;
with Message_Dispatch;
with Message;
with Network;
with Log_Writer;
with Seats;
package body Light_Controller is
Light_Controller_Id : Client.Id;
-- Client Id for this module. There is a dispatcher task handling
-- requests addressed to this client.
procedure Start is
begin
null; -- Startup automatic during elaboration.
end Start;
procedure Shutdown is
begin
null; -- no explicit shutdown needed.
end Shutdown;
task Dispatcher is
entry Start;
-- The client must be registered in elaboration code before this
-- entry is called. Once called, begin dispatching requests.
end Dispatcher;
task body Dispatcher is
Packet : Message.Packet;
-- This packet is allocated by the Message_Dispatch package and must
-- be explicitly freed here.
function Get_Seat (Cmd : String) return Seats.Seat_Id is
begin
if Cmd'Length >= 2 then
return Seats.Seat_Id'Value (Cmd (Cmd'First + 1 .. Cmd'Last));
else
return 0;
end if;
exception
when others =>
return 0;
end Get_Seat;
begin
accept Start;
loop
begin
-- Get a message
Message_Dispatch.Get_Message (Light_Controller_Id, Packet);
-- Decode message and process.
declare
Cmd : constant String := Message.Packet_Body (Packet);
Seat : Seats.Seat_Id := Get_Seat (Cmd);
begin
-- 1st char T => on F => off, rest of string is seat
-- number.
case Cmd (Cmd'First) is
when 'T' =>
Log_Writer.Log_Message
("Light_Controller",
"Light ON: " & Seats.Seat_Id'Image (Seat));
-- Call physical controller to turn light on
Panel_Interface.Light_On (Seat);
when 'F' =>
Log_Writer.Log_Message
("Light_Controller",
"Light OFF:" & Seats.Seat_Id'Image (Seat));
-- Call physical controller to turn light off
Panel_Interface.Light_Off (Seat);
when others =>
Log_Writer.Log_Message
("Light_Controller.Dispatcher",
"illegal message");
end case;
Message_Dispatch.Free_Buffer (Packet);
exception
when others =>
Log_Writer.Log_Message
("Light_Controller.Dispatcher", "exception");
delay 3.0; -- avoid infinite busy loops
end;
end;
end loop;
end Dispatcher;
begin
-- initialization: Register client and start dispatcher task
Light_Controller_Id := Client.Register ("Light_Controller");
Dispatcher.Start;
end Light_Controller;