-- CountInterface.mesa Edited by Sandman September 4, 1980  3:33 PM

DIRECTORY
  CountDefs USING [
    condition, EnumerateNotify, groups, loadmatrix, modePos, modulePos, mon,
    ParamNotify, printmodule, printsorted, printtables, processPos, setProcess,
    sort, SortClass, zero],
  CountPrivate USING [Mode],
  FormSW USING [
    AllocateItemDescriptor, ClientItemsProcType, CommandItem, Enumerated,
    EnumeratedItem, line0, line1, line2, line3, StringItem],
  PerfCommonOps USING [],
  Runtime USING [GetBcdTime],
  String USING [AppendString],
  Time USING [Append, Unpack],
  Tool USING [Create, MakeFileSW, MakeFormSW, MakeMsgSW],
  ToolWindow USING [TransitionProcType],
  Window USING [Handle, Place];

CountInterface: PROGRAM
  IMPORTS CountDefs, FormSW, Runtime, String, Time, Tool
  EXPORTS CountDefs, PerfCommonOps =PUBLIC

  BEGIN OPEN CountDefs;

  window: Window.Handle ← NIL;
  msgSW: Window.Handle ← NIL;
  cmdSW: Window.Handle ← NIL;
  logSW: Window.Handle ← NIL;

  MakeSWs: PROCEDURE [window: Window.Handle] =
    BEGIN
    msgSW ← Tool.MakeMsgSW[window];
    cmdSW ← Tool.MakeFormSW[window: window, formProc: MakeForm];
    logSW ← Tool.MakeFileSW[window: window, name: "Count.log"L];
    END;

  Init: PROCEDURE =
    BEGIN
    title: STRING = "Xfer Counter 6.0 of "L;
    herald: STRING ← [60];
    String.AppendString[to: herald, from: title];
    Time.Append[herald, Time.Unpack[Runtime.GetBcdTime[]]];
    herald.length ← herald.length - 3;
    window ← Tool.Create[
      makeSWsProc: MakeSWs, name: herald, clientTransition: TransitionProc];
    END;

  TransitionProc: ToolWindow.TransitionProcType =
    BEGIN
    SELECT TRUE FROM old = inactive => msgSW ← cmdSW ← logSW ← NIL; ENDCASE;
    END;

  monitorOn: BOOLEAN ← FALSE;
  module: STRING ← NIL;
  process: STRING ← NIL;
  sortClass: SortClass ← count;
  mode: CountPrivate.Mode ← plain;

  monPlace: Window.Place = [x: 0*7, y: FormSW.line0];
  zeroPlace: Window.Place = [x: 22*7, y: FormSW.line0];
  condPlace: Window.Place = [x: 42*7, y: FormSW.line0];
  ptPlace: Window.Place = [x: 0*7, y: FormSW.line1];
  psPlace: Window.Place = [x: 22*7, y: FormSW.line1];
  sortPlace: Window.Place = [x: 42*7, y: FormSW.line1];
  pmPlace: Window.Place = [x: 0*7, y: FormSW.line2];
  modulePlace: Window.Place = [x: 14*7, y: FormSW.line2];
  spPlace: Window.Place = [x: 39*7, y: FormSW.line2];
  pPlace: Window.Place = [x: 52*7, y: FormSW.line2];
  modePlace: Window.Place = [x: 0*7, y: FormSW.line3];
  matrixPlace: Window.Place = [x: 26*7, y: FormSW.line3];
  groupPlace: Window.Place = [x: 42*7, y: FormSW.line3];

  MakeForm: FormSW.ClientItemsProcType =
    BEGIN OPEN FormSW;
    sortClassEnumRec: ARRAY SortClass OF Enumerated ←
      [[string: "count"L, value: SortClass[count]],
	[string: "time"L, value: SortClass[time]]];
    monitorEnumRec: ARRAY BOOLEAN OF Enumerated ←
      [[string: "off"L, value: FALSE], [string: "on"L, value: TRUE]];
    modeEnumRec: ARRAY CountPrivate.Mode OF Enumerated ←
      [[string: "plain"L, value: CountPrivate.Mode[plain]],
	[string: "matrix"L, value: CountPrivate.Mode[matrix]]];
    nParams: CARDINAL = groups + 1;
    items ← AllocateItemDescriptor[nParams];
    items[mon] ← EnumeratedItem[
      tag: "Monitor"L, place: monPlace, feedback: all,
      choices: LOOPHOLE[DESCRIPTOR[monitorEnumRec]], proc: EnumerateNotify,
      value: @monitorOn];
    items[zero] ← CommandItem[
      tag: "Zero Tables"L, place: zeroPlace, proc: ParamNotify];
    items[condition] ← CommandItem[
      tag: "Condition Breaks"L, place: condPlace, proc: ParamNotify];
    items[printtables] ← CommandItem[
      tag: "Print Tables"L, place: ptPlace, proc: ParamNotify];
    items[printsorted] ← CommandItem[
      tag: "Print Sorted"L, place: psPlace, proc: ParamNotify];
    items[sort] ← EnumeratedItem[
      tag: "Sort by"L, place: sortPlace, feedback: all,
      choices: LOOPHOLE[DESCRIPTOR[sortClassEnumRec]], proc: EnumerateNotify,
      value: @sortClass];
    items[printmodule] ← CommandItem[
      tag: "Print Module"L, place: pmPlace, proc: ParamNotify];
    items[modulePos] ← StringItem[
      tag: "Module"L, place: modulePlace, string: @module, drawBox: TRUE,
      inHeap: TRUE];
    items[setProcess] ← CommandItem[
      tag: "Set Process"L, place: spPlace, proc: ParamNotify];
    items[processPos] ← StringItem[
      tag: "Process"L, place: pPlace, string: @process, drawBox: TRUE,
      inHeap: TRUE];
    items[modePos] ← EnumeratedItem[
      tag: "Mode"L, place: modePlace, feedback: all,
      choices: LOOPHOLE[DESCRIPTOR[modeEnumRec]], proc: EnumerateNotify,
      value: @mode];
    items[loadmatrix] ← CommandItem[
      tag: "Load Matrix"L, place: matrixPlace, proc: ParamNotify];
    items[groups] ← CommandItem[
      tag: "Show Group"L, place: groupPlace, proc: ParamNotify];
    END;


  Init[];

  END...