//-------------------------------------------------------------------------------------------------//

        public virtual ValidationReport Validate(string xmlSpecification)
        {
            const string STRLOG_MethodName = "Validate";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            ValidationReport validationReport = new ValidationReport(false);

            //
            // Parse the XML specification string to generate a validation report
            //
            try
            {
                ExperimentSpecification experimentSpecification = new ExperimentSpecification(this.labConfiguration, this.equipmentServiceProxy);
                validationReport = experimentSpecification.Parse(xmlSpecification);
            }
            catch (Exception ex)
            {
                validationReport.errorMessage = ex.Message;
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName);

            return(validationReport);
        }
        //-------------------------------------------------------------------------------------------------//
        public virtual ValidationReport Validate(string xmlSpecification)
        {
            const string STRLOG_MethodName = "Validate";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            ValidationReport validationReport = new ValidationReport(false);

            //
            // Parse the XML specification string to generate a validation report
            //
            try
            {
                ExperimentSpecification experimentSpecification = new ExperimentSpecification(this.labConfiguration, this.equipmentServiceProxy);
                validationReport = experimentSpecification.Parse(xmlSpecification);
            }
            catch (Exception ex)
            {
                validationReport.errorMessage = ex.Message;
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName);

            return validationReport;
        }
        //-------------------------------------------------------------------------------------------------//
        /// <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>
        /// 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);
        }