|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 6144 (0x1800)
Types: Ada Source
Notes: 03_class, FILE, R1k_Segment, e3_tag, procedure Consumer, seg_020b2d
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
└─⟦cfc2e13cd⟧ »Space Info Vol 2«
└─⟦this⟧
with Mail, Text_Io;
with Producer_A_Messages, Producer_B_Messages;
procedure Consumer is
use Producer_A_Messages.Predefined_Ops;
use Producer_B_Messages.Predefined_Ops;
-- Read all incoming mail on my mailbox.
-- Know that the producers are sending incrementing messages.
-- Verify that each message is one greater (toggled) than
-- the previous. Raise logic error if discrepancy is found.
-- Reply with a message derived from the original message.
Logic_Error : exception;
Test_Box : Mail.Mailbox := Mail.Look_Up ("consumer1");
Test_Box2 : Mail.Mailbox := Mail.Look_Up ("consumer2");
Test_Box3 : Mail.Mailbox := Mail.Look_Up ("consumer3");
A_First_Message_Has_Arrived, B_First_Message_Has_Arrived : Boolean := False;
Last_A_Msg : Producer_A_Messages.Message;
Last_B_Msg : Producer_B_Messages.Message;
procedure Process_A (The_Message : Producer_A_Messages.Message;
Response_Required : Boolean;
Response_Kind : Mail.Kind;
Transaction : Mail.Transaction_Id) is
begin
if A_First_Message_Has_Arrived then
-- do something
if The_Message /= Last_A_Msg + 1 then
raise Logic_Error;
else
Last_A_Msg := The_Message;
end if;
else
Last_A_Msg := The_Message;
A_First_Message_Has_Arrived := True;
end if;
Text_Io.Put_Line ("Received PRODUCER_A => " &
Producer_A_Messages.Message'Image (The_Message));
-- repond if necessary
if Response_Required then
case Response_Kind is
when Producer_A_Messages.Reply_Kind =>
Producer_A_Messages.Reply_Op.Nonblocked_Reply
(Producer_A_Messages.Reply (The_Message + 1),
Transaction);
when others =>
null; -- problem
end case;
end if;
end Process_A;
procedure Process_B (The_Message : Producer_B_Messages.Message;
Response_Required : Boolean;
Response_Kind : Mail.Kind;
Transaction : Mail.Transaction_Id) is
begin
if B_First_Message_Has_Arrived then
-- do something
if The_Message /= not Last_B_Msg then
raise Logic_Error;
else
Last_B_Msg := The_Message;
end if;
else
Last_B_Msg := The_Message;
B_First_Message_Has_Arrived := True;
end if;
Text_Io.Put_Line ("Received PRODUCER_B => " &
Producer_B_Messages.Message'Image (The_Message));
-- repond if necessary
if Response_Required then
case Response_Kind is
when Producer_B_Messages.Reply_Kind =>
Producer_B_Messages.Reply_Op.Nonblocked_Reply
(Producer_B_Messages.Reply
(Boolean'Pos (Boolean (The_Message))), Transaction);
when others =>
-- response that is not defined.
[statement]
end case;
end if;
end Process_B;
procedure Process_Message (The_Message : Mail.Raw_Message) is
Transaction : Mail.Transaction_Id;
Response_Required : Boolean := Mail.Response_Is_Required (The_Message);
Response_Kind : Mail.Kind;
begin
-- extract info from raw message
if Response_Required then
Transaction := Mail.Get_Transaction_Id (The_Message);
Response_Kind := Mail.Get_Response_Kind (The_Message);
end if;
-- receive different types of messages from different
-- sources on "our" mailbox
case Mail.Get_Kind (The_Message) is
when Producer_A_Messages.Message_Kind =>
Process_A (Producer_A_Messages.Op.Receive (The_Message),
Response_Required, Response_Kind, Transaction);
when Producer_B_Messages.Message_Kind =>
Process_B (Producer_B_Messages.Op.Receive (The_Message),
Response_Required, Response_Kind, Transaction);
when others =>
-- received unexpected message.
[statement]
end case;
end Process_Message;
begin
-- subscribe to interested messages
Producer_A_Messages.Op.Subscribe (Test_Box);
Producer_B_Messages.Op.Subscribe (Test_Box);
loop
Process_Message (Mail.Wait (Test_Box));
end loop;
end Consumer;
nblk1=5
nid=0
hdr6=a
[0x00] rec0=1d rec1=00 rec2=01 rec3=030
[0x01] rec0=1b rec1=00 rec2=02 rec3=03e
[0x02] rec0=22 rec1=00 rec2=03 rec3=01a
[0x03] rec0=1a rec1=00 rec2=04 rec3=068
[0x04] rec0=1d rec1=00 rec2=05 rec3=000
tail 0x2171d2a76838d4466810f 0x42a00088462060003