The GUIServer Class

GUIServer is a twisted based web server that serves as a bridge between dos and the browser. Functions served by GUIServer include:

Web Interface:

The GUIServer must be able to serve static html, js, css, and image files to the browser. This will be done by accessing the /static path. From there the server will look in its docroot for the static files to be served.

The GUIServer will also provide a polling mechanism for receiveing certain DOS runtime information. Shared Variables:

/SV is the root for all SV type commands. Subscription:

A client must first subscribe to a shared variable through this interface. This is done by hitting the following URL: /SV/subscribe?var=TEST_CHANNEL:g&var=TEST_CHANNEL2:ng The GUIServer checks the clients cookies for a session id and if not availble issues one. The GUIServer then uses this session id to keep track of the subscribed variables for that client. The GUIServer subscribes to these variables and receives all the updates realtime. The requests are then flushed when an update is called. /SV/unsubscribe can also be used.
Updates:

Once the client has issued a subscribe command the server will start caching any sv updates waiting for the client to request that data, since it is a polling system. The client requests the data by hitting /SV/update?sid=SESSIONID. This will return a JSON string of the requested information. The JSON array has the following format: {

SV : {
‘GROUP’ : { // A variable group
‘NAME’ : [ // An array of updates
{ value : 1, updated : 1234567890.1}, // An update object { value : 2, updated : 1234567891.1}, { value : 3, updated : 1234567892.1}

]

}

}, ALARMS : {

}, LOGGING : {

}

} The client is then responsible for parsing this data. This concatonates the updates from logging, alarms and svs so that only one update is required between the three of them.

Logging, Alarms:
The logging and alarm systems will be handled in exactly the same way as the shared variables but via ALARMS/subscribe LOGGING/subscribe This reduces the amount of work required to port these facilities.
PML:
PML is the simplest interface to implement as it only has one function, sending a command. This is done through: PML/execute?interface=SHUTTER&command=OPEN&args=12
A WebSocket Server:
Anticipating the release of HTML5 and WebSockets the GUIServer will also support a WebSocket interface to releive the need for periodic polling. The twisted core will simultaneously serve both the http interface and the ws interface. A WebSocket mimics the functionality of a unix type socket. A two way messaging protocol will be established to allow for realtime sending of updates. Specifics on the WebSocket server implementation will be deferred until we have a working WebSocket browser in hand. The server is required to do an http type handshake before establishing the connection.
class GUIServer.GUIServer(device_mode=False, noSVE=None, **extra_args)
init()

Method to be overidden by the user that will be called on initialization.

will_shutdown()

When the application shuts down, and the reactor to stop at the next appropriate point in its cycle.

class GUIServer.GUIServer(device_mode=False, noSVE=None, **extra_args)
init()

Method to be overidden by the user that will be called on initialization.

will_shutdown()

When the application shuts down, and the reactor to stop at the next appropriate point in its cycle.