3.3 nph-dsply.pl – the non-parsed header display

The script nph-dsply.pl is responsible for receiving data from dsplyserver.pl and adding the HTML tags required to display that data in the user's browser (Fig.4). When a browser connects to the web server with the URL for nph-dsply.pl, the script is launched and it proceeds to establish a socket connection to dsplyserver.pl. After sending a message to the display server declaring itself a listener, nph-dsply.pl sets up the server push technique by calling the CGI::Push routine do_push() (Stein, 1998) with the following argument string: {-next_page=>\&draw_a_page, -delay=>0}. This causes the page-drawing subroutine to be called repeatedly with no pause between updates.

Inside draw_a_page(), the update counter maintained by CGI.pm is examined and if equal to one, the subroutine returns the HTML for a simple page with the text "Waiting for input…". That page is sent to the users browser by do_push() after it adds the multipart/x-mixed-replace MIME headers. With the delay set to zero, draw_a_page() is re-called immediately with the update counter incremented. This and every subsequent time, the subroutine attempts to read the socket opened in the main program, blocking until data is available. After data is received from the display server, it is parsed, a time stamp and formatting tags are inserted, and the new data line is added to the top of the message list. This list is converted to an HTML table and is returned to do_push() to be sent to the user. The cycle: call draw_a_page(); block on data availability; create and send new HTML page; is repeated until the user presses "Stop" on the browser, or moves on to another web page.

Display output page

Figure 4: Display output page

The parsing section of draw_a_page() understands five basic types of data messages. The first type, the heartbeat message consisting of the single word "TICK", is simply thrown away after being received without modifying the current list. Since the reception of any data results in the page being sent to the browser, this effects a reset of its time-out process. The second message type is identified by the data beginning with the tag: "PAGEHEADER:". The string following the tag is converted to an HTML heading and is placed at the top of the displayed page (e.g.: the text beginning "Test: 911" in Fig.4). The third message type, identified by the tag "TABLEHEADER:" is assumed to contain tab-separated column labels and is parsed and converted to HTML accordingly (e.g.: the line beginning "Time Pt lift" at the top of the table in Fig.4). The fourth message type is used to insert text information into the data table and is recognized by three tags: "NOTICE:", "WARNING:" and "ERROR:". All three of these tags produce a bold text area spanning the entire table (e.g.: the line containing "End of Tare" near the bottom of Fig.4), the difference between them being a background colour set to blue, yellow and red respectively. If the message fits none of the above criteria, it is expected to be the last type, tab separated columnar data, and is parsed and formatted into an HTML table row.

In addition to the formatting mentioned in the paragraph above, draw_a_page() is also responsible for several other attributes of the display. To increase the ease of readability of the potentially long rows of data, every fourth line has the standard background colour (white) changed to light grey. Because of the importance of the pitch and yaw data to virtually all wind-tunnel tests, and the fact that the column order can change from one test to another, those column labels are identified by a regular expression and their background colours are altered. The user has the option of modifying the default number of lines in the message list by including a parameter 'length=' in the URL query string. The final feature of draw_a_page() was added as a safety measure. If nph-dsply.pl looses the connection to the display server at any time, the background colour of the entire page turns red and the heading is changed to an appropriate error message.


Previous Page   Title Page   Next page