mentor/derived/logoAlgClass.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:48:22 PST 1995 by kalsow  
      modified on Wed Feb 17 16:46:18 PST 1993 by johnh   
      modified on Thu Sep 24 10:59:20 PDT 1992 by mhb     

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

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


MODULE logoAlgClass;

<*NOWARN*> IMPORT Rd, ZeusClass, Fmt, Algorithm, Wr, ZeusPanel;
<*NOWARN*> IMPORT FormsVBT, VBT, Text, ZeusUtil;

<* PRAGMA LL *>
Fix any FormsVBT errors; don't handle exceptions for them.
<* FATAL FormsVBT.Error, FormsVBT.Unimplemented *>

REVEAL
  T = Public BRANDED OBJECT
      OVERRIDES
        <* LL = VBT.mu *>
        init := logoDefaultInit;
        snapshot := logoDefaultSnapshot;
        restore := logoDefaultRestore;
        updateEventCounts := logoDefaultUpdateCts;
      END;

PROCEDURE logoDefaultInit (v: T): Algorithm.T =
  <* LL = VBT.mu *>
  PROCEDURE Attach (id: TEXT; proc: FormsVBT.Proc) =
    BEGIN
      FormsVBT.AttachProc(v.eventData, id, proc, v);
    END Attach;
  BEGIN
    v.eventData := ZeusPanel.NewForm("logoEventData.fv");
    Attach("stopatCodeEvents", logoDoIt);
    Attach("waitatCodeEvents", logoDoIt);
    Attach("eventCounts", logoRefreshCts);
    Attach("stopAtInit", logoDoIt);
    Attach("waitAtInit", logoDoIt);
    Attach("stopAtRandomStep", logoDoIt);
    Attach("waitAtRandomStep", logoDoIt);
    Attach("stopAtShift", logoDoIt);
    Attach("waitAtShift", logoDoIt);
    Attach("stopAtMarquee", logoDoIt);
    Attach("waitAtMarquee", logoDoIt);
    Attach("stopAtMarqueeSpots", logoDoIt);
    Attach("waitAtMarqueeSpots", logoDoIt);
    FromFV (v.eventData, v);    (* Get FV and internal data in sync *)
    RETURN Algorithm.T.init(v);
  END logoDefaultInit;

PROCEDURE logoDoIt (           fv : FormsVBT.T;
                           e  : TEXT;
                           arg: REFANY;
                <*UNUSED*> t  : VBT.TimeStamp) =
  <* LL = VBT.mu *>
  BEGIN
    IF Text.Equal(e, "stopatCodeEvents") THEN
      NARROW(arg, T).stopatCodeEvents :=
          FormsVBT.GetBoolean(fv, "stopatCodeEvents");
    END;
    IF Text.Equal(e, "waitatCodeEvents") THEN
      NARROW(arg, T).waitatCodeEvents :=
          FormsVBT.GetInteger(fv, "waitatCodeEvents");
    END;
    IF Text.Equal(e, "stopAtInit") THEN
      NARROW(arg, T).eventDataRec.stopAtInit :=
          FormsVBT.GetBoolean(fv, "stopAtInit");
    END;
    IF Text.Equal(e, "waitAtInit") THEN
      NARROW(arg, T).eventDataRec.waitAtInit :=
          FormsVBT.GetInteger(fv, "waitAtInit");
    END;
    IF Text.Equal(e, "stopAtRandomStep") THEN
      NARROW(arg, T).eventDataRec.stopAtRandomStep :=
          FormsVBT.GetBoolean(fv, "stopAtRandomStep");
    END;
    IF Text.Equal(e, "waitAtRandomStep") THEN
      NARROW(arg, T).eventDataRec.waitAtRandomStep :=
          FormsVBT.GetInteger(fv, "waitAtRandomStep");
    END;
    IF Text.Equal(e, "stopAtShift") THEN
      NARROW(arg, T).eventDataRec.stopAtShift :=
          FormsVBT.GetBoolean(fv, "stopAtShift");
    END;
    IF Text.Equal(e, "waitAtShift") THEN
      NARROW(arg, T).eventDataRec.waitAtShift :=
          FormsVBT.GetInteger(fv, "waitAtShift");
    END;
    IF Text.Equal(e, "stopAtMarquee") THEN
      NARROW(arg, T).eventDataRec.stopAtMarquee :=
          FormsVBT.GetBoolean(fv, "stopAtMarquee");
    END;
    IF Text.Equal(e, "waitAtMarquee") THEN
      NARROW(arg, T).eventDataRec.waitAtMarquee :=
          FormsVBT.GetInteger(fv, "waitAtMarquee");
    END;
    IF Text.Equal(e, "stopAtMarqueeSpots") THEN
      NARROW(arg, T).eventDataRec.stopAtMarqueeSpots :=
          FormsVBT.GetBoolean(fv, "stopAtMarqueeSpots");
    END;
    IF Text.Equal(e, "waitAtMarqueeSpots") THEN
      NARROW(arg, T).eventDataRec.waitAtMarqueeSpots :=
          FormsVBT.GetInteger(fv, "waitAtMarqueeSpots");
    END;
  END logoDoIt;

PROCEDURE logoRefreshCts (
                <*UNUSED*> fv  : FormsVBT.T;
                <*UNUSED*> e   : TEXT;
                           arg : REFANY;
                <*UNUSED*> t   : VBT.TimeStamp) =
  <* LL = VBT.mu *>
  BEGIN
    NARROW(arg, T).updateEventCounts(FALSE);
  END logoRefreshCts;

PROCEDURE FromFV (fv : FormsVBT.T; alg: T) =
  <* LL = VBT.mu *>
  BEGIN
    alg.stopatCodeEvents :=
        FormsVBT.GetBoolean(fv, "stopatCodeEvents");
    alg.waitatCodeEvents :=
        FormsVBT.GetInteger(fv, "waitatCodeEvents");
    alg.eventDataRec.stopAtInit :=
        FormsVBT.GetBoolean(fv, "stopAtInit");
    alg.eventDataRec.waitAtInit :=
        FormsVBT.GetInteger(fv, "waitAtInit");
    alg.eventDataRec.stopAtRandomStep :=
        FormsVBT.GetBoolean(fv, "stopAtRandomStep");
    alg.eventDataRec.waitAtRandomStep :=
        FormsVBT.GetInteger(fv, "waitAtRandomStep");
    alg.eventDataRec.stopAtShift :=
        FormsVBT.GetBoolean(fv, "stopAtShift");
    alg.eventDataRec.waitAtShift :=
        FormsVBT.GetInteger(fv, "waitAtShift");
    alg.eventDataRec.stopAtMarquee :=
        FormsVBT.GetBoolean(fv, "stopAtMarquee");
    alg.eventDataRec.waitAtMarquee :=
        FormsVBT.GetInteger(fv, "waitAtMarquee");
    alg.eventDataRec.stopAtMarqueeSpots :=
        FormsVBT.GetBoolean(fv, "stopAtMarqueeSpots");
    alg.eventDataRec.waitAtMarqueeSpots :=
        FormsVBT.GetInteger(fv, "waitAtMarqueeSpots");
  END FromFV;

<*UNUSED*>
PROCEDURE ToFV (fv : FormsVBT.T; alg: T) =
  <* LL = VBT.mu *>
  BEGIN
    FormsVBT.PutBoolean(fv, "stopatCodeEvents", alg.stopatCodeEvents);
    FormsVBT.PutInteger(fv, "waitatCodeEvents", alg.waitatCodeEvents);
    FormsVBT.PutBoolean(fv, "stopAtInit",
                        alg.eventDataRec.stopAtInit);
    FormsVBT.PutInteger(fv, "waitAtInit",
                        alg.eventDataRec.waitAtInit);
    FormsVBT.PutBoolean(fv, "stopAtRandomStep",
                        alg.eventDataRec.stopAtRandomStep);
    FormsVBT.PutInteger(fv, "waitAtRandomStep",
                        alg.eventDataRec.waitAtRandomStep);
    FormsVBT.PutBoolean(fv, "stopAtShift",
                        alg.eventDataRec.stopAtShift);
    FormsVBT.PutInteger(fv, "waitAtShift",
                        alg.eventDataRec.waitAtShift);
    FormsVBT.PutBoolean(fv, "stopAtMarquee",
                        alg.eventDataRec.stopAtMarquee);
    FormsVBT.PutInteger(fv, "waitAtMarquee",
                        alg.eventDataRec.waitAtMarquee);
    FormsVBT.PutBoolean(fv, "stopAtMarqueeSpots",
                        alg.eventDataRec.stopAtMarqueeSpots);
    FormsVBT.PutInteger(fv, "waitAtMarqueeSpots",
                        alg.eventDataRec.waitAtMarqueeSpots);
    CountsToFV (fv, alg);
  END ToFV;

PROCEDURE CountsToFV (fv : FormsVBT.T; alg: T) =
  <* LL = VBT.mu *>
  BEGIN
    FormsVBT.PutText(fv, "ctOfInit",
                        Fmt.Int(alg.eventDataRec.ctOfInit));
    FormsVBT.PutText(fv, "ctOfRandomStep",
                        Fmt.Int(alg.eventDataRec.ctOfRandomStep));
    FormsVBT.PutText(fv, "ctOfShift",
                        Fmt.Int(alg.eventDataRec.ctOfShift));
    FormsVBT.PutText(fv, "ctOfMarquee",
                        Fmt.Int(alg.eventDataRec.ctOfMarquee));
    FormsVBT.PutText(fv, "ctOfMarqueeSpots",
                        Fmt.Int(alg.eventDataRec.ctOfMarqueeSpots));
  END CountsToFV;

PROCEDURE logoDefaultUpdateCts ( v: T; reset: BOOLEAN) =
  <* LL = VBT.mu *>
  BEGIN
    IF reset THEN
      v.eventDataRec.ctOfInit := 0;
      v.eventDataRec.ctOfRandomStep := 0;
      v.eventDataRec.ctOfShift := 0;
      v.eventDataRec.ctOfMarquee := 0;
      v.eventDataRec.ctOfMarqueeSpots := 0;
    END;
    CountsToFV (v.eventData, v);
  END logoDefaultUpdateCts;

PROCEDURE logoDefaultSnapshot (v: T; wr: Wr.T)
  RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    TRY
      Wr.PutChar(wr, '(')
    EXCEPT
    ELSE
      RAISE ZeusClass.Error(
          "logoAlgClass.logoDefaultSnapshot write error");
    END;
    IF v.eventData = NIL THEN
      RAISE ZeusClass.Error(
          "logoAlgClass.logoDefaultSnapshot: " &
          "eventData not set!");
    END;
    TRY
      v.eventData.snapshot(wr)
    EXCEPT
      FormsVBT.Error (msg) =>
        RAISE ZeusClass.Error(
          "logoAlgClass.logoDefaultSnapshot FV error: "
          & msg);
    ELSE
      RAISE ZeusClass.Error(
        "logoAlgClass.logoDefaultSnapshot error");
    END;
    Algorithm.T.snapshot(v, wr);
    TRY
      Wr.PutChar(wr, ')')
    EXCEPT
    ELSE
      RAISE ZeusClass.Error(
          "logoAlgClass.logoDefaultSnapshot write error");
    END;
  END logoDefaultSnapshot;

PROCEDURE logoDefaultRestore (v: T; rd: Rd.T)
  RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    IF rd = NIL THEN RETURN END;
    IF NOT ZeusUtil.EatChar(rd, '(') THEN
      RAISE ZeusClass.Error(
          "logoAlgClass.logoDefaultRestore read error");
    END;
    IF v.eventData = NIL THEN
      RAISE ZeusClass.Error(
          "logoAlgClass.logoDefaultRestore: " &
          "eventData not set!");
    END;
    TRY
      v.eventData.restore(rd);
      v.updateEventCounts(FALSE);
      FromFV(v.eventData, v);
    EXCEPT
    ELSE
      RAISE ZeusClass.Error(
          "logoAlgClass.logoDefaultRestore error");
    END;
    Algorithm.T.restore(v, rd);
    IF NOT ZeusUtil.EatChar(rd, ')') THEN
      RAISE ZeusClass.Error(
          "logoAlgClass.logoDefaultRestore read error");
    END;
  END logoDefaultRestore;

BEGIN
END logoAlgClass.