/* Test.Module.cs Copyright © 2008 Diversified Technical Systems, Inc. All Rights Reserved */ using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; using DTS.Common.Enums.DASFactory; using DTS.Common.Utilities; using DTS.Common.Utilities.DotNetProgrammingConstructs; using DTS.Common.Utilities.Xml; using DTS.Common.Utils; namespace DTS.Serialization { // *** See Test.cs *** public partial class Test : Exceptional, IXmlSerializable { /// /// Representation of serializable module information. /// [XmlSerializationTag("Module")] public partial class Module : Exceptional { /// /// finds any trigger or start record timestamps to return /// public static IEnumerable GetModuleTimeStamps(IEnumerable basemodules, out IEnumerable starts) { var testModuleTimeStamps = new List(); var startList = new List(); var noMasterSync = !basemodules.Any(module => module.PTPMasterSync); foreach (var module in basemodules) { //if there's no master sync, but we have RTC time stamps, use those if (module.PTPMasterSync || noMasterSync) { //if there's a trigger timestamp, use that, otherwise use the start if (module.TriggerTimestampNanoSec > 0 || module.TriggerTimestampSec > 0) { var testModuleTimeStamp = new TestModuleTimeStamp { TriggerTimestampSec = (int)module.TriggerTimestampSec, TriggerTimestampNanoSec = (int)module.TriggerTimestampNanoSec }; testModuleTimeStamps.Add(testModuleTimeStamp); } else if ((module.StartRecordTimestampNanoSec > 0 || module.StartRecordTimestampSec > 0)) { var testModuleTimeStamp = new TestModuleTimeStamp { TriggerTimestampSec = (int)module.StartRecordTimestampSec, TriggerTimestampNanoSec = (int)module.StartRecordTimestampNanoSec }; startList.Add(testModuleTimeStamp); } } } starts = startList; return testModuleTimeStamps; } /// /// The that contains this module. /// public Test ParentTest { get => _ParentTest.Value; private set => _ParentTest.Value = value; } private readonly Property _ParentTest = new Property( typeof(Module).Namespace + ".Test.Module.ParentTest", null, false ); /// /// Initialize an instance of the DTS.Serialization.Test.Module class. /// /// /// /// The containing this object. /// /// public Module(Test parentTest) { try { ParentTest = parentTest; } catch (System.Exception ex) { throw new Exception("encountered problem constructing " + GetType().Name, ex); } } /// /// Get/set the list of channels on this module. /// [XmlSerializationTag("Channels")] public List Channels { get => _Channels.Value; set => _Channels.Value = value; } private readonly Property> _Channels = new Property>( typeof(Module).Namespace + ".Test.Module.Channels", new List(), true ); /// /// The list of modules in this test. /// [XmlSerializationTag("CalculatedChannels")] public List CalculatedChannels { get => _CalculatedChannels.Value; set => _CalculatedChannels.Value = value; } private readonly Property> _CalculatedChannels = new Property>( typeof(Module).Namespace + ".Test.Module.CalculatedChannels", new List(), true ); /// /// Get/set the module number of this module. /// [XmlSerializationTag("Number")] public int Number { get => _Number.Value; set => _Number.Value = value; } private readonly Property _Number = new Property( typeof(Module).Namespace + ".Test.Module.Number", 0, false ); /// /// Get/set the serial number for this DAS. /// [XmlSerializationTag("SerialNumber")] public string SerialNumber { get => _SerialNumber.Value; set => _SerialNumber.Value = value; } private readonly Property _SerialNumber = new Property( typeof(Module).Namespace + ".Test.Module.SerialNumber", "", true ); /// /// A string that describes the module, for example, to know if it was created for the /// purposes of adding it to the .dts file during download of Slice6 Distributor attributes. /// [XmlSerializationTag("Description")] public string Description { get => _Description.Value; set => _Description.Value = value; } private readonly Property _Description = new Property( typeof(Module).Namespace + ".Test.Module.Description", "", true ); /// /// Get/set the base serial number for this DAS. /// [XmlSerializationTag("BaseSerialNumber")] public string BaseSerialNumber { get => _BaseSerialNumber.Value; set => _BaseSerialNumber.Value = value; } private readonly Property _BaseSerialNumber = new Property( typeof(Module).Namespace + ".Test.Module.BaseSerialNumber", "", true ); /// /// Get/set the number of requested seconds pre-trigger for this module. /// [XmlSerializationTag("RequestedPreTriggerSeconds")] public double RequestedPreTriggerSeconds { get => _RequestedPreTriggerSeconds.Value; set => _RequestedPreTriggerSeconds.Value = value; } private readonly Property _RequestedPreTriggerSeconds = new Property( typeof(Module).Namespace + ".Test.Module.RequestedPreTriggerSeconds", 0.0, false ); /// /// Get/set the number of requested seconds post-trigger for this module. /// [XmlSerializationTag("RequestedPostTriggerSeconds")] public double RequestedPostTriggerSeconds { get => _RequestedPostTriggerSeconds.Value; set => _RequestedPostTriggerSeconds.Value = value; } private readonly Property _RequestedPostTriggerSeconds = new Property( typeof(Module).Namespace + ".Test.Module.RequestedPostTriggerSeconds", 0.0, false ); /// /// Get/set the number of seconds pre-trigger for this module. /// [XmlSerializationTag("PreTriggerSeconds")] public double PreTriggerSeconds { get => _PreTriggerSeconds.Value; set => _PreTriggerSeconds.Value = value; } private readonly Property _PreTriggerSeconds = new Property( typeof(Module).Namespace + ".Test.Module.PreTriggerSeconds", 0.0, false ); /// /// Get/set the number of seconds post-trigger for this module. /// [XmlSerializationTag("PostTriggerSeconds")] public double PostTriggerSeconds { get => _PostTriggerSeconds.Value; set => _PostTriggerSeconds.Value = value; } private readonly Property _PostTriggerSeconds = new Property( typeof(Module).Namespace + ".Test.Module.PostTriggerSeconds", 0.0, false ); /// /// Get/set the number of samples in this test modules. /// [XmlSerializationTag("NumberOfSamples")] public UInt64 NumberOfSamples { get => _NumberOfSamples.Value; set { if (!_UnsubsampledNumberOfSamples.IsInitialized || value > UnsubsampledNumberOfSamples) UnsubsampledNumberOfSamples = value; _NumberOfSamples.Value = value; } } private readonly Property _NumberOfSamples = new Property( typeof(Module).Namespace + ".Test.Module.NumberOfSamples", 0, false ); /// /// Get/set the unsubsampled number of samples in this test modules. /// [XmlSerializationTag("UnsubsampledNumberOfSamples")] public UInt64 UnsubsampledNumberOfSamples { get => _UnsubsampledNumberOfSamples.Value; set => _UnsubsampledNumberOfSamples.Value = value; } private readonly Property _UnsubsampledNumberOfSamples = new Property( typeof(Module).Namespace + ".Test.Module.UnsubsampledNumberOfSamples", 0, false ); /// /// Get/set the trigger sample numbers for this module. /// private const int DataName = 0; private const int DatumName = 1; private const int DatumValueName = 2; [XmlSerializationTag("TriggerSampleNumbers", DataName)] [XmlSerializationTag("TriggerSampleNumber", DatumName)] [XmlSerializationTag("Value", DatumValueName)] public List TriggerSampleNumbers { get => _TriggerSampleNumbers.Value; set => _TriggerSampleNumbers.Value = value; } private readonly Property> _TriggerSampleNumbers = new Property>( typeof(Module).Namespace + ".Test.Module.TriggerSampleNumbers", null, false ); /// /// Get/set the unsubsampled trigger sample numbers for this module. /// [XmlSerializationTag("UnsubsampledTriggerSampleNumbers", DataName)] [XmlSerializationTag("UnsubsampledTriggerSampleNumber", DatumName)] [XmlSerializationTag("Value", DatumValueName)] public List UnsubsampledTriggerSampleNumbers { get => _UnsubsampledTriggerSampleNumbers.Value; set => _UnsubsampledTriggerSampleNumbers.Value = value; } private readonly Property> _UnsubsampledTriggerSampleNumbers = new Property>( typeof(Module).Namespace + ".Test.Module.UnsubsampledTriggerSampleNumbers", null, false ); /// /// Get/set the start record sample number for this module. /// [XmlSerializationTag("StartRecordSampleNumber")] public UInt64 StartRecordSampleNumber { get => _StartRecordSampleNumber.Value; set => _StartRecordSampleNumber.Value = value; } private readonly Property _StartRecordSampleNumber = new Property( typeof(Module).Namespace + ".Test.Module.StartRecordSampleNumber", 0, false ); /// /// Get/set the sample rate for this test module. /// [XmlSerializationTag("SampleRateHz")] public float SampleRateHz { get => _SampleRateHz.Value; set => _SampleRateHz.Value = value; } private readonly Property _SampleRateHz = new Property( typeof(Module).Namespace + ".Test.Module.SampleRateHz", 0, false ); /// /// /// [XmlSerializationTag("StartRecordTimestampSec")] public double StartRecordTimestampSec { get => _StartRecordTimestampSec.Value; set => _StartRecordTimestampSec.Value = value; } private readonly Property _StartRecordTimestampSec = new Property( typeof(Module).Namespace + ".Test.Module.StartRecordTimestampSec", 0, false ); /// /// /// [XmlSerializationTag("TriggerTimestampSec")] public double TriggerTimestampSec { get => _TriggerTimestampSec.Value; set => _TriggerTimestampSec.Value = value; } private readonly Property _TriggerTimestampSec = new Property( typeof(Module).Namespace + ".Test.Module.TriggerTimestampSec", 0, false ); /// /// /// [XmlSerializationTag("StartRecordTimestampNanoSec")] public double StartRecordTimestampNanoSec { get => _StartRecordTimestampNanoSec.Value; set => _StartRecordTimestampNanoSec.Value = value; } private readonly Property _StartRecordTimestampNanoSec = new Property( typeof(Module).Namespace + ".Test.Module.StartRecordTimestampNanoSec", 0, false ); /// /// /// [XmlSerializationTag("TriggerTimestampNanoSec")] public double TriggerTimestampNanoSec { get => _TriggerTimestampNanoSec.Value; set => _TriggerTimestampNanoSec.Value = value; } private readonly Property _TriggerTimestampNanoSec = new Property( typeof(Module).Namespace + ".Test.Module.TriggerTimestampNanoSec", 0, false ); /// /// /// [XmlSerializationTag("PTPMasterSync")] public bool PTPMasterSync { get => _PTPMasterSync.Value; set => _PTPMasterSync.Value = value; } private readonly Property _PTPMasterSync = new Property( typeof(Module).Namespace + ".Test.Module.PTPMasterSync", false, false ); /// /// A string that represents the System ID. /// [XmlSerializationTag("SystemID")] public string SystemID { get => _SystemID.Value; set => _SystemID.Value = value ?? string.Empty; } private readonly Property _SystemID = new Property( typeof(Module).Namespace + ".Test.Module.SystemID", "", true ); /// /// A string that represents the System Location. /// [XmlSerializationTag("SystemLocation")] public string SystemLocation { get => _SystemLocation.Value; set => _SystemLocation.Value = value ?? string.Empty; } private readonly Property _SystemLocation = new Property( typeof(Module).Namespace + ".Test.Module.SystemLocation", "", true ); /// /// A string that represents the first target axis. /// [XmlSerializationTag("TargetAxisOne")] public double TargetAxisOne { get => _TargetAxisOne.Value; set => _TargetAxisOne.Value = value; } private readonly Property _TargetAxisOne = new Property( typeof(Module).Namespace + ".Test.Module.TargetAxisOne", 0, false ); /// /// A string that represents the second target axis. /// [XmlSerializationTag("TargetAxisTwo")] public double TargetAxisTwo { get => _TargetAxisTwo.Value; set => _TargetAxisTwo.Value = value; } private readonly Property _TargetAxisTwo = new Property( typeof(Module).Namespace + ".Test.Module.TargetAxisTwo", 0, false ); /// /// A string that represents the X target axis. /// [XmlSerializationTag("TargetAxisX")] public double TargetAxisX { get => _TargetAxisX.Value; set => _TargetAxisX.Value = value; } private readonly Property _TargetAxisX = new Property( typeof(Module).Namespace + ".Test.Module.TargetAxisX", double.NaN, false ); /// /// A string that represents the Y target axis. /// [XmlSerializationTag("TargetAxisY")] public double TargetAxisY { get => _TargetAxisY.Value; set => _TargetAxisY.Value = value; } private readonly Property _TargetAxisY = new Property( typeof(Module).Namespace + ".Test.Module.TargetAxisY", double.NaN, false ); /// /// A string that represents the Z target axis. /// [XmlSerializationTag("TargetAxisZ")] public double TargetAxisZ { get => _TargetAxisZ.Value; set => _TargetAxisZ.Value = value; } private readonly Property _TargetAxisZ = new Property( typeof(Module).Namespace + ".Test.Module.TargetAxisZ", double.NaN, false ); /// /// The value for the X axis of a Slice6 tilt sensor /// [XmlSerializationTag("TiltSensorAxisXDegreesPre")] public double TiltSensorAxisXDegreesPre { get => _TiltSensorAxisXDegreesPre.Value; set => _TiltSensorAxisXDegreesPre.Value = value; } private readonly Property _TiltSensorAxisXDegreesPre = new Property( typeof(Module).Namespace + ".Test.Module.TiltSensorAxisXDegreesPre", 0, false ); /// /// The value for the Y axis of a Slice6 tilt sensor /// [XmlSerializationTag("TiltSensorAxisYDegreesPre")] public double TiltSensorAxisYDegreesPre { get => _TiltSensorAxisYDegreesPre.Value; set => _TiltSensorAxisYDegreesPre.Value = value; } private readonly Property _TiltSensorAxisYDegreesPre = new Property( typeof(Module).Namespace + ".Test.Module.TiltSensorAxisYDegreesPre", 0, false ); /// /// The value for the Z axis of a Slice6 tilt sensor /// [XmlSerializationTag("TiltSensorAxisZDegreesPre")] public double TiltSensorAxisZDegreesPre { get => _TiltSensorAxisZDegreesPre.Value; set => _TiltSensorAxisZDegreesPre.Value = value; } private readonly Property _TiltSensorAxisZDegreesPre = new Property( typeof(Module).Namespace + ".Test.Module.TiltSensorAxisZDegreesPre", 0, false ); /// /// The value for the X axis of a Slice6 tilt sensor /// [XmlSerializationTag("TiltSensorAxisXDegreesPost")] public double TiltSensorAxisXDegreesPost { get => _TiltSensorAxisXDegreesPost.Value; set => _TiltSensorAxisXDegreesPost.Value = value; } private readonly Property _TiltSensorAxisXDegreesPost = new Property( typeof(Module).Namespace + ".Test.Module.TiltSensorAxisXDegreesPost", 0, false ); /// /// The value for the Y axis of a Slice6 tilt sensor /// [XmlSerializationTag("TiltSensorAxisYDegreesPost")] public double TiltSensorAxisYDegreesPost { get => _TiltSensorAxisYDegreesPost.Value; set => _TiltSensorAxisYDegreesPost.Value = value; } private readonly Property _TiltSensorAxisYDegreesPost = new Property( typeof(Module).Namespace + ".Test.Module.TiltSensorAxisYDegreesPost", 0, false ); /// /// The value for the Z axis of a Slice6 tilt sensor /// [XmlSerializationTag("TiltSensorAxisZDegreesPost")] public double TiltSensorAxisZDegreesPost { get => _TiltSensorAxisZDegreesPost.Value; set => _TiltSensorAxisZDegreesPost.Value = value; } private readonly Property _TiltSensorAxisZDegreesPost = new Property( typeof(Module).Namespace + ".Test.Module.TiltSensorAxisZDegreesPost", 0, false ); /// /// The value for the 1st location of a Slice6 temperature sensor /// [XmlSerializationTag("TemperatureLocation1Pre")] public float TemperatureLocation1Pre { get => _TemperatureLocation1Pre.Value; set => _TemperatureLocation1Pre.Value = value; } private readonly Property _TemperatureLocation1Pre = new Property( typeof(Module).Namespace + ".Test.Module.TemperatureLocation1Pre", 0, false ); /// /// The value for the 2nd location of a Slice6 temperature sensor /// [XmlSerializationTag("TemperatureLocation2Pre")] public float TemperatureLocation2Pre { get => _TemperatureLocation2Pre.Value; set => _TemperatureLocation2Pre.Value = value; } private readonly Property _TemperatureLocation2Pre = new Property( typeof(Module).Namespace + ".Test.Module.TemperatureLocation2Pre", 0, false ); /// /// The value for the 3rd location of a Slice6 temperature sensor /// [XmlSerializationTag("TemperatureLocation3Pre")] public float TemperatureLocation3Pre { get => _TemperatureLocation3Pre.Value; set => _TemperatureLocation3Pre.Value = value; } private readonly Property _TemperatureLocation3Pre = new Property( typeof(Module).Namespace + ".Test.Module.TemperatureLocation3Pre", 0, false ); /// /// The value for the 4th location of a Slice6 temperature sensor /// [XmlSerializationTag("TemperatureLocation4Pre")] public float TemperatureLocation4Pre { get => _TemperatureLocation4Pre.Value; set => _TemperatureLocation4Pre.Value = value; } private readonly Property _TemperatureLocation4Pre = new Property( typeof(Module).Namespace + ".Test.Module.TemperatureLocation4Pre", 0, false ); /// /// The value for the 1st location of a Slice6 temperature sensor post-trigger /// [XmlSerializationTag("TemperatureLocation1Post")] public float TemperatureLocation1Post { get => _TemperatureLocation1Post.Value; set => _TemperatureLocation1Post.Value = value; } private readonly Property _TemperatureLocation1Post = new Property( typeof(Module).Namespace + ".Test.Module.TemperatureLocation1Post", 0, false ); /// /// The value for the 2nd location of a Slice6 temperature sensor post-trigger /// [XmlSerializationTag("TemperatureLocation2Post")] public float TemperatureLocation2Post { get => _TemperatureLocation2Post.Value; set => _TemperatureLocation2Post.Value = value; } private readonly Property _TemperatureLocation2Post = new Property( typeof(Module).Namespace + ".Test.Module.TemperatureLocation2Post", 0, false ); /// /// The value for the 3rd location of a Slice6 temperature sensor post-trigger /// [XmlSerializationTag("TemperatureLocation3Post")] public float TemperatureLocation3Post { get => _TemperatureLocation3Post.Value; set => _TemperatureLocation3Post.Value = value; } private readonly Property _TemperatureLocation3Post = new Property( typeof(Module).Namespace + ".Test.Module.TemperatureLocation3Post", 0, false ); /// /// The value for the 4th location of a Slice6 temperature sensor post-trigger /// [XmlSerializationTag("TemperatureLocation4Post")] public float TemperatureLocation4Post { get => _TemperatureLocation4Post.Value; set => _TemperatureLocation4Post.Value = value; } private readonly Property _TemperatureLocation4Post = new Property( typeof(Module).Namespace + ".Test.Module.TemperatureLocation4Post", 0, false ); /// /// The value for the input voltage /// [XmlSerializationTag("InputVoltage")] public double InputVoltage { get => _inputVoltage.Value; set => _inputVoltage.Value = value; } private readonly Property _inputVoltage = new Property( typeof(Module).Namespace + ".Test.Module.InputVoltage", 0, false ); /// /// The value for the battery voltage /// [XmlSerializationTag("BatteryVoltage")] public double BatteryVoltage { get => _batteryVoltage.Value; set => _batteryVoltage.Value = value; } private readonly Property _batteryVoltage = new Property( typeof(Module).Namespace + ".Test.Module.BatteryVoltage", 0, false ); /// /// Get/set the AA filter rate for this test module. /// [XmlSerializationTag("AaFilterRateHz")] public float AaFilterRateHz { get => _AaFilterRateHz.Value; set => _AaFilterRateHz.Value = value; } private readonly Property _AaFilterRateHz = new Property( typeof(Module).Namespace + ".Test.Module.AaFilterRateHz", 0, false ); /// /// Get/set the recording mode of this module. /// [XmlSerializationTag("RecordingMode")] public DFConstantsAndEnums.RecordingMode RecordingMode { get => _RecordingMode.Value; set => _RecordingMode.Value = value; } private readonly Property _RecordingMode = new Property( typeof(Module).Namespace + ".Test.Module.RecordingMode", DFConstantsAndEnums.RecordingMode.CircularBuffer, false ); /// /// Get the number of channels in the channel list. (Intended for de/serialization only!) /// [XmlSerializationTag("NumberOfChannels")] public int NumberOfChannels => Channels.Count; /// /// Get/set inline serialized data switch. /// [XmlSerializationTag("InlineSerializedData")] public bool InlineSerializedData { get => _InlineSerializedData.Value; set { try { _InlineSerializedData.Value = value; foreach (var channel in Channels) channel.ExpressDataInlineOnXmlSerialization = value; } catch (System.Exception ex) { throw new Exception("encountered problem setting module InlineSerializedData state", ex); } } } private readonly Property _InlineSerializedData = new Property("InlineSerializedData", false, true); /// /// Write XML serialization for this object to the specified writer. /// /// /// /// The to which this object's XML serialization /// will be written. /// /// public void WriteXml(XmlWriter writer) { try { var cult = new CultureInfo(""); var attributeExtractor = new AttributeExtractor(); // // Write simple module properties. // // NOTE: The way this really should be done is to examine this object using reflection and just automatically // assemble the list of properties that have been tagged with the serialization attribute. That way, when I // add in a property after the fact, I don't have to worry about any of this crap below. It would just automatically // get de/serialized. The equality check should also pick it's comparison properties that way. I'd do the conversion // now, but we're under pressure for a release so it'll have to wait. // writer.WriteStartElement(attributeExtractor.ExtractAttachedAttributeFromObject(this).Value); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "AaFilterRateHz").Value, AaFilterRateHz.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Number").Value, Number.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SerialNumber").Value, (SerialNumber ?? "").ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "NumberOfSamples").Value, NumberOfSamples.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UnsubsampledNumberOfSamples").Value, UnsubsampledNumberOfSamples.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "RequestedPostTriggerSeconds").Value, RequestedPostTriggerSeconds.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "RequestedPreTriggerSeconds").Value, RequestedPreTriggerSeconds.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "PostTriggerSeconds").Value, PostTriggerSeconds.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "PreTriggerSeconds").Value, PreTriggerSeconds.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "RecordingMode").Value, RecordingMode.ToString()); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SampleRateHz").Value, SampleRateHz.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "StartRecordSampleNumber").Value, StartRecordSampleNumber.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "NumberOfChannels").Value, NumberOfChannels.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "InlineSerializedData").Value, InlineSerializedData.ToString(cult)); try { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "BaseSerialNumber").Value, BaseSerialNumber.ToString(cult)); } catch (System.Exception) { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "BaseSerialNumber").Value, "NA"); } writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "StartRecordTimestampSec").Value, StartRecordTimestampSec.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "StartRecordTimestampNanoSec").Value, StartRecordTimestampNanoSec.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TriggerTimestampSec").Value, TriggerTimestampSec.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TriggerTimestampNanoSec").Value, TriggerTimestampNanoSec.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "PTPMasterSync").Value, PTPMasterSync.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TiltSensorAxisXDegreesPre").Value, TiltSensorAxisXDegreesPre.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TiltSensorAxisYDegreesPre").Value, TiltSensorAxisYDegreesPre.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TiltSensorAxisZDegreesPre").Value, TiltSensorAxisZDegreesPre.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TiltSensorAxisXDegreesPost").Value, TiltSensorAxisXDegreesPost.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TiltSensorAxisYDegreesPost").Value, TiltSensorAxisYDegreesPost.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TiltSensorAxisZDegreesPost").Value, TiltSensorAxisZDegreesPost.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation1Pre").Value, TemperatureLocation1Pre.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation2Pre").Value, TemperatureLocation2Pre.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation3Pre").Value, TemperatureLocation3Pre.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation4Pre").Value, TemperatureLocation4Pre.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation1Post").Value, TemperatureLocation1Post.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation2Post").Value, TemperatureLocation2Post.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation3Post").Value, TemperatureLocation3Post.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation4Post").Value, TemperatureLocation4Post.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SystemID").Value, SystemID.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SystemLocation").Value, SystemLocation.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TargetAxisX").Value, TargetAxisX.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TargetAxisY").Value, TargetAxisY.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TargetAxisZ").Value, TargetAxisZ.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "InputVoltage").Value, InputVoltage.ToString(cult)); writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "BatteryVoltage").Value, BatteryVoltage.ToString(cult)); //// //// Write out trigger sample numbers list. //// //List triggerSampleNumberAttributes = attributeExtractor.ExtractAttachedAttributesFromProperty( this, "TriggerSampleNumbers" ); //triggerSampleNumberAttributes.Sort( ); //writer.WriteStartElement( triggerSampleNumberAttributes[ DataName ].Value ); //for ( int i=0; i < TriggerSampleNumbers.Count; i++ ) //{ // writer.WriteStartElement( triggerSampleNumberAttributes[ DatumName ].Value ); // writer.WriteAttributeString( triggerSampleNumberAttributes[ DatumValueName ].Value, this.TriggerSampleNumbers[ i ].ToString( ) ); // writer.WriteEndElement( ); //} //writer.WriteEndElement( ); // // Write out unsubsampled trigger sample numbers list. // var unsubsampledTriggerSampleNumberAttributes = attributeExtractor.ExtractAttachedAttributesFromProperty(this, "TriggerSampleNumbers"); unsubsampledTriggerSampleNumberAttributes.Sort(); writer.WriteStartElement(unsubsampledTriggerSampleNumberAttributes[DataName].Value); for (var i = 0; i < UnsubsampledTriggerSampleNumbers.Count; i++) { writer.WriteStartElement(unsubsampledTriggerSampleNumberAttributes[DatumName].Value); writer.WriteAttributeString(unsubsampledTriggerSampleNumberAttributes[DatumValueName].Value, UnsubsampledTriggerSampleNumbers[i].ToString(cult)); writer.WriteEndElement(); } writer.WriteEndElement(); // // Write out channel list, if it's not empty. // writer.WriteStartElement(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Channels").Value); foreach (var c in Channels) { c.WriteXml(writer); } writer.WriteEndElement(); writer.WriteStartElement(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "CalculatedChannels").Value); foreach (var c in CalculatedChannels) { c.WriteXml(writer); } writer.WriteEndElement(); writer.WriteEndElement(); } catch (System.Exception ex) { throw new Exception("encountered problem converting DTS.Serialization.Test.Module object to XML", ex); } } /// /// parses out channels from xml document, if empty advances to next element /// private void ReadChannels(XmlReader reader, AttributeExtractor attributeExtractor) { try { // // Read channel list, if it exists. // Channels = new List(); var isChannels = string.Equals( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Channels").Value, reader.Name, StringComparison.OrdinalIgnoreCase); if (!reader.IsEmptyElement && isChannels) { ReadChannelElements(reader); reader.ReadEndElement(); } else if ( reader.IsEmptyElement && isChannels) { reader.Read(); } } catch (System.Exception ex) { throw new Exception("encountered problem parsing channel list", ex); } } private void ReadChannelElements(XmlReader reader) { while (reader.Read() && (XmlNodeType.Element == reader.MoveToContent())) { var channelType = new PropertyAttributeDecoder( new AnalogInputChannel(this)) .ExtractStringProperty("ChannelType", reader); if (null == channelType) throw new Exception("expected channel type string but got " + (null != channelType ? ("\"" + channelType + "\"") : "<>")); var channelClassType = Type.GetType(channelType); var deserializedChannel = Activator.CreateInstance(channelClassType, new object[] { this }) as Channel; if ( !(deserializedChannel.ExpressDataInlineOnXmlSerialization = InlineSerializedData)) deserializedChannel.Data = new Channel.DataArray(); deserializedChannel.ReadXml(reader); Channels.Add(deserializedChannel); } } /// /// Read XML serialization for this object from the specified reader. /// /// /// /// The from which this object's XML serialization /// will be read. /// /// public void ReadXml(XmlReader reader) { try { var cult = new CultureInfo(""); var attributeExtractor = new AttributeExtractor(); reader.MoveToContent(); // // Read simple attributes. // if ( float.TryParse( reader.GetAttribute( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "AaFilterRateHz").Value), NumberStyles.Any, cult, out float aafilterRateHz)) { AaFilterRateHz = aafilterRateHz; } else { throw new Exception("error reading AaFilterRateHz"); } if ( int.TryParse( reader.GetAttribute( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Number").Value), NumberStyles.Any, cult, out int number)) { Number = number; } else { throw new Exception("error reading Number"); } try { SerialNumber = reader.GetAttribute( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SerialNumber").Value); } catch { throw new Exception("error reading SerialNumber"); } if ( ulong.TryParse( reader.GetAttribute( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "NumberOfSamples").Value), NumberStyles.Any, cult, out ulong numberOfSamples)) { NumberOfSamples = numberOfSamples; } else { throw new Exception("error reading NumberOfSamples"); } if ( double.TryParse( reader.GetAttribute( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "PostTriggerSeconds").Value), NumberStyles.Any, cult, out double postTriggerSeconds)) { PostTriggerSeconds = postTriggerSeconds; } else { throw new Exception("error reading PostTriggerSeconds"); } if ( double.TryParse( reader.GetAttribute( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "PreTriggerSeconds").Value), NumberStyles.Any, cult, out double preTriggerSeconds)) { PreTriggerSeconds = preTriggerSeconds; } else { throw new Exception("error reading PreTriggerSeconds"); } RequestedPostTriggerSeconds = double.TryParse( reader.GetAttribute( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "RequestedPostTriggerSeconds").Value), NumberStyles.Any, cult, out double requestedPostTriggerSeconds) ? requestedPostTriggerSeconds : PostTriggerSeconds; RequestedPreTriggerSeconds = double.TryParse( reader.GetAttribute( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "RequestedPreTriggerSeconds").Value), NumberStyles.Any, cult, out double requestedPreTriggerSeconds) ? requestedPreTriggerSeconds : PreTriggerSeconds; if (float.TryParse( reader.GetAttribute( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SampleRateHz").Value), NumberStyles.Any, cult, out float sampleRateHz)) { SampleRateHz = sampleRateHz; } else { throw new Exception("error reading SampleRateHz"); } double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "StartRecordTimestampSec").Value), NumberStyles.Any, cult, out double startRecordTimestampSec); StartRecordTimestampSec = startRecordTimestampSec; double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TriggerTimestampSec").Value), NumberStyles.Any, cult, out double triggerTimestampSec); TriggerTimestampSec = triggerTimestampSec; double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "StartRecordTimestampNanoSec").Value), NumberStyles.Any, cult, out double startRecordTimestampNanoSec); StartRecordTimestampNanoSec = startRecordTimestampNanoSec; double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TriggerTimestampNanoSec").Value), NumberStyles.Any, cult, out double triggerTimestampNanoSec); TriggerTimestampNanoSec = triggerTimestampNanoSec; bool.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "PTPMasterSync").Value), out bool pTpMasterSync); PTPMasterSync = pTpMasterSync; try { SystemID = reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SystemID").Value); } catch { SystemID = string.Empty; } try { SystemLocation = reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SystemLocation").Value); } catch { SystemLocation = string.Empty; } double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "InputVoltage").Value), NumberStyles.Any, cult, out double inputVoltage); InputVoltage = inputVoltage; double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "BatteryVoltage").Value), NumberStyles.Any, cult, out double batteryVoltage); BatteryVoltage = batteryVoltage; double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TargetAxisOne").Value), NumberStyles.Any, cult, out double targetAxisOne); TargetAxisOne = targetAxisOne; double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TargetAxisTwo").Value), NumberStyles.Any, cult, out double targetAxisTwo); TargetAxisTwo = targetAxisTwo; double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TiltSensorAxisXDegreesPre").Value), NumberStyles.Any, cult, out double tiltSensorAxisXDegreesPre); TiltSensorAxisXDegreesPre = tiltSensorAxisXDegreesPre; double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TiltSensorAxisYDegreesPre").Value), NumberStyles.Any, cult, out double tiltSensorAxisYDegreesPre); TiltSensorAxisYDegreesPre = tiltSensorAxisYDegreesPre; double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TiltSensorAxisZDegreesPre").Value), NumberStyles.Any, cult, out double tiltSensorAxisZDegreesPre); TiltSensorAxisZDegreesPre = tiltSensorAxisZDegreesPre; double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TiltSensorAxisXDegreesPost").Value), NumberStyles.Any, cult, out double tiltSensorAxisXDegreesPost); TiltSensorAxisXDegreesPost = tiltSensorAxisXDegreesPost; double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TiltSensorAxisYDegreesPost").Value), NumberStyles.Any, cult, out double tiltSensorAxisYDegreesPost); TiltSensorAxisYDegreesPost = tiltSensorAxisYDegreesPost; double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TiltSensorAxisZDegreesPost").Value), NumberStyles.Any, cult, out double tiltSensorAxisZDegreesPost); TiltSensorAxisZDegreesPost = tiltSensorAxisZDegreesPost; float.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation1Pre").Value), NumberStyles.Any, cult, out float temperatureLocation1Pre); TemperatureLocation1Pre = temperatureLocation1Pre; float.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation2Pre").Value), NumberStyles.Any, cult, out float temperatureLocation2Pre); TemperatureLocation2Pre = temperatureLocation2Pre; float.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation3Pre").Value), NumberStyles.Any, cult, out float temperatureLocation3Pre); TemperatureLocation3Pre = temperatureLocation3Pre; float.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation4Pre").Value), NumberStyles.Any, cult, out float temperatureLocation4Pre); TemperatureLocation4Pre = temperatureLocation4Pre; float.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation1Post").Value), NumberStyles.Any, cult, out float temperatureLocation1Post); TemperatureLocation1Post = temperatureLocation1Post; float.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation2Post").Value), NumberStyles.Any, cult, out float temperatureLocation2Post); TemperatureLocation2Post = temperatureLocation2Post; float.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation3Post").Value), NumberStyles.Any, cult, out float temperatureLocation3Post); TemperatureLocation3Post = temperatureLocation3Post; float.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TemperatureLocation4Post").Value), NumberStyles.Any, cult, out float temperatureLocation4Post); TemperatureLocation4Post = temperatureLocation4Post; if ( ulong.TryParse( reader.GetAttribute( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "StartRecordSampleNumber") .Value), NumberStyles.Any, cult, out ulong startRecordSampleNumber)) { StartRecordSampleNumber = startRecordSampleNumber; } else { throw new Exception("error reading StartRecordSampleNumber"); } if (bool.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "InlineSerializedData").Value), out bool inlineSerializedData)) { InlineSerializedData = inlineSerializedData; } else { throw new Exception("error reading InlineSerializedData"); } try { RecordingMode = Common.DAS.Concepts.Test.Module.GetRecordingModeFromString( reader.GetAttribute( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "RecordingMode").Value)); } catch { throw new Exception("error reading RecordingMode"); } try { BaseSerialNumber = reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "BaseSerialNumber").Value); } catch (Exception) { throw new Exception("error reading BaseSerialNumber"); } UnsubsampledNumberOfSamples = ulong.TryParse( reader.GetAttribute( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UnsubsampledNumberOfSamples").Value), NumberStyles.Any, cult, out ulong unsubsampledNumberOfSamples) ? unsubsampledNumberOfSamples : NumberOfSamples; // Can't set the property from whence this came; but we should use it to initialize the channel list with // the proper number of entries so subsequent logic will know how many sequential channel files to gobble // up for this module. if (int.TryParse( reader.GetAttribute( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "NumberOfChannels").Value), NumberStyles.Any, cult, out int numberOfChannelsToRead)) { // // Read unsubsampled trigger sample numbers list. // reader.Read(); reader.MoveToContent(); var unsubsampledTriggerSampleNumberAttributes = attributeExtractor.ExtractAttachedAttributesFromProperty(this, "TriggerSampleNumbers"); unsubsampledTriggerSampleNumberAttributes.Sort(); UnsubsampledTriggerSampleNumbers = new List(); if ( reader.Name.Equals(unsubsampledTriggerSampleNumberAttributes[DataName].Value, StringComparison.OrdinalIgnoreCase) && !reader.IsEmptyElement) { // // UnsubsampledTriggerSampleNumbers is populated, so spin through it. // for (reader.Read(), reader.MoveToContent(); reader.Name.Equals(unsubsampledTriggerSampleNumberAttributes[DatumName].Value, StringComparison.OrdinalIgnoreCase); reader.Read(), reader.MoveToContent()) UnsubsampledTriggerSampleNumbers.Add( UInt64.Parse( reader.GetAttribute( unsubsampledTriggerSampleNumberAttributes[DatumValueName].Value), cult)); reader.ReadEndElement(); reader.MoveToContent(); } else { // // UnsubsampledTriggerSampleNumbers is an empty tag, so consume it and move on. reader.Read(); reader.MoveToContent(); } ReadChannels(reader, attributeExtractor); try { // // Read calculated channel list, if it exists. // CalculatedChannels.Clear(); if (!reader.IsEmptyElement && string.Equals( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "CalculatedChannels") .Value, reader.Name, StringComparison.OrdinalIgnoreCase)) { while (reader.Read() && (XmlNodeType.Element == reader.MoveToContent())) { var channelType = new PropertyAttributeDecoder( new AnalogInputChannel(this)) .ExtractStringProperty("ChannelType", reader); if (null == channelType) throw new Exception("expected channel type string but got " + (null != channelType ? ("\"" + channelType + "\"") : "<>")); var channelClassType = Type.GetType(channelType); var deserializedChannel = Activator.CreateInstance(channelClassType, new object[] { this }) as Channel; // ( channelClassType, true ) as Test.Module.Channel; if ( !(deserializedChannel.ExpressDataInlineOnXmlSerialization = InlineSerializedData)) deserializedChannel.Data = new Channel.DataArray(); deserializedChannel.ReadXml(reader); CalculatedChannels.Add(deserializedChannel); } reader.ReadEndElement(); } } catch (System.Exception ex) { throw new Exception("encountered problem parsing channel list", ex); } reader.Read(); // consume attribute end tag. } else { throw new Exception("error reading NumberOfChannels"); } } catch (System.Exception ex) { throw new Exception("encountered problem converting XML to DTS.Serialization.Test.Module object", ex); } } /// /// Should normally return a schema representing the form of the XML /// generated/consumed by WriteXml/ReadXml, but it never called during /// the serialization process so ours just returns null. /// /// /// /// Null reference, always. /// /// public XmlSchema GetSchema() { // This method is never invoked during XML object serialization. return null; } /// /// Test the specified object for equality with this object. /// /// /// /// The to be tested for equality. /// /// /// /// true if the specified object has memeberwise equality with /// this object; false otherwise. /// /// public override bool Equals(object obj) { try { return obj is Module that && AaFilterRateHz.Equals(that.AaFilterRateHz) && Number.Equals(that.Number) && SerialNumber.Equals(that.SerialNumber) && NumberOfSamples.Equals(that.NumberOfSamples) && UnsubsampledNumberOfSamples.Equals(that.UnsubsampledNumberOfSamples) && RequestedPostTriggerSeconds.Equals(that.RequestedPostTriggerSeconds) && RequestedPreTriggerSeconds.Equals(that.RequestedPreTriggerSeconds) && PostTriggerSeconds.Equals(that.PostTriggerSeconds) && PreTriggerSeconds.Equals(that.PreTriggerSeconds) && RecordingMode.Equals(that.RecordingMode) && SampleRateHz.Equals(that.SampleRateHz) && StartRecordTimestampSec.Equals(that.StartRecordTimestampSec) && TriggerTimestampSec.Equals(that.TriggerTimestampSec) && StartRecordTimestampSec.Equals(that.StartRecordTimestampNanoSec) && TriggerTimestampSec.Equals(that.TriggerTimestampNanoSec) && PTPMasterSync.Equals(that.PTPMasterSync) && SystemID.Equals(that.SystemID) && SystemLocation.Equals(that.SystemLocation) && TargetAxisOne.Equals(that.TargetAxisOne) && TargetAxisTwo.Equals(that.TargetAxisTwo) && TiltSensorAxisXDegreesPre.Equals(that.TiltSensorAxisXDegreesPre) && TiltSensorAxisYDegreesPre.Equals(that.TiltSensorAxisYDegreesPre) && TiltSensorAxisZDegreesPre.Equals(that.TiltSensorAxisZDegreesPre) && TiltSensorAxisXDegreesPost.Equals(that.TiltSensorAxisXDegreesPost) && TiltSensorAxisYDegreesPost.Equals(that.TiltSensorAxisYDegreesPost) && TiltSensorAxisZDegreesPost.Equals(that.TiltSensorAxisZDegreesPost) && TemperatureLocation1Pre.Equals(that.TemperatureLocation1Pre) && TemperatureLocation2Pre.Equals(that.TemperatureLocation2Pre) && TemperatureLocation3Pre.Equals(that.TemperatureLocation3Pre) && TemperatureLocation4Pre.Equals(that.TemperatureLocation4Pre) && TemperatureLocation1Post.Equals(that.TemperatureLocation1Post) && TemperatureLocation2Post.Equals(that.TemperatureLocation2Post) && TemperatureLocation3Post.Equals(that.TemperatureLocation3Post) && TemperatureLocation4Post.Equals(that.TemperatureLocation4Post) && StartRecordSampleNumber.Equals(that.StartRecordSampleNumber) && TriggerSampleNumbersEquals(that.TriggerSampleNumbers) && UnsubsampledTriggerSampleNumbersEquals(that.UnsubsampledTriggerSampleNumbers) && ChannelsEquals(that.Channels) && BaseSerialNumber.Equals(that.BaseSerialNumber); } catch (System.Exception ex) { throw new Exception("encountered problem equality-testing object " + (null != obj ? "\"" + obj.ToString() + "\"" : "<>"), ex); } } /// /// Test the specified object's trigger sample number list for equality with this /// object's module list. /// /// /// /// The of object to be /// compared for equality with this test's equivalent. /// /// /// /// true if the two lists contain equivalent-valued members; /// false otherwise. /// /// private bool TriggerSampleNumbersEquals(List thoseTriggerSampleNumbers) { try { if (null == thoseTriggerSampleNumbers || TriggerSampleNumbers.Count != thoseTriggerSampleNumbers.Count) return false; for (var i = 0; i < thoseTriggerSampleNumbers.Count; i++) if (!TriggerSampleNumbers[i].Equals(thoseTriggerSampleNumbers[i])) return false; return true; } catch (System.Exception ex) { throw new Exception("encountered problem equality-testing trigger sample numbers list ", ex); } } /// /// Test the specified object's unsubsampled trigger sample number list for equality with this /// object's module list. /// /// /// /// The of object to be /// compared for equality with this test's equivalent. /// /// /// /// true if the two lists contain equivalent-valued members; /// false otherwise. /// /// private bool UnsubsampledTriggerSampleNumbersEquals(List thoseUnsubsampledTriggerSampleNumbers) { try { if (null == thoseUnsubsampledTriggerSampleNumbers || UnsubsampledTriggerSampleNumbers.Count != thoseUnsubsampledTriggerSampleNumbers.Count) return false; for (var i = 0; i < thoseUnsubsampledTriggerSampleNumbers.Count; i++) if (!TriggerSampleNumbers[i].Equals(thoseUnsubsampledTriggerSampleNumbers[i])) return false; return true; } catch (System.Exception ex) { throw new Exception("encountered problem equality-testing unsubsampled trigger sample numbers list ", ex); } } /// /// Test the specified object's module list for equality with this object's /// module list. /// /// /// /// The of object to be /// compared for equality with this test's equivalent. /// /// /// /// true if the two lists contain equivalent-valued members; /// false otherwise. /// /// private bool ChannelsEquals(List thoseChannels) { try { if (null == thoseChannels || Channels.Count != thoseChannels.Count) return false; for (var i = 0; i < thoseChannels.Count; i++) if (!Channels[i].Equals(thoseChannels[i])) { var test = Channels[i].Equals(thoseChannels[i]); return false; } //return false; return true; } catch (System.Exception ex) { throw new Exception("encountered problem equality-testing channel list", ex); } } /// /// Return the hash code for this object. /// /// /// /// The hash code for this object. /// /// public override int GetHashCode() { return base.GetHashCode(); } } } }