How To Create A New LabServer

Draft - 7 Sep 2009 - LJP


The following assumes that you are using Microsoft Visual Studio 2008 on a Microsoft Windows operating system.

Two parts are required:

  1. LabLibraries – Code common to all LabServers. Download 'LabLibraries.zip' either from the MIT Wiki or from SourceForge.

  2. Template – A template or skeleton for the new LabServer implementation. Download 'Template.zip' either from the MIT Wiki or from SourceForge.

Open the Visual Studio solution "./Template/Template.sln". There are seven projects in the solution:

You only need to be concerned with:

DO NOT make changes to the other projects!

The 'DummyServiceBroker' project is provided in the solution to allow development of the LabServer and LabClient in an enviroment without an iLab ServiceBroker getting in the way. The 'DummyServiceBroker' simply provides pass-through methods to allow LabClient-to-LabServer communication.

The 'LabClientHtml', 'LabServer' and 'DummyServiceBroker' use ports on 'localhost' and there is no need to use IIS Virtual Directories. This makes it much easier to move the solution to different development computers or even folders and drives on a single computer.

The 'TimeOfDay' example is one of several that are provided for comparison and gives an idea of the changes that need to be made to create a new experiment. It's a lot easier to 'Copy-Paste-Change' than it is to think it up from new. Download 'TimeOfDay.zip' either from the MIT Wiki or from SourceForge.

Before we start making code changes, let's compile the 'Template' solution. It should compile without any errors or warnings. The startup project should be set to "LabClientHtml". Don't run the solution yet because there are a couple of things that need to be done first.


LabClientHtml

There are several files here that need to be changed:

LabConsts.cs

XML string constants and string constants are placed here in one place. It makes them easier to find.

Used by 'LabResults.ascx.cs', 'LabSetup.ascx.cs' and 'Result.cs'.

LabResults.ascx.cs

Obtains the experiment specification and result information strings that are used by 'Results.ascx.cs' to display information on the 'Results' webpage.

Change the two locations in the file marked by:

//
// YOUR CODE HERE
//

LabSetup.ascx

This file contains the HTML markup that provides the entry of the experiment specification. Uses the styles in 'LabControls.css'.

LabSetup.ascx.cs

Add code to populate and update the webpage controls. The 'BuildSpecification' method takes information from the controls and places it in the XML specification node that is used by 'Setup.ascx.cs'.

Change the four locations in the file marked by:

//
// YOUR CODE HERE
//

Result.cs

Takes the information from the XML ExperimentResult node and places it into a 'ResultInfo' structure where it can be accessed by 'LabResults.ascx.cs'.

TypeResultInfo.cs

The 'ResultInfo' structure that contains the information taken from the XML ExperimentResult node.

Web.config

Copy 'web.config.template' to 'Web.config' and update the following keys:


LabServer

There are three files here that need to be changed:

LabConfiguration.xml

This file contains the information required by the LabClient to display information on the 'Setup' webpage and populate the controls.

The LabClient may want to display various versions of an experiment that the user can choose from to submit. These are called 'Experiment Setups'. The 'Configuration' element contains a list of the setups to display. Each setup has an 'id', 'name' and 'description'. The 'id' is used by both the LabServer and LabClient to determine what operations to perform. The 'name' and 'description' elements are displayed in fields in the 'Setup' webpage.

The 'Configuration' element may contain elements with information common to all listed setups.

An empty XML Specification element is provided so that the LabClient can fill in information and send it to the LabServer.

An empty ExperimentResults element is provided so that the LabServer can fill in information and send it to the LabClient.

Web.config

Copy 'web.config.template' to 'Web.config' and update the following keys:

Add extra keys as required for the Setup and Equipment Drivers.


LibraryLabServer

There are several files here that need to be changed:

Configuration.cs

Takes information from the 'Configuration' element of 'LabConfiguration.xml' and places it in private variables that can be accessed through 'Properties'. This is information is not the setups. The setups are already handled by the base class in 'LibraryLabServerEngine.LabConfiguration'.

Consts.cs

XML string constants and string constants are placed here in one place. It makes them easier to find.

ExperimentEngine.cs

Change the location in the file marked by:

//
// YOUR CODE HERE
if (specification.SetupId.Equals(Consts.STRXML_SetupId_Template))
{
driver = new DriverTemplate(this.labExperimentInfo.cancelExperiment);
}
//

This creates an instance of the driver for the specified setup that will execute the experiment.

ExperimentResult.cs

Information is taken from the Specification and ResultInfo structure and placed in the XML ExperimentResult node which is then saved to local disk storage. This information is available for retrieval by the ServiceBroker.

Specification.cs

Takes information from the XML Specification string and places it in private variables that can be accessed through 'Properties'. This information is then checked for validity. If the specification is valid, an instance of the driver for the specified setup is created to obtain the estimated execution time.

Change the three locations in the file marked by:

//
// YOUR CODE HERE
//

TypeResultInfo.cs

The 'ResultInfo' structure that contains the information that will be placed in the XML ExperimentResult node.

Validation.cs

May or may not be used, depending on the experiment. Boundary conditions such as 'Minimum' and 'Maximum' values are checked here.

Drivers\Equipment\DoesNothing.cs

This drives the experiment for a particular piece of equipment. This may be a network connection or an equipment API.

Drivers\Setup\DriverTemplate.cs

This drives the experiment for a particular 'setup' and makes calls to the equipment driver.

Change the two locations in the file marked by:

//
// YOUR CODE HERE
//