A Remote BIM Display for ROCS

Server and tty Client

John C L Brazier

Consultant to CERN

 

 

 

 

Brazier Systems & Consultants Ltd.

240 Bridge Road,

Sarisbury Green,

SOUTHAMPTON SO31 6BN

England

Tel. +44 (0)1489 573442

Fax. +44 (0)1489 573884

Email: john@bscdev.co.uk

 

Document Number: ROCS/UM/09

Document Revision: 1.1

Date: March 1998

Background

The Built In Monitor (BIM) facilities in the ROCS system have proved to be immensely useful both in the development environment and operationally. The BIM concept is quite simple, each process in the system has a thread running at a low priority which gathers useful data about the process. The thread sleeps most of the time and wakes up at regular intervals to run a user written data gathering routine. This data is time-stamped and placed in a special region of the General Shared Memory Segment. Even if the developer can't think of anything useful to monitor, the time-stamp still serves as an "I am alive" indication.

To display the results, a special program (printbim) is run which attaches to the shared memory segment and prints the data. As all the gathering routines are running asynchronously, the display program is synchronised by means of a global update flag which they all set when they have new data. The printbim program periodically checks this flag, prints the data and clears the flag. Note that there is no semaphore on this flag as there must never be any possibility that a 'real' process could be held up because of a monitor.

The data is printed by the printbim program which must know about the its format, ie. if an application developer changes the data stored by a particular module, then the printbim program must be changed to suit.

The current printbim program is written as a Unix Curses program. This will allow formatted whole screen presentation of the data on any ASCII terminal. The program is run by using telnet to open a window on the workstation logged onto the target. The printbim program is then run to display the results.

This is the major drawback of printbim, namely, the user must log onto the target system to run the program.. A lesser drawback comes from the monitoring of the update flag. Only a single instance of printbim should ever be run, although this is not checked. This development overcomes these two drawbacks.

 

A Remote BIM Monitor

The solution to the problems outlined above is to take the single 'stand-alone' printbim and turn it into a client server model. Now a bimserver program runs on the target system with display client(s) running on remote workstations connected by TCP/IP.

As with all client-server solutions, the thickness of the client is of paramount importance to the design. Who is to format the data ? It can be the client, where the server sends over raw data in some agreed format and the client lays the data out in the window. In the other case, the server can do the formatting of the data which is sent to the client as simple ASCII strings. The thin client in this case only has to display the text in the window. This is the scenario called for in this application for a number of reasons including:

The server resides on the target machine in the same way as the printbim program does now. The developer adding new data just changes the bimserver and the clients will follow. The alternative would be to modify possibly several client programs.
Since the client only displays simple text, it can be written on many different platforms in different languages.
The server can send the text strings to a number of clients at the same time.
Since only the output changes, the bimserver program can be almost identical to the original printbim.

Data Format

The format of the data that is issued by the server will be essentially a simple text string with some row information prepended. To save bandwidth, the strings will be of variable length, being terminated by a newline character. Thus a line will be:

022,:This will go on line 22\n

Here, the header extends up to and including the first ':' character. The number 022 is the row number (in the range 0-899). The row number is terminated with a ','. In between the ',' and the ':' is reserved for future uses (such as attributes, column numbers, etc.). The actual string starts with the first character after the ':' and ends with the newline '\n' character.

Line numbers greater than or equal to 900 are reserved for special usage. At present the only one envisaged is:

900,:Refresh

This will allow batching of updates if the client can handle them. It is a matter of individual definition whether the '900' or the word 'Refresh' determines the function.

Server Operation

The server consists of a data gathering and formatting part, much the same as the printbim program and a network control part. The communication is a TCP session with each client. Remembering that the server must serve multiple clients, this lends itself to a multi-threaded solution. Operation of the server is as follows.

The server sets up to receive connections on TCP port 1524 and then sleeps waiting for a client to connect. When this happens, the network thread will accept the connection and create a new socket for the communication. This socket will be added to a list of active clients. A thread is now be started at a low priority to do the data gathering and formatting in the normal way. The server will be linked with a special set of 'curses' routines that will write lines of data with the headers appended to the sockets in the list. The format of these special routines will be identical to the proper 'curses' variants.

The control thread immediately goes back to waiting for more connections. When another client connects, the new communication socket is added to the client list but since a thread is already running, nothing more will need to be done.

When a client disconnects, the write to that socket will return an error. If this happens, the socket is closed and removed from the list. When the last client is removed from the list, the thread will die.

Client Operation

The first, and simplest client is a Unix 'curses' client. Operation of this is quite straightforward. The program is told the hostname of the target system and attempts to make a connection to the bimserver port (1524). When the connection is made, it enters an endless loop getting and displaying the data, ie.

Connect to server

forever

get line

extract row number

(maybe extract other attributes)

if row is 900

refresh display

else

display text at row

endif

endloop

 

The nett result will be a screen that looks identical to the current printbim, however with the following advantages:

No logon to the target system is necessary therefore:
No user/passwords need to be given out
There is no possibility to compromise the system
The client can be compiled on any Unix system, eg. HP-UX, AIX (cernsp), Linux, etc.
No special terminal is needed
Any number (within reason) of clients can attach to the server.

 

Future Directions

Future developments to this system will cover a 'universal client' for the server written in Java and running in a Web Browser. This will require a separate network broker program to vector the requests from many clients to many servers.