//-------------------------------------------------------------------------------------------------// protected void Application_Start(object sender, EventArgs e) { const string STRLOG_MethodName = "Application_Start"; // // Set the filepath for the log files // string rootFilePath = HostingEnvironment.ApplicationPhysicalPath; string logFilesPath = Utilities.GetAppSetting(Consts.STRCFG_LogFilesPath); Logfile.SetFilePath(Path.Combine(rootFilePath, logFilesPath)); Logfile.Write(""); Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName); // // Create the experiment manager // allowedServiceBrokers = new AllowedServiceBrokersDB(); configuration = new Configuration(rootFilePath); experimentManager = new ExperimentManager(allowedServiceBrokers, configuration); experimentManager.Create(); // // Now start the experiment manager // experimentManager.Start(); Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public ExperimentResult(Configuration configuration) : base(configuration) { try { // // Check that all required XML nodes exist // XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_formatName, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_serverUrl, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_timeofday, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_dayofweek, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_day, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_month, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_year, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_hours, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_minutes, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_seconds, true); } catch (Exception ex) { // Log the message and throw the exception back to the caller Logfile.WriteError(ex.Message); throw; } }
//-------------------------------------------------------------------------------------------------// protected void Application_Start(object sender, EventArgs e) { const string STRLOG_MethodName = "Application_Start"; // // Set the filepath for the log files // string rootFilePath = HostingEnvironment.ApplicationPhysicalPath; string logFilesPath = Utilities.GetAppSetting(Consts.STRCFG_LogFilesPath); Logfile.SetFilePath(Path.Combine(rootFilePath, logFilesPath)); Logfile.Write(""); Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName); // // Create the experiment manager // allowedServiceBrokers = new AllowedServiceBrokersDB(); configuration = new Library.LabServer.Configuration(rootFilePath); experimentManager = new ExperimentManager(allowedServiceBrokers, configuration); experimentManager.Create(); // // Now start the experiment manager // experimentManager.Start(); Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public ExperimentResult(Configuration configuration) : base(configuration) { try { // // Check that all required XML nodes exist // XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_speedMin, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_speedMax, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_speedStep, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_fieldMin, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_fieldMax, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_fieldStep, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_loadMin, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_loadMax, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_loadStep, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_speedVector, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_fieldVector, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_voltageVector, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_loadVector, true); } catch (Exception ex) { // Log the message and throw the exception back to the caller Logfile.WriteError(ex.Message); throw; } }
//-------------------------------------------------------------------------------------------------// public Specification(Configuration configuration, EquipmentService equipmentServiceProxy) : base(configuration, equipmentServiceProxy) { const string STRLOG_MethodName = "Specification"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Save these for use by the Parse() method // this.configuration = configuration; // // Check that the specification template is valid. This is used by the LabClient to submit // the experiment specification to the LabServer for execution. // try { // // Check that all required XML nodes exist // // // Nothing to do here // } 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 // // // 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 Validation(Configuration configuration) : base(configuration) { const string STRLOG_MethodName = "Validation"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Get information from the validation XML node // try { // // Get distance range information from the validation node // XmlNode xmlNode = XmlUtilities.GetXmlNode(this.xmlNodeValidation, Consts.STRXML_vdnDistance); this.distance = new VdnMinMax(); this.distance.min = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_minimum); this.distance.max = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_maximum); // // Get duration range information from the validation node // xmlNode = XmlUtilities.GetXmlNode(this.xmlNodeValidation, Consts.STRXML_vdnDuration); this.duration = new VdnMinMax(); this.duration.min = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_minimum); this.duration.max = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_maximum); // // Get distance range information from the validation node // xmlNode = XmlUtilities.GetXmlNode(this.xmlNodeValidation, Consts.STRXML_vdnRepeat); this.repeat = new VdnMinMax(); this.repeat.min = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_minimum); this.repeat.max = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_maximum); // // Get distance range information from the validation node // xmlNode = XmlUtilities.GetXmlNode(this.xmlNodeValidation, Consts.STRXML_vdnTotaltime); this.totalTime = new VdnMinMax(); this.totalTime.min = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_minimum); this.totalTime.max = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_maximum); } catch (Exception ex) { Logfile.WriteError(ex.Message); throw; } Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public Validation(Configuration configuration) : base(configuration) { const string STRLOG_MethodName = "Validation"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Get information from the validation XML node // try { // // Get speed range information from the lab configuration node // XmlNode xmlNode = XmlUtilities.GetXmlNode(this.xmlNodeValidation, Consts.STRXML_vdnSpeed); this.speed = new VdnMinMaxStep(); this.speed.min = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_minimum); this.speed.max = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_maximum); this.speed.stepMin = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_stepMin); this.speed.stepMax = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_stepMax); // // Get field range information from the lab configuration node // xmlNode = XmlUtilities.GetXmlNode(this.xmlNodeValidation, Consts.STRXML_vdnField); this.field = new VdnMinMaxStep(); this.field.min = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_minimum); this.field.max = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_maximum); this.field.stepMin = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_stepMin); this.field.stepMax = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_stepMax); // // Get load range information from the lab configuration node // xmlNode = XmlUtilities.GetXmlNode(this.xmlNodeValidation, Consts.STRXML_vdnLoad); this.load = new VdnMinMaxStep(); this.load.min = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_minimum); this.load.max = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_maximum); this.load.stepMin = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_stepMin); this.load.stepMax = XmlUtilities.GetIntValue(xmlNode, Consts.STRXML_stepMax); } catch (Exception ex) { Logfile.WriteError(ex.Message); throw; } Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public Specification(Configuration configuration, EquipmentService equipmentServiceProxy) : base(configuration, equipmentServiceProxy) { const string STRLOG_MethodName = "Specification"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Save these for use by the Parse() method // this.configuration = configuration; // // Check that the specification template is valid. This is used by the LabClient to submit // the experiment specification to the LabServer for execution. // try { // // Check that all required XML nodes exist // XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_speedMin, true); XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_speedMax, true); XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_speedStep, true); XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_fieldMin, true); XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_fieldMax, true); XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_fieldStep, true); XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_loadMin, true); XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_loadMax, true); XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_loadStep, true); // // Create an instance fo the Validation class // this.validation = new Validation(configuration); } catch (Exception ex) { Logfile.WriteError(ex.Message); throw; } Logfile.WriteCompleted(null, STRLOG_MethodName); }
//-------------------------------------------------------------------------------------------------// public ExperimentResult(Configuration configuration) : base(configuration) { try { // // Check that all required XML nodes exist // // // Nothing to do here // } catch (Exception ex) { // Log the message and throw the exception back to the caller Logfile.WriteError(ex.Message); throw; } }
//-------------------------------------------------------------------------------------------------// 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(Configuration configuration) : base(configuration) { try { // // Check that all required XML nodes exist // XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_sourceName, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_absorberName, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_distance, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_duration, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_repeat, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_dataType, true); XmlUtilities.GetXmlValue(this.xmlNodeExperimentResult, Consts.STRXML_dataVector, true); } catch (Exception ex) { // Log the message and throw the exception back to the caller Logfile.WriteError(ex.Message); throw; } }
//-------------------------------------------------------------------------------------------------// public Validation(Configuration configuration) : base(configuration) { const string STRLOG_MethodName = "Validation"; Logfile.WriteCalled(null, STRLOG_MethodName); // // Get information from the validation XML node // try { // // YOUR CODE HERE // } 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 ExperimentManager(AllowedServiceBrokersDB allowedServiceBrokers, Configuration configuration) : this(allowedServiceBrokers, configuration, 0) { }
//-------------------------------------------------------------------------------------------------// 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 ExperimentManager(AllowedServiceBrokersDB allowedServiceBrokers, Configuration configuration, int farmSize) : base(allowedServiceBrokers, configuration, farmSize) { }
//-------------------------------------------------------------------------------------------------// 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 ExperimentEngine(int unitId, AppData appData) : base(unitId, appData) { this.configuration = (Configuration)appData.labConfiguration; }