//-------------------------------------------------------------------------------------------------//
        public ExperimentResult(int experimentId, string sbName, DateTime dateTime, int unitId, Configuration configuration,
            Specification specification, ResultInfo resultInfo)
            : base(experimentId, sbName, dateTime, specification.SetupId, unitId, configuration)
        {
            const string STRLOG_MethodName = "ExperimentResult";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            try
            {
                //
                // Add the specification information
                //
                //
                // YOUR CODE HERE
                //

                //
                // Add the result information
                //
                if (resultInfo.statusCode == StatusCodes.Completed)
                {
                    //
                    // YOUR CODE HERE
                    //
                }
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
        //-------------------------------------------------------------------------------------------------//
        public override 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!)
                //
                Specification specification = new Specification(this.configuration, this.equipmentServiceProxy);
                ValidationReport validationReport = specification.Parse(experimentInfo.xmlSpecification);
                if (validationReport.accepted == false)
                {
                    throw new ArgumentException(validationReport.errorMessage);
                }
                experimentInfo.setupId = specification.SetupId;

                //
                // Create an instance of the driver for the specified setup and then
                // execute the experiment and return the result information
                //
                ResultInfo resultInfo = null;

                //
                // All setups use the equipment driver
                //
                DriverEquipment driver = new DriverEquipment(this.equipmentServiceProxy, this.configuration, this.labExperimentInfo.cancelExperiment);
                resultInfo = (ResultInfo)driver.Execute(specification);

                //
                // Create an instance of LabExperimentResult to convert the experiment results to an XML string
                //
                ExperimentResult experimentResult = new ExperimentResult(
                    experimentInfo.experimentId, experimentInfo.sbName, DateTime.Now,
                    this.unitId, (Configuration)this.labConfiguration, specification, resultInfo);

                //
                // Fill in the result report
                //
                experimentInfo.resultReport.experimentResults = experimentResult.ToString();
                experimentInfo.resultReport.statusCode = (int)resultInfo.statusCode;
                experimentInfo.resultReport.errorMessage = resultInfo.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;
        }
        //-------------------------------------------------------------------------------------------------//
        public ExperimentResult(int experimentId, string sbName, DateTime dateTime, int unitId, Configuration configuration,
            Specification specification, ResultInfo resultInfo)
            : base(experimentId, sbName, dateTime, specification.SetupId, unitId, configuration)
        {
            const string STRLOG_MethodName = "ExperimentResult";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            try
            {
                //
                // Add the specification information
                //
                XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_formatName, specification.FormatName, false);
                if (specification.SetupId.Equals(Consts.STRXML_SetupId_NTPServer))
                {
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_serverUrl, specification.ServerUrl, false);
                }

                //
                // Add the result information
                //
                if (resultInfo.statusCode == StatusCodes.Completed)
                {
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_timeofday, resultInfo.timeofday, false);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_dayofweek, resultInfo.dateTime.DayOfWeek.ToString(), false);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_day, resultInfo.dateTime.Day);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_month, resultInfo.dateTime.Month);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_year, resultInfo.dateTime.Year);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_hours, resultInfo.dateTime.Hour);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_minutes, resultInfo.dateTime.Minute);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_seconds, resultInfo.dateTime.Second);
                }
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
        //-------------------------------------------------------------------------------------------------//
        public ExperimentResult(int experimentId, string sbName, DateTime dateTime, int unitId, Configuration configuration,
            Specification specification, ResultInfo resultInfo)
            : base(experimentId, sbName, dateTime, specification.SetupId, unitId, configuration)
        {
            const string STRLOG_MethodName = "ExperimentResult";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            try
            {
                //
                // Add the specification information
                //
                //
                // Nothing to do here
                //

                //
                // Add the result information
                //
                if (resultInfo.statusCode == StatusCodes.Completed)
                {
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_voltage, resultInfo.voltage.ToString("F02"), false);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_current, resultInfo.current.ToString("F03"), false);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_powerFactor, resultInfo.powerFactor.ToString("F04"), false);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_speed, resultInfo.speed.ToString(), false);
                }
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
        //-------------------------------------------------------------------------------------------------//
        public override void Create()
        {
            const string STRLOG_MethodName = "Create";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            //
            // Create local class instances just to check that all is in order
            //
            Configuration configuration = (Configuration)this.appData.labConfiguration;
            Specification specification = new Specification(configuration, null);
            ExperimentResult experimentResult = new ExperimentResult(configuration);

            //
            // Create instances of the experiment engines
            //
            this.appData.labExperimentEngines = new ExperimentEngine[appData.farmSize];
            for (int i = 0; i < appData.farmSize; i++)
            {
                this.appData.labExperimentEngines[i] = new ExperimentEngine(i, this.appData);
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName);
        }
        //-------------------------------------------------------------------------------------------------//
        public ExperimentResult(int experimentId, string sbName, DateTime dateTime, int unitId, Configuration configuration,
            Specification specification, ResultInfo resultInfo)
            : base(experimentId, sbName, dateTime, specification.SetupId, unitId, configuration)
        {
            const string STRLOG_MethodName = "ExperimentResult";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            try
            {
                //
                // Add the specification information
                //
                //
                // Nothing to do here
                //

                //
                // Add the result information
                //
                if (resultInfo.statusCode == StatusCodes.Completed)
                {
                    string[] measurements = null;

                    //
                    // Load XML measurements string
                    //
                    XmlDocument xmlDocument = XmlUtilities.GetXmlDocument(resultInfo.xmlMeasurements);
                    XmlNode xmlNodeRoot = XmlUtilities.GetXmlRootNode(xmlDocument, Consts.STRXML_measurements);

                    if (specification.SetupId.Equals(Consts.STRXML_SetupId_OpenCircuitVaryField) == true)
                    {
                        measurements = new string[] {
                            Consts.STRXML_fieldCurrent,
                            Consts.STRXML_speed,
                            Consts.STRXML_voltage,
                        };
                    }
                    else if (specification.SetupId.Equals(Consts.STRXML_SetupId_OpenCircuitVarySpeed) == true)
                    {
                        measurements = new string[] {
                            Consts.STRXML_speed,
                            Consts.STRXML_fieldCurrent,
                            Consts.STRXML_voltage,
                        };
                    }
                    else if (specification.SetupId.Equals(Consts.STRXML_SetupId_ShortCircuitVaryField) == true)
                    {
                        measurements = new string[] {
                            Consts.STRXML_fieldCurrent,
                            Consts.STRXML_speed,
                            Consts.STRXML_statorCurrent,
                        };
                    }
                    else if (specification.SetupId.Equals(Consts.STRXML_SetupId_PreSynchronisation) == true)
                    {
                        measurements = new string[] {
                            Consts.STRXML_fieldCurrent,
                            Consts.STRXML_speedSetpoint,
                            Consts.STRXML_mainsVoltage,
                            Consts.STRXML_mainsFrequency,
                            Consts.STRXML_syncVoltage,
                            Consts.STRXML_syncFrequency,
                            Consts.STRXML_syncMainsPhase,
                            Consts.STRXML_synchronism,
                        };
                    }
                    else if (specification.SetupId.Equals(Consts.STRXML_SetupId_Synchronisation) == true)
                    {
                        measurements = new string[] {
                            Consts.STRXML_torqueSetpoint,
                            Consts.STRXML_fieldCurrent,
                            Consts.STRXML_syncVoltage,
                            Consts.STRXML_syncFrequency,
                            Consts.STRXML_powerFactor,
                            Consts.STRXML_realPower,
                            Consts.STRXML_reactivePower,
                            Consts.STRXML_phaseCurrent,
                        };
                    }

                    if (measurements != null)
                    {
                        for (int i = 0; i < measurements.Length; i++)
                        {
                            XmlNode xmlNode = XmlUtilities.GetXmlNode(xmlNodeRoot, measurements[i]);
                            XmlDocumentFragment xmlFragment = this.xmlNodeExperimentResult.OwnerDocument.CreateDocumentFragment();
                            xmlFragment.InnerXml = xmlNode.OuterXml;
                            this.xmlNodeExperimentResult.AppendChild(xmlFragment);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
        //-------------------------------------------------------------------------------------------------//
        public override ValidationReport Validate(string xmlSpecification)
        {
            const string STRLOG_MethodName = "Validate";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            //
            // Parse the XML specification string to generate a validation report
            //
            ValidationReport validationReport = null;
            try
            {
                Specification specification = new Specification(this.configuration, this.equipmentServiceProxy);
                validationReport = specification.Parse(xmlSpecification);
            }
            catch (Exception ex)
            {
                validationReport = new ValidationReport(false);
                validationReport.errorMessage = ex.Message;
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName);

            return validationReport;
        }
        //-------------------------------------------------------------------------------------------------//
        public ExperimentResult(int experimentId, string sbName, DateTime dateTime, int unitId, Configuration configuration,
            Specification specification, ResultInfo resultInfo)
            : base(experimentId, sbName, dateTime, specification.SetupId, unitId, configuration)
        {
            const string STRLOG_MethodName = "ExperimentResult";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            try
            {
                //
                // Add the specification information
                //
                if (specification.SetupId.Equals(Consts.STRXML_SetupId_VoltageVsSpeed))
                {
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_speedMin, specification.Speed.min);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_speedMax, specification.Speed.max);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_speedStep, specification.Speed.step);
                }
                else if (specification.SetupId.Equals(Consts.STRXML_SetupId_VoltageVsField))
                {
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_fieldMin, specification.Field.min);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_fieldMax, specification.Field.max);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_fieldStep, specification.Field.step);
                }
                else if (specification.SetupId.Equals(Consts.STRXML_SetupId_VoltageVsLoad))
                {
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_loadMin, specification.Load.min);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_loadMax, specification.Load.max);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_loadStep, specification.Load.step);
                }
                else if (specification.SetupId.Equals(Consts.STRXML_SetupId_SpeedVsVoltage))
                {
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_speedMin, specification.Speed.min);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_speedMax, specification.Speed.max);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_speedStep, specification.Speed.step);
                }
                else if (specification.SetupId.Equals(Consts.STRXML_SetupId_SpeedVsField))
                {
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_fieldMin, specification.Field.min);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_fieldMax, specification.Field.max);
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_fieldStep, specification.Field.step);
                }

                //
                // Add the result information
                //
                if (resultInfo.statusCode == StatusCodes.Completed)
                {
                    if (specification.SetupId.Equals(Consts.STRXML_SetupId_VoltageVsSpeed))
                    {
                        XmlUtilities.SetXmlValues(this.xmlNodeExperimentResult, Consts.STRXML_speedVector, resultInfo.speedVector, Consts.CHR_Splitter, false);
                        XmlUtilities.SetXmlValues(this.xmlNodeExperimentResult, Consts.STRXML_voltageVector, resultInfo.voltageVector, Consts.CHR_Splitter, false);
                    }
                    else if (specification.SetupId.Equals(Consts.STRXML_SetupId_VoltageVsField))
                    {
                        XmlUtilities.SetXmlValues(this.xmlNodeExperimentResult, Consts.STRXML_fieldVector, resultInfo.fieldVector, "F02", Consts.CHR_Splitter, false);
                        XmlUtilities.SetXmlValues(this.xmlNodeExperimentResult, Consts.STRXML_voltageVector, resultInfo.voltageVector, Consts.CHR_Splitter, false);
                    }
                    else if (specification.SetupId.Equals(Consts.STRXML_SetupId_VoltageVsLoad))
                    {
                        XmlUtilities.SetXmlValues(this.xmlNodeExperimentResult, Consts.STRXML_loadVector, resultInfo.loadVector, Consts.CHR_Splitter, false);
                        XmlUtilities.SetXmlValues(this.xmlNodeExperimentResult, Consts.STRXML_voltageVector, resultInfo.voltageVector, Consts.CHR_Splitter, false);
                        XmlUtilities.SetXmlValues(this.xmlNodeExperimentResult, Consts.STRXML_speedVector, resultInfo.speedVector, Consts.CHR_Splitter, false);
                    }
                    else if (specification.SetupId.Equals(Consts.STRXML_SetupId_SpeedVsVoltage))
                    {
                        XmlUtilities.SetXmlValues(this.xmlNodeExperimentResult, Consts.STRXML_speedVector, resultInfo.speedVector, Consts.CHR_Splitter, false);
                        XmlUtilities.SetXmlValues(this.xmlNodeExperimentResult, Consts.STRXML_voltageVector, resultInfo.voltageVector, Consts.CHR_Splitter, false);
                    }
                    else if (specification.SetupId.Equals(Consts.STRXML_SetupId_SpeedVsField))
                    {
                        XmlUtilities.SetXmlValues(this.xmlNodeExperimentResult, Consts.STRXML_fieldVector, resultInfo.fieldVector, "F02", Consts.CHR_Splitter, false);
                        XmlUtilities.SetXmlValues(this.xmlNodeExperimentResult, Consts.STRXML_speedVector, resultInfo.speedVector, Consts.CHR_Splitter, false);
                        XmlUtilities.SetXmlValues(this.xmlNodeExperimentResult, Consts.STRXML_voltageVector, resultInfo.voltageVector, Consts.CHR_Splitter, false);
                    }
                }
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
        //-------------------------------------------------------------------------------------------------//
        public ExperimentResult(int experimentId, string sbName, DateTime dateTime, int unitId, Configuration configuration,
            Specification specification, ResultInfo resultInfo)
            : base(experimentId, sbName, dateTime, specification.SetupId, unitId, configuration)
        {
            const string STRLOG_MethodName = "ExperimentResult";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            try
            {
                //
                // Add the specification information
                //
                XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_sourceName, specification.SourceName, false);
                XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_duration, specification.Duration);
                XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_repeat, specification.Repeat);
                if (specification.SetupId.Equals(Consts.STRXML_SetupId_RadioactivityVsTime) ||
                    specification.SetupId.Equals(Consts.STRXML_SetupId_SimActivityVsTime) ||
                    specification.SetupId.Equals(Consts.STRXML_SetupId_SimActivityVsTimeNoDelay))
                {
                    Specification.Absorber absorber = specification.AbsorberList[0];
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_absorberName, absorber.name, false);

                    int distance = specification.DistanceList[0];
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_distance, distance.ToString(), false);
                }
                else if (specification.SetupId.Equals(Consts.STRXML_SetupId_RadioactivityVsDistance) ||
                    specification.SetupId.Equals(Consts.STRXML_SetupId_SimActivityVsDistance) ||
                    specification.SetupId.Equals(Consts.STRXML_SetupId_SimActivityVsDistanceNoDelay))
                {
                    Specification.Absorber absorber = specification.AbsorberList[0];
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_absorberName, absorber.name, false);

                    //
                    // Create a CSV string of distances
                    //
                    string csvDistances = string.Empty;
                    for (int i = 0; i < specification.DistanceList.Length; i++)
                    {
                        if (i > 0)
                        {
                            csvDistances += Consts.CHR_CsvSplitter;
                        }
                        csvDistances += specification.DistanceList[i].ToString();
                    }
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_distance, csvDistances, false);
                }
                else if (specification.SetupId.Equals(Consts.STRXML_SetupId_RadioactivityVsAbsorber))
                {
                    //
                    // Create a CSV string of absorbers
                    //
                    string csvAbsorbers = string.Empty;
                    for (int i = 0; i < specification.AbsorberList.Length; i++)
                    {
                        if (i > 0)
                        {
                            csvAbsorbers += Consts.CHR_CsvSplitter;
                        }
                        csvAbsorbers += specification.AbsorberList[i].name;
                    }
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_absorberName, csvAbsorbers, false);

                    int distance = specification.DistanceList[0];
                    XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_distance, distance.ToString(), false);
                }

                //
                // Add the result information
                //
                if (resultInfo.statusCode == StatusCodes.Completed)
                {
                    if (specification.SetupId.Equals(Consts.STRXML_SetupId_RadioactivityVsTime) ||
                        specification.SetupId.Equals(Consts.STRXML_SetupId_RadioactivityVsDistance) ||
                        specification.SetupId.Equals(Consts.STRXML_SetupId_RadioactivityVsAbsorber) ||
                        specification.SetupId.Equals(Consts.STRXML_SetupId_SimActivityVsTime) ||
                        specification.SetupId.Equals(Consts.STRXML_SetupId_SimActivityVsDistance) ||
                        specification.SetupId.Equals(Consts.STRXML_SetupId_SimActivityVsTimeNoDelay) ||
                        specification.SetupId.Equals(Consts.STRXML_SetupId_SimActivityVsDistanceNoDelay))
                    {
                        XmlUtilities.SetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_dataType, resultInfo.dataType.ToString(), false);
                        XmlNode xmlNode = XmlUtilities.GetXmlNode(this.xmlNodeExperimentResult, Consts.STRXML_dataVector);
                        XmlNode xmlNodeCopy = null;
                        XmlNode xmlNodeTemp = null;
                        for (int i = 0; i < resultInfo.dataVectors.GetLength(0); i++)
                        {
                            if (i == 0)
                            {
                                // Keep a copy of the node for more dataVectors
                                xmlNodeCopy = xmlNode.Clone();
                                xmlNodeTemp = xmlNode;
                            }
                            else
                            {
                                // Get a copy of the nodeCopy to add another dataVector
                                xmlNodeTemp = xmlNodeCopy.Clone();
                            }

                            //
                            // Create CSV string from data vector
                            //
                            string csvString = string.Empty;
                            for (int j = 0; j < resultInfo.dataVectors.GetLength(1); j++)
                            {
                                if (j > 0)
                                {
                                    csvString += Consts.CHR_CsvSplitter;
                                }
                                csvString += resultInfo.dataVectors[i, j].ToString();
                            }
                            xmlNodeTemp.InnerXml = csvString;

                            if (i > 0)
                            {
                                // Append xml fragment to experiment result node
                                this.xmlNodeExperimentResult.AppendChild(xmlNodeTemp);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
        //-------------------------------------------------------------------------------------------------//

        public override 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!)
                //
                Specification    specification    = new Specification(this.configuration, this.equipmentServiceProxy);
                ValidationReport validationReport = specification.Parse(experimentInfo.xmlSpecification);
                if (validationReport.accepted == false)
                {
                    throw new ArgumentException(validationReport.errorMessage);
                }
                experimentInfo.setupId = specification.SetupId;

                //
                // Create an instance of the driver for the specified setup and then
                // execute the experiment and return the result information
                //
                ResultInfo resultInfo = null;
                if (specification.SetupId.Equals(Consts.STRXML_SetupId_NTPServer))
                {
                    DriverNetwork driver = new DriverNetwork(this.equipmentServiceProxy, this.configuration, this.labExperimentInfo.cancelExperiment);
                    resultInfo = (ResultInfo)driver.Execute(specification);
                }
                else if (specification.SetupId.Equals(Consts.STRXML_SetupId_LocalClock))
                {
                    DriverLocal driver = new DriverLocal(this.configuration, this.labExperimentInfo.cancelExperiment);
                    resultInfo = (ResultInfo)driver.Execute(specification);
                }

                //
                // Create an instance of LabExperimentResult to convert the experiment results to an XML string
                //
                ExperimentResult experimentResult = new ExperimentResult(
                    experimentInfo.experimentId, experimentInfo.sbName, DateTime.Now,
                    this.unitId, (Configuration)this.labConfiguration, specification, resultInfo);

                //
                // Fill in the result report
                //
                experimentInfo.resultReport.experimentResults = experimentResult.ToString();
                experimentInfo.resultReport.statusCode        = (int)resultInfo.statusCode;
                experimentInfo.resultReport.errorMessage      = resultInfo.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);
        }
Exemplo n.º 11
0
        //-------------------------------------------------------------------------------------------------//
        public override 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!)
                //
                Specification specification = new Specification(this.configuration, this.equipmentServiceProxy);
                ValidationReport validationReport = specification.Parse(experimentInfo.xmlSpecification);
                if (validationReport.accepted == false)
                {
                    throw new ArgumentException(validationReport.errorMessage);
                }
                experimentInfo.setupId = specification.SetupId;

                //
                // Create an instance of the driver for the specified setup and then
                // execute the experiment and return the result information
                //
                ResultInfo resultInfo = null;
                if (specification.SetupId.Equals(Consts.STRXML_SetupId_RadioactivityVsTime) ||
                    specification.SetupId.Equals(Consts.STRXML_SetupId_RadioactivityVsDistance))
                {
                    if (this.equipmentServiceProxy != null)
                    {
                        //
                        // Hardware is available to this unit, run it there
                        //
                        DriverRadioactivity driver = new DriverRadioactivity(this.equipmentServiceProxy, this.configuration, this.labExperimentInfo.cancelExperiment);
                        resultInfo = (ResultInfo)driver.Execute(specification);
                    }
                    else
                    {
                        //
                        // This unit does not have hardware available, run the simulation instead
                        //
                        DriverSimActivity driver = new DriverSimActivity(this.configuration, this.labExperimentInfo.cancelExperiment);
                        resultInfo = (ResultInfo)driver.Execute(specification);
                    }
                }
                else if (specification.SetupId.Equals(Consts.STRXML_SetupId_RadioactivityVsAbsorber))
                {
                    DriverAbsorbers driver = new DriverAbsorbers(this.equipmentServiceProxy, this.configuration, this.labExperimentInfo.cancelExperiment);
                    resultInfo = (ResultInfo)driver.Execute(specification);
                }
                else if (specification.SetupId.Equals(Consts.STRXML_SetupId_SimActivityVsTime) ||
                    specification.SetupId.Equals(Consts.STRXML_SetupId_SimActivityVsDistance))
                {
                    DriverSimActivity driver = new DriverSimActivity(this.configuration, this.labExperimentInfo.cancelExperiment);
                    resultInfo = (ResultInfo)driver.Execute(specification);
                }
                else if (specification.SetupId.Equals(Consts.STRXML_SetupId_SimActivityVsTimeNoDelay) ||
                    specification.SetupId.Equals(Consts.STRXML_SetupId_SimActivityVsDistanceNoDelay))
                {
                    DriverSimActivity driver = new DriverSimActivity(this.configuration, this.labExperimentInfo.cancelExperiment, false);
                    resultInfo = (ResultInfo)driver.Execute(specification);
                }

                //
                // Create an instance of LabExperimentResult to convert the experiment results to an XML string
                //
                ExperimentResult experimentResult = new ExperimentResult(
                    experimentInfo.experimentId, experimentInfo.sbName, DateTime.Now,
                    this.unitId, (Configuration)this.labConfiguration, specification, resultInfo);

                //
                // Fill in the result report
                //
                experimentInfo.resultReport.experimentResults = experimentResult.ToString();
                experimentInfo.resultReport.statusCode = (int)resultInfo.statusCode;
                experimentInfo.resultReport.errorMessage = resultInfo.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;
        }