-- LutherWatcherImpl.mesa
-- Last edited by
-- Kolling on January 26, 1984 4:30:39 pm PST
DIRECTORY
AlpineEnvironment
USING[FileStore],
AlpInstance
USING[Create, Failed, Handle],
AlpTransaction
USING[Create, OperationFailed],
Commander
USING[CommandProc, Register],
Icons
USING[IconFlavor, NewIconFromFile],
IO
USING[PutF, PutRope, rope],
Process
USING[Pause, SecondsToTicks],
ProcessExtras
USING[CheckForAbort],
Rope
USING[Equal, ROPE],
RPC
USING[CallFailed],
LutherWatcherSpecialCache
USING[NameIt],
UserProfile
USING[Boolean],
ViewerClasses
USING[ViewerClass, ViewerClassRec, Viewer],
ViewerOps
USING[CreateViewer, DestroyViewer, PaintViewer, RegisterViewerClass];
LutherWatcherImpl: CEDAR PROGRAM
IMPORTS AlpI: AlpInstance, AlpT: AlpTransaction, Commander, Icons, IO, Process,
ProcessExtras, Rope, RPC, LutherWatcherSpecialCache, UserProfile, ViewerOps
SHARES LutherWatcherSpecialCache =
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: BOOLEAN ← TRUE;
-- Commander.CommandProc TYPE = PROC [cmd: Handle] RETURNS [result: REF ← NIL, msg: Rope.ROPE ← NIL];
LutherWatcherProc: Commander.CommandProc =
BEGIN
ENABLE 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
cmd.out.PutF["%g.
", IO.rope[what]];
lastMsg ← what;
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]]; ProcessExtras.CheckForAbort[];
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;];
cmd.out.PutRope["Luther up.
"];
IF NOT firstFail
THEN BEGIN
IF UserProfile.Boolean["LutherWatcher.Armageddon", TRUE]
THEN TRUSTED BEGIN LutherWatcherSpecialCache.NameIt[viewerName]; END;
ViewerOps.DestroyViewer[LutherWatcherTool];
END;
EXIT;
ENDLOOP;
END;
-- main line code.
Commander.Register["LutherWatcher", LutherWatcherProc, NIL, ];
END.
Edit Log
Initial: Kolling: July 18, 1983 2:28 pm