using System; using System.Collections.Generic; using DTS.Common.Enums.Sensors; using DTS.Common.Utilities; using DTS.Common.Utilities.DotNetProgrammingConstructs; namespace DTS.Serialization { [Serializable] public partial class TestSetup : Exceptional { public TestSetup() { _dateOfTheTest.Value = null; _description.Value = null; _calibrationBehavior.Value = CalibrationBehaviors.NonLinearIfAvailable; _exportFolder.Value = null; _exportTypes.Value = 0; _labName.Value = null; _laboratoryName.Value = null; _laboratoryContactName.Value = null; _laboratoryContactPhone.Value = null; _laboratoryContactFax.Value = null; _laboratoryContactEmail.Value = null; _laboratoryTestReferenceNumber.Value = null; _custName.Value = null; _customerName.Value = null; _customerTestReferenceNumber.Value = null; _customerProjectReferenceNumber.Value = null; _customerOrderNumber.Value = null; _customerCostUnit.Value = null; _testEngineerName.Value = null; _testEngineerPhone.Value = null; _testEngineerFax.Value = null; _testEngineerEmail.Value = null; _name.Value = null; _numberOfMedia.Value = null; _numberOfTestObjects.Value = null; _testComment.Value = null; _typeOfTheTest.Value = null; _referenceTemperature.Value = null; _relativeAirHumidity.Value = null; _regulation.Value = null; _subtype.Value = null; _dateOfTheTest.Value = null; _timestamp.Value = null; //version 2.0 - 2019-05-17 added Upload/UploadFolder/UploadExportsOnly _version.Value = "2.0.0.0"; _upload.Value = false; _uploadExportsOnly.Value = false; _uploadFolder.Value = ""; } private readonly Property _upload = new Property(typeof(TestSetup).Namespace + ".TestSetup.Upload", false, true); /// /// indicates whether the test setup was configured to upload when it was run /// 12874 export button, upload feature not displaying information /// public bool Upload { get => _upload.Value; set => _upload.Value = value; } private readonly Property _uploadFolder = new Property(typeof(TestSetup).Namespace + ".TestSetup.UploadFolder", "", true); /// /// stores the simple upload folder value set in edit test setup /// 12874 export button, upload feature not displaying information /// this is where the test setup was configured to upload when it was run /// this is overridden by an INI file if one is set /// public string UploadFolder { get => _uploadFolder.Value; set => _uploadFolder.Value = value; } private readonly Property _uploadExportsOnly = new Property(typeof(TestSetup).Namespace + ".TestSetup.UploadExportsOnly", false, true); /// /// stores the simple upload folder value set in edit test setup /// 12874 export button, upload feature not displaying information /// this is where the test setup was configured to upload when it was run /// this is overridden by an INI file if one is set /// public bool UploadExportsOnly { get => _uploadExportsOnly.Value; set => _uploadExportsOnly.Value = value; } private readonly Property _isfFile = new Property(typeof(TestSetup).Namespace + ".TestSetup.ISFFile", "", true); public string ISFFile { get => _isfFile.Value; set => _isfFile.Value = value; } public string DateOfTheTest { get => _dateOfTheTest.Value; set => _dateOfTheTest.Value = value; } private readonly Property _dateOfTheTest = new Property(typeof(TestSetup).Namespace + ".TestSetup.DateOfTheTest", "", false); public string Description { get => _description.Value; set => _description.Value = value; } private readonly Property _description = new Property(typeof(TestSetup).Namespace + ".TestSetup.Description", "", false); public CalibrationBehaviors CalibrationBehavior { get => _calibrationBehavior.Value; set => _calibrationBehavior.Value = value; } private readonly Property _calibrationBehavior = new Property(typeof(TestSetup).Namespace + ".TestSetup.CalibrationBehavior", CalibrationBehaviors.NonLinearIfAvailable, false); public string ExportFolder { get => _exportFolder.Value; set => _exportFolder.Value = value; } private readonly Property _exportFolder = new Property(typeof(TestSetup).Namespace + ".TestSetup.ExportFolder", "", false); public Int32 ExportTypes { get => _exportTypes.Value; set => _exportTypes.Value = value; } private readonly Property _exportTypes = new Property(typeof(TestSetup).Namespace + ".TestSetup.ExportFormats", new Int32(), false); public List Graphs { get => _graphs.Value; set => _graphs.Value = value; } private readonly Property> _graphs = new Property>(typeof(TestSetup).Namespace + ".TestSetup.Graphs", new List(), true); public List Sensors { get => _sensors.Value; set => _sensors.Value = value; } private readonly Property> _sensors = new Property>(typeof(TestSetup).Namespace + ".TestSetup.Sensors", new List(), true); public string LabName { get => _labName.Value; set => _labName.Value = value; } private readonly Property _labName = new Property(typeof(TestSetup).Namespace + ".TestSetup.LabName", "", false); public string LaboratoryName { get => _laboratoryName.Value; set => _laboratoryName.Value = value; } private readonly Property _laboratoryName = new Property(typeof(TestSetup).Namespace + ".TestSetup.LaboratoryName", "", false); public string LaboratoryContactName { get => _laboratoryContactName.Value; set => _laboratoryContactName.Value = value; } private readonly Property _laboratoryContactName = new Property(typeof(TestSetup).Namespace + ".TestSetup.LaboratoryContactName", "", false); public string LaboratoryContactPhone { get => _laboratoryContactPhone.Value; set => _laboratoryContactPhone.Value = value; } private readonly Property _laboratoryContactPhone = new Property(typeof(TestSetup).Namespace + ".TestSetup.LaboratoryContactPhone", "", false); public string LaboratoryContactFax { get => _laboratoryContactFax.Value; set => _laboratoryContactFax.Value = value; } private readonly Property _laboratoryContactFax = new Property(typeof(TestSetup).Namespace + ".TestSetup.LaboratoryContactFax", "", false); public string LaboratoryContactEmail { get => _laboratoryContactEmail.Value; set => _laboratoryContactEmail.Value = value; } private readonly Property _laboratoryContactEmail = new Property(typeof(TestSetup).Namespace + ".TestSetup.LaboratoryContactEmail", "", false); public string LaboratoryTestReferenceNumber { get => _laboratoryTestReferenceNumber.Value; set => _laboratoryTestReferenceNumber.Value = value; } private readonly Property _laboratoryTestReferenceNumber = new Property(typeof(TestSetup).Namespace + ".TestSetup.LaboratoryTestReferenceNumber", "", false); public string LaboratoryProjectReferenceNumber { get { if (_laboratoryProjectReferenceNumber.IsValueInitialized) { return _laboratoryProjectReferenceNumber.Value; } return ""; } set => _laboratoryProjectReferenceNumber.Value = value; } private readonly Property _laboratoryProjectReferenceNumber = new Property(typeof(TestSetup).Namespace + ".TestSetup.LaboratoryProjectReferenceNumber", "", false); public string CustName { get => _custName.Value; set => _custName.Value = value; } private readonly Property _custName = new Property(typeof(TestSetup).Namespace + ".TestSetup.CustName", "", false); public string CustomerName { get => _customerName.Value; set => _customerName.Value = value; } private readonly Property _customerName = new Property(typeof(TestSetup).Namespace + ".TestSetup.CustomerName", "", false); public string CustomerTestReferenceNumber { get => _customerTestReferenceNumber.Value; set => _customerTestReferenceNumber.Value = value; } private readonly Property _customerTestReferenceNumber = new Property(typeof(TestSetup).Namespace + ".TestSetup.CustomerTestReferenceNumber", "", false); public string CustomerProjectReferenceNumber { get => _customerProjectReferenceNumber.Value; set => _customerProjectReferenceNumber.Value = value; } private readonly Property _customerProjectReferenceNumber = new Property(typeof(TestSetup).Namespace + ".TestSetup.CustomerProjectReferenceNumber", "", false); public string CustomerOrderNumber { get => _customerOrderNumber.Value; set => _customerOrderNumber.Value = value; } private readonly Property _customerOrderNumber = new Property(typeof(TestSetup).Namespace + ".TestSetup.CustomerOrderNumber", "", false); public string CustomerCostUnit { get => _customerCostUnit.Value; set => _customerCostUnit.Value = value; } private readonly Property _customerCostUnit = new Property(typeof(TestSetup).Namespace + ".TestSetup.CustomerCostUnit", "", false); public string TEName { get => _teName.IsValueInitialized ? _teName.Value : ""; set => _teName.Value = value; } private readonly Property _teName = new Property(typeof(TestSetup).Namespace + ".TestSetup.TEName", "", false); public string TestEngineerName { get => _testEngineerName.Value; set => _testEngineerName.Value = value; } private readonly Property _testEngineerName = new Property(typeof(TestSetup).Namespace + ".TestSetup.TestEngineerName", "", false); public string TestEngineerPhone { get => _testEngineerPhone.Value; set => _testEngineerPhone.Value = value; } private readonly Property _testEngineerPhone = new Property(typeof(TestSetup).Namespace + ".TestSetup.TestEngineerPhone", "", false); public string TestEngineerFax { get => _testEngineerFax.Value; set => _testEngineerFax.Value = value; } private readonly Property _testEngineerFax = new Property(typeof(TestSetup).Namespace + ".TestSetup.TestEngineerFax", "", false); public string TestEngineerEmail { get => _testEngineerEmail.Value; set => _testEngineerEmail.Value = value; } private readonly Property _testEngineerEmail = new Property(typeof(TestSetup).Namespace + ".TestSetup.TestEngineerEmail", "", false); public string Name { get => _name.Value; set => _name.Value = value; } private readonly Property _name = new Property(typeof(TestSetup).Namespace + ".TestSetup.Name", "", false); public string NumberOfTestObjects { get => _numberOfTestObjects.Value; set => _numberOfTestObjects.Value = value; } private readonly Property _numberOfTestObjects = new Property(typeof(TestSetup).Namespace + ".TestSetup.NumberOfTestObjects", "", false); public string NumberOfMedia { get => _numberOfMedia.Value; set => _numberOfMedia.Value = value; } private readonly Property _numberOfMedia = new Property(typeof(TestSetup).Namespace + ".TestSetup.NumberOfMedia", "", false); public string ReferenceTemperature { get => _referenceTemperature.Value; set => _referenceTemperature.Value = value; } private readonly Property _referenceTemperature = new Property(typeof(TestSetup).Namespace + ".TestSetup.ReferenceTemperature", "", false); public string Regulation { get => _regulation.Value; set => _regulation.Value = value; } private readonly Property _regulation = new Property(typeof(TestSetup).Namespace + ".TestSetup.Regulation", "", false); public string RelativeAirHumidity { get => _relativeAirHumidity.Value; set => _relativeAirHumidity.Value = value; } private readonly Property _relativeAirHumidity = new Property(typeof(TestSetup).Namespace + ".TestSetup.RelativeAirHumidity", "", false); public string Subtype { get => _subtype.Value; set => _subtype.Value = value; } private readonly Property _subtype = new Property(typeof(TestSetup).Namespace + ".TestSetup.Subtype", "", false); public string TestComment { get => _testComment.Value; set => _testComment.Value = value; } private readonly Property _testComment = new Property(typeof(TestSetup).Namespace + ".TestSetup.TestComment", "", false); public List ExtraProperties { get => _extraProperties.Value; set => _extraProperties.Value = value; } private readonly Property> _extraProperties = new Property>(typeof(TestSetup).Namespace + ".TestSetup.ExtraProperties", new List(), true); public List TestObjects { get => _testObjects.Value; set => _testObjects.Value = value; } private readonly Property> _testObjects = new Property>(typeof(TestSetup).Namespace + ".TestSetup.TestObjects", new List(), true); public string Timestamp { get => _timestamp.Value; set => _timestamp.Value = value; } private readonly Property _timestamp = new Property(typeof(TestSetup).Namespace + ".TestSetup.Timestamp", "", false); public string TypeOfTheTest { get => _typeOfTheTest.Value; set => _typeOfTheTest.Value = value; } private readonly Property _typeOfTheTest = new Property(typeof(TestSetup).Namespace + ".TestSetup.TypeOfTheTest", "", false); public virtual string Version { get => _version.Value; set => _version.Value = value; } private readonly Property _version = new Property(typeof(TestSetup).Namespace + ".TestSetup.Version", "", false); //Placeholder for all graph channels [System.Xml.Serialization.XmlIgnore] public List Channels = new List(); //Placeholder for Single Channel Graphs [System.Xml.Serialization.XmlIgnore] public List SingleChannelGraphs = new List(); [System.Xml.Serialization.XmlIgnore] public IDictionary SortedGraphs = new Dictionary(); /* * Display listing of graphs is a little funny: * First come defined multi-channel graphs in the order that they are listed in the .dts file. * Next come the single channel files that are created when a dts file is read in sorted by display order * Finally come all the calculated channels, sorted in display order. */ public void SortGraphs() { SortedGraphs.Clear(); foreach (var g in Graphs) { SortedGraphs.Add(g.Identifier, g); } //All of the multi channel graphs are in the dictionary in the correct order, now sort the single channel graphs. SingleChannelGraphs.Sort(GraphDisplayOrderComparer); //Add them to the dictionary foreach (var g in SingleChannelGraphs) { SortedGraphs.Add(g.Identifier, g); } } private int GraphDisplayOrderComparer(Graph a, Graph b) { if (a == b) { return 0; } if (null == a) { return -1; } if (null == b) { return 1; } return a.FirstTestChannel.AbsoluteDisplayOrder.CompareTo(b.FirstTestChannel.AbsoluteDisplayOrder); } } }