/* Test.Module.AnalogInputChannel.cs Copyright © 2008 Diversified Technical Systems, Inc. All Rights Reserved */ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; using DTS.DAS.Concepts; using DTS.Utilities; using DTS.Utilities.DotNetProgrammingConstructs; using DTS.Utilities.Xml; namespace DTS.Serialization { // *** see Test.cs *** public partial class Test { // *** see Test.Module.cs *** public partial class Module { /// /// Representation of an analog channel. /// [XmlSerializationTag( "AnalogInputChanel" )] public class AnalogInputChannel : Channel, DTS.DAS.Concepts.DAS.Channel.IEngineeringUnitAware, DTS.DAS.Concepts.DAS.Channel.IInversionAware, DTS.DAS.Concepts.DAS.Channel.ISerialNumberAware, DTS.DAS.Concepts.DAS.Channel.IIsoCodeAware, DTS.DAS.Concepts.DAS.Channel.IShuntAware, DTS.DAS.Concepts.DAS.Channel.ICalSignalAware, DTS.DAS.Concepts.DAS.Channel.IVoltageInsertionAware, DTS.DAS.Concepts.DAS.Channel.ILinearized { /// /// Initialize an instance of the class. /// /// /// /// The that contains this object. /// /// public AnalogInputChannel( Test.Module parentModule ) : base( parentModule ) { } /// /// Get/set the bridge configuration of this channel. /// [XmlSerializationTag( "Bridge" )] public DTS.DAS.Concepts.Test.Module.Channel.Sensor.BridgeType Bridge { get { return _Bridge.Value; } set { _Bridge.Value = value; } } private Property _Bridge = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.BridgeType", DTS.DAS.Concepts.Test.Module.Channel.Sensor.BridgeType.FullBridge, false ); [XmlSerializationTag( "ZeroPoint" )] public double ZeroPoint { get { if (_ZeroPoint.IsValueInitialized) { return _ZeroPoint.Value; } else{ return 0D; } } set{ _ZeroPoint.Value = value; } } private Property _ZeroPoint = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.ZeroPoint", 0D, false); /// /// Get/set the bridge resistance for this channel. /// [XmlSerializationTag( "BridgeResistanceOhms" )] public double BridgeResistanceOhms { get { return _BridgeResistanceOhms.Value; } set { _BridgeResistanceOhms.Value = value; } } private Property _BridgeResistanceOhms = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.BridgeResistanceOhms", 0.0, false ); /// /// Get/set the unit conversion for this channel. /// [XmlSerializationTag("UnitConversion")] public double UnitConversion { get { return _UnitConversion.Value; } set { _UnitConversion.Value = value; } } private Property _UnitConversion = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.UnitConversion", 1.0, false ); /// /// Get/set the multiplier for this channel. /// [XmlSerializationTag("Multiplier")] public double Multiplier { get { return _Multiplier.Value; } set { _Multiplier.Value = value; } } private Property _Multiplier = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.Multiplier", 1.0, false ); /// /// Get/set the modified offset for this channel. /// [XmlSerializationTag("UserOffsetEU")] public double UserOffsetEU { get { return _UserOffsetEU.Value; } set { _UserOffsetEU.Value = value; } } private Property _UserOffsetEU = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.UserOffsetEU", 0.0, false ); /// /// Get/set the description for this channel. /// [XmlSerializationTag( "Description" )] public string Description { get { return null != _Description.Value ? _Description.Value : ""; } set { _Description.Value = value; } } private Property _Description = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.Description", "", true ); /// /// Get/set the manufacture for this channel's sensor. /// [XmlSerializationTag("Manufacturer")] public string Manufacturer { get { return null != _Manufacturer.Value ? _Manufacturer.Value : ""; } set { _Manufacturer.Value = value; } } private Property _Manufacturer = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.Manufacturer", "", true ); /// /// Get/set the model for this channel's sensor. /// [XmlSerializationTag("Model")] public string Model { get { return null != _Model.Value ? _Model.Value : ""; } set { _Model.Value = value; } } private Property _Model = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.Model", "", true ); /// /// Get/set the desired range for this channel. /// [XmlSerializationTag( "DesiredRange" )] public double DesiredRange { get { return _DesiredRange.Value; } set { _DesiredRange.Value = value; } } private Property _DesiredRange = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.DesiredRange", 0.0, false ); /// /// Get/set the sensitivity for this channel. /// [XmlSerializationTag( "Sensitivity" )] public double Sensitivity { get { return _Sensitivity.Value; } set { _Sensitivity.Value = value; } } private Property _Sensitivity = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.Sensitivity", 0.0, false ); /// /// Get/set the descriptor indiciating whether or not this channel is /// based on output at capacity. /// [XmlSerializationTag("AtCapacity")] public bool AtCapacity { get { return _AtCapacity.Value; } set { _AtCapacity.Value = value; } } private Property _AtCapacity = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.AtCapacity", false, true ); /// /// Get/set the capacity output is based on value for this channel. /// [XmlSerializationTag("CapacityOutputIsBasedOn")] public double CapacityOutputIsBasedOn { get { return _CapacityOutputIsBasedOn.Value; } set { _CapacityOutputIsBasedOn.Value = value; } } private Property _CapacityOutputIsBasedOn = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.CapacityOutputIsBasedOn", 1.000, true ); /// /// Get/set the Sensitivity Units for this channel. /// [XmlSerializationTag("SensitivityUnits")] public DAS.Concepts.Test.Module.Channel.Sensor.SensUnits SensitivityUnits { get { return _SensitivityUnits.Value; } set { _SensitivityUnits.Value = value; } } private Property _SensitivityUnits = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.SensitivityUnits", DAS.Concepts.Test.Module.Channel.Sensor.SensUnits.NONE, true ); /// /// Get/set the descriptor indiciating whether or not this channel is /// proportional to excitation. /// [XmlSerializationTag( "ProportionalToExcitation" )] public bool ProportionalToExcitation { get { return _ProportionalToExcitation.Value; } set { _ProportionalToExcitation.Value = value; } } private Property _ProportionalToExcitation = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.ProportionalToExcitation", false, false ); /// /// Get/set the excitation voltage for this channel. /// [XmlSerializationTag( "ExcitationVoltage" )] public DAS.Concepts.Test.Module.Channel.Sensor.ExcitationVoltageOption ExcitationVoltage { get { return _ExcitationVoltage.Value; } set { _ExcitationVoltage.Value = value; } } private Property _ExcitationVoltage = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.ExcitationVoltage", DAS.Concepts.Test.Module.Channel.Sensor.ExcitationVoltageOption.Volt5, false ); public bool MeasuredExcitationVoltageValid { get { return _MeasuredExcitationVoltage.IsInitialized; } } /// /// Get/set the measured excitation value for this channel. /// [XmlSerializationTag( "MeasuredExcitationVoltage" )] public double MeasuredExcitationVoltage { get { return _MeasuredExcitationVoltage.Value; } set { _MeasuredExcitationVoltage.Value = value; } } private Property _MeasuredExcitationVoltage = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.MeasuredExcitationVoltage", 0.0, false ); public bool FactoryExcitationVoltageValid { get { return _FactoryExcitationVoltage.IsInitialized; } } /// /// Get/set the factory excitation value for this channel. /// [XmlSerializationTag( "FactoryExcitationVoltage" )] public double FactoryExcitationVoltage { get { return _FactoryExcitationVoltage.Value; } set { _FactoryExcitationVoltage.Value = value; } } private Property _FactoryExcitationVoltage = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.FactoryExcitationVoltage", 0.0, false ); /// /// Get/set the engineering units for this channel. /// [XmlSerializationTag( "Eu" )] public string EngineeringUnits { get { return _EngineeringUnits.Value; } set { _EngineeringUnits.Value = value; } } private Property _EngineeringUnits = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.EngineeringUnits", null, false ); /// /// Get/set the ISO code for this channel's data source. /// public string IsoCode { get { return _IsoCode.Value; } set { _IsoCode.Value = value; } } private Property _IsoCode = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.IsoCode", null, false ); public bool IsIsoCodeValid { get { return _IsoCode.IsInitialized; } } public bool MeasureShuntDeflectionMvValid { get { return _MeasuredShuntDeflectionMv.IsInitialized; } } /// /// Get/set the measured shunt deflection value for this channel. /// [XmlSerializationTag( "MeasuredShuntDeflectionMv" )] public double MeasuredShuntDeflectionMv { get { return _MeasuredShuntDeflectionMv.Value; } set { _MeasuredShuntDeflectionMv.Value = value; } } private Property _MeasuredShuntDeflectionMv = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.MeasuredShuntDeflectionMv", 0.0, false ); public bool TargetShuntDeflectionMvValid { get { return _TargetShuntDeflectionMv.IsInitialized; } } /// /// Get/set the measured gain value for this channel. /// [XmlSerializationTag("MeasuredGain")] public double MeasuredGain { get { return _MeasuredGain.Value; } set { _MeasuredGain.Value = value; } } private Property _MeasuredGain = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.MeasuredGain", 0.0, false ); public bool MeasuredGainValid { get { return _MeasuredGain.IsInitialized; } } /// /// Get/set the expected gain value for this channel. /// [XmlSerializationTag("ExpectedGain")] public double ExpectedGain { get { return _ExpectedGain.Value; } set { _ExpectedGain.Value = value; } } private Property _ExpectedGain = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.ExpectedGain", 0.0, false ); public bool ExpectedGainValid { get { return _ExpectedGain.IsInitialized; } } /// /// Get/set the target shunt deflection value for this channel. /// [XmlSerializationTag( "TargetShuntDeflectionMv" )] public double TargetShuntDeflectionMv { get { return _TargetShuntDeflectionMv.Value; } set { _TargetShuntDeflectionMv.Value = value; } } private Property _TargetShuntDeflectionMv = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.TargetShuntDeflectionMv", 0.0, false ); public bool IsDigital() { return Bridge == DAS.Concepts.Test.Module.Channel.Sensor.BridgeType.DigitalInput; } public bool IsSquib() { return ParentModule.SerialNumber.StartsWith("TOM") || ParentModule.SerialNumber.StartsWith("SPT") || ParentModule.SerialNumber.StartsWith("SLT"); } /// /// Get the whether or not this is really a Squib channel. /// [XmlSerializationTag("IsSquibChannel")] public bool IsSquibChannel { get { return IsSquib(); } set { _isSquibChannel.Value = value; } } private Property _isSquibChannel = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.IsSquibChannel", false, false ); public bool IsSquibVoltage() { return IsSquib() && EngineeringUnits.Trim().Equals("V") && (ParentModule.SerialNumber.StartsWith("TOM") || ParentModule.SerialNumber.StartsWith("DR") || ParentModule.SerialNumber.StartsWith("SPT") || ParentModule.SerialNumber.StartsWith("SLT")); } public bool MeasuredCalSignalMvValid { get { return _MeasuredCalSignalMv.IsInitialized; } } /// /// Get/set the measured shunt deflection value for this channel. /// [XmlSerializationTag("MeasuredCalSignalMv")] public double MeasuredCalSignalMv { get { return _MeasuredCalSignalMv.Value; } set { _MeasuredCalSignalMv.Value = value; } } private Property _MeasuredCalSignalMv = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.MeasuredCalSignalMv", 0.0, false ); public bool TargetCalSignalMvValid { get { return _TargetCalSignalMv.IsInitialized; } } /// /// Get/set the target shunt deflection value for this channel. /// [XmlSerializationTag("TargetCalSignalMv")] public double TargetCalSignalMv { get { return _TargetCalSignalMv.Value; } set { _TargetCalSignalMv.Value = value; } } private Property _TargetCalSignalMv = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.TargetShuntCalSignalMv", 0.0, false ); public bool TriggerBelowThresholdValid { get { return _TriggerBelowThresholdEu.IsInitialized; } } /// /// Get/set the "trigger below" threshold. Set to "null" to deactivate. /// [XmlSerializationTag( "TriggerBelowThresholdEu" )] public double? TriggerBelowThresholdEu { get { return _TriggerBelowThresholdEu.Value; } set { _TriggerBelowThresholdEu.Value = value; } } private Property _TriggerBelowThresholdEu = new Property( typeof( AnalogInputChannel ).FullName + ".TriggerBelowThresholdEu", null, false ); public bool TriggerAboveThresholdValid { get { return _TriggerAboveThresholdEu.IsInitialized; } } /// /// Get/set the "trigger above" threshold. Set to "null" to deactivate. /// [XmlSerializationTag( "TriggerAboveThresholdEu" )] public double? TriggerAboveThresholdEu { get { return _TriggerAboveThresholdEu.Value; } set { _TriggerAboveThresholdEu.Value = value; } } private Property _TriggerAboveThresholdEu = new Property( typeof( AnalogInputChannel ).FullName + ".TriggerAboveThresholdEu", null, false ); [XmlSerializationTag("LevelTriggerType")] public DTS.DAS.Concepts.DAS.Channel.LevelTriggerTypes LevelTriggerType { get { return _levelTriggerType.Value; } set { _levelTriggerType.Value = value; } } public bool LevelTriggerTypeValid { get { return _levelTriggerType.IsValueInitialized; } } private Property _levelTriggerType = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.LevelTriggerType", DTS.DAS.Concepts.DAS.Channel.LevelTriggerTypes.NONE, true); /// /// Get/set the serial number for this channel's data source. /// [XmlSerializationTag( "SerialNumber" )] public string SerialNumber { get { return _SerialNumber.Value; } set { _SerialNumber.Value = value; } } private Property _SerialNumber = new Property( typeof( AnalogInputChannel ).Namespace +".Test.Module.AnalogInputChannel.SerialNumber", null, false ); /// /// Get/set the shunt enable indicator for this channel. /// [XmlSerializationTag( "ShuntEnabled" )] public bool ShuntEnabled { get { return _ShuntEnabled.Value; } set { _ShuntEnabled.Value = value; } } private Property _ShuntEnabled = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.ShuntEnabled", false, false ); /// /// Get/set the shunt enable indicator for this channel. /// [XmlSerializationTag("VoltageInsertionCheckEnabled")] public bool VoltageInsertionCheckEnabled { get { return _VoltageInsertionCheckEnabled.Value; } set { _VoltageInsertionCheckEnabled.Value = value; } } private Property _VoltageInsertionCheckEnabled = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.VoltageInsertionCheckEnabled", false, false ); /// /// Get/set the shunt enable indicator for this channel. /// [XmlSerializationTag("CalSignalEnabled")] public bool CalSignalEnabled { get { return _CalSignalEnabled.Value; } set { _CalSignalEnabled.Value = value; } } private Property _CalSignalEnabled = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.CalSignalEnabled", false, false ); /// /// Get/set the software filter for this channel's data source. /// [XmlSerializationTag( "SoftwareFilter" )] public string SoftwareFilter { get { return _SoftwareFilter.Value; } set { _SoftwareFilter.Value = value; } } private Property _SoftwareFilter = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.SoftwareFilter", null, false ); /// /// Get/set the remove offset option for this channel. /// [XmlSerializationTag( "RemoveOffset" )] public bool RemoveOffset { get { return _RemoveOffset.Value; } set { _RemoveOffset.Value = value; } } private Property _RemoveOffset = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.RemoveOffset", false, false ); /// /// Get/set the zero method option for this channel. /// [XmlSerializationTag( "ZeroMethod" )] public DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType ZeroMethod { get { try { if (null != LinearizationFormula && LinearizationFormula.IsValid()) { switch (LinearizationFormula.Style) { case DAS.Concepts.LinearizationFormula.Styles.IRTraccDiagnosticsZero: _ZeroMethod.Value = DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType.UsePreEventDiagnosticsZero; break; case DAS.Concepts.LinearizationFormula.Styles.IRTraccAverageOverTime: _ZeroMethod.Value = DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType.AverageOverTime; break; } } } catch (System.Exception) { } return _ZeroMethod.Value; } set { _ZeroMethod.Value = value; } } private Property _ZeroMethod = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.ZeroMethod", DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType.AverageOverTime, false ); /// /// Get/set zero average window definition. /// [XmlSerializationTag( "ZeroAverageWindow" )] public IntervalSec ZeroAverageWindow { get { return _ZeroAverageWindow.Value; } set { _ZeroAverageWindow.Value = value; } } private Property _ZeroAverageWindow = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.ZeroAverageWindow", null, false ); private const int InvalidWindowAverage = short.MinValue; /// /// Get data zero level counts. /// public override short DataZeroLevelAdc { get { if (null == _DataZeroLevelAdc) { switch (this.ZeroMethod) { case DTS.DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType.AverageOverTime: if (WindowAverageADC != InvalidWindowAverage) { _DataZeroLevelAdc = WindowAverageADC; } else { try { double preTriggerSeconds = 0; try { if (null != ParentModule.TriggerSampleNumbers && ParentModule.TriggerSampleNumbers.Count > 0) { preTriggerSeconds = (double)ParentModule.TriggerSampleNumbers[0] - (double)ParentModule.StartRecordSampleNumber; preTriggerSeconds /= ParentModule.SampleRateHz; } } catch { } //figure out the average window, get the average in raw adc. //per TJK and MB these values are okay in unfiltered ADC as the averaging mechanism is itself an filter mechanism //and most serious users will have their own zeroing tools double preTriggerTime = 0D; if (null != ParentModule.TriggerSampleNumbers) { preTriggerTime = ((double)ParentModule.TriggerSampleNumbers[0] - (double)ParentModule.StartRecordSampleNumber) / (double)ParentModule.SampleRateHz; } if (preTriggerTime < 0) { preTriggerTime = 0; } try { ulong numSamples = (ulong)((ZeroAverageWindow.End - ZeroAverageWindow.Begin) * ParentModule.SampleRateHz) + 1; double[] windowSamples = new double[numSamples]; ulong startingIndex = ((ulong)((preTriggerTime + ZeroAverageWindow.Begin) * ParentModule.SampleRateHz)); var pc = PersistentChannelInfo; int insertPoint = 0; for (ulong i = startingIndex; i < startingIndex + numSamples; i++) { windowSamples[insertPoint++] = Convert.ToDouble(pc[i]); } _DataZeroLevelAdc = Convert.ToInt16(windowSamples.Average()); } catch (System.Exception ex) { DTS.Utilities.Logging.APILogger.Log(ex); _DataZeroLevelAdc = PreTestZeroLevelAdc; } } catch (System.Exception ex) { DTS.Utilities.Logging.APILogger.Log(ex); _DataZeroLevelAdc = PreTestZeroLevelAdc; } } break; case DTS.DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType.UsePreEventDiagnosticsZero: _DataZeroLevelAdc = PreTestZeroLevelAdc; break; case DTS.DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType.None: if (null != LinearizationFormula && LinearizationFormula.IsValid()) { _DataZeroLevelAdc = 0; } else { _DataZeroLevelAdc = ZeroMvInADC; } break; default: throw new NotSupportedException("Test::Module::AnalogInputChannel DataZeroLevelAdc zeromethod not supported, " + ZeroMethod.ToString()); } } return (short) _DataZeroLevelAdc; } } private short? _DataZeroLevelAdc = null; /// /// Get/set the average value of all ADC so far added to this channel's data set. /// public AverageShortValueOverTime AverageAdcOverTime { get { return _AverageAdcOverTime.Value; } set { _AverageAdcOverTime.Value = value; } } private Property _AverageAdcOverTime = new Property( typeof( AnalogInputChannel ).Namespace + ".Event.Module.AnalogInputChannel.AverageAdcOverTime", null, false ); /// /// Get/set the initial EU value. /// [XmlSerializationTag( "InitialEu" )] public double InitialEu { get { return _InitialEu.Value; } set { _InitialEu.Value = value; } } private Property _InitialEu = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.InitialEu", 0.0, false ); [XmlSerializationTag("InitialOffset")] public string InitialOffset { get { return _initialOffset.Value; } set { _initialOffset.Value = value; } } private Property _initialOffset = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.InitialOffset", "", true); private const string BeginTagModifier = "Begin"; private const string EndTagModifier = "End"; /// /// Get/set the inversion status of this channel. /// [XmlSerializationTag("IsInverted")] public bool IsInverted { get { return _IsInverted.Value; } set { _IsInverted.Value = value; } } private Property _IsInverted = new Property( typeof( AnalogInputChannel ).Namespace + ".Test.Module.AnalogInputChannel.IsInverted", false, false ); /// /// Get/set the Linearization Formula of this channel. /// [XmlSerializationTag("LinearizationFormula")] public DTS.DAS.Concepts.LinearizationFormula LinearizationFormula { get { if (!_LinearizationFormula.IsInitialized) { return new LinearizationFormula(); } else { return _LinearizationFormula.Value; } } set { _LinearizationFormula.Value = value; } } private Property _LinearizationFormula = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.LinearizationFormula", null, false ); [XmlSerializationTag("DigitalMultiplier")] public DTS.DAS.Concepts.DigitalInputScaleMultiplier DigitalMultiplier { get { if (!_DigitalMultiplier.IsInitialized || null == _DigitalMultiplier.Value) { _DigitalMultiplier.Value = new DigitalInputScaleMultiplier(); } return _DigitalMultiplier.Value; } set { _DigitalMultiplier.Value = value; } } private Property _DigitalMultiplier = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.DigitalMultiplier", null, false); [XmlSerializationTag("DigitalMode")] public DTS.DAS.Concepts.DigitalInputScaleMultiplier.InputModes DigitalMode { get { if (!_digitalMode.IsInitialized) { return DigitalInputScaleMultiplier.InputModes.CCNC; } else { return _digitalMode.Value; } } set { _digitalMode.Value = value; } } private Property _digitalMode = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.DigitalMode", DTS.DAS.Concepts.DigitalInputScaleMultiplier.InputModes.CCNC, true ); /// /// The original sensor capacity from the sensor database. /// [XmlSerializationTag("SensorCapacity")] public double SensorCapacity { get { return _sensorCapacity.Value; } set { _sensorCapacity.Value = value; } } private Property _sensorCapacity = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.SensorCapacity", 0.0, false ); /// /// The name of the .chn file in the Binary folder that corresponds to this channel. /// [XmlSerializationTag("FileName")] public string FileName { get { return _fileName.Value; } set { _fileName.Value = value; } } private Property _fileName = new Property( typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.FileName", "", false ); /// /// Write XML serialization for this object to the specified writer. /// /// /// /// The to which this object's XML serialization /// will be written. /// /// public override void WriteXml(XmlWriter writer) { AttributeExtractor attributeExtractor = new AttributeExtractor(); writer.WriteStartElement(attributeExtractor.ExtractAttachedAttributeFromObject(this).Value); writeXmlAttributes(writer); writer.WriteEndElement(); } protected void writeXmlAttributes(XmlWriter writer) { int line = 0; try { var cult = System.Globalization.CultureInfo.InvariantCulture; DTS.Utilities.Logging.APILogger.Log(string.Format("{0} number : ", System.Reflection.MethodBase.GetCurrentMethod().Name, this.SerialNumber.ToString(cult))); AttributeExtractor attributeExtractor = new AttributeExtractor(); line = 2; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ChannelType").Value, this.ChannelType.ToString(cult)); line = 3; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Number").Value, this.Number.ToString(cult)); line = 4; try { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "DigitalMultiplier").Value, this.DigitalMultiplier.ToSerializeDbString()); } catch (System.Exception) { } line = 5; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "DigitalMode").Value, this.DigitalMode.ToString()); line = 6; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Start").Value, this.Start.ToString(cult)); line = 7; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Bridge").Value, this.Bridge.ToString()); line = 8; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "BridgeResistanceOhms").Value, this.BridgeResistanceOhms.ToString(cult)); writer.WriteAttributeString( attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ZeroPoint").Value, this.ZeroPoint.ToString(cult)); line = 9; try { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ChannelDescriptionString").Value, this.ChannelDescriptionString.ToString(cult)); } catch { } line = 10; try { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ChannelName2").Value, this.ChannelName2.ToString()); } catch { } try { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ChannelId").Value, this.ChannelId); } catch (System.Exception) { } line = 11; try { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "HardwareChannelName").Value, this.HardwareChannelName.ToString()); } catch { } line = 12; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Description").Value, this.Description.ToString(cult)); line = 13; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "DesiredRange").Value, this.DesiredRange.ToString(cult)); line = 14; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Sensitivity").Value, this.Sensitivity.ToString(cult)); line = 15; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SoftwareFilter").Value, this.SoftwareFilter.ToString(cult)); line = 16; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ProportionalToExcitation").Value, this.ProportionalToExcitation.ToString(cult)); line = 17; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "IsInverted").Value, this.IsInverted.ToString(cult)); line = 18; if (null == LinearizationFormula) { LinearizationFormula = new LinearizationFormula(); } line = 19; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "LinearizationFormula").Value, this.LinearizationFormula.ToSerializeString()); line = 20; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "IsSubsampled").Value, this.IsSubsampled.ToString(cult)); line = 21; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "AbsoluteDisplayOrder").Value, this.AbsoluteDisplayOrder.ToString(cult)); line = 22; if (this.IsLastCalibrationDateValid) { line = 23; try { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "LastCalibrationDate").Value, this.LastCalibrationDate.ToString(cult)); } catch { } } if (null == SensorID) { SensorID = ""; } if (this.IsSensorIDValid) { line = 24; try { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SensorID").Value, this.SensorID.ToString()); } catch { } } if (this.IsOffsetToleranceLowMvValid) { line = 25; try { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "OffsetToleranceLowMv").Value, this.OffsetToleranceLowMv.ToString(cult)); } catch { } } if (this.IsOffsetToleranceHighMvValid) { line = 26; try { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "OffsetToleranceHighMv").Value, this.OffsetToleranceHighMv.ToString(cult)); } catch { } } if (this.IsDataFlagValid) { try { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "DataFlag").Value, this.DataFlag.ToString(cult)); } catch { } } line = 27; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ExcitationVoltage").Value, this.ExcitationVoltage.ToString()); line = 28; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "EngineeringUnits").Value, this.EngineeringUnits.ToString(cult)); line = 29; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SerialNumber").Value, this.SerialNumber.ToString(cult)); line = 30; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "CalSignalEnabled").Value, this.CalSignalEnabled.ToString(cult)); line = 31; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ShuntEnabled").Value, this.ShuntEnabled.ToString(cult)); line = 32; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "VoltageInsertionCheckEnabled").Value, this.VoltageInsertionCheckEnabled.ToString(cult)); line = 33; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "RemoveOffset").Value, this.RemoveOffset.ToString(cult)); //writer.WriteAttributeString( attributeExtractor.ExtractAttachedAttributeFromProperty( this, "ZeroMethod" ).Value, this.ZeroMethod .ToString( ) ); line = 34; switch (ZeroMethod) { case DTS.DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType.UsePreEventDiagnosticsZero: writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ZeroMethod").Value, "UsePreCalZero"); break; default: writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ZeroMethod").Value, this.ZeroMethod.ToString()); break; } line = 35; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ZeroAverageWindow").Value + BeginTagModifier, this.ZeroAverageWindow.Begin.ToString(cult)); line = 36; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ZeroAverageWindow").Value + EndTagModifier, this.ZeroAverageWindow.End.ToString(cult)); line = 37; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "InitialEu").Value, this.InitialEu.ToString(cult)); line = 38; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "InitialOffset").Value, InitialOffset); line = 39; writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UnsubsampledSampleRateHz").Value, this.UnsubsampledSampleRateHz.ToString(cult)); line = 40; if (!string.IsNullOrEmpty(UserValue1)) { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UserValue1").Value, this.UserValue1); } line = 41; if (!string.IsNullOrEmpty(UserValue2)) { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UserValue2").Value, this.UserValue2); } line = 42; if (!string.IsNullOrEmpty(UserValue3)) { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UserValue3").Value, this.UserValue3); } line = 43; // Potentially valid "uninitialized" values need special handling. if (this._MeasuredShuntDeflectionMv.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "MeasuredShuntDeflectionMv").Value, this.MeasuredShuntDeflectionMv.ToString(cult)); line = 44; if (this._MeasuredGain.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "MeasuredGain").Value, this.MeasuredGain.ToString(cult)); line = 45; if (this._ExpectedGain.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ExpectedGain").Value, this.ExpectedGain.ToString(cult)); line = 46; if (this._TargetShuntDeflectionMv.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TargetShuntDeflectionMv").Value, this.TargetShuntDeflectionMv.ToString(cult)); line = 47; if (this._MeasuredCalSignalMv.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "MeasuredCalSignalMv").Value, this.MeasuredCalSignalMv.ToString(cult)); line = 48; if (this._TargetCalSignalMv.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TargetCalSignalMv").Value, this.TargetCalSignalMv.ToString(cult)); line = 49; if (this._MeasuredExcitationVoltage.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "MeasuredExcitationVoltage").Value, this.MeasuredExcitationVoltage.ToString(cult)); line = 50; if (this._FactoryExcitationVoltage.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "FactoryExcitationVoltage").Value, this.FactoryExcitationVoltage.ToString(cult)); line = 51; if (this._TimeOfFirstSampleSec.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TimeOfFirstSampleSec").Value, this.TimeOfFirstSampleSec.ToString(cult)); line = 52; // Potentially valid "uninitialized" and/or nullable values need special handling. if (this._TriggerAboveThresholdEu.IsInitialized && null != TriggerAboveThresholdEu) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TriggerAboveThresholdEu").Value, ((double)this.TriggerAboveThresholdEu).ToString(cult)); line = 53; if (this._TriggerBelowThresholdEu.IsInitialized && null != TriggerBelowThresholdEu) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TriggerBelowThresholdEu").Value, ((double)this.TriggerBelowThresholdEu).ToString(cult)); line = 54; if (this._Multiplier.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Multiplier").Value, this.Multiplier.ToString(cult)); line = 55; if (this._UserOffsetEU.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UserOffsetEU").Value, this.UserOffsetEU.ToString(cult)); line = 56; if (this._UnitConversion.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UnitConversion").Value, this.UnitConversion.ToString(cult)); line = 57; if (this._AtCapacity.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "AtCapacity").Value, this.AtCapacity.ToString(cult)); line = 58; if (this._CapacityOutputIsBasedOn.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "CapacityOutputIsBasedOn").Value, this.CapacityOutputIsBasedOn.ToString(cult)); line = 59; if (this._SensitivityUnits.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SensitivityUnits").Value, this.SensitivityUnits.ToString()); line = 60; if (this._isSquibChannel.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "IsSquibChannel").Value, this.IsSquibChannel.ToString(cult)); line = 61; if (this._sensorCapacity.IsInitialized) writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SensorCapacity").Value, this.SensorCapacity.ToString(cult)); line = 62; if (ExpressDataInlineOnXmlSerialization) this.Data.WriteXml(writer); line = 63; try { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ChannelGroupName").Value, this.ChannelGroupName); } catch (System.Exception) { } line = 64; if (this._Manufacturer.IsInitialized) { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Manufacturer").Value, this.Manufacturer.ToString(cult)); } line = 65; if (this._Model.IsInitialized) { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Model").Value, this.Model.ToString(cult)); } line = 66; } catch (System.Exception ex) { throw new Exception("encountered problem converting " + this.GetType().FullName + " object to XML, Line: " + line.ToString(), ex); } } /// /// Read XML serialization for this object from the specified reader. /// /// /// /// The from which this object's XML serialization /// will be read. /// /// //Note: This does not read in the parent (Channel) xml public override void ReadXml(XmlReader reader) { try { var cult = new System.Globalization.CultureInfo(""); AttributeExtractor attributeExtractor = new AttributeExtractor(); DTS.Utilities.Xml.PropertyAttributeDecoder xmlAttributeDecoder = new PropertyAttributeDecoder(this); if (null != reader.GetAttribute("AbsoluteDisplayOrder")) { try { this.AbsoluteDisplayOrder = xmlAttributeDecoder.ExtractIntProperty("AbsoluteDisplayOrder", reader); } catch (System.Exception) { } } if (null != reader.GetAttribute("Multiplier")) { try { this.Data.Multiplier = xmlAttributeDecoder.ExtractDoubleProperty("Multiplier", reader); } catch (System.Exception ex) { string temp2 = ex.Message; } } if (null != reader.GetAttribute("UnitConversion")) { try { this.Data.UnitConversion = xmlAttributeDecoder.ExtractDoubleProperty("UnitConversion", reader); } catch (System.Exception ex) { string temp2 = ex.Message; } } if (null != reader.GetAttribute("UserOffsetEU")) { try { this.Data.UserOffsetEU = xmlAttributeDecoder.ExtractDoubleProperty("UserOffsetEU", reader); } catch (System.Exception ex) { string temp2 = ex.Message; } } if (null != reader.GetAttribute("AtCapacity")) { try { this.AtCapacity = xmlAttributeDecoder.ExtractBoolProperty("AtCapacity", reader, false); } catch (System.Exception ex) { string temp2 = ex.Message; } } if (null != reader.GetAttribute("CapacityOutputIsBasedOn")) { try { this.CapacityOutputIsBasedOn = xmlAttributeDecoder.ExtractDoubleProperty("CapacityOutputIsBasedOn", reader); } catch (System.Exception ex) { string temp2 = ex.Message; } } if (null != reader.GetAttribute("SensitivityUnits")) { try { this.SensitivityUnits = (DTS.DAS.Concepts.Test.Module.Channel.Sensor.SensUnits)xmlAttributeDecoder.ExtractEnumProperty("SensitivityUnits", typeof(DTS.DAS.Concepts.Test.Module.Channel.Sensor.SensUnits), reader); } catch (System.Exception ex) { string temp2 = ex.Message; } } this.Number = xmlAttributeDecoder.ExtractIntProperty("Number", reader); this.BridgeResistanceOhms = xmlAttributeDecoder.ExtractDoubleProperty("BridgeResistanceOhms", reader); try { if (null != reader.GetAttribute("ZeroPoint")) { this.ZeroPoint = xmlAttributeDecoder.ExtractDoubleProperty("ZeroPoint", reader); } } catch (System.Exception) { } this.ChannelDescriptionString = xmlAttributeDecoder.ExtractStringProperty("ChannelDescriptionString", reader); try { this.ChannelName2 = xmlAttributeDecoder.ExtractStringProperty("ChannelName2", reader); } catch (System.Exception) { } try { this.HardwareChannelName = xmlAttributeDecoder.ExtractStringProperty("HardwareChannelName", reader); } catch (System.Exception) { } try { this.ChannelId = xmlAttributeDecoder.ExtractStringProperty("ChannelId", reader); } catch (System.Exception) { } try { this.ChannelGroupName = xmlAttributeDecoder.ExtractStringProperty("ChannelGroupName", reader); } catch (System.Exception) { } this.DesiredRange = xmlAttributeDecoder.ExtractDoubleProperty("DesiredRange", reader); this.Description = xmlAttributeDecoder.ExtractStringProperty("Description", reader); this.Manufacturer = xmlAttributeDecoder.ExtractStringProperty("Manufacturer", reader); this.Model = xmlAttributeDecoder.ExtractStringProperty("Model", reader); this.EngineeringUnits = xmlAttributeDecoder.ExtractStringProperty("EngineeringUnits", reader); try { this.InitialOffset = xmlAttributeDecoder.ExtractStringProperty("InitialOffset", reader); } catch (System.Exception) { } this.InitialEu = xmlAttributeDecoder.ExtractDoubleProperty("InitialEu", reader); this.ProportionalToExcitation = xmlAttributeDecoder.ExtractBoolProperty("ProportionalToExcitation", reader); this.RemoveOffset = xmlAttributeDecoder.ExtractBoolProperty("RemoveOffset", reader); this.Sensitivity = xmlAttributeDecoder.ExtractDoubleProperty("Sensitivity", reader); try { DateTime dt; if (DateTime.TryParse(xmlAttributeDecoder.ExtractStringProperty("LastCalibrationDate", reader), cult, System.Globalization.DateTimeStyles.None, out dt)) { this.LastCalibrationDate = dt; } } catch { } this.SerialNumber = xmlAttributeDecoder.ExtractStringProperty("SerialNumber", reader); try { this.CalSignalEnabled = xmlAttributeDecoder.ExtractBoolProperty("CalSignalEnabled", reader, false); } catch { CalSignalEnabled = false; } this.ShuntEnabled = xmlAttributeDecoder.ExtractBoolProperty("ShuntEnabled", reader); try { this.VoltageInsertionCheckEnabled = xmlAttributeDecoder.ExtractBoolProperty("VoltageInsertionCheckEnabled", reader, false); } catch { VoltageInsertionCheckEnabled = false; } this.SoftwareFilter = xmlAttributeDecoder.ExtractStringProperty("SoftwareFilter", reader); this.Bridge = (DTS.DAS.Concepts.Test.Module.Channel.Sensor.BridgeType)xmlAttributeDecoder.ExtractEnumProperty("Bridge", typeof(DTS.DAS.Concepts.Test.Module.Channel.Sensor.BridgeType), reader); this.ExcitationVoltage = (DTS.DAS.Concepts.Test.Module.Channel.Sensor.ExcitationVoltageOption)xmlAttributeDecoder.ExtractEnumProperty("ExcitationVoltage", typeof(DTS.DAS.Concepts.Test.Module.Channel.Sensor.ExcitationVoltageOption), reader); string sZeroMethod = xmlAttributeDecoder.ExtractStringProperty("ZeroMethod", reader); try { if (null != sZeroMethod && "UsePreCalZero" == sZeroMethod) { this.ZeroMethod = DTS.DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType.UsePreEventDiagnosticsZero; } else { this.ZeroMethod = (DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType)Enum.Parse(typeof(DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType), sZeroMethod); } } catch { DTS.DAS.Concepts.Test.Module.Channel.Sensor.OriginalZeroMethodType originalZeroMethodType = (DTS.DAS.Concepts.Test.Module.Channel.Sensor.OriginalZeroMethodType)xmlAttributeDecoder.ExtractEnumProperty("ZeroMethod", typeof(DTS.DAS.Concepts.Test.Module.Channel.Sensor.OriginalZeroMethodType), reader); switch (originalZeroMethodType) { case DTS.DAS.Concepts.Test.Module.Channel.Sensor.OriginalZeroMethodType.AverageOverTime: this.ZeroMethod = DTS.DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType.AverageOverTime; break; case DTS.DAS.Concepts.Test.Module.Channel.Sensor.OriginalZeroMethodType.UsePreCalZero: this.ZeroMethod = DTS.DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType.UsePreEventDiagnosticsZero; break; case DTS.DAS.Concepts.Test.Module.Channel.Sensor.OriginalZeroMethodType.None: this.ZeroMethod = DTS.DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType.None; break; default:// // If we've gotten here, we've changed the enum and forgotten to put in // a corresponding conversion. // Debug.Assert(false); this.ZeroMethod = DTS.DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType.None; break; } } try { this.UnsubsampledSampleRateHz = float.Parse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UnsubsampledSampleRateHz").Value), cult); } catch ( System.Exception ) { this.UnsubsampledSampleRateHz = ParentModule.SampleRateHz; } try { this.UserValue1 = xmlAttributeDecoder.ExtractStringProperty("UserValue1", reader); } catch (System.Exception) { } try { this.UserValue2 = xmlAttributeDecoder.ExtractStringProperty("UserValue2", reader); } catch (System.Exception) { } try { this.UserValue3 = xmlAttributeDecoder.ExtractStringProperty("UserValue3", reader); } catch (System.Exception) { } double temp; //try { this.MeasuredShuntDeflectionMv = double.Parse( reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty ( this, "MeasuredShuntDeflectionMv" ).Value ), cult ); } //catch ( System.Exception ) { /*this.MeasuredShuntDeflectionMv = 0.0;*/ } try { if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "MeasuredShuntDeflectionMv").Value), System.Globalization.NumberStyles.Any, cult, out temp)) { this.MeasuredShuntDeflectionMv = temp; } } catch (System.Exception) { } try { if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "MeasuredGain").Value), System.Globalization.NumberStyles.Any, cult, out temp)) { this.MeasuredGain = temp; } } catch (System.Exception) { } try { if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ExpectedGain").Value), System.Globalization.NumberStyles.Any, cult, out temp)) { this.ExpectedGain = temp; } } catch (System.Exception) { } try { if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TargetShuntDeflectionMv").Value), System.Globalization.NumberStyles.Any, cult, out temp)) { this.TargetShuntDeflectionMv = temp; } } catch (System.Exception) { } try { if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "MeasuredCalSignalMv").Value), System.Globalization.NumberStyles.Any, cult, out temp)) { this.MeasuredCalSignalMv = temp; } } catch (System.Exception) { } try { if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TargetCalSignalMv").Value), System.Globalization.NumberStyles.Any, cult, out temp)) { this.TargetCalSignalMv = temp; } } catch (System.Exception) { } try { if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TriggerAboveThresholdEu").Value), System.Globalization.NumberStyles.Any, cult, out temp)) { this.TriggerAboveThresholdEu = temp; } } catch (System.Exception) { } try { if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TriggerBelowThresholdEu").Value), System.Globalization.NumberStyles.Any, cult, out temp)) { this.TriggerBelowThresholdEu = temp; } } catch { } try { if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "MeasuredExcitationVoltage").Value), System.Globalization.NumberStyles.Float, cult, out temp)) { this.MeasuredExcitationVoltage = temp; } } catch (System.Exception) { /* leave it uninitialized */ } try { if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "FactoryExcitationVoltage").Value), System.Globalization.NumberStyles.Float, cult, out temp)) { this.FactoryExcitationVoltage = temp; } } catch (System.Exception) { /* leave it uninitialized */ } try { if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TimeOfFirstSampleSec").Value), System.Globalization.NumberStyles.Float, cult, out temp)) { this.TimeOfFirstSampleSec = temp; } } catch (System.Exception) { } try { this.IsInverted = xmlAttributeDecoder.ExtractBoolProperty("IsInverted", reader, false); } catch (System.Exception) { this.IsInverted = false; } try { this.IsSubsampled = xmlAttributeDecoder.ExtractBoolProperty("IsSubsampled", reader, false); } catch (System.Exception) { this.IsSubsampled = false; } try { this.LinearizationFormula = new LinearizationFormula(); this.LinearizationFormula.FromSerializeString(xmlAttributeDecoder.ExtractStringProperty("LinearizationFormula", reader)); } catch (System.Exception) { this.LinearizationFormula = null; } try { this.DigitalMultiplier = new DTS.DAS.Concepts.DigitalInputScaleMultiplier(); this.DigitalMultiplier.FromDbSerializeString(xmlAttributeDecoder.ExtractStringProperty("DigitalMultiplier", reader)); } catch (System.Exception) { this.DigitalMultiplier = new DTS.DAS.Concepts.DigitalInputScaleMultiplier(); } try { DTS.DAS.Concepts.DigitalInputScaleMultiplier.InputModes mode = DigitalInputScaleMultiplier.InputModes.CCNC; Enum.TryParse(xmlAttributeDecoder.ExtractStringProperty("DigitalMode", reader), out mode); DigitalMode = mode; } catch (System.Exception) { } try { DateTime calDate; if (DateTime.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "LastCalibrationDate").Value), cult, System.Globalization.DateTimeStyles.None, out calDate)) { this.LastCalibrationDate = calDate; } else { this.LastCalibrationDate = DateTime.MinValue; } } catch { this.LastCalibrationDate = DateTime.MinValue; } try { this.SensorID = xmlAttributeDecoder.ExtractStringProperty("SensorID", reader); } catch (System.Exception) { this.SensorID = ""; } try { this.OffsetToleranceLowMv = xmlAttributeDecoder.ExtractDoubleProperty("OffsetToleranceLowMv", reader); } catch (System.Exception) { this.OffsetToleranceLowMv = 0; } try { this.OffsetToleranceHighMv = xmlAttributeDecoder.ExtractDoubleProperty("OffsetToleranceHighMv", reader); } catch (System.Exception) { this.OffsetToleranceHighMv = 0; } try { this.DataFlag = xmlAttributeDecoder.ExtractIntProperty("DataFlag", reader); } catch (System.Exception) { this.DataFlag =new DTS.Utilities.DataFlagAttributeCoder().DecodeAttributeValue(DTS.Utilities.DataFlag.Normal); } try { // // Extract and parse start time value. // string startTimeString; try { startTimeString = reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Start").Value); } catch (System.Exception ex) { throw new Test.Module.AnalogInputChannel.Exception("encountered problem extracting start time value string", ex); } try { this.Start = DateTime.Parse(startTimeString, cult); } catch (System.Exception) { this.Start = DateTime.Now; // throw new Test.Module.AnalogInputChannel.Exception( "encountered problem parsing DateTime value " + ( null != startTimeString ? ( "\"" + startTimeString + "\"" ) : "<>" ), ex ); } } catch (System.Exception ex) { throw new Test.Module.AnalogInputChannel.Exception("encountered problem extracting start time property", ex); } try { // // Extract and parse zero average window begin value. // string zeroAverageWindowBeginString; try { zeroAverageWindowBeginString = reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ZeroAverageWindow").Value + BeginTagModifier); } catch (System.Exception ex) { throw new Test.Module.AnalogInputChannel.Exception("encountered problem extracting ZeroAverageWindow begin value string", ex); } double zeroAverageWindowBeginValue; try { zeroAverageWindowBeginValue = double.Parse(zeroAverageWindowBeginString, cult); } catch (System.Exception ex) { throw new Test.Module.AnalogInputChannel.Exception("encountered problem parsing double value " + (null != zeroAverageWindowBeginString ? ("\"" + zeroAverageWindowBeginString + "\"") : "<"), ex); } // // Extract and parse zero average window end value. // string zeroAverageWindowEndString; try { zeroAverageWindowEndString = reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ZeroAverageWindow").Value + EndTagModifier); } catch (System.Exception ex) { throw new Test.Module.AnalogInputChannel.Exception("encountered problem extacting ZeroAverageWindow end value string", ex); } double zeroAverageWindowEndValue; try { zeroAverageWindowEndValue = double.Parse(zeroAverageWindowEndString, cult); } catch (System.Exception ex) { throw new Test.Module.AnalogInputChannel.Exception("encountered problem parsing double value " + (null != zeroAverageWindowEndString ? ("\"" + zeroAverageWindowEndString + "\"") : "<"), ex); } try { // // Synthesize new zero average window value. // this.ZeroAverageWindow = new IntervalSec(zeroAverageWindowBeginValue, zeroAverageWindowEndValue); } catch (System.Exception ex) { throw new Test.Module.AnalogInputChannel.Exception("encountered problem synthesizing zero average window from begin: " + zeroAverageWindowBeginValue.ToString() + ", end: " + zeroAverageWindowEndValue.ToString(), ex); } } catch (System.Exception ex) { throw new Test.Module.AnalogInputChannel.Exception("encountered problem extracting zero average window property", ex); } if (ExpressDataInlineOnXmlSerialization) { reader.Read(); short[] dummyValues = { 0 }; this.Data = new DataArray(dummyValues); this.Data.ReadXml(reader); } try { this.IsSquibChannel = xmlAttributeDecoder.ExtractBoolProperty("IsSquibChannel", reader, false); } catch (System.Exception) { this.IsSquibChannel = false; } try { double d; if (xmlAttributeDecoder.ExtractDoubleProperty("SensorCapacity", reader, out d)) { this.SensorCapacity = d; } else { this.SensorCapacity = 0D; } } catch (System.Exception) { this.SensorCapacity = 0; } } catch (System.Exception ex) { throw new Exception("encountered problem converting XML to " + this.GetType().FullName + " object", ex); } } /// /// 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 { Test.Module.AnalogInputChannel that = obj as Test.Module.AnalogInputChannel; return null != obj // Must-be-initialized properties. && this.ChannelId.Equals(that.ChannelId) && this.ChannelGroupName.Equals(that.ChannelGroupName) && this.Data.Equals(that.Data) && this.ExpressDataInlineOnXmlSerialization.Equals(that.ExpressDataInlineOnXmlSerialization) && this.Number.Equals(that.Number) && this.Bridge.Equals(that.Bridge) && this.BridgeResistanceOhms.Equals(that.BridgeResistanceOhms) && this.ZeroPoint.Equals(that.ZeroPoint) && this.Description.Equals(that.Description, StringComparison.OrdinalIgnoreCase) && this.DesiredRange.Equals(that.DesiredRange) && this.EngineeringUnits.Equals(that.EngineeringUnits, StringComparison.OrdinalIgnoreCase) && this.ExcitationVoltage.Equals(that.ExcitationVoltage) && this.InitialEu.Equals(that.InitialEu) && this.InitialOffset.Equals(that.InitialOffset) && this.ProportionalToExcitation.Equals(that.ProportionalToExcitation) && this.IsInverted.Equals(that.IsInverted) && this.IsSubsampled.Equals(that.IsSubsampled) //handle nullable && (this.IsLastCalibrationDateValid && that.IsLastCalibrationDateValid) ? this.LastCalibrationDate.Equals(that.LastCalibrationDate) : that.IsLastCalibrationDateValid ? false : true && (this.IsSensorIDValid && that.IsSensorIDValid) ? this.SensorID.Equals(that.SensorID) : that.IsSensorIDValid ? false : true && (this.IsOffsetToleranceLowMvValid && that.IsOffsetToleranceLowMvValid) ? this.OffsetToleranceLowMv.Equals(that.OffsetToleranceLowMv) : that.IsOffsetToleranceLowMvValid ? false : true && (this.IsOffsetToleranceHighMvValid && that.IsOffsetToleranceHighMvValid) ? this.OffsetToleranceHighMv.Equals(that.OffsetToleranceHighMv) : that.IsOffsetToleranceHighMvValid ? false : true && ( (null == this.LinearizationFormula && null == that.LinearizationFormula) || (null != this.LinearizationFormula && LinearizationFormula.Equals(that.LinearizationFormula)) ) && this.IsoCode.Equals(that.IsoCode, StringComparison.OrdinalIgnoreCase) && this.RemoveOffset.Equals(that.RemoveOffset) && this.Sensitivity.Equals(that.Sensitivity) && this.SerialNumber.Equals(that.SerialNumber, StringComparison.OrdinalIgnoreCase) && this.ShuntEnabled.Equals(that.ShuntEnabled) && this.VoltageInsertionCheckEnabled.Equals(that.VoltageInsertionCheckEnabled) && this.CalSignalEnabled.Equals(that.CalSignalEnabled) && this.SoftwareFilter.Equals(that.SoftwareFilter) && this.UnsubsampledSampleRateHz.Equals(that.UnsubsampledSampleRateHz) && this.ZeroAverageWindow.Equals(that.ZeroAverageWindow) && this.ZeroMethod.Equals(that.ZeroMethod) && this.Start.ToString().Equals(that.Start.ToString()) && this.AbsoluteDisplayOrder.Equals(that.AbsoluteDisplayOrder) // Potentially valid-as-uninitialized and/or nullable properties. && this._MeasuredShuntDeflectionMv.IsInitialized ? this.MeasuredShuntDeflectionMv.Equals(that.MeasuredShuntDeflectionMv) : this._MeasuredShuntDeflectionMv.IsInitialized == that._MeasuredShuntDeflectionMv.IsInitialized && this._TargetShuntDeflectionMv.IsInitialized ? this.TargetShuntDeflectionMv.Equals(that.TargetShuntDeflectionMv) : this._TargetShuntDeflectionMv.IsInitialized == that._TargetShuntDeflectionMv.IsInitialized && this._TriggerAboveThresholdEu.IsInitialized ? this.TriggerAboveThresholdEu.Equals(that.TriggerAboveThresholdEu) : this._TriggerAboveThresholdEu.IsInitialized == that._TriggerAboveThresholdEu.IsInitialized && this._TriggerBelowThresholdEu.IsInitialized ? this.TriggerBelowThresholdEu.Equals(that.TriggerBelowThresholdEu) : this._TriggerBelowThresholdEu.IsInitialized == that._TriggerBelowThresholdEu.IsInitialized && this._MeasuredGain.IsInitialized ? this.MeasuredGain.Equals(that.MeasuredGain) : this._MeasuredGain.IsInitialized == that._MeasuredGain.IsInitialized && this.UserValue1 == that.UserValue1 && this.UserValue2 == that.UserValue2 && this.UserValue3 == that.UserValue3 && this.DigitalMultiplier.ToSerializeDbString() == that.DigitalMultiplier.ToSerializeDbString() && this.DigitalMode == that.DigitalMode && this.DataFlag.Equals(that.DataFlag) && this._ExpectedGain.IsInitialized ? this.ExpectedGain.Equals(that.ExpectedGain) : this._ExpectedGain.IsInitialized == that._ExpectedGain.IsInitialized && this.UnitConversion.Equals(that.UnitConversion) && this.AtCapacity.Equals(that.AtCapacity) && this.CapacityOutputIsBasedOn.Equals(that.CapacityOutputIsBasedOn) && this.SensitivityUnits.Equals(that.SensitivityUnits); } catch (System.Exception ex) { throw new Exception("encountered problem equality-testing the object " + (null != obj ? "\"" + obj.ToString() + "\"" : "<>"), ex); } } /// /// Return the hash code for this object. /// /// /// /// The hash code for this object. /// /// public override int GetHashCode( ) { return base.GetHashCode( ); } } } } }