mentor/derived/EuclidAlgClass.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 Euclid.evt.
      ********************************************************************


MODULE EuclidAlgClass;

<*NOWARN*> IMPORT Rd, ZeusClass, Fmt, Algorithm, Wr, ZeusPanel;
<*NOWARN*> IMPORT FormsVBT, Euclid, 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 := EuclidDefaultInit;
        snapshot := EuclidDefaultSnapshot;
        restore := EuclidDefaultRestore;
        updateEventCounts := EuclidDefaultUpdateCts;
      END;

PROCEDURE EuclidDefaultInit (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("EuclidEventData.fv");
    Attach("stopatCodeEvents", EuclidDoIt);
    Attach("waitatCodeEvents", EuclidDoIt);
    Attach("eventCounts", EuclidRefreshCts);
    Attach("stopAtSetupTriangle", EuclidDoIt);
    Attach("waitAtSetupTriangle", EuclidDoIt);
    Attach("stopAtSetupSquare", EuclidDoIt);
    Attach("waitAtSetupSquare", EuclidDoIt);
    Attach("stopAtLineAL", EuclidDoIt);
    Attach("waitAtLineAL", EuclidDoIt);
    Attach("stopAtTriangle", EuclidDoIt);
    Attach("waitAtTriangle", EuclidDoIt);
    Attach("stopAtQuad", EuclidDoIt);
    Attach("waitAtQuad", EuclidDoIt);
    Attach("stopAtShear", EuclidDoIt);
    Attach("waitAtShear", EuclidDoIt);
    Attach("stopAtRotateTriangle", EuclidDoIt);
    Attach("waitAtRotateTriangle", EuclidDoIt);
    Attach("stopAtRotateLine", EuclidDoIt);
    Attach("waitAtRotateLine", EuclidDoIt);
    Attach("stopAtRotateAngle", EuclidDoIt);
    Attach("waitAtRotateAngle", EuclidDoIt);
    Attach("stopAtHighlightLine", EuclidDoIt);
    Attach("waitAtHighlightLine", EuclidDoIt);
    Attach("stopAtHighlightAngle", EuclidDoIt);
    Attach("waitAtHighlightAngle", EuclidDoIt);
    Attach("stopAtRemove", EuclidDoIt);
    Attach("waitAtRemove", EuclidDoIt);
    Attach("stopAtStep", EuclidDoIt);
    Attach("waitAtStep", EuclidDoIt);
    FromFV (v.eventData, v);    (* Get FV and internal data in sync *)
    RETURN Algorithm.T.init(v);
  END EuclidDefaultInit;

PROCEDURE EuclidDoIt (           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, "stopAtSetupTriangle") THEN
      NARROW(arg, T).eventDataRec.stopAtSetupTriangle :=
          FormsVBT.GetBoolean(fv, "stopAtSetupTriangle");
    END;
    IF Text.Equal(e, "waitAtSetupTriangle") THEN
      NARROW(arg, T).eventDataRec.waitAtSetupTriangle :=
          FormsVBT.GetInteger(fv, "waitAtSetupTriangle");
    END;
    IF Text.Equal(e, "stopAtSetupSquare") THEN
      NARROW(arg, T).eventDataRec.stopAtSetupSquare :=
          FormsVBT.GetBoolean(fv, "stopAtSetupSquare");
    END;
    IF Text.Equal(e, "waitAtSetupSquare") THEN
      NARROW(arg, T).eventDataRec.waitAtSetupSquare :=
          FormsVBT.GetInteger(fv, "waitAtSetupSquare");
    END;
    IF Text.Equal(e, "stopAtLineAL") THEN
      NARROW(arg, T).eventDataRec.stopAtLineAL :=
          FormsVBT.GetBoolean(fv, "stopAtLineAL");
    END;
    IF Text.Equal(e, "waitAtLineAL") THEN
      NARROW(arg, T).eventDataRec.waitAtLineAL :=
          FormsVBT.GetInteger(fv, "waitAtLineAL");
    END;
    IF Text.Equal(e, "stopAtTriangle") THEN
      NARROW(arg, T).eventDataRec.stopAtTriangle :=
          FormsVBT.GetBoolean(fv, "stopAtTriangle");
    END;
    IF Text.Equal(e, "waitAtTriangle") THEN
      NARROW(arg, T).eventDataRec.waitAtTriangle :=
          FormsVBT.GetInteger(fv, "waitAtTriangle");
    END;
    IF Text.Equal(e, "stopAtQuad") THEN
      NARROW(arg, T).eventDataRec.stopAtQuad :=
          FormsVBT.GetBoolean(fv, "stopAtQuad");
    END;
    IF Text.Equal(e, "waitAtQuad") THEN
      NARROW(arg, T).eventDataRec.waitAtQuad :=
          FormsVBT.GetInteger(fv, "waitAtQuad");
    END;
    IF Text.Equal(e, "stopAtShear") THEN
      NARROW(arg, T).eventDataRec.stopAtShear :=
          FormsVBT.GetBoolean(fv, "stopAtShear");
    END;
    IF Text.Equal(e, "waitAtShear") THEN
      NARROW(arg, T).eventDataRec.waitAtShear :=
          FormsVBT.GetInteger(fv, "waitAtShear");
    END;
    IF Text.Equal(e, "stopAtRotateTriangle") THEN
      NARROW(arg, T).eventDataRec.stopAtRotateTriangle :=
          FormsVBT.GetBoolean(fv, "stopAtRotateTriangle");
    END;
    IF Text.Equal(e, "waitAtRotateTriangle") THEN
      NARROW(arg, T).eventDataRec.waitAtRotateTriangle :=
          FormsVBT.GetInteger(fv, "waitAtRotateTriangle");
    END;
    IF Text.Equal(e, "stopAtRotateLine") THEN
      NARROW(arg, T).eventDataRec.stopAtRotateLine :=
          FormsVBT.GetBoolean(fv, "stopAtRotateLine");
    END;
    IF Text.Equal(e, "waitAtRotateLine") THEN
      NARROW(arg, T).eventDataRec.waitAtRotateLine :=
          FormsVBT.GetInteger(fv, "waitAtRotateLine");
    END;
    IF Text.Equal(e, "stopAtRotateAngle") THEN
      NARROW(arg, T).eventDataRec.stopAtRotateAngle :=
          FormsVBT.GetBoolean(fv, "stopAtRotateAngle");
    END;
    IF Text.Equal(e, "waitAtRotateAngle") THEN
      NARROW(arg, T).eventDataRec.waitAtRotateAngle :=
          FormsVBT.GetInteger(fv, "waitAtRotateAngle");
    END;
    IF Text.Equal(e, "stopAtHighlightLine") THEN
      NARROW(arg, T).eventDataRec.stopAtHighlightLine :=
          FormsVBT.GetBoolean(fv, "stopAtHighlightLine");
    END;
    IF Text.Equal(e, "waitAtHighlightLine") THEN
      NARROW(arg, T).eventDataRec.waitAtHighlightLine :=
          FormsVBT.GetInteger(fv, "waitAtHighlightLine");
    END;
    IF Text.Equal(e, "stopAtHighlightAngle") THEN
      NARROW(arg, T).eventDataRec.stopAtHighlightAngle :=
          FormsVBT.GetBoolean(fv, "stopAtHighlightAngle");
    END;
    IF Text.Equal(e, "waitAtHighlightAngle") THEN
      NARROW(arg, T).eventDataRec.waitAtHighlightAngle :=
          FormsVBT.GetInteger(fv, "waitAtHighlightAngle");
    END;
    IF Text.Equal(e, "stopAtRemove") THEN
      NARROW(arg, T).eventDataRec.stopAtRemove :=
          FormsVBT.GetBoolean(fv, "stopAtRemove");
    END;
    IF Text.Equal(e, "waitAtRemove") THEN
      NARROW(arg, T).eventDataRec.waitAtRemove :=
          FormsVBT.GetInteger(fv, "waitAtRemove");
    END;
    IF Text.Equal(e, "stopAtStep") THEN
      NARROW(arg, T).eventDataRec.stopAtStep :=
          FormsVBT.GetBoolean(fv, "stopAtStep");
    END;
    IF Text.Equal(e, "waitAtStep") THEN
      NARROW(arg, T).eventDataRec.waitAtStep :=
          FormsVBT.GetInteger(fv, "waitAtStep");
    END;
  END EuclidDoIt;

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

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.stopAtSetupTriangle :=
        FormsVBT.GetBoolean(fv, "stopAtSetupTriangle");
    alg.eventDataRec.waitAtSetupTriangle :=
        FormsVBT.GetInteger(fv, "waitAtSetupTriangle");
    alg.eventDataRec.stopAtSetupSquare :=
        FormsVBT.GetBoolean(fv, "stopAtSetupSquare");
    alg.eventDataRec.waitAtSetupSquare :=
        FormsVBT.GetInteger(fv, "waitAtSetupSquare");
    alg.eventDataRec.stopAtLineAL :=
        FormsVBT.GetBoolean(fv, "stopAtLineAL");
    alg.eventDataRec.waitAtLineAL :=
        FormsVBT.GetInteger(fv, "waitAtLineAL");
    alg.eventDataRec.stopAtTriangle :=
        FormsVBT.GetBoolean(fv, "stopAtTriangle");
    alg.eventDataRec.waitAtTriangle :=
        FormsVBT.GetInteger(fv, "waitAtTriangle");
    alg.eventDataRec.stopAtQuad :=
        FormsVBT.GetBoolean(fv, "stopAtQuad");
    alg.eventDataRec.waitAtQuad :=
        FormsVBT.GetInteger(fv, "waitAtQuad");
    alg.eventDataRec.stopAtShear :=
        FormsVBT.GetBoolean(fv, "stopAtShear");
    alg.eventDataRec.waitAtShear :=
        FormsVBT.GetInteger(fv, "waitAtShear");
    alg.eventDataRec.stopAtRotateTriangle :=
        FormsVBT.GetBoolean(fv, "stopAtRotateTriangle");
    alg.eventDataRec.waitAtRotateTriangle :=
        FormsVBT.GetInteger(fv, "waitAtRotateTriangle");
    alg.eventDataRec.stopAtRotateLine :=
        FormsVBT.GetBoolean(fv, "stopAtRotateLine");
    alg.eventDataRec.waitAtRotateLine :=
        FormsVBT.GetInteger(fv, "waitAtRotateLine");
    alg.eventDataRec.stopAtRotateAngle :=
        FormsVBT.GetBoolean(fv, "stopAtRotateAngle");
    alg.eventDataRec.waitAtRotateAngle :=
        FormsVBT.GetInteger(fv, "waitAtRotateAngle");
    alg.eventDataRec.stopAtHighlightLine :=
        FormsVBT.GetBoolean(fv, "stopAtHighlightLine");
    alg.eventDataRec.waitAtHighlightLine :=
        FormsVBT.GetInteger(fv, "waitAtHighlightLine");
    alg.eventDataRec.stopAtHighlightAngle :=
        FormsVBT.GetBoolean(fv, "stopAtHighlightAngle");
    alg.eventDataRec.waitAtHighlightAngle :=
        FormsVBT.GetInteger(fv, "waitAtHighlightAngle");
    alg.eventDataRec.stopAtRemove :=
        FormsVBT.GetBoolean(fv, "stopAtRemove");
    alg.eventDataRec.waitAtRemove :=
        FormsVBT.GetInteger(fv, "waitAtRemove");
    alg.eventDataRec.stopAtStep :=
        FormsVBT.GetBoolean(fv, "stopAtStep");
    alg.eventDataRec.waitAtStep :=
        FormsVBT.GetInteger(fv, "waitAtStep");
  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, "stopAtSetupTriangle",
                        alg.eventDataRec.stopAtSetupTriangle);
    FormsVBT.PutInteger(fv, "waitAtSetupTriangle",
                        alg.eventDataRec.waitAtSetupTriangle);
    FormsVBT.PutBoolean(fv, "stopAtSetupSquare",
                        alg.eventDataRec.stopAtSetupSquare);
    FormsVBT.PutInteger(fv, "waitAtSetupSquare",
                        alg.eventDataRec.waitAtSetupSquare);
    FormsVBT.PutBoolean(fv, "stopAtLineAL",
                        alg.eventDataRec.stopAtLineAL);
    FormsVBT.PutInteger(fv, "waitAtLineAL",
                        alg.eventDataRec.waitAtLineAL);
    FormsVBT.PutBoolean(fv, "stopAtTriangle",
                        alg.eventDataRec.stopAtTriangle);
    FormsVBT.PutInteger(fv, "waitAtTriangle",
                        alg.eventDataRec.waitAtTriangle);
    FormsVBT.PutBoolean(fv, "stopAtQuad",
                        alg.eventDataRec.stopAtQuad);
    FormsVBT.PutInteger(fv, "waitAtQuad",
                        alg.eventDataRec.waitAtQuad);
    FormsVBT.PutBoolean(fv, "stopAtShear",
                        alg.eventDataRec.stopAtShear);
    FormsVBT.PutInteger(fv, "waitAtShear",
                        alg.eventDataRec.waitAtShear);
    FormsVBT.PutBoolean(fv, "stopAtRotateTriangle",
                        alg.eventDataRec.stopAtRotateTriangle);
    FormsVBT.PutInteger(fv, "waitAtRotateTriangle",
                        alg.eventDataRec.waitAtRotateTriangle);
    FormsVBT.PutBoolean(fv, "stopAtRotateLine",
                        alg.eventDataRec.stopAtRotateLine);
    FormsVBT.PutInteger(fv, "waitAtRotateLine",
                        alg.eventDataRec.waitAtRotateLine);
    FormsVBT.PutBoolean(fv, "stopAtRotateAngle",
                        alg.eventDataRec.stopAtRotateAngle);
    FormsVBT.PutInteger(fv, "waitAtRotateAngle",
                        alg.eventDataRec.waitAtRotateAngle);
    FormsVBT.PutBoolean(fv, "stopAtHighlightLine",
                        alg.eventDataRec.stopAtHighlightLine);
    FormsVBT.PutInteger(fv, "waitAtHighlightLine",
                        alg.eventDataRec.waitAtHighlightLine);
    FormsVBT.PutBoolean(fv, "stopAtHighlightAngle",
                        alg.eventDataRec.stopAtHighlightAngle);
    FormsVBT.PutInteger(fv, "waitAtHighlightAngle",
                        alg.eventDataRec.waitAtHighlightAngle);
    FormsVBT.PutBoolean(fv, "stopAtRemove",
                        alg.eventDataRec.stopAtRemove);
    FormsVBT.PutInteger(fv, "waitAtRemove",
                        alg.eventDataRec.waitAtRemove);
    FormsVBT.PutBoolean(fv, "stopAtStep",
                        alg.eventDataRec.stopAtStep);
    FormsVBT.PutInteger(fv, "waitAtStep",
                        alg.eventDataRec.waitAtStep);
    CountsToFV (fv, alg);
  END ToFV;

PROCEDURE CountsToFV (fv : FormsVBT.T; alg: T) =
  <* LL = VBT.mu *>
  BEGIN
    FormsVBT.PutText(fv, "ctOfSetupTriangle",
                        Fmt.Int(alg.eventDataRec.ctOfSetupTriangle));
    FormsVBT.PutText(fv, "ctOfSetupSquare",
                        Fmt.Int(alg.eventDataRec.ctOfSetupSquare));
    FormsVBT.PutText(fv, "ctOfLineAL",
                        Fmt.Int(alg.eventDataRec.ctOfLineAL));
    FormsVBT.PutText(fv, "ctOfTriangle",
                        Fmt.Int(alg.eventDataRec.ctOfTriangle));
    FormsVBT.PutText(fv, "ctOfQuad",
                        Fmt.Int(alg.eventDataRec.ctOfQuad));
    FormsVBT.PutText(fv, "ctOfShear",
                        Fmt.Int(alg.eventDataRec.ctOfShear));
    FormsVBT.PutText(fv, "ctOfRotateTriangle",
                        Fmt.Int(alg.eventDataRec.ctOfRotateTriangle));
    FormsVBT.PutText(fv, "ctOfRotateLine",
                        Fmt.Int(alg.eventDataRec.ctOfRotateLine));
    FormsVBT.PutText(fv, "ctOfRotateAngle",
                        Fmt.Int(alg.eventDataRec.ctOfRotateAngle));
    FormsVBT.PutText(fv, "ctOfHighlightLine",
                        Fmt.Int(alg.eventDataRec.ctOfHighlightLine));
    FormsVBT.PutText(fv, "ctOfHighlightAngle",
                        Fmt.Int(alg.eventDataRec.ctOfHighlightAngle));
    FormsVBT.PutText(fv, "ctOfRemove",
                        Fmt.Int(alg.eventDataRec.ctOfRemove));
    FormsVBT.PutText(fv, "ctOfStep",
                        Fmt.Int(alg.eventDataRec.ctOfStep));
  END CountsToFV;

PROCEDURE EuclidDefaultUpdateCts ( v: T; reset: BOOLEAN) =
  <* LL = VBT.mu *>
  BEGIN
    IF reset THEN
      v.eventDataRec.ctOfSetupTriangle := 0;
      v.eventDataRec.ctOfSetupSquare := 0;
      v.eventDataRec.ctOfLineAL := 0;
      v.eventDataRec.ctOfTriangle := 0;
      v.eventDataRec.ctOfQuad := 0;
      v.eventDataRec.ctOfShear := 0;
      v.eventDataRec.ctOfRotateTriangle := 0;
      v.eventDataRec.ctOfRotateLine := 0;
      v.eventDataRec.ctOfRotateAngle := 0;
      v.eventDataRec.ctOfHighlightLine := 0;
      v.eventDataRec.ctOfHighlightAngle := 0;
      v.eventDataRec.ctOfRemove := 0;
      v.eventDataRec.ctOfStep := 0;
    END;
    CountsToFV (v.eventData, v);
  END EuclidDefaultUpdateCts;

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

PROCEDURE EuclidDefaultRestore (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(
          "EuclidAlgClass.EuclidDefaultRestore read error");
    END;
    IF v.eventData = NIL THEN
      RAISE ZeusClass.Error(
          "EuclidAlgClass.EuclidDefaultRestore: " &
          "eventData not set!");
    END;
    TRY
      v.eventData.restore(rd);
      v.updateEventCounts(FALSE);
      FromFV(v.eventData, v);
    EXCEPT
    ELSE
      RAISE ZeusClass.Error(
          "EuclidAlgClass.EuclidDefaultRestore error");
    END;
    Algorithm.T.restore(v, rd);
    IF NOT ZeusUtil.EatChar(rd, ')') THEN
      RAISE ZeusClass.Error(
          "EuclidAlgClass.EuclidDefaultRestore read error");
    END;
  END EuclidDefaultRestore;

BEGIN
END EuclidAlgClass.