MonitorToolImpl.mesa
Last Edited by: Pier, July 30, 1985 5:35:43 pm PDT
DIRECTORY
Buttons USING [ButtonProc, Create],
ColorDisplayHeadDorado,
Commander USING [CommandProc, Handle, Register],
Containers USING [ChildXBound, Create],
IO USING [card, Error, GetCard, GetReal, PutFR, real, RIS],
Labels USING [Create, Set],
Menus USING [AppendMenuEntry, CreateEntry, CreateMenu, Menu, MenuProc],
MessageWindow USING [Append, Blink],
MonitorToolButtons USING [BitsPerPixel, EntryViewer, EntryViewerRec, Handle, HBlank, MTViewerRec, Position, Refresh, ResultViewer, ResultViewerRec, ScreenHeight, ScreenWidth, VBlank],
MonitorToolDefs USING [DoMonitorParams, fieldFreq, fieldTime, hBLeadLength, hBTrailLength, hRamMaxAddr, hSTrailAddr, MonitorParam, MonitorParamRec, SetMonitorParams, trueDiv, trueLinefreq, trueLinetime, trueMul, truePixelfreq, truePixeltime, vbToVS, visibleLines, vsToVB, vsToVS],
Rope USING [Equal, ROPE],
Rules USING [Create, Rule],
VFonts USING [CharWidth],
ViewerOps USING [PaintViewer, SetOpenHeight],
ViewerTools USING [EnableUserEdits, GetContents, InhibitUserEdits, MakeNewTextViewer, SetContents],
WindowManager USING [ScreenPos, StopColorViewers];
MonitorToolImpl: CEDAR PROGRAM
IMPORTS Buttons, Containers, ColorDisplayHeadDorado, IO, Labels, Menus, MessageWindow, MonitorToolButtons, MonitorToolDefs, Rope, Rules, Commander, VFonts, ViewerOps, ViewerTools, WindowManager
SHARES ColorDisplayHeadDorado = {
entryHeight: CARDINAL = 15; -- how tall to make each line of items
entryVSpace: CARDINAL = 6;  -- vertical leading space between lines
entryHSpace: CARDINAL = 10;  -- horizontal space between items in a line
entryTabSpace: CARDINAL ← 36*3;  -- horizontal tab between items in a line
ruleHeight: CARDINAL ← 4;
resultWidth: CARDINAL = 12*VFonts.CharWidth['0];-- 12 digits worth of width
default values for 1024X768 monitor
defaultScreenWidth: Rope.ROPE = "1024";
defaultScreenHeight: Rope.ROPE = "768";
defaultRefresh: Rope.ROPE = "30";
defaultHBlank: Rope.ROPE = "6";
defaultVBlank: Rope.ROPE = "850";
defaultBPP: Rope.ROPE = "8";
defaultPosition: Rope.ROPE = "right";
MakeMonitorTool: Commander.CommandProc = TRUSTED {
myRule: Rules.Rule;
myMenu: Menus.Menu ← Menus.CreateMenu[];
my: MonitorToolButtons.Handle ← NEW[MonitorToolButtons.MTViewerRec];
Menus.AppendMenuEntry[ -- add command to the menu
menu: myMenu,
entry: Menus.CreateEntry[
name: "Calculate", -- name of the command
proc: CalculateProc, -- MenuProc associated with command
clientData: my
]
];
Menus.AppendMenuEntry[ -- add command to the menu
menu: myMenu,
entry: Menus.CreateEntry[
name: "Set", -- name of the command
proc: SetParametersProc, -- MenuProc associated with command
clientData: my
]
];
Menus.AppendMenuEntry[ -- add command to the menu
menu: myMenu,
entry: Menus.CreateEntry[
name: "TurnOff", -- name of the command
proc: TurnOffProc, -- MenuProc associated with command
clientData: my
]
];
Menus.AppendMenuEntry[ -- add command to the menu
menu: myMenu,
entry: Menus.CreateEntry[
name: "NTSC", -- name of the command
proc: NTSCProc, -- MenuProc associated with command
clientData: my
]
];
my.container ← Containers.Create[info: [-- construct the outer container
name: "MonitorTool", -- name displayed in the caption
iconic: FALSE,   -- so tool won't be iconic (small) when first created
column: left,    -- initially in the left column
menu: myMenu,  -- displaying our menu command
scrollable: TRUE ]];  -- allow scrolling contents
my.screenWidth ← MakeEntryViewer[handle: my, buttonName: "screen width", labelName: "visible pixels", proc: MonitorToolButtons.ScreenWidth, initialData: defaultScreenWidth];
my.screenHeight ← MakeEntryViewer[handle: my, buttonName: "screen height", labelName: "visible pixels", proc: MonitorToolButtons.ScreenHeight, initialData: defaultScreenHeight];
my.refresh ← MakeEntryViewer[handle: my, buttonName: "refresh rate", labelName: "frames per second", proc: MonitorToolButtons.Refresh, initialData: defaultRefresh];
my.hBlank ← MakeEntryViewer[handle: my, buttonName: "hBlank time", labelName: "microseconds", proc: MonitorToolButtons.HBlank, initialData: defaultHBlank];
my.vBlank ← MakeEntryViewer[handle: my, buttonName: "vBlank time", labelName: "microseconds", proc: MonitorToolButtons.VBlank, initialData: defaultVBlank];
my.bpp ← MakeEntryViewer[handle: my, buttonName: "bits per pixel", labelName: "{1,2,4,8,24}", proc: MonitorToolButtons.BitsPerPixel, initialData: defaultBPP];
my.position ← MakeEntryViewer[handle: my, buttonName: "Position", labelName: "{Left/Right}", proc: MonitorToolButtons.Position, initialData: defaultPosition];
my.height ← my.height + entryHeight+ entryVSpace; --space down
myRule ← Rules.Create[info: [parent: my.container, wx: my.screenWidth.button.wx, wy: my.height, ww: my.container.ww-my.screenWidth.button.wx*2, wh: ruleHeight]];
my.height ← my.height + ruleHeight+ entryVSpace; --space down
Containers.ChildXBound[my.container, myRule];
now create output viewers
my.fieldTime ← MakeResultViewer[handle: my, leftLabelName: "field time", rightLabelName: "milliseconds"];
my.fieldFreq ← MakeResultViewer[handle: my, leftLabelName: "field freq", rightLabelName: "Hz"];
my.lineTime ← MakeResultViewer[handle: my, leftLabelName: "line time", rightLabelName: "microseconds"];
my.lineFreq ← MakeResultViewer[handle: my, leftLabelName: "line freq", rightLabelName: "KHz"];
my.pixelTime ← MakeResultViewer[handle: my, leftLabelName: "pixel time", rightLabelName: "nanoseconds"];
my.pixelFreq ← MakeResultViewer[handle: my, leftLabelName: "pixel freq", rightLabelName: "MHz"];
my.MUL ← MakeResultViewer[handle: my, leftLabelName: "MUL", rightLabelName: "[0..255]"];
my.DIV ← MakeResultViewer[handle: my, leftLabelName: "DIV", rightLabelName: "[0..15]"];
my.vControl ← MakeResultViewer[handle: my, leftLabelName: "vertical ctrl", rightLabelName: "", entryheight: 4*entryHeight, entrywidth: 3*resultWidth];
my.hControl ← MakeResultViewer[handle: my, leftLabelName: "horizontal ctrl", rightLabelName: "", entryheight: 4*entryHeight, entrywidth: 3*resultWidth];
now set up default values
CalculateProc[parent: NIL, clientData: my];
MessageWindow.Append[message: "Default Parameters for 1024x768 Monitor", clearFirst: TRUE];
ViewerOps.SetOpenHeight[my.container, my.height]; -- hint our desired height
ViewerOps.PaintViewer[my.container, all];    -- reflect above change
};
TurnOffProc: Menus.MenuProc = TRUSTED {
WindowManager.StopColorViewers[];
};
NTSCProc: Menus.MenuProc = TRUSTED {
this proc should only be called when a Dorado with NTSC-modified DispM board
is set up to do video tape recording. The parameters in the 24 Bpp MonitorParam below
were carefully determined by Pier and Gasbarro using trial and error on 8/24/83.
mp: MonitorToolDefs.MonitorParam;
bpp: LONG CARDINAL;
full: BOOLEANFALSE;
my: MonitorToolButtons.Handle ← NARROW[clientData];
{--for catch phrases
bpp ← IO.GetCard[IO.RIS[ViewerTools.GetContents[my.bpp.input]] ! IO.Error => {
MessageWindow.Append[message: "Input Syntax Error in ", clearFirst: TRUE];
MessageWindow.Append[message: my.bpp.button.name, clearFirst: FALSE];
GOTO error
};];
SELECT bpp FROM
24 => full←TRUE;
8,4,2,1 => NULL;
ENDCASE => {
MessageWindow.Append[message: "Input Value Error in ", clearFirst: TRUE];
MessageWindow.Append[message: my.bpp.button.name, clearFirst: FALSE];
GOTO error;
};
N.B.: we will set up the monitor waveforms identicallty for all bpp values. The values are the same as the "double speed" values for 24 bpp. This guarantees locking to the NTSC frequency. For bpp#24, run the video at 1/2 resolution horizontally and double the visible pixels per line.
mp ← NEW[MonitorToolDefs.MonitorParamRec ← [
hRes: 640, vRes: 480, vc: [VBtoVS: 3, VStoVS: 3, VStoVB: 20B, VisibleLines: 240],
hc: [HRamMaxAddr: 909, HBLeadLength: 12, HSTrailAddr: 56, HBTrailLength: 202],
cc: [zero: 5, mul: 115, div: 14], lmarg: 474, truePixelFreq: 0, truePixelTime: 0]];
MonitorToolDefs.SetMonitorParams[bpp: bpp, mp: mp];
IF NOT full THEN { --bpp#24
ColorDisplayHeadDorado.channelA.pixelsPerLine�
ColorDisplayHeadDorado.channelA.scanControl.resolution←half;
};
MessageWindow.Append[message: "Note: NTSC REQUIRES LATE MODEL HARDWARE", clearFirst: TRUE];
MessageWindow.Blink[]; MessageWindow.Blink[];
EXITS
error => NULL;
}; --for catch phrases
};
SetParametersProc: Menus.MenuProc = TRUSTED {
MenuProc: TYPE = PROC [parent: REF ANY, clientData: REF ANY ← NIL,
mouseButton: MouseButton ← red, shift, control: BOOL ← FALSE] ;
my: MonitorToolButtons.Handle ← NARROW[clientData];
sw, sh, refresh, bpp: LONG CARDINAL;
hBlank, vBlank: REAL;
posRope: Rope.ROPE;
pos: WindowManager.ScreenPos;
mp: MonitorToolDefs.MonitorParam;
{ --for catch phrases
sw ← IO.GetCard[IO.RIS[ViewerTools.GetContents[my.screenWidth.input]] ! IO.Error => {
MessageWindow.Append[message: "Input Syntax Error in ", clearFirst: TRUE];
MessageWindow.Append[message: my.screenWidth.button.name, clearFirst: FALSE];
GOTO error
};];
sh ← IO.GetCard[IO.RIS[ViewerTools.GetContents[my.screenHeight.input]] ! IO.Error => {
MessageWindow.Append[message: "Input Syntax Error in ", clearFirst: TRUE];
MessageWindow.Append[message: my.screenHeight.button.name, clearFirst: FALSE];
GOTO error
};];
refresh ← IO.GetCard[IO.RIS[ViewerTools.GetContents[my.refresh.input]] ! IO.Error => {
MessageWindow.Append[message: "Input Syntax Error in ", clearFirst: TRUE];
MessageWindow.Append[message: my.refresh.button.name, clearFirst: FALSE];
GOTO error
};];
bpp ← IO.GetCard[IO.RIS[ViewerTools.GetContents[my.bpp.input]] ! IO.Error => {
MessageWindow.Append[message: "Input Syntax Error in ", clearFirst: TRUE];
MessageWindow.Append[message: my.bpp.button.name, clearFirst: FALSE];
GOTO error
};];
hBlank ← 1E-6* IO.GetReal[IO.RIS[ViewerTools.GetContents[my.hBlank.input]] ! IO.Error => {
MessageWindow.Append[message: "Input Syntax Error in ", clearFirst: TRUE];
MessageWindow.Append[message: my.hBlank.button.name, clearFirst: FALSE];
GOTO error
};];
vBlank ← 1E-6* IO.GetReal[IO.RIS[ViewerTools.GetContents[my.vBlank.input]] ! IO.Error => {
MessageWindow.Append[message: "Input Syntax Error in ", clearFirst: TRUE];
MessageWindow.Append[message: my.vBlank.button.name, clearFirst: FALSE];
GOTO error
};];
posRope ← ViewerTools.GetContents[my.position.input ! IO.Error => {
MessageWindow.Append[message: "Input Syntax Error in ", clearFirst: TRUE];
MessageWindow.Append[message: my.position.button.name, clearFirst: FALSE];
GOTO error
};];
SELECT TRUE FROM
Rope.Equal[s1: posRope, s2: "left", case: FALSE] => pos ← left;
Rope.Equal[s1: posRope, s2: "right", case: FALSE] => pos ← right;
ENDCASE => {
MessageWindow.Append[message: "Input Syntax Error in Position", clearFirst: TRUE];
GOTO error
};
mp ← MonitorToolDefs.DoMonitorParams[sw,sh,refresh,hBlank,vBlank];
MonitorToolDefs.SetMonitorParams[bpp, pos, mp];
EXITS
error => NULL;
}; --for catch phrases
};
CalculateProc: Menus.MenuProc = TRUSTED {
my: MonitorToolButtons.Handle ← NARROW[clientData];
sw, sh, refresh, bpp: LONG CARDINAL;
hBlank, vBlank: REAL;
mp: MonitorToolDefs.MonitorParam;
{ --for catch phrases
sw ← IO.GetCard[IO.RIS[ViewerTools.GetContents[my.screenWidth.input]] ! IO.Error => {
MessageWindow.Append[message: "Input Syntax Error in ", clearFirst: TRUE];
MessageWindow.Append[message: my.screenWidth.button.name, clearFirst: FALSE];
GOTO error
};];
sh ← IO.GetCard[IO.RIS[ViewerTools.GetContents[my.screenHeight.input]] ! IO.Error => {
MessageWindow.Append[message: "Input Syntax Error in ", clearFirst: TRUE];
MessageWindow.Append[message: my.screenHeight.button.name, clearFirst: FALSE];
GOTO error
};];
refresh ← IO.GetCard[IO.RIS[ViewerTools.GetContents[my.refresh.input]] ! IO.Error => {
MessageWindow.Append[message: "Input Syntax Error in ", clearFirst: TRUE];
MessageWindow.Append[message: my.refresh.button.name, clearFirst: FALSE];
GOTO error
};];
bpp ← IO.GetCard[IO.RIS[ViewerTools.GetContents[my.bpp.input]] ! IO.Error => {
MessageWindow.Append[message: "Input Syntax Error in ", clearFirst: TRUE];
MessageWindow.Append[message: my.bpp.button.name, clearFirst: FALSE];
GOTO error
};];
hBlank ← 1E-6* IO.GetReal[IO.RIS[ViewerTools.GetContents[my.hBlank.input]] ! IO.Error => {
MessageWindow.Append[message: "Input Syntax Error in ", clearFirst: TRUE];
MessageWindow.Append[message: my.hBlank.button.name, clearFirst: FALSE];
GOTO error
};];
vBlank ← 1E-6* IO.GetReal[IO.RIS[ViewerTools.GetContents[my.vBlank.input]] ! IO.Error => {
MessageWindow.Append[message: "Input Syntax Error in ", clearFirst: TRUE];
MessageWindow.Append[message: my.vBlank.button.name, clearFirst: FALSE];
GOTO error
};];
EXITS
error => RETURN;
}; --for catch phrases
mp ← MonitorToolDefs.DoMonitorParams[sw,sh,refresh,hBlank,vBlank];
Labels.Set[label: my.fieldTime.data, value: IO.PutFR[format: "%g", v1: IO.real[1E3*MonitorToolDefs.fieldTime]]];
Labels.Set[label: my.fieldFreq.data, value: IO.PutFR[format: "%g", v1: IO.real[MonitorToolDefs.fieldFreq]]];
Labels.Set[label: my.lineTime.data, value: IO.PutFR[format: "%g", v1: IO.real[1E6*MonitorToolDefs.trueLinetime]]];
Labels.Set[label: my.lineFreq.data, value: IO.PutFR[format: "%g", v1: IO.real[1E-3*MonitorToolDefs.trueLinefreq]]];
Labels.Set[label: my.pixelTime.data, value: IO.PutFR[format: "%g", v1: IO.real[1E9*MonitorToolDefs.truePixeltime]]];
Labels.Set[label: my.pixelFreq.data, value: IO.PutFR[format: "%g", v1: IO.real[1E-6*MonitorToolDefs.truePixelfreq]]];
Labels.Set[label: my.MUL.data, value: IO.PutFR[format: "%g", v1: IO.card[MonitorToolDefs.trueMul]]];
Labels.Set[label: my.DIV.data, value: IO.PutFR[format: "%g", v1: IO.card[MonitorToolDefs.trueDiv]]];
ViewerTools.EnableUserEdits[my.hControl.data];
ViewerTools.SetContents[viewer: my.hControl.data, contents: IO.PutFR[format: "HRamMaxAddr: %g\nHBlankLeadLength: %g\nHSTrailAddr: %g\nHBTrailLength: %g", v1: IO.card[MonitorToolDefs.hRamMaxAddr], v2: IO.card[MonitorToolDefs.hBLeadLength], v3: IO.card[MonitorToolDefs.hSTrailAddr], v4: IO.card[MonitorToolDefs.hBTrailLength]]];
ViewerTools.InhibitUserEdits[my.hControl.data];
ViewerTools.EnableUserEdits[my.vControl.data];
ViewerTools.SetContents[viewer: my.vControl.data, contents: IO.PutFR[format: "VBtoVSLines: %g\nVStoVSLines: %g\nVStoVBLines: %g\nVisibleLines: %g", v1: IO.card[MonitorToolDefs.vbToVS], v2: IO.card[MonitorToolDefs.vsToVS], v3: IO.card[MonitorToolDefs.vsToVB], v4: IO.card[MonitorToolDefs.visibleLines]]];
ViewerTools.InhibitUserEdits[my.vControl.data];
};
MakeEntryViewer: PROCEDURE [handle: MonitorToolButtons.Handle, buttonName: Rope.ROPE, labelName: Rope.ROPE, proc: Buttons.ButtonProc, initialData: Rope.ROPE] RETURNS [ev: MonitorToolButtons.EntryViewer] = {
adds an entry viewer with a button, text viewer, and suffix label to the container
ev ← NEW[MonitorToolButtons.EntryViewerRec];
ev.button← Buttons.Create[
info: [
name: buttonName,
wy: handle.height,
default the width so that it will be computed for us --
wh: entryHeight, -- specify rather than defaulting so line is uniform
parent: handle.container,
border: FALSE ],
proc: proc,
clientData: handle]; -- this will be passed to our button proc
ev.input ← ViewerTools.MakeNewTextViewer[ [
parent: handle.container,
wx: entryTabSpace,
wy: handle.height+2,
ww: 12*VFonts.CharWidth['0], -- 12 digits worth of width
wh: entryHeight,
data: initialData, -- initial contents
scrollable: FALSE,
border: TRUE]];
ev.units ← Labels.Create[ [
name: labelName,
wx: ev.input.wx + ev.input.ww + entryHSpace,
wy: handle.height,
default ww
wh: entryHeight,
parent: handle.container,
border: FALSE]];
handle.height ← handle.height + entryHeight+ entryVSpace; --space down for next guy
};
MakeResultViewer: PROCEDURE [handle: MonitorToolButtons.Handle, leftLabelName, rightLabelName: Rope.ROPE, entryheight: CARDINAL ← entryHeight, entrywidth: CARDINAL ← resultWidth]RETURNS [rv: MonitorToolButtons.ResultViewer] = {
adds a result viewer with a label, text viewer, and units to the container
initialData: Rope.ROPE = " ????? ";
rv ← NEW[MonitorToolButtons.ResultViewerRec];
rv.left ← Labels.Create[ [
name: leftLabelName,
wy: handle.height,
default the width so that it will be computed for us --
wh: entryHeight,
parent: handle.container,
scrollable: FALSE,
border: FALSE]];
rv.data ← ViewerTools.MakeNewTextViewer[ [
data: initialData,
wx: entryTabSpace,
wy: handle.height,
ww: entrywidth,
wh: entryheight,
scrollable: FALSE,
parent: handle.container,
border: TRUE]];
rv.right ← Labels.Create[ [
name: rightLabelName,
wx: rv.data.wx + rv.data.ww + entryHSpace,
wy: handle.height,
default ww
wh: entryHeight,
parent: handle.container,
scrollable: FALSE,
border: FALSE]];
handle.height ← handle.height + entryheight+ entryVSpace; --space down for next guy
};
Commander.Register[key: "MonitorTool", proc: MakeMonitorTool,
doc: "Create a color monitor control tool" ];
}.