mentor/derived/PktRouteIE.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:50:48 PST 1995 by kalsow  
      modified on Sun Jun  5 21:59:57 PDT 1994 by mhb     
      modified on Wed Feb 17 16:46:47 PST 1993 by johnh   

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

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


<* PRAGMA LL *>

MODULE PktRouteIE;

<*NOWARN*> IMPORT TextConv, Zeus, ZeusClass, IntList;
<*NOWARN*> IMPORT PktRouteViewClass, Algorithm, PktRouteAlgClass;
<*NOWARN*> IMPORT IntListUtils, RefIntArray, Thread, View;
<*NOWARN*> IMPORT AlgorithmClass, OblFmt;

<* FATAL Zeus.Error, Zeus.Locked *>
If you get either of these errors, contact a Zeus implementor.

TYPE
  StartGraphArgs = BRANDED REF RECORD
    nodeCnt: CARDINAL;
    queueSize: CARDINAL;
    bounded: BOOLEAN;
    maxX: REAL;
    maxY: REAL;
  END;

  NewNodeArgs = BRANDED REF RECORD
    id: CARDINAL;
    x: REAL;
    y: REAL;
  END;

  NewStraightEdgeArgs = BRANDED REF RECORD
    id1: CARDINAL;
    id2: CARDINAL;
  END;

  NewCurvedEdgeArgs = BRANDED REF RECORD
    id1: CARDINAL;
    id2: CARDINAL;
    x1: REAL;
    y1: REAL;
    x2: REAL;
    y2: REAL;
  END;

  NewLabelArgs = BRANDED REF RECORD
    label: TEXT;
    x: REAL;
    y: REAL;
  END;

  EndGraphArgs = BRANDED REF RECORD
  END;

  StartPacketsArgs = BRANDED REF RECORD
    pktCnt: CARDINAL;
  END;

  NewPacketArgs = BRANDED REF RECORD
    id: CARDINAL;
    source: CARDINAL;
    dest: CARDINAL;
    fewestHops: CARDINAL;
    name: TEXT;
  END;

  EndPacketsArgs = BRANDED REF RECORD
  END;

  BlockedArgs = BRANDED REF RECORD
    id: CARDINAL;
    from: CARDINAL;
    to: CARDINAL;
  END;

  MovePacketArgs = BRANDED REF RECORD
    id: CARDINAL;
    from: CARDINAL;
    to: CARDINAL;
  END;

  QueueSizesArgs = BRANDED REF RECORD
    sz: RefIntArray.T;
  END;

  AbsorbArgs = BRANDED REF RECORD
    pktId: CARDINAL;
    node: CARDINAL;
  END;

  StepArgs = BRANDED REF RECORD
  END;
Zeus calls the following to invoke vbt v's event handler:

<*NOWARN*> PROCEDURE OEDispatcher(v: ZeusClass.T; evt: REFANY) RAISES {Thread.Alerted} =
  <* LL <= VBT.mu *>
  (* LL = {} if event style is output, LL = VBT.mu if event style is update. *)
  BEGIN
    TYPECASE v OF
    | PktRouteViewClass.T (view) => <*NOWARN*>
      TYPECASE evt OF
      | StartGraphArgs(varStartGraphArgs) => <*NOWARN*>
          view.oeStartGraph (
              varStartGraphArgs.nodeCnt
                ,
              varStartGraphArgs.queueSize
                ,
              varStartGraphArgs.bounded
                ,
              varStartGraphArgs.maxX
                ,
              varStartGraphArgs.maxY
              )
      | NewNodeArgs(varNewNodeArgs) => <*NOWARN*>
          view.oeNewNode (
              varNewNodeArgs.id
                ,
              varNewNodeArgs.x
                ,
              varNewNodeArgs.y
              )
      | NewStraightEdgeArgs(varNewStraightEdgeArgs) => <*NOWARN*>
          view.oeNewStraightEdge (
              varNewStraightEdgeArgs.id1
                ,
              varNewStraightEdgeArgs.id2
              )
      | NewCurvedEdgeArgs(varNewCurvedEdgeArgs) => <*NOWARN*>
          view.oeNewCurvedEdge (
              varNewCurvedEdgeArgs.id1
                ,
              varNewCurvedEdgeArgs.id2
                ,
              varNewCurvedEdgeArgs.x1
                ,
              varNewCurvedEdgeArgs.y1
                ,
              varNewCurvedEdgeArgs.x2
                ,
              varNewCurvedEdgeArgs.y2
              )
      | NewLabelArgs(varNewLabelArgs) => <*NOWARN*>
          view.oeNewLabel (
              varNewLabelArgs.label
                ,
              varNewLabelArgs.x
                ,
              varNewLabelArgs.y
              )
      | EndGraphArgs(varEndGraphArgs) => <*NOWARN*>
          view.oeEndGraph (
              )
      | StartPacketsArgs(varStartPacketsArgs) => <*NOWARN*>
          view.oeStartPackets (
              varStartPacketsArgs.pktCnt
              )
      | NewPacketArgs(varNewPacketArgs) => <*NOWARN*>
          view.oeNewPacket (
              varNewPacketArgs.id
                ,
              varNewPacketArgs.source
                ,
              varNewPacketArgs.dest
                ,
              varNewPacketArgs.fewestHops
                ,
              varNewPacketArgs.name
              )
      | EndPacketsArgs(varEndPacketsArgs) => <*NOWARN*>
          view.oeEndPackets (
              )
      | BlockedArgs(varBlockedArgs) => <*NOWARN*>
          view.oeBlocked (
              varBlockedArgs.id
                ,
              varBlockedArgs.from
                ,
              varBlockedArgs.to
              )
      | MovePacketArgs(varMovePacketArgs) => <*NOWARN*>
          view.oeMovePacket (
              varMovePacketArgs.id
                ,
              varMovePacketArgs.from
                ,
              varMovePacketArgs.to
              )
      | QueueSizesArgs(varQueueSizesArgs) => <*NOWARN*>
          view.oeQueueSizes (
              varQueueSizesArgs.sz
              )
      | AbsorbArgs(varAbsorbArgs) => <*NOWARN*>
          view.oeAbsorb (
              varAbsorbArgs.pktId
                ,
              varAbsorbArgs.node
              )
      | StepArgs(varStepArgs) => <*NOWARN*>
          view.oeStep (
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this view isn't a PktRouteViewClass, so just ignore *)
    END
  END OEDispatcher;

<*NOWARN*> PROCEDURE FEDispatcher(v: ZeusClass.T; evt: REFANY) =
  <* LL = VBT.mu *>
  BEGIN
    TYPECASE v OF
    | PktRouteAlgClass.T (alg) => <*NOWARN*>
      TYPECASE evt OF
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this alg isn't a PktRouteAlgClass, so just ignore *)
    END
  END FEDispatcher;

PROCEDURE StartGraph (
      initiator: Algorithm.T;
       nodeCnt: CARDINAL; queueSize: CARDINAL; bounded: BOOLEAN; maxX, maxY: REAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(StartGraphArgs
               , nodeCnt := nodeCnt
               , queueSize := queueSize
               , bounded := bounded
               , maxX := maxX
               , maxY := maxY
      );
      alg := NARROW(initiator, PktRouteAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfStartGraph);
      alg.stopAtEvent := alg.eventDataRec.stopAtStartGraph;
      alg.waitAtEvent := alg.eventDataRec.waitAtStartGraph;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "StartGraph", OEDispatcher, zumeArgRec);
    END;
  END StartGraph;

PROCEDURE NewNode (
      initiator: Algorithm.T;
       id: CARDINAL; x, y: REAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(NewNodeArgs
               , id := id
               , x := x
               , y := y
      );
      alg := NARROW(initiator, PktRouteAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfNewNode);
      alg.stopAtEvent := alg.eventDataRec.stopAtNewNode;
      alg.waitAtEvent := alg.eventDataRec.waitAtNewNode;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "NewNode", OEDispatcher, zumeArgRec);
    END;
  END NewNode;

PROCEDURE NewStraightEdge (
      initiator: Algorithm.T;
       id1, id2: CARDINAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(NewStraightEdgeArgs
               , id1 := id1
               , id2 := id2
      );
      alg := NARROW(initiator, PktRouteAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfNewStraightEdge);
      alg.stopAtEvent := alg.eventDataRec.stopAtNewStraightEdge;
      alg.waitAtEvent := alg.eventDataRec.waitAtNewStraightEdge;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "NewStraightEdge", OEDispatcher, zumeArgRec);
    END;
  END NewStraightEdge;

PROCEDURE NewCurvedEdge (
      initiator: Algorithm.T;
       id1, id2: CARDINAL; x1, y1, x2, y2: REAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(NewCurvedEdgeArgs
               , id1 := id1
               , id2 := id2
               , x1 := x1
               , y1 := y1
               , x2 := x2
               , y2 := y2
      );
      alg := NARROW(initiator, PktRouteAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfNewCurvedEdge);
      alg.stopAtEvent := alg.eventDataRec.stopAtNewCurvedEdge;
      alg.waitAtEvent := alg.eventDataRec.waitAtNewCurvedEdge;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "NewCurvedEdge", OEDispatcher, zumeArgRec);
    END;
  END NewCurvedEdge;

PROCEDURE NewLabel (
      initiator: Algorithm.T;
       label: TEXT; x, y: REAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(NewLabelArgs
               , label := label
               , x := x
               , y := y
      );
      alg := NARROW(initiator, PktRouteAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfNewLabel);
      alg.stopAtEvent := alg.eventDataRec.stopAtNewLabel;
      alg.waitAtEvent := alg.eventDataRec.waitAtNewLabel;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "NewLabel", OEDispatcher, zumeArgRec);
    END;
  END NewLabel;

PROCEDURE EndGraph (
      initiator: Algorithm.T;

    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(EndGraphArgs
      );
      alg := NARROW(initiator, PktRouteAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfEndGraph);
      alg.stopAtEvent := alg.eventDataRec.stopAtEndGraph;
      alg.waitAtEvent := alg.eventDataRec.waitAtEndGraph;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "EndGraph", OEDispatcher, zumeArgRec);
    END;
  END EndGraph;

PROCEDURE StartPackets (
      initiator: Algorithm.T;
       pktCnt: CARDINAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(StartPacketsArgs
               , pktCnt := pktCnt
      );
      alg := NARROW(initiator, PktRouteAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfStartPackets);
      alg.stopAtEvent := alg.eventDataRec.stopAtStartPackets;
      alg.waitAtEvent := alg.eventDataRec.waitAtStartPackets;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "StartPackets", OEDispatcher, zumeArgRec);
    END;
  END StartPackets;

PROCEDURE NewPacket (
      initiator: Algorithm.T;
       id, source, dest, fewestHops: CARDINAL; name: TEXT
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(NewPacketArgs
               , id := id
               , source := source
               , dest := dest
               , fewestHops := fewestHops
               , name := name
      );
      alg := NARROW(initiator, PktRouteAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfNewPacket);
      alg.stopAtEvent := alg.eventDataRec.stopAtNewPacket;
      alg.waitAtEvent := alg.eventDataRec.waitAtNewPacket;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "NewPacket", OEDispatcher, zumeArgRec);
    END;
  END NewPacket;

PROCEDURE EndPackets (
      initiator: Algorithm.T;

    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(EndPacketsArgs
      );
      alg := NARROW(initiator, PktRouteAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfEndPackets);
      alg.stopAtEvent := alg.eventDataRec.stopAtEndPackets;
      alg.waitAtEvent := alg.eventDataRec.waitAtEndPackets;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "EndPackets", OEDispatcher, zumeArgRec);
    END;
  END EndPackets;

PROCEDURE Blocked (
      initiator: Algorithm.T;
       id, from, to: CARDINAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(BlockedArgs
               , id := id
               , from := from
               , to := to
      );
      alg := NARROW(initiator, PktRouteAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfBlocked);
      alg.stopAtEvent := alg.eventDataRec.stopAtBlocked;
      alg.waitAtEvent := alg.eventDataRec.waitAtBlocked;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Blocked", OEDispatcher, zumeArgRec);
    END;
  END Blocked;

PROCEDURE MovePacket (
      initiator: Algorithm.T;
       id, from, to: CARDINAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(MovePacketArgs
               , id := id
               , from := from
               , to := to
      );
      alg := NARROW(initiator, PktRouteAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfMovePacket);
      alg.stopAtEvent := alg.eventDataRec.stopAtMovePacket;
      alg.waitAtEvent := alg.eventDataRec.waitAtMovePacket;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "MovePacket", OEDispatcher, zumeArgRec);
    END;
  END MovePacket;

PROCEDURE QueueSizes (
      initiator: Algorithm.T;
       sz: RefIntArray.T
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(QueueSizesArgs
               , sz := sz
      );
      alg := NARROW(initiator, PktRouteAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfQueueSizes);
      alg.stopAtEvent := alg.eventDataRec.stopAtQueueSizes;
      alg.waitAtEvent := alg.eventDataRec.waitAtQueueSizes;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "QueueSizes", OEDispatcher, zumeArgRec);
    END;
  END QueueSizes;

PROCEDURE Absorb (
      initiator: Algorithm.T;
       pktId, node: CARDINAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(AbsorbArgs
               , pktId := pktId
               , node := node
      );
      alg := NARROW(initiator, PktRouteAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfAbsorb);
      alg.stopAtEvent := alg.eventDataRec.stopAtAbsorb;
      alg.waitAtEvent := alg.eventDataRec.waitAtAbsorb;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Absorb", OEDispatcher, zumeArgRec);
    END;
  END Absorb;

PROCEDURE Step (
      initiator: Algorithm.T;

    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(StepArgs
      );
      alg := NARROW(initiator, PktRouteAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfStep);
      alg.stopAtEvent := alg.eventDataRec.stopAtStep;
      alg.waitAtEvent := alg.eventDataRec.waitAtStep;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Step", OEDispatcher, zumeArgRec);
    END;
  END Step;

BEGIN
END PktRouteIE.

interface View is in: