ShowEvents: ButtonProc ~ {
dH: DataHandle ~ NARROW[tH.data];
cH: ControlHandle ~ NARROW[tH.control];
peH: PrintEntry ← NIL;
startTime, stopTime: BasicTime.GMT;
seconds: INT;
PerMin:
PROC [n:
INT]
RETURNS [
IO.Value] ~
INLINE {
RETURN [ [integer[(60*n)/seconds]] ] };
IF NOT Enter[tH, showEvents] THEN RETURN;
FlushPEQueue[dH];
XNSRouterPrivate.SetEventProc[MyEventProc];
startTime ← BasicTime.Now[];
IO.PutF[tH.out, "\nStarted %g\n\n", [time[startTime]] ];
DO
ENABLE IO.Error, ABORTED => EXIT;
IF peH # NIL THEN PEFree[dH, peH];
peH ← PEDequeue[dH];
IF dH.pleaseStop THEN EXIT;
SELECT peH.kind
FROM
change => {
IF peH.old.immediate = peH.new.immediate
THEN {
dH.nDelayChanges ← dH.nDelayChanges.SUCC;
IF NOT cH.putDelayChanges THEN LOOP }
ELSE {
dH.nRouteChanges ← dH.nRouteChanges.SUCC };
};
add => {
dH.nAdds ← dH.nAdds.SUCC };
delete => {
dH.nDeletes ← dH.nDeletes.SUCC };
ENDCASE => ERROR;
TRUSTED { gmt: ProcessorFace.GreenwichMeanTime ← ProcessorFace.GetGreenwichMeanTime[] - ProcessorFace.gmtEpoch;
IO.PutRope[tH.out, Convert.RopeFromTime[from~LOOPHOLE[gmt], start~hours, end~seconds, useAMPM~FALSE, includeZone~FALSE]];
IO.PutF[tH.out, " net %xH rte ", [cardinal[CfF[LOOPHOLE[peH.net]]]] ];
};
IF peH.kind # add THEN PutRTE[tH.out, peH.old];
IO.PutRope[tH.out, " ==> "];
IF peH.kind # delete THEN PutRTE[tH.out, peH.new];
IO.PutRope[tH.out, "\n"];
ENDLOOP;
stopTime ← BasicTime.Now[];
seconds ← BasicTime.Period[from~startTime, to~stopTime];
XNSRouterPrivate.ClearEventProc[MyEventProc];
IO.PutF[tH.out, "\n\nStopped %g after %g seconds\n\n", [time[stopTime]], [integer[seconds]] ];
IF seconds <= 0 THEN seconds ← 1;
IO.PutF[tH.out, "Adds: %g = %g / min\n", [integer[dH.nAdds]], PerMin[dH.nAdds] ];
IO.PutF[tH.out, "Delay Changes: %g = %g / min\n", [integer[dH.nDelayChanges]], PerMin[dH.nDelayChanges] ];
IO.PutF[tH.out, "Route Changes: %g = %g / min\n", [integer[dH.nRouteChanges]], PerMin[dH.nRouteChanges] ];
IO.PutF[tH.out, "Deletes: %g = %g / min\n", [integer[dH.nDeletes]], PerMin[dH.nDeletes] ];
IO.PutRope[tH.out, "\n\n"];
Exit[tH];
};