DIRECTORY Atom, Buttons USING [ButtonProc, Create, SetDisplayStyle], IO, Labels USING [Create, Set], NumberLabels USING [NumberLabel, CreateNumber, NumberLabelUpdate], Rope USING [ROPE, Length], VFonts, ViewerClasses USING [Viewer, ViewerRec], ViewerOps, ViewerTools USING [GetContents, MakeNewTextViewer, SetContents, SetSelection], NewEthernetFace USING [Status], NSPilotSystem USING [HostNumber], Unformat USING [Error, HostNumber], EtherTesterOps USING [HWTestMode, Pattern, StatsType, hwMode, pattern, realBackground, stats], EtherTesterViewer; EtherTesterViewerImpl: PROGRAM IMPORTS Buttons, IO, Labels, NumberLabels, Rope, ViewerOps, ViewerTools, Unformat, EtherTesterOps, EtherTesterViewer EXPORTS EtherTesterViewer = BEGIN OPEN IO, EtherTesterViewer; ROPE: TYPE = Rope.ROPE; Viewer: TYPE = ViewerClasses.Viewer; ViewerRec: TYPE = ViewerClasses.ViewerRec; ButtonAndText: PUBLIC PROC[name: ROPE, sib: Viewer, width: INTEGER, newLine: BOOL _ FALSE, default: ROPE _ NIL, valType: ValueType _ cardinal] RETURNS[item: ButtonItem] = BEGIN button, text: Viewer; info: ViewerRec _ [name: name, parent: sib.parent, wy: sib.wy, wh: entryHeight, border: FALSE, scrollable: FALSE]; IF newLine THEN { info.wx _ IF sib.parent.scrollable THEN 0 ELSE xFudge; info.wy _ info.wy + sib.wh + 2; } ELSE info.wx _ sib.wx+sib.ww+8; button _ Buttons.Create[info: info, proc: ButtonItemProc]; text _ ViewerTools.MakeNewTextViewer[ info: [parent: sib.parent, wx: button.wx+button.ww+xFudge, wy: button.wy, ww: width, wh: entryHeight, border: FALSE, scrollable: FALSE]]; ViewerTools.SetContents[text, default]; item _ NEW[ButtonItemObject _ [button: button, text: text, default: default, valType: valType]]; ViewerOps.AddProp[button, $ButtonItem, item]; END; ButtonItemProc: Buttons.ButtonProc = TRUSTED BEGIN v: Viewer = NARROW[parent]; item: ButtonItem = NARROW[ViewerOps.FetchProp[v, $ButtonItem]]; SELECT mouseButton FROM red, blue => ViewerTools.SetSelection[item.text, NIL]; yellow => ViewerTools.SetContents[item.text, item.default]; ENDCASE => NULL; END; ReadCard: PUBLIC PROC[item: ButtonItem] RETURNS[val: CARDINAL] = BEGIN v: Viewer _ item.text; h: IO.STREAM; txt: ROPE _ ViewerTools.GetContents[v]; parseError: BOOL _ FALSE; IF txt.Length[] = 0 THEN txt _ item.default; h _ IO.RIS[txt]; val _ h.GetCard[ ! IO.Error => {parseError _ TRUE; CONTINUE}]; IF parseError THEN SIGNAL ParseError; END; ReadINT: PUBLIC PROC[item: ButtonItem] RETURNS[val: INT] = BEGIN v: Viewer _ item.text; h: IO.STREAM; txt: ROPE _ ViewerTools.GetContents[v]; parseError: BOOL _ FALSE; IF txt.Length[] = 0 THEN txt _ item.default; h _ IO.RIS[txt]; val _ h.GetInt[ ! IO.Error => {parseError _ TRUE; CONTINUE}]; IF parseError THEN SIGNAL ParseError; END; ReadHostNum: PUBLIC PROC[v: Viewer] RETURNS[num: NSPilotSystem.HostNumber] = BEGIN txt: ROPE _ ViewerTools.GetContents[v]; parseError: BOOL _ FALSE; num _ Unformat.HostNumber[txt, octal ! Unformat.Error => {parseError _ TRUE; CONTINUE}]; IF parseError THEN SIGNAL ParseError; END; StatusToRope: PUBLIC PROC[s: NewEthernetFace.Status] RETURNS [r: ROPE] = BEGIN SELECT s FROM pending => r _ "pending"; ok => r _ "ok"; overrun => r _ "overrun"; underrun => r _ "underrun"; packetTooLong => r _ "packetTooLong"; tooManyCollisions => r _ "tooManyCollisions"; lateCollision => r _ "lateCollision"; crc => r _ "crc"; crcAndBadAlignment => r _ "crcAndBadAlignment"; badAlignmentButOkCrc => r _ "badAlignmentButOkCrc"; otherError=> r _ "otherError"; ENDCASE => r _ "ERROR"; END; MakeFirstBoolItem: PUBLIC PROC[name: ROPE, proc: BoolItemProc, parent: Viewer, init: BOOL] RETURNS[button: Viewer] = BEGIN boolItem: BoolItem; info: ViewerRec _ [name: name, parent: parent, wx: 0, wy: 0, wh: entryHeight, border: FALSE]; button _ Buttons.Create[info: info, proc: BooleanButton]; IF ~init THEN Buttons.SetDisplayStyle[button, $WhiteOnBlack]; boolItem _ NEW[BoolItemObject _ [button, proc, init]]; ViewerOps.AddProp[button, $BoolItem, boolItem]; END; MakeBoolItem: PUBLIC PROC[ name: ROPE, proc: BoolItemProc, sib: Viewer, init: BOOL, newLine: BOOL _ FALSE] RETURNS[button: Viewer] = BEGIN boolItem: BoolItem; info: ViewerRec _ [name: name, parent: sib.parent, wy: sib.wy, wh: entryHeight, border: FALSE]; IF newLine THEN { info.wx _ IF sib.parent.scrollable THEN 0 ELSE xFudge; info.wy _ info.wy + sib.wh + 2; } ELSE info.wx _ sib.wx+sib.ww+4; button _ Buttons.Create[info: info, proc: BooleanButton]; IF init THEN Buttons.SetDisplayStyle[button, $WhiteOnBlack]; boolItem _ NEW[BoolItemObject _ [button, proc, init]]; ViewerOps.AddProp[button, $BoolItem, boolItem]; END; BooleanButton: Buttons.ButtonProc = TRUSTED BEGIN v: Viewer _ NARROW[parent]; item: BoolItem _ NARROW[ViewerOps.FetchProp[v, $BoolItem]]; IF ~item.value THEN Buttons.SetDisplayStyle[v, $WhiteOnBlack] ELSE Buttons.SetDisplayStyle[v, $BlackOnWhite]; item.value _ ~item.value; -- complement the value item.proc[item.value]; -- call proc to change its stored value END; PatternButton: PUBLIC PROC[sib: Viewer, newLine: BOOL _ FALSE] = BEGIN button: Viewer; info: ViewerRec _ [name: "Pattern:", parent: sib.parent, wy: sib.wy, wh: entryHeight, border: FALSE]; IF newLine THEN { info.wx _ IF sib.parent.scrollable THEN 0 ELSE xFudge; info.wy _ info.wy + sib.wh; } ELSE info.wx _ sib.wx+sib.ww; button _ Buttons.Create[info: info, proc: PatternItemProc]; patternButton _ Labels.Create[ info: [name: " ", parent: sib.parent, wx: button.wx+button.ww+xFudge, wy: button.wy, wh: entryHeight, border: FALSE]]; SetPatternText[EtherTesterOps.pattern]; END; SetPatternText: PROC[pat: EtherTesterOps.Pattern] = BEGIN r: ROPE; r _ SELECT pat FROM ignore => "Ignore", zeros => "Zeros", ones => "Ones", alternating => "125252B", pairs => "146314B", oneTwentyFive => "125B", countBytes => "CountBytes", countWords => "CountWords", lenOne => "Len-1", lenSix => "Len-6", ENDCASE => ERROR; Labels.Set[patternButton, r]; END; PatternItemProc: Buttons.ButtonProc = TRUSTED BEGIN OPEN EtherTesterOps; new: Pattern _ IF pattern = LAST[Pattern] THEN FIRST[Pattern] ELSE SUCC[pattern]; pattern _ new; SetPatternText[pattern]; END; HWModeButton: PUBLIC PROC[sib: Viewer, newLine: BOOL _ FALSE] = BEGIN button: Viewer; info: ViewerRec _ [name: "HWMode:", parent: sib.parent, wy: sib.wy, wh: entryHeight, border: FALSE]; IF newLine THEN { info.wx _ IF sib.parent.scrollable THEN 0 ELSE xFudge; info.wy _ info.wy + sib.wh; } ELSE info.wx _ sib.wx+sib.ww; button _ Buttons.Create[info: info, proc: HWModeItemProc]; hwModeButton _ Labels.Create[ info: [name: " ", parent: sib.parent, wx: button.wx+button.ww+xFudge, wy: button.wy, wh: entryHeight, border: FALSE]]; SetHWModeText[EtherTesterOps.hwMode]; END; SetHWModeText: PROC[mode: EtherTesterOps.HWTestMode] = BEGIN r: ROPE; r _ SELECT mode FROM normal => r _ "normal", loopBack => r _ "loopback", other => r _ "other", ENDCASE => ERROR; Labels.Set[hwModeButton, r]; END; HWModeItemProc: Buttons.ButtonProc = TRUSTED BEGIN OPEN EtherTesterOps; new: HWTestMode _ IF hwMode = LAST[HWTestMode] THEN FIRST[HWTestMode] ELSE SUCC[hwMode]; hwMode _ new; SetHWModeText[hwMode]; END; MakeStatsDisplayers: PUBLIC PROC[y: INTEGER, parent: Viewer] = BEGIN x: INTEGER _ 0; numY: INTEGER _ y + 3; labelY: INTEGER _ numY + entryHeight + 4; last: StatsItem _ NIL; statsDisplayer _ NIL; FOR i: EtherTesterOps.StatsType IN [sent .. idle] DO box: Viewer _ ViewerTools.MakeNewTextViewer[ info: [parent: parent, wx: x + 9, wy: y, ww: 40, wh: 2*entryHeight, border: FALSE, scrollable: FALSE]]; num: NumberLabels.NumberLabel _ NumberLabels.CreateNumber[ info: [parent: parent, wx: x+2, wy: numY, ww: 50, wh: entryHeight+1, scrollable: FALSE], chars: 6]; label: Viewer _ Labels.Create[ info: [name: StatsTypeToRope[i], parent: parent, wx: x+6, wy: labelY, wh: entryHeight, border: FALSE]]; this: StatsItem _ NEW[StatsItemObject _ [box, label, num, right, i, 0, NIL]]; IF last # NIL THEN last.next _ this; last _ this; IF statsDisplayer = NIL THEN statsDisplayer _ this; x _ x + 50; ENDLOOP; END; StatsTypeToRope: PUBLIC PROC[which: EtherTesterOps.StatsType] RETURNS[r: ROPE] = BEGIN SELECT which FROM sent => r _ "sent"; coll => r _ "coll"; errOut => r _ "errOut"; recv => r _ "recv"; noIn => r _ "noIn"; noOut => r _ "noOut"; errIn => r _ "errIn"; echoed => r _ "echoed"; late => r _ "late"; lost => r _ "lost"; dally => r _ "dally"; idle => r _ "idle"; ENDCASE => r _ "ERROR"; END; UpdateStatsBoxes: PUBLIC PROC = BEGIN item: StatsItem _ statsDisplayer; curr: INT; IF (curr _ EtherTesterOps.stats.pktsOut) # item.currentlyDisplayed THEN NumberLabels.NumberLabelUpdate[item.num, item.currentlyDisplayed _ curr]; item _ item.next; IF (curr _ EtherTesterOps.stats.collisions) # item.currentlyDisplayed THEN NumberLabels.NumberLabelUpdate[item.num, item.currentlyDisplayed _ curr]; item _ item.next; IF (curr _ EtherTesterOps.stats.errsOut) # item.currentlyDisplayed THEN NumberLabels.NumberLabelUpdate[item.num, item.currentlyDisplayed _ curr]; item _ item.next; IF (curr _ EtherTesterOps.stats.pktsIn) # item.currentlyDisplayed THEN NumberLabels.NumberLabelUpdate[item.num, item.currentlyDisplayed _ curr]; item _ item.next; IF (curr _ EtherTesterOps.stats.missed) # item.currentlyDisplayed THEN NumberLabels.NumberLabelUpdate[item.num, curr]; item _ item.next; IF (curr _ EtherTesterOps.stats.packetsNotEchoed) # item.currentlyDisplayed THEN NumberLabels.NumberLabelUpdate[item.num, item.currentlyDisplayed _ curr]; item _ item.next; IF (curr _ EtherTesterOps.stats.errsIn) # item.currentlyDisplayed THEN NumberLabels.NumberLabelUpdate[item.num, item.currentlyDisplayed _ curr]; item _ item.next; IF (curr _ EtherTesterOps.stats.packetsEchoed) # item.currentlyDisplayed THEN NumberLabels.NumberLabelUpdate[item.num, item.currentlyDisplayed _ curr]; item _ item.next; IF (curr _ EtherTesterOps.stats.lateEchos) # item.currentlyDisplayed THEN NumberLabels.NumberLabelUpdate[item.num, item.currentlyDisplayed _ curr]; item _ item.next; IF (curr _ EtherTesterOps.stats.echosMissed) # item.currentlyDisplayed THEN NumberLabels.NumberLabelUpdate[item.num, item.currentlyDisplayed _ curr]; item _ item.next; IF (curr _ EtherTesterOps.stats.dallyForEcho) # item.currentlyDisplayed THEN NumberLabels.NumberLabelUpdate[item.num, item.currentlyDisplayed _ curr]; item _ item.next; IF (curr _ EtherTesterOps.realBackground) # item.currentlyDisplayed THEN NumberLabels.NumberLabelUpdate[item.num, item.currentlyDisplayed _ curr]; END; END. EtherTesterViewerImpl.mesa last edited by Willie-Sue, January 10, 1986 4:45:50 pm PST sugested by: EtherTesterTajo.mesa, AOF, 26-Sep-83 17:13:41 Global Data Creating and using viewers ********************************* procs for Boolean buttons ********************* Ê ¦˜Jšœ™Jšœ:™:J˜Jšœ:™:J˜šÏk ˜ Jšœ˜Jšœœ'˜4Jšœ˜Jšœœ˜Jšœ œ0˜BJšœœœœ˜J˜Jšœœ˜(J˜ Jšœ œ=˜NJ˜Jšœœ ˜Jšœœ˜!J˜#JšœœJ˜^Jšœ˜J˜—šœ˜š˜Jšœ œ5˜@J˜ Jšœ!˜!—Jšœ˜—J˜Jšœ˜!J˜Jšœ ™ J˜Jšœœœ˜Jšœœ˜$J˜Jšœ<™Jšœ œœ ˜%—Jšœ˜—J˜šžœ œœœ˜:š˜J˜Jšœœœ˜ Jšœœ˜'Jšœ œœ˜Jšœœœ ˜,J˜Jšœœœ˜Jšœœœœ˜=Jšœ œœ ˜%—Jšœ˜—J™šž œ œ œ!˜Lš˜Jšœœ˜'Jšœ œœ˜JšœGœœ˜XJšœ œœ ˜%—Jšœ˜—J˜šž œ œœœ˜Hš˜šœ˜ Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ%˜%Jšœ-˜-Jšœ%˜%Jšœ˜Jšœ/˜/Jšœ3˜3Jšœ˜Jšœ˜——Jšœ˜—J™Jšœ/™/J™š žœ œœ,œœ˜vš˜Jšœ˜šœ˜JšœDœ˜K—J˜Jšœ9˜9Jšœœ0˜=Jšœ œ(˜6Jšœ/˜/—Jšœ˜—J˜šž œ œ œ)œ œœœ˜‡š˜Jšœ˜šœ˜JšœFœ˜M—šœ ˜šœ œœœ˜8Jšœ˜—Jšœ˜—Jšœ˜J˜Jšœ9˜9Jšœœ0˜š˜Jšœœ˜Jšœœ ˜Jšœœ˜)Jšœœ˜Jšœœ˜šœœ˜4šœ,˜,JšœNœœ˜i—šœ:˜:JšœSœ ˜e—šœ˜Jšœaœ˜i—Jšœœ2œ˜MJšœœœ˜$J˜ Jšœœœ˜3J˜ —Jšœ˜—Jšœ˜—J˜š žœœœ"œœ˜Pš˜šœ˜J˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜——Jšœ˜—J˜šžœ œ˜š˜J˜!Jšœœ˜ šœA˜GJšœJ˜J—J˜šœD˜JJšœJ˜J—J˜šœA˜GJšœJ˜J—J˜šœ@˜FJšœJ˜J—J˜šœ@˜FJšœ0˜0—J˜šœJ˜PJšœJ˜J—J˜šœ@˜FJšœJ˜J—J˜šœG˜MJšœJ˜J—J˜šœC˜IJšœJ˜J—J˜šœE˜KJšœJ˜J—J˜šœF˜LJšœJ˜J—J˜šœB˜HJšœJ˜J——Jšœ˜—J˜Jšœ˜—…—(ú5´