-- LutherWatcherImpl.mesa
-- Last edited by
-- Kolling on August 17, 1983 3:45 pm

DIRECTORY

AlpineEnvironment
USING[FileStore],
AlpInstance
USING[Create, Failed, Handle],
AlpTransaction
USING[Create, OperationFailed],
Icons
USING[IconFlavor, NewIconFromFile],
IO
USING[PutF, PutRope, rope, UserAborted],
Process
USING[Pause, SecondsToTicks],
Rope
USING[Equal, ROPE],
RPC
USING[CallFailed],
SpecialCache
USING[NameIt],
UserExec
USING[CheckForAbort, CommandProc, ExecHandle, GetStreams,
RegisterCommand],
UserProfile
USING[Boolean],
ViewerClasses
USING[ViewerClass, ViewerClassRec, Viewer],
ViewerOps
USING[CreateViewer, DestroyViewer, PaintViewer, RegisterViewerClass];


LutherWatcherImpl: CEDAR PROGRAM
IMPORTS AlpI: AlpInstance, AlpT: AlpTransaction, Icons, IO, Process, Rope, RPC, SpecialCache,
UserExec, UserProfile, ViewerOps
SHARES SpecialCache =

BEGIN OPEN AE: AlpineEnvironment;

fileStore
: AE.FileStore ← "luther.alpine";
quiescent: Icons.IconFlavor ← Icons.NewIconFromFile[file:
"LutherWatcher.icons", n: 0];
stillDownFlavor1: Icons.IconFlavor ← Icons.NewIconFromFile[file:
"LutherWatcher.icons", n: 1];
stillDownFlavor2: Icons.IconFlavor ← Icons.NewIconFromFile[file:
"LutherWatcher.icons", n: 2];
stillDownFlavor3: Icons.IconFlavor ← Icons.NewIconFromFile[file:
"LutherWatcher.icons", n: 3];
stillDownFlavor4: Icons.IconFlavor ← Icons.NewIconFromFile[file:
"LutherWatcher.icons", n: 4];
viewerClass: ViewerClasses.ViewerClass ← NEW[ViewerClasses.ViewerClassRec ←
[icon: quiescent]];
LutherWatcherTool: ViewerClasses.Viewer;
viewerName
: Rope.ROPE ← "LutherWatcher";
firstFail: BOOLEANTRUE;


LutherWatcherProc
: UserExec.CommandProc =
BEGIN
ENABLE IO.UserAborted, ABORTED => IF NOT firstFail
THEN ViewerOps.DestroyViewer[LutherWatcherTool];
instHandle: AlpI.Handle ← NIL;
lastMsg: Rope.ROPE ← NIL;
DoNumber: PROCEDURE[what: Rope.ROPE] =
BEGIN
IF NOT Rope.Equal[lastMsg, what, TRUE]
THEN BEGIN
UserExec.GetStreams[exec].out.PutF["%g.
", IO.rope[what]];
lastMsgwhat;
END;
IF
firstFail
THEN BEGIN
ViewerOps.RegisterViewerClass[$LutherWatcher, viewerClass];
LutherWatcherTool ← ViewerOps.CreateViewer[
flavor: $LutherWatcher,
info: [
name: viewerName,
iconic: TRUE,
column: right,
icon: quiescent,
scrollable: FALSE
]];
firstFail ← FALSE;
END;
LutherWatcherTool.icon ← quiescent;
ViewerOps.PaintViewer[LutherWatcherTool, all];
Process.Pause[10];
LutherWatcherTool.icon ← stillDownFlavor1;
ViewerOps.PaintViewer[LutherWatcherTool, all];
Process.Pause[10];
LutherWatcherTool.icon ← stillDownFlavor2;
ViewerOps.PaintViewer[LutherWatcherTool, all];
Process.Pause[10];
LutherWatcherTool.icon ← stillDownFlavor3;
ViewerOps.PaintViewer[LutherWatcherTool, all];
Process.Pause[10];
LutherWatcherTool.icon ← stillDownFlavor4;
ViewerOps.PaintViewer[LutherWatcherTool, all];
Process.Pause[20];
LutherWatcherTool.icon ← quiescent;
ViewerOps.PaintViewer[LutherWatcherTool, all];
THROUGH [1..15]
DO Process.Pause[Process.SecondsToTicks[6]]; UserExec.CheckForAbort[exec, ];
ENDLOOP;
END;
firstFail ← TRUE;
DO
instHandle ← AlpI.Create[fileStore, ,
! AlpI.Failed => SELECT why FROM
grapevineDownOrCommunications =>
BEGIN DoNumber["Grapevine down or Ethernet problem"]; LOOP; END;
alpineDownOrCommunications =>
BEGIN DoNumber["Luther down or Ethernet problem"]; LOOP; END;
alpineDown =>
BEGIN DoNumber["Luther down"]; LOOP; END;
ENDCASE;];
[] ← AlpT.Create[instHandle, TRUE
! RPC.CallFailed => SELECT why FROM
timeout => BEGIN DoNumber["Luther down or Ethernet problem"]; LOOP; END;
unbound => BEGIN DoNumber["Luther down"]; LOOP; END;
ENDCASE;
AlpT.OperationFailed => IF why = busy
THEN BEGIN DoNumber["Luther busy"]; RETRY; END;];
UserExec.GetStreams[exec].out.PutRope["Luther up.
"];
IF NOT firstFail
THEN BEGIN
IF
UserProfile.Boolean["LutherWatcher.Armageddon", TRUE]
THEN TRUSTED BEGIN SpecialCache.NameIt[viewerName]; END;
ViewerOps.DestroyViewer[LutherWatcherTool];
END;
EXIT;
ENDLOOP;

END;



-- main line code.

UserExec.RegisterCommand["LutherWatcher", LutherWatcherProc, NIL, NIL, ];



END.


Edit Log

Initial: Kolling: July 18, 1983 2:28 pm