-- LutherWatcherImpl.mesa
-- Last edited by
-- Kolling on August 12, 1983 11:51 am

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[ROPE],
RPC
USING[CallFailed],
SpecialCache
USING[NameIt],
UserExec
USING[CheckForAbort, ExecHandle, GetStreams, HistoryEvent, 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, 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
: PROCEDURE[event: UserExec.HistoryEvent, exec: UserExec.ExecHandle,
clientData: REF ANY] RETURNS[ok: BOOLEAN, msg: Rope.ROPE] =
BEGIN
ENABLE IO.UserAborted, ABORTED => IF NOT firstFail
THEN ViewerOps.DestroyViewer[LutherWatcherTool];
instHandle: AlpI.Handle ← NIL;
DoNumber: PROCEDURE[what: Rope.ROPE] =
BEGIN
UserExec.GetStreams[exec].out.PutF["%g.
", IO.rope[what]];
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..5]
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