mentor/derived/PktRouteTranscriptView.m3


 Copyright (C) 1995, Digital Equipment Corporation.       
 All rights reserved.                                     
 See the file COPYRIGHT for a full description.           
                                                          
 Last modified on Thu Feb  9 08:56:02 PST 1995 by kalsow  
      modified on Mon Jun  6 03:18:55 PDT 1994 by mhb   
      modified on Tue Feb 16 16:31:40 PST 1993 by johnh 

********************************************************************

      *  NOTE: This file is generated automatically from the event
      *        definition file PktRoute.evt.
      ********************************************************************


<* PRAGMA LL *>

MODULE PktRouteTranscriptView;

<*NOWARN*> IMPORT TextConv, TextPort, Rd, IntList, ZeusClass;
<*NOWARN*> IMPORT Filter, TextEditVBT, PktRouteViewClass, Fmt;
<*NOWARN*> IMPORT ZFmt, Wr, IntListUtils, ZeusPanel, FormsVBT;
<*NOWARN*> IMPORT RefIntArray, VBT, View, OblFmt;

<* FATAL FormsVBT.Error, FormsVBT.Unimplemented *>

REVEAL
  T = Public BRANDED OBJECT
    fv: FormsVBT.T := NIL;
    te: TextEditVBT.T := NIL;
  OVERRIDES
    init       := TViewInit;
    install    := TViewInstall;
    delete     := TViewDelete;
    snapshot   := TViewSnapshot;
    restore    := TViewRestore;
    config     := TViewConfig;
    reactivity := TViewReactivity;
    startrun   := TViewStartrun;
    endrun     := TViewEndrun;
    oeStartGraph := StartGraph;
    oeNewNode := NewNode;
    oeNewStraightEdge := NewStraightEdge;
    oeNewCurvedEdge := NewCurvedEdge;
    oeNewLabel := NewLabel;
    oeEndGraph := EndGraph;
    oeStartPackets := StartPackets;
    oeNewPacket := NewPacket;
    oeEndPackets := EndPackets;
    oeBlocked := Blocked;
    oeMovePacket := MovePacket;
    oeQueueSizes := QueueSizes;
    oeAbsorb := Absorb;
    oeStep := Step;
  END;

PROCEDURE TViewInit (view: T): T =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "init");
    RETURN PktRouteViewClass.T.init (view, NIL);
  END TViewInit;

PROCEDURE Clear (<* UNUSED *> fv  : FormsVBT.T;
                 <* UNUSED *> name: TEXT;
                              cl  : REFANY;
                 <* UNUSED *> time: VBT.TimeStamp) =
  BEGIN
    TextPort.SetText(NARROW(cl, T).te.tp, "")
  END Clear;

PROCEDURE TViewInstall (view: T) =
  <* LL = VBT.mu *>
  BEGIN
    view.fv := ZeusPanel.NewForm("PktRouteTranscriptView.fv");
    view.te := FormsVBT.GetVBT(view.fv, "transcript");
    TViewZTrace (view, "install");
    FormsVBT.AttachProc(view.fv, "clear", Clear, view);
    EVAL Filter.Replace (view, view.fv);
    PktRouteViewClass.T.install (view);
  END TViewInstall;

PROCEDURE TViewDelete (view: T) =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "delete");
    PktRouteViewClass.T.delete (view);
   END TViewDelete;

PROCEDURE TViewSnapshot (view: T; wr: Wr.T) RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "snapshot");
    PktRouteViewClass.T.snapshot (view, wr);
   END TViewSnapshot;

PROCEDURE TViewRestore (view: T; rd: Rd.T) RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "restore");
    PktRouteViewClass.T.restore (view, rd);
   END TViewRestore;

PROCEDURE TViewConfig (
    view: T;
    state: ZeusClass.StateChange;
    o: ZeusClass.T) =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "config");
    PktRouteViewClass.T.config (view, state, o);
   END TViewConfig;

PROCEDURE TViewReactivity (view: T; <*UNUSED*> on: BOOLEAN) =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace(view, "reactivity");
    PktRouteViewClass.T.reactivity (view, TRUE);
  END TViewReactivity;

PROCEDURE TViewStartrun (view: T) =
  <* LL = {} *>
  BEGIN
    TViewZTrace (view, "startrun");
    PktRouteViewClass.T.startrun (view);
   END TViewStartrun;

PROCEDURE TViewEndrun (view: T) =
  <* LL = {} *>
  BEGIN
    TViewZTrace (view, "endrun");
    PktRouteViewClass.T.endrun (view);
  END TViewEndrun;
event handling methods:

PROCEDURE StartGraph (view: T;  nodeCnt: CARDINAL; queueSize: CARDINAL; bounded: BOOLEAN; maxX, maxY: REAL) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "StartGraph ...")
       ELSE
          TViewTrace (view, "StartGraph "
          & Fmt.Int(nodeCnt)
          & " "
          & Fmt.Int(queueSize)
          & " "
          & OblFmt.Bool(bounded)
          & " "
          & OblFmt.Real(maxX)
          & " "
          & OblFmt.Real(maxY)
          )
       END
    END
    END
  END StartGraph;

PROCEDURE NewNode (view: T;  id: CARDINAL; x, y: REAL) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "NewNode ...")
       ELSE
          TViewTrace (view, "NewNode "
          & Fmt.Int(id)
          & " "
          & OblFmt.Real(x)
          & " "
          & OblFmt.Real(y)
          )
       END
    END
    END
  END NewNode;

PROCEDURE NewStraightEdge (view: T;  id1, id2: CARDINAL) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "NewStraightEdge ...")
       ELSE
          TViewTrace (view, "NewStraightEdge "
          & Fmt.Int(id1)
          & " "
          & Fmt.Int(id2)
          )
       END
    END
    END
  END NewStraightEdge;

PROCEDURE NewCurvedEdge (view: T;  id1, id2: CARDINAL; x1, y1, x2, y2: REAL) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "NewCurvedEdge ...")
       ELSE
          TViewTrace (view, "NewCurvedEdge "
          & Fmt.Int(id1)
          & " "
          & Fmt.Int(id2)
          & " "
          & OblFmt.Real(x1)
          & " "
          & OblFmt.Real(y1)
          & " "
          & OblFmt.Real(x2)
          & " "
          & OblFmt.Real(y2)
          )
       END
    END
    END
  END NewCurvedEdge;

PROCEDURE NewLabel (view: T;  label: TEXT; x, y: REAL) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "NewLabel ...")
       ELSE
          TViewTrace (view, "NewLabel "
          & TextConv.Encode(label)
          & " "
          & OblFmt.Real(x)
          & " "
          & OblFmt.Real(y)
          )
       END
    END
    END
  END NewLabel;

PROCEDURE EndGraph (view: T;  ) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "EndGraph ...")
       ELSE
          TViewTrace (view, "EndGraph "
          )
       END
    END
    END
  END EndGraph;

PROCEDURE StartPackets (view: T;  pktCnt: CARDINAL) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "StartPackets ...")
       ELSE
          TViewTrace (view, "StartPackets "
          & Fmt.Int(pktCnt)
          )
       END
    END
    END
  END StartPackets;

PROCEDURE NewPacket (view: T;  id, source, dest, fewestHops: CARDINAL; name: TEXT) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "NewPacket ...")
       ELSE
          TViewTrace (view, "NewPacket "
          & Fmt.Int(id)
          & " "
          & Fmt.Int(source)
          & " "
          & Fmt.Int(dest)
          & " "
          & Fmt.Int(fewestHops)
          & " "
          & TextConv.Encode(name)
          )
       END
    END
    END
  END NewPacket;

PROCEDURE EndPackets (view: T;  ) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "EndPackets ...")
       ELSE
          TViewTrace (view, "EndPackets "
          )
       END
    END
    END
  END EndPackets;

PROCEDURE Blocked (view: T;  id, from, to: CARDINAL) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "Blocked ...")
       ELSE
          TViewTrace (view, "Blocked "
          & Fmt.Int(id)
          & " "
          & Fmt.Int(from)
          & " "
          & Fmt.Int(to)
          )
       END
    END
    END
  END Blocked;

PROCEDURE MovePacket (view: T;  id, from, to: CARDINAL) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "MovePacket ...")
       ELSE
          TViewTrace (view, "MovePacket "
          & Fmt.Int(id)
          & " "
          & Fmt.Int(from)
          & " "
          & Fmt.Int(to)
          )
       END
    END
    END
  END MovePacket;

PROCEDURE QueueSizes (view: T;  sz: RefIntArray.T) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "QueueSizes ...")
       ELSE
          TViewTrace (view, "QueueSizes "
          & RefIntArray.ToText(sz)
          )
       END
    END
    END
  END QueueSizes;

PROCEDURE Absorb (view: T;  pktId, node: CARDINAL) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "Absorb ...")
       ELSE
          TViewTrace (view, "Absorb "
          & Fmt.Int(pktId)
          & " "
          & Fmt.Int(node)
          )
       END
    END
    END
  END Absorb;

PROCEDURE Step (view: T;  ) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "Step ...")
       ELSE
          TViewTrace (view, "Step "
          )
       END
    END
    END
  END Step;

PROCEDURE TViewZTrace (view: T; t: TEXT) =
  BEGIN
    IF view.fv # NIL THEN
      IF FormsVBT.GetBoolean(view.fv, "zeus") THEN
        TextPort.PutText(view.te.tp, "**zeus:  " & t & "\n");
        TextPort.Normalize(view.te.tp, LAST(INTEGER))
      END
    END
  END TViewZTrace;

PROCEDURE TViewTrace (view: T; t: TEXT) =
  BEGIN
    TextPort.PutText(view.te.tp, "--event: " & t & "\n");
    TextPort.Normalize(view.te.tp, LAST(INTEGER))
  END TViewTrace;

PROCEDURE TViewNew (): View.T =
  BEGIN
    RETURN NEW(T).init()
  END TViewNew;

BEGIN
  ZeusPanel.RegisterView
      (TViewNew, "PktRoute Transcript View", "PktRoute");
END PktRouteTranscriptView.

interface View is in: