//-------------------------------------------------------------------------------------------------//
        /// <summary>
        /// Run the experiment and fill in the result report. Override in a derived class.
        /// </summary>
        /// <param name="experimentInfo"></param>
        /// <returns></returns>
        public virtual ExperimentInfo RunExperiment(ExperimentInfo experimentInfo)
        {
            const string STRLOG_MethodName = "RunExperiment";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            // Create a result report ready to fill in
            experimentInfo.resultReport = new ResultReport();

            try
            {
                //
                // Parse the XML specification string to generate a validation report (should be accepted!)
                //
                ExperimentSpecification experimentSpecification = new ExperimentSpecification(this.labConfiguration, this.equipmentServiceProxy);
                ValidationReport validationReport = experimentSpecification.Parse(experimentInfo.xmlSpecification);
                if (validationReport.accepted == false)
                {
                    throw new ArgumentException(validationReport.errorMessage);
                }
                experimentInfo.setupId = experimentSpecification.SetupId;

                //
                // Create an instance of the driver for the specified setup and then
                // execute the experiment and return the result information
                //
                ExperimentResultInfo experimentResultInfo = null;
                if (experimentSpecification.SetupId.Equals(Consts.STRXML_SetupId_EquipmentGeneric))
                {
                    DriverEquipmentGeneric driver = new DriverEquipmentGeneric(this.equipmentServiceProxy, this.labConfiguration, this.labExperimentInfo.cancelExperiment);
                    experimentResultInfo = driver.Execute(experimentSpecification);
                }
                else if (experimentSpecification.SetupId.Equals(Consts.STRXML_SetupId_ModuleGeneric))
                {
                    DriverModuleGeneric driver = new DriverModuleGeneric(this.labConfiguration, this.labExperimentInfo.cancelExperiment);
                    experimentResultInfo = driver.Execute(experimentSpecification);
                }

                //
                // Create an instance of LabExperimentResult to convert the experiment results to an XML string
                //
                LabExperimentResult labExperimentResult = new LabExperimentResult(
                    experimentInfo.experimentId, experimentInfo.sbName, DateTime.Now,
                    experimentSpecification.SetupId, this.unitId, this.labConfiguration);

                //
                // Fill in the result report
                //
                experimentInfo.resultReport.experimentResults = labExperimentResult.ToString();
                experimentInfo.resultReport.statusCode = (int)experimentResultInfo.statusCode;
                experimentInfo.resultReport.errorMessage = experimentResultInfo.errorMessage;
            }
            catch (Exception ex)
            {
                experimentInfo.resultReport.statusCode = (int)StatusCodes.Failed;
                experimentInfo.resultReport.errorMessage = ex.Message;
                Logfile.WriteError(ex.Message);
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName);

            return experimentInfo;
        }
        //-------------------------------------------------------------------------------------------------//
        /// <summary>
        /// Parse the XML specification string to check its validity. No exceptions are thrown back to the
        /// calling method. If an error occurs, 'accepted' is set to false and the error message is placed
        /// in 'errorMessage' where it can be examined by the calling method. Return 'accepted'.
        /// </summary>
        /// <param name="xmlSpecification"></param>
        public virtual ValidationReport Parse(string xmlSpecification)
        {
            const string STRLOG_MethodName = "Parse";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            //
            // Create a new validation report ready to fill in
            //
            ValidationReport validationReport = new ValidationReport();

            //
            // Process the XML specification string
            //
            try
            {
                // Load XML specification string
                XmlDocument xmlDocument = XmlUtilities.GetXmlDocument(xmlSpecification);

                //
                // Get a copy of the specification XML node
                //
                XmlNode xmlNode = XmlUtilities.GetXmlRootNode(xmlDocument, Consts.STRXML_experimentSpecification);
                this.xmlNodeSpecification = xmlNode.Clone();

                //
                // Get the setup id and check that it exists - search is case-sensitive
                //
                this.setupId = XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_setupId, false);
                int setupIndex = Array.IndexOf(this.labConfiguration.SetupIds, this.setupId);
                if (setupIndex < 0)
                {
                    throw new ArgumentException(STRERR_SetupIdInvalid, this.setupId);
                }

                //
                // Get the specified setup XML node
                //
                XmlNodeList xmlNodeList = XmlUtilities.GetXmlNodeList(this.xmlNodeConfiguration, Consts.STRXML_setup, true);
                this.xmlNodeSetup = xmlNodeList.Item(setupIndex);

                //
                // Create an instance of the driver for the specified setup and then
                // get the driver's execution time for this specification
                //
                int executionTime = -1;
                if (this.SetupId.Equals(Consts.STRXML_SetupId_EquipmentGeneric))
                {
                    if (this.equipmentServiceProxy == null)
                    {
                        throw new ArgumentException(STRERR_EquipmentServiceNotAvailable, this.setupId);
                    }

                    DriverEquipmentGeneric driver = new DriverEquipmentGeneric(this.equipmentServiceProxy, this.labConfiguration);
                    executionTime = driver.GetExecutionTime(this);
                }
                else if (this.SetupId.Equals(Consts.STRXML_SetupId_ModuleGeneric))
                {
                    DriverModuleGeneric driver = new DriverModuleGeneric(this.labConfiguration);
                    executionTime = driver.GetExecutionTime(this);
                }

                //
                // Specification is valid
                //
                validationReport.estRuntime = executionTime;
                validationReport.accepted = true;
            }
            catch (Exception ex)
            {
                validationReport.errorMessage = ex.Message;
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName);

            return validationReport;
        }