6~CAL PR0~ TO DISPLAY A T E ~ BI~ D ~ WITH REAL-TIME DATA ON AN I B M ~ ~ Theodore J. Sheskin Industrial Engineering Department Cleveland State University Cleveland, OH 44115
ABSTRACT A graphical program called TESTBED was written in Pascal in summer 1985 for NASA Lewis Research Center, Cleveland, Ohio. TESTBED displays on an IBM Personal Computer/XTa block diagram of the DC testbed for the power management and distribution system for the space station. When the testbed, which will contain photovoltaic arrays, batteries, and loads, is deployed in the field, it will be permanently connected to the I~M PC/XT via direct memory access. Sensors attached to the testbed in the field will continually collect and update data in real time. The program will superimpose the real-time data on the block diagram of the testbed displayed on the screen of the PC/XT. The program uses procedures ocntained in Metawindow, a software package of graphics utilities written by Metagraphics Corp., Mothntain View, California.
Graphical Pascal program, IBM PC/XT, block diagram, real-time data.
~
G
N
The TEBTHED program is written as a set of Pascal procedures followed by a main program. The main program draws the block diagram of the testbed. The block diagram contains seven rectangles representing the seven major subsystea%s or modules of the testbed. The modules Solar Array (SA) and Solar Array Simulator (SAS) are displayed at the left of the screen. Two load bank modules (LBI, LB2) appear at the right. At the bottnm of the screen three battery bank modules (BBI, BB2, ~33) are displayed. The graphics display system is initialized by the program to place the origin of a Cartesian coordinate system in the lower left corner of the screen. Within each row the X pixel position is nunbered sequentially from 0 on the left to 639 cn the right. Within each column the Y raster position is numbered sequentially from 0 on the bottcm to 199 ca the top. To demonstrate the capability to display numerical data in real time overlayed on a graphical display of a block diagram, Pascal procedures generate random n t m ~ s to simulate real-time data. (When the testbed is deployed in the field, these random number procedures will not be called. ) Adjacent to each rectangle represent/ng a module in the testbed block diagram, a pair of cc~tinually changing random n ~ s is displayed to represent the current and voltage recorded by sensors attached to the module. For each of two load bank modules, a sequence of ten continuously varying random binary digits is displayed to indicate which load bank inuieT~ts are operating. The main program enables the cursor position on the screen to be automatically updated to follow the ~ t of the mouse by the operator. This cursor tracking capability is used to allow any one of the seven modules to be expanded for a full screen display of its internal structure and data in real time. By moving the mouse to move the cursor inside a rectangle representing a module on the block diagram, and then pressing the left button ca the mouse, the operator will "open a window" to display a full scree~ image of the selected module. Seven Pascal procedures will each "open a window" to allow the operator to display each of the seven modules. An eighth Pascal procedure will allow the operator to "close a window" by pressing the right button on the mouse to restore the display of the testbed block diagram. To exit from the program, the operator must press both buttons on the mouse. The TESTBED program was written in Microsoft Pascal. The program will run on an I~M Personal Cbmputer (PC or XT) with at least 128 Kb of m ~ D r y and one double-sided disk drive. An IBM Enhanced Graphics Adaptor display card and a Microsoft Mouse are needed to implement the program. PASCAL ~ Eleven Pascal procedures precede the body of the T ~ main program in Pascal. ~ eleven procedures are named Rand, Rand Wind, Rand LB, Open Window SA, Open Window SAS, Open Window LBI, Open Window LB2, O p ~ Window HBI, Open Window BB2, Open Window BB3, and Close Window. Procedure Rand generates a stream of random n ~ s between 0 and 999. A Pascal function named Random is called to display randcm three-diglt integers in scientific notation with a field width of eleven d%aracters (including sign). In addlticn, for each of two load bank modules, a sequence of ten 4-45
446
PROCEEDINGS
OF THE 8TH ANNUAL CONFERENCE ON COMPUTERS AND INDUSTRIAL ENGINEERING
continuously varying randcm binary digits, oonsisting of a "0" or "i", is displayed. A "i" in a given position represents a load bank increment which is operating. A "0" represents a load bank increment which is not operating. To generate a stream of randan numbers, a Pascal Repeat-Until loop is used. The condition for exiting from the loop is that a key 'Q' or 'q' is depressed. Upon exiting, data is frozen, that is, a stream of random nunbers is transformed into a static display. (See Fig. i. ) Following the initial display of the testbed block diagram by the main program, procedure Rand is called once to superimpose the stream of random n t m ~ s on the block diagram. Procedure Rand is also called each time after the mouse right button is pressed to close a window to restore the image of the testbed block diagram. Procedure Rand Wind is almost identical to procedure Rand. The statements in procedure Rand which generate random bits to represent the status of increments in Load Bank 1 and Load Bank 2 are omitted from procedure Rand Wind. Procedure Rand Wind is called by the Open Window procedures which display images of the following modules: SA, SAS, BBI, BB2, and BB3. (See Fig. 2. ) Procedure Rand LB is also similar to procedure Rand. The difference is that a sequence of oonsecutive n~mbers 1 through I0 is printed in a row near the top of the screen. A set of five randam numbers in scientific notation is printed in a row below the odd ntm~bers near the top of the screen. A second set of five random numbers in scientific notation is printed in a row below the even numbers. Procedure Rand LB is called by the Open Window procedures which display images of the LBI and LB2 modules. (See Fig. 3. ) To enable details of the Solar Array module to be viewed, procedure Open Window SA will display an enlarged image, called a window, of the SA module. Procedure Close Window is called to replace a display of a selected module with a display of the testbed. MAIN PRO6RAM The major Pascal ccmmsnds and Metawindow procedures of the TESTBED main program are outlined. Basic programming structures are described by using key Pascal statements and Metawindow procedures a c c ~ e d by ocmment statements enclosed in braces, { }. The symbol {M} following a command will der~te a Metawindow procedure. View Port (0, 0, 639, 199); {M} {Define the rectangular limits of the screen as the entire screen for subseq;_ent writing operations. } Raster Op(1); {M} {Screen writing operations will overlay what is on the screen.} The seven rectangles representing the modules of the testbed are drawn by the following pair of Metawindow procedures: Set Rect (Ri, X, Y, X + & X, Y + A Y); {M} {Specify the coordinates of rectangle Ri to represent the i th module. } Frame Rect (Ri); {M} {Draw an outline of rectangle Ri.} Rand; {Display streams of randcm n ~ pairs adjacent to each testbed module to represent realdata. Display ten randam bits to represent the increments for each load bank. }
Load lJ+.k I Iocrem,.l I I I 1191101
[-so+V-Lumt,Bz +_'_'LLJl'.+m+'m
.
4,38~[+B2 ~J,SZ60DB2
I
,.rosE,B2|
+mtlalor
+,SmElO2
.
.
.
.
.
.
.
For del~ll, ,+o~ cttrsor inside ]
1
.
.
/
cJ'tOOO(+921 B,mk2 I
......... I
l,oad B
block. Press left Imttm raise, L__J To PestoP+te+O++,rightImllon I mo.se,
Fig. I.
.
3.momz
|
To t'rtwC.ll.+d,'kta,strike 'O' or 'q',
To exit, both buttons muse,
.
........ {
32400F.+BZ~-.......
~la--r-~era~ 2,4mE+91
.
OllO60t
2
Batter+ Banks
PowerMa,a~lemei+ta1+dDistribtttio, (Ptt~l)) Test Bed
.
.
SHESKIN: Graphical Program to Display Testbed Block Diagram
447
Switching between the testbed block diagram and individual diagrams of the testbed modules is performed under the oontrol of a mouse/cttrsor t r a c k ~ programmed loop. Within a Read Mouse Repeat-Until polling loop, the cursor position on the screen is automatically updated to follow a movement of the mouse by the operator. The basic structure of the mouse/cursor tracking loop is outlined below. Limit Mouse (0, 0, 639, 199); {M} {Insure that mouse tracking extends within the minirma, and X and Y screen eoordinate limits. } Write the following messages instructing the operator what to do after data has been frozen: "For detail, move cursor inside block. Press left button mouse. To restore testbed, right button mouse. To exit, both buttons mouse." Track Cursor (True); {M} {When ~ r tracking is enabled, the cursor position is automatically updated to follow the movement of the mouse. } Repeat {Begin mouse/cursor tracking loop. } Repeat Read ~buse (X, Y, Switch) {M} Until Switch >_ 0; {Poll to detect changes in the mouse position or in the mouse buttcr~. } If (Switch = 0) then Begin {No mouse button has been pressed. } Move To (X, Y); {M} {Move the cursor without drawing a line. The operator can move the cursor on the diagram of the testbed inside the rectangle of a module selected for display as a full screen image} End {No mouse button has been pressed. } Else If (Switch = Sw Left) then Begin {Mouse left buttcn has been pressed. } Query Cursor (Curs X, Curs Y, Curs Level, Switches); {M} {Return the cordinates of the cursor and t/he status of the mouse buttons. } If (0 < Curs X < 80) and (125 < Curs Y < 150) then {Move the cursor inside the rectangle for the SA module. } Begin {Open a wj_r~ow for the SA module. } Open Window SA (0, 0, 640, 200, 'Solar Array', Save Image); {Display a full screen image of the SA module. The image of the testbed block diagram is stored. }
6~8~eP02 9,$5~4(+02
I.OO00P~! 4,3mPOL 1,8600P02 6.0600P02
~799D02 4.~999P01 4.9299£~0Z
~298Eo92 1~19eD92 1.6~[~62 5,~[,OZ
~,W~E+02
f r ~ data, strike ~'or '6
~to~e testbod, :,ight ~ttoc: ~se. 're exit, both I:uttons ~se . . . . . . . . . . . . . rig.
2.
Solar i~rra~l SiHla(or
Rand Wind; {Generate streams of random ntm~ers to represent real-time data for the selected module. } End {Open a ~ for the SA module. } End {Morose left button has been pressed. } Else If (Switch = Sw Right) then Begin {Mouse right button has been pressed. } Close WJ_ndc~ (0, 0, 640, 200, Save Image); {1~estore a full screen image of the testbed.} Rand; {Display streams of random number ~r~4rs adjacent to each testbed module. } End {Mouse right button has been pressed. } Until {Both buttons on mouse have been pressed}
448
PROCEEDINGS OF THE 8TH ANNUAL CONFERENCE ON COMPUTERS AND INDUSTRIAL ENGINEERING
1+i............................................................. 2 3 4 5 + 7 + + ?.?~D@2
~.47@gE+92
G.9~E+92
9.%~E+@2
f1499P,02
~@@E+@I
1,30~E+RI
£39~E+@2
2~mE+~2
,+I
I
~,tg@sE,92
~e [~eze data, strike 'q' or 'q',
o ~store testbed, rig]it button
V4OUSe.
~o exit, both ~tttons I,aise.
Fig. 3.
Load Bank 1
~I~USION The ~ program is a valuable tool for monitoring the performance of the DC testbed for the power management and distribution system for the space station. The program will evolve as the requirements and applications of the testbed evolve.
ACKNOWIaIXlM~ The author is grateful to James Soeder, Michael Mack/n, and Kathleen Schubert of NASA Research Center, Space Statie~ Directorate, Cleveland, Ohio, for helpful discussions.
Lewis
Peru~ C E S Conlan, J. (1984). ~ Metagraphics Corp. CA.
PC Pascal.
Wiley, New York.
(1984). Metawindcw User Guide for the ~
Personal Ocmputer.
Mountain View,