2027 lines
109 KiB
Plaintext
2027 lines
109 KiB
Plaintext
/*
|
|
Test.Module.AnalogInputChannel.cs
|
|
|
|
Copyright © 2008
|
|
Diversified Technical Systems, Inc.
|
|
All Rights Reserved
|
|
*/
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using System.Xml;
|
|
using DTS.Common.Classes.Sensors;
|
|
using DTS.Common.DAS.Concepts;
|
|
using DTS.Common.Enums;
|
|
using DTS.Common.Enums.Sensors;
|
|
using DTS.Common.Utilities;
|
|
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
|
using DTS.Common.Utilities.Logging;
|
|
using DTS.Common.Utilities.Xml;
|
|
|
|
namespace DTS.Serialization
|
|
{
|
|
// *** see Test.cs ***
|
|
public partial class Test
|
|
{
|
|
// *** see Test.Module.cs ***
|
|
public partial class Module
|
|
{
|
|
/// <summary>
|
|
/// Representation of an analog channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("AnalogInputChanel")]
|
|
public class AnalogInputChannel
|
|
: Channel,
|
|
Common.DAS.Concepts.DAS.Channel.IEngineeringUnitAware,
|
|
Common.DAS.Concepts.DAS.Channel.IInversionAware,
|
|
Common.DAS.Concepts.DAS.Channel.ISerialNumberAware,
|
|
Common.DAS.Concepts.DAS.Channel.IIsoCodeAware,
|
|
Common.DAS.Concepts.DAS.Channel.IShuntAware,
|
|
Common.DAS.Concepts.DAS.Channel.ICalSignalAware,
|
|
Common.DAS.Concepts.DAS.Channel.IVoltageInsertionAware,
|
|
Common.DAS.Concepts.DAS.Channel.ILinearized
|
|
{
|
|
/// <summary>
|
|
/// Initialize an instance of the <see cref="DTS.Serialization.Test.Module.AnalogInputChannel"/> class.
|
|
/// </summary>
|
|
///
|
|
/// <param name="parentModule">
|
|
/// The <see cref="DTS.Serialization.Test.Module"/> that contains this object.
|
|
/// </param>
|
|
///
|
|
public AnalogInputChannel(Module parentModule)
|
|
: base(parentModule)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get/set the <see cref="Common.DAS.Concepts.SensorConstants.BridgeType"/> bridge configuration of this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("Bridge")]
|
|
public SensorConstants.BridgeType Bridge
|
|
{
|
|
get => _Bridge.Value;
|
|
set => _Bridge.Value = value;
|
|
}
|
|
private readonly Property<SensorConstants.BridgeType> _Bridge
|
|
= new Property<SensorConstants.BridgeType>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.BridgeType",
|
|
SensorConstants.BridgeType.FullBridge,
|
|
false
|
|
);
|
|
|
|
[XmlSerializationTag("ZeroPoint")]
|
|
public double ZeroPoint
|
|
{
|
|
get
|
|
{
|
|
if (_ZeroPoint.IsValueInitialized)
|
|
{
|
|
return _ZeroPoint.Value;
|
|
}
|
|
return 0D;
|
|
}
|
|
set => _ZeroPoint.Value = value;
|
|
}
|
|
private readonly Property<double> _ZeroPoint
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.ZeroPoint",
|
|
0D,
|
|
false);
|
|
/// <summary>
|
|
/// Get/set the bridge resistance for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("BridgeResistanceOhms")]
|
|
public double BridgeResistanceOhms
|
|
{
|
|
get => _BridgeResistanceOhms.Value;
|
|
set => _BridgeResistanceOhms.Value = value;
|
|
}
|
|
private readonly Property<double> _BridgeResistanceOhms
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.BridgeResistanceOhms",
|
|
0.0,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the unit conversion for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("UnitConversion")]
|
|
public double UnitConversion
|
|
{
|
|
get => _UnitConversion.Value;
|
|
set => _UnitConversion.Value = value;
|
|
}
|
|
private readonly Property<double> _UnitConversion
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.UnitConversion",
|
|
1.0,
|
|
false
|
|
);
|
|
|
|
|
|
/// <summary>
|
|
/// Get/set the multiplier for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("Multiplier")]
|
|
public double Multiplier
|
|
{
|
|
get => _Multiplier.Value;
|
|
set => _Multiplier.Value = value;
|
|
}
|
|
private readonly Property<double> _Multiplier
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.Multiplier",
|
|
1.0,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the modified offset for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("UserOffsetEU")]
|
|
public double UserOffsetEU
|
|
{
|
|
get => _UserOffsetEU.Value;
|
|
set => _UserOffsetEU.Value = value;
|
|
}
|
|
private readonly Property<double> _UserOffsetEU
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.UserOffsetEU",
|
|
0.0,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the description for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("Description")]
|
|
public string Description
|
|
{
|
|
get => _Description.Value ?? "";
|
|
set => _Description.Value = value;
|
|
}
|
|
private readonly Property<string> _Description
|
|
= new Property<string>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.Description",
|
|
"",
|
|
true
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the manufacture for this channel's sensor.
|
|
/// </summary>
|
|
[XmlSerializationTag("Manufacturer")]
|
|
public string Manufacturer
|
|
{
|
|
get => _Manufacturer.Value ?? "";
|
|
set => _Manufacturer.Value = value;
|
|
}
|
|
private readonly Property<string> _Manufacturer
|
|
= new Property<string>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.Manufacturer",
|
|
"",
|
|
true
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the model for this channel's sensor.
|
|
/// </summary>
|
|
[XmlSerializationTag("Model")]
|
|
public string Model
|
|
{
|
|
get => _Model.Value ?? "";
|
|
set => _Model.Value = value;
|
|
}
|
|
private readonly Property<string> _Model
|
|
= new Property<string>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.Model",
|
|
"",
|
|
true
|
|
);
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Get/set the model for this channel's sensor.
|
|
/// </summary>
|
|
[XmlSerializationTag("UserCode")]
|
|
public string UserCode
|
|
{
|
|
get => _UserCode.Value ?? "";
|
|
set => _UserCode.Value = value;
|
|
}
|
|
private readonly Property<string> _UserCode
|
|
= new Property<string>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.UserCode",
|
|
"",
|
|
true
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the model for this channel's sensor.
|
|
/// </summary>
|
|
[XmlSerializationTag("UserChannelName")]
|
|
public string UserChannelName
|
|
{
|
|
get => _UserChannelName.Value ?? "";
|
|
set => _UserChannelName.Value = value;
|
|
}
|
|
private readonly Property<string> _UserChannelName
|
|
= new Property<string>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.UserChannelName",
|
|
"",
|
|
true
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the model for this channel's sensor.
|
|
/// </summary>
|
|
[XmlSerializationTag("IsoChannelName")]
|
|
public string IsoChannelName
|
|
{
|
|
get => _IsoChannelName.Value ?? "";
|
|
set => _IsoChannelName.Value = value;
|
|
}
|
|
private readonly Property<string> _IsoChannelName
|
|
= new Property<string>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.IsoChannelName",
|
|
"",
|
|
true
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the desired range for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("DesiredRange")]
|
|
public double DesiredRange
|
|
{
|
|
get => _DesiredRange.Value;
|
|
set => _DesiredRange.Value = value;
|
|
}
|
|
private readonly Property<double> _DesiredRange
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.DesiredRange",
|
|
0.0,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the sensitivity for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("Sensitivity")]
|
|
public double Sensitivity
|
|
{
|
|
get => _Sensitivity.Value;
|
|
set => _Sensitivity.Value = value;
|
|
}
|
|
private readonly Property<double> _Sensitivity
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.Sensitivity",
|
|
0.0,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the descriptor indiciating whether or not this channel is
|
|
/// based on output at capacity.
|
|
/// </summary>
|
|
[XmlSerializationTag("AtCapacity")]
|
|
public bool AtCapacity
|
|
{
|
|
get => _AtCapacity.Value;
|
|
set => _AtCapacity.Value = value;
|
|
}
|
|
private readonly Property<bool> _AtCapacity
|
|
= new Property<bool>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.AtCapacity",
|
|
false,
|
|
true
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the capacity output is based on value for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("CapacityOutputIsBasedOn")]
|
|
public double CapacityOutputIsBasedOn
|
|
{
|
|
get => _CapacityOutputIsBasedOn.Value;
|
|
set => _CapacityOutputIsBasedOn.Value = value;
|
|
}
|
|
private readonly Property<double> _CapacityOutputIsBasedOn
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.CapacityOutputIsBasedOn",
|
|
1.000,
|
|
true
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the Sensitivity Units for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("SensitivityUnits")]
|
|
public SensorConstants.SensUnits SensitivityUnits
|
|
{
|
|
get => _SensitivityUnits.Value;
|
|
set => _SensitivityUnits.Value = value;
|
|
}
|
|
private readonly Property<SensorConstants.SensUnits> _SensitivityUnits
|
|
= new Property<SensorConstants.SensUnits>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.SensitivityUnits",
|
|
SensorConstants.SensUnits.NONE,
|
|
true
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the descriptor indiciating whether or not this channel is
|
|
/// proportional to excitation.
|
|
/// </summary>
|
|
[XmlSerializationTag("ProportionalToExcitation")]
|
|
public bool ProportionalToExcitation
|
|
{
|
|
get => _ProportionalToExcitation.Value;
|
|
set => _ProportionalToExcitation.Value = value;
|
|
}
|
|
private readonly Property<bool> _ProportionalToExcitation
|
|
= new Property<bool>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.ProportionalToExcitation",
|
|
false,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the excitation voltage for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("ExcitationVoltage")]
|
|
public ExcitationVoltageOptions.ExcitationVoltageOption ExcitationVoltage
|
|
{
|
|
get => _ExcitationVoltage.Value;
|
|
set => _ExcitationVoltage.Value = value;
|
|
}
|
|
private readonly Property<ExcitationVoltageOptions.ExcitationVoltageOption> _ExcitationVoltage
|
|
= new Property<ExcitationVoltageOptions.ExcitationVoltageOption>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.ExcitationVoltage",
|
|
ExcitationVoltageOptions.ExcitationVoltageOption.Volt5,
|
|
false
|
|
);
|
|
|
|
public bool MeasuredExcitationVoltageValid => _MeasuredExcitationVoltage.IsInitialized;
|
|
|
|
/// <summary>
|
|
/// Get/set the measured excitation value for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("MeasuredExcitationVoltage")]
|
|
public double MeasuredExcitationVoltage
|
|
{
|
|
get => _MeasuredExcitationVoltage.Value;
|
|
set => _MeasuredExcitationVoltage.Value = value;
|
|
}
|
|
private readonly Property<double> _MeasuredExcitationVoltage
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.MeasuredExcitationVoltage",
|
|
0.0,
|
|
false
|
|
);
|
|
|
|
public bool FactoryExcitationVoltageValid => _FactoryExcitationVoltage.IsInitialized;
|
|
|
|
/// <summary>
|
|
/// Get/set the factory excitation value for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("FactoryExcitationVoltage")]
|
|
public double FactoryExcitationVoltage
|
|
{
|
|
get => _FactoryExcitationVoltage.Value;
|
|
set => _FactoryExcitationVoltage.Value = value;
|
|
}
|
|
private readonly Property<double> _FactoryExcitationVoltage
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.FactoryExcitationVoltage",
|
|
0.0,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the engineering units for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("Eu")]
|
|
public string EngineeringUnits
|
|
{
|
|
get => _EngineeringUnits.Value;
|
|
set => _EngineeringUnits.Value = value;
|
|
}
|
|
private readonly Property<string> _EngineeringUnits
|
|
= new Property<string>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.EngineeringUnits",
|
|
null,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the ISO code for this channel's data source.
|
|
/// </summary>
|
|
[XmlSerializationTag("IsoCode")]
|
|
public string IsoCode
|
|
{
|
|
get => _IsoCode.Value;
|
|
set => _IsoCode.Value = value;
|
|
}
|
|
private readonly Property<string> _IsoCode
|
|
= new Property<string>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.IsoCode",
|
|
null,
|
|
false
|
|
);
|
|
public bool IsIsoCodeValid => _IsoCode.IsInitialized;
|
|
|
|
|
|
public bool MeasureShuntDeflectionMvValid => _MeasuredShuntDeflectionMv.IsInitialized;
|
|
|
|
/// <summary>
|
|
/// Get/set the <see cref="double"/> measured shunt deflection value for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("MeasuredShuntDeflectionMv")]
|
|
public double MeasuredShuntDeflectionMv
|
|
{
|
|
get => _MeasuredShuntDeflectionMv.Value;
|
|
set => _MeasuredShuntDeflectionMv.Value = value;
|
|
}
|
|
private readonly Property<double> _MeasuredShuntDeflectionMv
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.MeasuredShuntDeflectionMv",
|
|
0.0,
|
|
false
|
|
);
|
|
|
|
public bool TargetShuntDeflectionMvValid => _TargetShuntDeflectionMv.IsInitialized;
|
|
|
|
/// <summary>
|
|
/// Get/set the <see cref="double"/> measured gain value for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("MeasuredGain")]
|
|
public double MeasuredGain
|
|
{
|
|
get => _MeasuredGain.Value;
|
|
set => _MeasuredGain.Value = value;
|
|
}
|
|
private readonly Property<double> _MeasuredGain
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.MeasuredGain",
|
|
0.0,
|
|
false
|
|
);
|
|
|
|
public bool MeasuredGainValid => _MeasuredGain.IsInitialized;
|
|
|
|
/// <summary>
|
|
/// Get/set the <see cref="double"/> expected gain value for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("ExpectedGain")]
|
|
public double ExpectedGain
|
|
{
|
|
get => _ExpectedGain.Value;
|
|
set => _ExpectedGain.Value = value;
|
|
}
|
|
private readonly Property<double> _ExpectedGain
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.ExpectedGain",
|
|
0.0,
|
|
false
|
|
);
|
|
|
|
public bool ExpectedGainValid => _ExpectedGain.IsInitialized;
|
|
|
|
/// <summary>
|
|
/// Get/set the <see cref="double"/> target shunt deflection value for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("TargetShuntDeflectionMv")]
|
|
public double TargetShuntDeflectionMv
|
|
{
|
|
get => _TargetShuntDeflectionMv.Value;
|
|
set => _TargetShuntDeflectionMv.Value = value;
|
|
}
|
|
private readonly Property<double> _TargetShuntDeflectionMv
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.TargetShuntDeflectionMv",
|
|
0.0,
|
|
false
|
|
);
|
|
|
|
public bool IsDigital() { return Bridge == SensorConstants.BridgeType.DigitalInput; }
|
|
|
|
public bool IsSquib()
|
|
{
|
|
return ParentModule.SerialNumber.StartsWith("TOM")
|
|
|| ParentModule.SerialNumber.StartsWith("SPT")
|
|
|| ParentModule.SerialNumber.StartsWith("SLT");
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Get the <see cref="bool"/> whether or not this is really a Squib channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("IsSquibChannel")]
|
|
public bool IsSquibChannel
|
|
{
|
|
get => IsSquib();
|
|
set => _isSquibChannel.Value = value;
|
|
}
|
|
private readonly Property<bool> _isSquibChannel
|
|
= new Property<bool>(
|
|
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 => _MeasuredCalSignalMv.IsInitialized;
|
|
|
|
/// <summary>
|
|
/// Get/set the <see cref="double"/> measured shunt deflection value for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("MeasuredCalSignalMv")]
|
|
public double MeasuredCalSignalMv
|
|
{
|
|
get => _MeasuredCalSignalMv.Value;
|
|
set => _MeasuredCalSignalMv.Value = value;
|
|
}
|
|
private readonly Property<double> _MeasuredCalSignalMv
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.MeasuredCalSignalMv",
|
|
0.0,
|
|
false
|
|
);
|
|
|
|
public bool TargetCalSignalMvValid => _TargetCalSignalMv.IsInitialized;
|
|
|
|
/// <summary>
|
|
/// Get/set the <see cref="double"/> target shunt deflection value for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("TargetCalSignalMv")]
|
|
public double TargetCalSignalMv
|
|
{
|
|
get => _TargetCalSignalMv.Value;
|
|
set => _TargetCalSignalMv.Value = value;
|
|
}
|
|
private readonly Property<double> _TargetCalSignalMv
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.TargetShuntCalSignalMv",
|
|
0.0,
|
|
false
|
|
);
|
|
public bool TriggerBelowThresholdValid => _TriggerBelowThresholdEu.IsInitialized;
|
|
|
|
/// <summary>
|
|
/// Get/set the "trigger below" threshold. Set to "null" to deactivate.
|
|
/// </summary>
|
|
[XmlSerializationTag("TriggerBelowThresholdEu")]
|
|
public double? TriggerBelowThresholdEu
|
|
{
|
|
get => _TriggerBelowThresholdEu.Value;
|
|
set => _TriggerBelowThresholdEu.Value = value;
|
|
}
|
|
private readonly Property<double?> _TriggerBelowThresholdEu
|
|
= new Property<double?>(
|
|
typeof(AnalogInputChannel).FullName + ".TriggerBelowThresholdEu",
|
|
null,
|
|
false
|
|
);
|
|
|
|
public bool TriggerAboveThresholdValid => _TriggerAboveThresholdEu.IsInitialized;
|
|
|
|
/// <summary>
|
|
/// Get/set the "trigger above" threshold. Set to "null" to deactivate.
|
|
/// </summary>
|
|
[XmlSerializationTag("TriggerAboveThresholdEu")]
|
|
public double? TriggerAboveThresholdEu
|
|
{
|
|
get => _TriggerAboveThresholdEu.Value;
|
|
set => _TriggerAboveThresholdEu.Value = value;
|
|
}
|
|
private readonly Property<double?> _TriggerAboveThresholdEu
|
|
= new Property<double?>(
|
|
typeof(AnalogInputChannel).FullName + ".TriggerAboveThresholdEu",
|
|
null,
|
|
false
|
|
);
|
|
|
|
[XmlSerializationTag("LevelTriggerType")]
|
|
public Common.DAS.Concepts.DAS.Channel.LevelTriggerTypes LevelTriggerType
|
|
{
|
|
get => _levelTriggerType.Value;
|
|
set => _levelTriggerType.Value = value;
|
|
}
|
|
public bool LevelTriggerTypeValid => _levelTriggerType.IsValueInitialized;
|
|
|
|
private readonly Property<Common.DAS.Concepts.DAS.Channel.LevelTriggerTypes> _levelTriggerType
|
|
= new Property<Common.DAS.Concepts.DAS.Channel.LevelTriggerTypes>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.LevelTriggerType",
|
|
Common.DAS.Concepts.DAS.Channel.LevelTriggerTypes.NONE,
|
|
true);
|
|
/// <summary>
|
|
/// Get/set the serial number for this channel's data source.
|
|
/// </summary>
|
|
[XmlSerializationTag("SerialNumber")]
|
|
public string SerialNumber
|
|
{
|
|
get => _SerialNumber.Value;
|
|
set => _SerialNumber.Value = value;
|
|
}
|
|
private readonly Property<string> _SerialNumber
|
|
= new Property<string>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.SerialNumber",
|
|
null,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the shunt enable indicator for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("ShuntEnabled")]
|
|
public bool ShuntEnabled
|
|
{
|
|
get => _ShuntEnabled.Value;
|
|
set => _ShuntEnabled.Value = value;
|
|
}
|
|
private readonly Property<bool> _ShuntEnabled
|
|
= new Property<bool>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.ShuntEnabled",
|
|
false,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the shunt enable indicator for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("VoltageInsertionCheckEnabled")]
|
|
public bool VoltageInsertionCheckEnabled
|
|
{
|
|
get => _VoltageInsertionCheckEnabled.Value;
|
|
set => _VoltageInsertionCheckEnabled.Value = value;
|
|
}
|
|
private readonly Property<bool> _VoltageInsertionCheckEnabled
|
|
= new Property<bool>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.VoltageInsertionCheckEnabled",
|
|
false,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the shunt enable indicator for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("CalSignalEnabled")]
|
|
public bool CalSignalEnabled
|
|
{
|
|
get => _CalSignalEnabled.Value;
|
|
set => _CalSignalEnabled.Value = value;
|
|
}
|
|
private readonly Property<bool> _CalSignalEnabled
|
|
= new Property<bool>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.CalSignalEnabled",
|
|
false,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the software filter for this channel's data source.
|
|
/// </summary>
|
|
[XmlSerializationTag("SoftwareFilter")]
|
|
public string SoftwareFilter
|
|
{
|
|
get => _SoftwareFilter.Value;
|
|
set => _SoftwareFilter.Value = value;
|
|
}
|
|
private readonly Property<string> _SoftwareFilter
|
|
= new Property<string>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.SoftwareFilter",
|
|
null,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the remove offset option for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("RemoveOffset")]
|
|
public bool RemoveOffset
|
|
{
|
|
get => _RemoveOffset.Value;
|
|
set => _RemoveOffset.Value = value;
|
|
}
|
|
private readonly Property<bool> _RemoveOffset
|
|
= new Property<bool>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.RemoveOffset",
|
|
false,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the zero method option for this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("ZeroMethod")]
|
|
public ZeroMethodType ZeroMethod
|
|
{
|
|
get
|
|
{
|
|
try
|
|
{
|
|
if (null != LinearizationFormula && LinearizationFormula.IsValid())
|
|
{
|
|
switch (LinearizationFormula.NonLinearStyle)
|
|
{
|
|
case NonLinearStyles.IRTraccDiagnosticsZero: _ZeroMethod.Value = ZeroMethodType.UsePreEventDiagnosticsZero; break;
|
|
case NonLinearStyles.IRTraccAverageOverTime: _ZeroMethod.Value = ZeroMethodType.AverageOverTime; break;
|
|
}
|
|
}
|
|
}
|
|
catch (System.Exception) { }
|
|
return _ZeroMethod.Value;
|
|
}
|
|
set => _ZeroMethod.Value = value;
|
|
}
|
|
private readonly Property<ZeroMethodType> _ZeroMethod
|
|
= new Property<ZeroMethodType>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.ZeroMethod",
|
|
SensorConstants.DefaultZeroMethodType, // FB12764: Default in SensorConstants
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set zero average window definition.
|
|
/// </summary>
|
|
[XmlSerializationTag("ZeroAverageWindow")]
|
|
public IntervalSec ZeroAverageWindow
|
|
{
|
|
get => _ZeroAverageWindow.Value;
|
|
set => _ZeroAverageWindow.Value = value;
|
|
}
|
|
private readonly Property<IntervalSec> _ZeroAverageWindow
|
|
= new Property<IntervalSec>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.ZeroAverageWindow",
|
|
null,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Sets DataZeroLevelADC to PreTestADC, logs a message (if not null or empty) and returns value as short
|
|
/// originally added for MS 30446 - Unexpected-DataZeroLevelADC-15292-when-scheduled-recording-with-TSR-AIR-at-100sps
|
|
/// </summary>
|
|
/// <param name="errorMessage"></param>
|
|
/// <returns></returns>
|
|
private short SetDataZeroToPretestADC(string errorMessage)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(errorMessage))
|
|
{
|
|
APILogger.Log(errorMessage);
|
|
}
|
|
_DataZeroLevelAdc = PreTestZeroLevelAdc;
|
|
return (short)_DataZeroLevelAdc;
|
|
}
|
|
|
|
private const int InvalidWindowAverage = short.MinValue;
|
|
/// <summary>
|
|
/// Get data zero level counts.
|
|
/// </summary>
|
|
public override short DataZeroLevelAdc
|
|
{
|
|
get
|
|
{
|
|
if (null == _DataZeroLevelAdc)
|
|
{
|
|
switch (ZeroMethod)
|
|
{
|
|
case ZeroMethodType.AverageOverTime:
|
|
if (WindowAverageADC != InvalidWindowAverage) { _DataZeroLevelAdc = WindowAverageADC; }
|
|
else
|
|
{
|
|
try
|
|
{
|
|
double preTriggerSeconds = 0;
|
|
try
|
|
{
|
|
if (null != ParentModule.TriggerSampleNumbers && ParentModule.TriggerSampleNumbers.Count > 0)
|
|
{
|
|
preTriggerSeconds = 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
|
|
var preTriggerTime = 0D;
|
|
if (null != ParentModule.TriggerSampleNumbers)
|
|
{
|
|
preTriggerTime = (ParentModule.TriggerSampleNumbers[0] - (double)ParentModule.StartRecordSampleNumber) / ParentModule.SampleRateHz;
|
|
}
|
|
if (preTriggerTime < 0) { preTriggerTime = 0; }
|
|
try
|
|
{
|
|
var numSamples = (ulong)((ZeroAverageWindow.End - ZeroAverageWindow.Begin) * ParentModule.SampleRateHz) + 1;
|
|
var windowSamples = new double[numSamples];
|
|
|
|
if (preTriggerTime == 0 && ZeroAverageWindow.Begin < 0)
|
|
{
|
|
//starting index will be invalid, don't use Average over time
|
|
return SetDataZeroToPretestADC($"{FileName} Average over time window is not available, using PreTestZeroLevelADC");
|
|
}
|
|
|
|
var startingIndex = ((ulong)((preTriggerTime + ZeroAverageWindow.Begin) * ParentModule.SampleRateHz));
|
|
|
|
if (startingIndex >= long.MaxValue)
|
|
{
|
|
//starting index is invalid here too, don't use Average over time
|
|
return SetDataZeroToPretestADC($"{FileName} Average over time window is not available, using PreTestZeroLevelADC"); ;
|
|
}
|
|
|
|
var pc = PersistentChannelInfo;
|
|
|
|
//18966 Data incorrect when performing multiple ROI downloads with dual-sensitivity sensor
|
|
//if PersistentChannelInfo is not memorymapped before
|
|
//this process, then unmap it when we are done, otherwise
|
|
//we may hold onto a file handle
|
|
var deleteWhenDone = !pc.IsMemoryMapped;
|
|
var insertPoint = 0;
|
|
for (var i = startingIndex; i < startingIndex + numSamples; i++)
|
|
{
|
|
//don't try to access any indicies that are out of range
|
|
if (i >= 0 && (long)i < pc.Length)
|
|
{
|
|
windowSamples[insertPoint++] = Convert.ToDouble(pc[i]);
|
|
}
|
|
}
|
|
_DataZeroLevelAdc = Convert.ToInt16(windowSamples.Average());
|
|
if (deleteWhenDone) { pc.Dispose(); }
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
return SetDataZeroToPretestADC($"DataZeroLevelADC exception: {ex.Message} {ex.StackTrace}");
|
|
}
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
return SetDataZeroToPretestADC($"DataZeroLevelADC exception: {ex.Message} {ex.StackTrace}");
|
|
}
|
|
}
|
|
break;
|
|
|
|
case ZeroMethodType.UsePreEventDiagnosticsZero:
|
|
return SetDataZeroToPretestADC(null);
|
|
case 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;
|
|
|
|
/// <summary>
|
|
/// Get/set the average value of all ADC so far added to this channel's data set.
|
|
/// </summary>
|
|
public AverageShortValueOverTime AverageAdcOverTime
|
|
{
|
|
get => _AverageAdcOverTime.Value;
|
|
set => _AverageAdcOverTime.Value = value;
|
|
}
|
|
private readonly Property<AverageShortValueOverTime> _AverageAdcOverTime
|
|
= new Property<AverageShortValueOverTime>(
|
|
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.AverageAdcOverTime",
|
|
null,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the initial EU value.
|
|
/// </summary>
|
|
[XmlSerializationTag("InitialEu")]
|
|
public double InitialEu
|
|
{
|
|
get => _InitialEu.Value;
|
|
set => _InitialEu.Value = value;
|
|
}
|
|
private readonly Property<double> _InitialEu
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.InitialEu",
|
|
0.0,
|
|
false
|
|
);
|
|
|
|
[XmlSerializationTag("InitialOffset")]
|
|
public string InitialOffset
|
|
{
|
|
get => _initialOffset.Value;
|
|
set => _initialOffset.Value = value;
|
|
}
|
|
|
|
private readonly Property<string> _initialOffset
|
|
= new Property<string>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.InitialOffset",
|
|
"", true);
|
|
|
|
private const string BeginTagModifier = "Begin";
|
|
private const string EndTagModifier = "End";
|
|
|
|
/// <summary>
|
|
/// Get/set the inversion status of this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("IsInverted")]
|
|
public bool IsInverted
|
|
{
|
|
get => _IsInverted.Value;
|
|
set => _IsInverted.Value = value;
|
|
}
|
|
|
|
private readonly Property<bool> _IsInverted
|
|
= new Property<bool>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.IsInverted",
|
|
false,
|
|
false
|
|
);
|
|
|
|
|
|
/// <summary>
|
|
/// Get/set the Linearization Formula of this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("LinearizationFormula")]
|
|
public DTS.Common.Classes.Sensors.LinearizationFormula LinearizationFormula
|
|
{
|
|
get
|
|
{
|
|
if (!_LinearizationFormula.IsInitialized) { return new DTS.Common.Classes.Sensors.LinearizationFormula(); }
|
|
return _LinearizationFormula.Value;
|
|
}
|
|
set => _LinearizationFormula.Value = value;
|
|
}
|
|
private readonly Property<DTS.Common.Classes.Sensors.LinearizationFormula> _LinearizationFormula
|
|
= new Property<DTS.Common.Classes.Sensors.LinearizationFormula>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.LinearizationFormula",
|
|
null,
|
|
false
|
|
);
|
|
|
|
|
|
[XmlSerializationTag("DigitalMultiplier")]
|
|
public DigitalInputScaleMultiplier DigitalMultiplier
|
|
{
|
|
get
|
|
{
|
|
if (!_DigitalMultiplier.IsInitialized || null == _DigitalMultiplier.Value) { _DigitalMultiplier.Value = new DigitalInputScaleMultiplier(); }
|
|
return _DigitalMultiplier.Value;
|
|
}
|
|
set => _DigitalMultiplier.Value = value;
|
|
}
|
|
private readonly Property<DigitalInputScaleMultiplier> _DigitalMultiplier
|
|
= new Property<DigitalInputScaleMultiplier>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.DigitalMultiplier",
|
|
null,
|
|
false);
|
|
|
|
|
|
[XmlSerializationTag("DigitalMode")]
|
|
public DigitalInputModes DigitalMode
|
|
{
|
|
get
|
|
{
|
|
if (!_digitalMode.IsInitialized) { return DigitalInputModes.CCNC; }
|
|
return _digitalMode.Value;
|
|
}
|
|
set => _digitalMode.Value = value;
|
|
}
|
|
private readonly Property<DigitalInputModes> _digitalMode
|
|
= new Property<DigitalInputModes>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.DigitalMode",
|
|
DigitalInputModes.CCNC, true
|
|
);
|
|
|
|
/// <summary>
|
|
/// The original sensor capacity from the sensor database.
|
|
/// </summary>
|
|
[XmlSerializationTag("SensorCapacity")]
|
|
public double SensorCapacity
|
|
{
|
|
get => _sensorCapacity.Value;
|
|
set => _sensorCapacity.Value = value;
|
|
}
|
|
private readonly Property<double> _sensorCapacity
|
|
= new Property<double>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.SensorCapacity",
|
|
0.0,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// The original sensor polarity from the sensor database.
|
|
/// </summary>
|
|
[XmlSerializationTag("SensorPolarity")]
|
|
public string SensorPolarity
|
|
{
|
|
get => _sensorPolarity.Value;
|
|
set => _sensorPolarity.Value = value;
|
|
}
|
|
private readonly Property<string> _sensorPolarity
|
|
= new Property<string>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.SensorPolarity",
|
|
"",
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// The name of the .chn file in the Binary folder that corresponds to this channel.
|
|
/// </summary>
|
|
[XmlSerializationTag("FileName")]
|
|
public string FileName
|
|
{
|
|
get => _fileName.Value;
|
|
set => _fileName.Value = value;
|
|
}
|
|
private readonly Property<string> _fileName
|
|
= new Property<string>(
|
|
typeof(AnalogInputChannel).Namespace + ".Test.Module.AnalogInputChannel.FileName",
|
|
"",
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Write XML serialization for this object to the specified writer.
|
|
/// </summary>
|
|
///
|
|
/// <param name="writer">
|
|
/// The <see cref="XmlWriter"/> to which this object's XML serialization
|
|
/// will be written.
|
|
/// </param>
|
|
///
|
|
public override void WriteXml(XmlWriter writer)
|
|
{
|
|
var attributeExtractor = new AttributeExtractor<XmlSerializationTagAttribute>();
|
|
writer.WriteStartElement(attributeExtractor.ExtractAttachedAttributeFromObject(this).Value);
|
|
|
|
writeXmlAttributes(writer);
|
|
|
|
writer.WriteEndElement();
|
|
}
|
|
|
|
protected void writeXmlAttributes(XmlWriter writer)
|
|
{
|
|
var line = 0;
|
|
try
|
|
{
|
|
var cult = System.Globalization.CultureInfo.InvariantCulture;
|
|
|
|
var attributeExtractor = new AttributeExtractor<XmlSerializationTagAttribute>();
|
|
|
|
line = 2;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ChannelType").Value, ChannelType.ToString(cult));
|
|
line = 3;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Number").Value, Number.ToString(cult));
|
|
line = 4;
|
|
try
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "DigitalMultiplier").Value, DigitalMultiplier.ToSerializeDbString());
|
|
}
|
|
catch (System.Exception) { }
|
|
line = 5;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "DigitalMode").Value, DigitalMode.ToString());
|
|
line = 6;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Start").Value, Start.ToString(cult));
|
|
line = 7;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Bridge").Value, Bridge.ToString());
|
|
line = 8;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "BridgeResistanceOhms").Value, BridgeResistanceOhms.ToString(cult));
|
|
|
|
writer.WriteAttributeString(
|
|
attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ZeroPoint").Value,
|
|
ZeroPoint.ToString(cult));
|
|
|
|
line = 9;
|
|
try
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ChannelDescriptionString").Value, ChannelDescriptionString.ToString(cult));
|
|
}
|
|
catch { }
|
|
line = 10;
|
|
try
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ChannelName2").Value, ChannelName2.ToString());
|
|
}
|
|
catch { }
|
|
try
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ChannelId").Value, ChannelId);
|
|
}
|
|
catch (System.Exception) { }
|
|
line = 11;
|
|
try
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "HardwareChannelName").Value, HardwareChannelName.ToString());
|
|
}
|
|
catch { }
|
|
line = 12;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Description").Value, Description.ToString(cult));
|
|
line = 13;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "DesiredRange").Value, DesiredRange.ToString(cult));
|
|
line = 14;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Sensitivity").Value, Sensitivity.ToString(cult));
|
|
line = 15;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SoftwareFilter").Value, SoftwareFilter.ToString(cult));
|
|
line = 16;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ProportionalToExcitation").Value, ProportionalToExcitation.ToString(cult));
|
|
line = 17;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "IsInverted").Value, IsInverted.ToString(cult));
|
|
line = 18;
|
|
if (null == LinearizationFormula) { LinearizationFormula = new DTS.Common.Classes.Sensors.LinearizationFormula(); }
|
|
line = 19;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "LinearizationFormula").Value, LinearizationFormula.ToSerializeString());
|
|
line = 20;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "IsSubsampled").Value, IsSubsampled.ToString(cult));
|
|
line = 21;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "AbsoluteDisplayOrder").Value, AbsoluteDisplayOrder.ToString(cult));
|
|
line = 22;
|
|
if (IsLastCalibrationDateValid)
|
|
{
|
|
line = 23;
|
|
try
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "LastCalibrationDate").Value, LastCalibrationDate.ToString(cult));
|
|
}
|
|
catch { }
|
|
}
|
|
if (IsCalDueDateValid)
|
|
{
|
|
line = 24;
|
|
try
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "CalDueDate").Value, CalDueDate.ToString(cult));
|
|
}
|
|
catch { }
|
|
}
|
|
if (null == SensorID) { SensorID = ""; }
|
|
if (IsSensorIDValid)
|
|
{
|
|
line = 25;
|
|
try
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SensorID").Value, SensorID.ToString());
|
|
}
|
|
catch { }
|
|
}
|
|
if (IsOffsetToleranceLowMvValid)
|
|
{
|
|
line = 26;
|
|
try
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "OffsetToleranceLowMv").Value, OffsetToleranceLowMv.ToString(cult));
|
|
}
|
|
catch { }
|
|
}
|
|
if (IsOffsetToleranceHighMvValid)
|
|
{
|
|
line = 27;
|
|
try
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "OffsetToleranceHighMv").Value, OffsetToleranceHighMv.ToString(cult));
|
|
}
|
|
catch { }
|
|
}
|
|
|
|
if (IsDataFlagValid)
|
|
{
|
|
try { writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "DataFlag").Value, DataFlag.ToString(cult)); }
|
|
catch { }
|
|
}
|
|
line = 28;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ExcitationVoltage").Value, ExcitationVoltage.ToString());
|
|
line = 29;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "EngineeringUnits").Value, EngineeringUnits.ToString(cult));
|
|
line = 30;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SerialNumber").Value, SerialNumber.ToString(cult));
|
|
line = 31;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "CalSignalEnabled").Value, CalSignalEnabled.ToString(cult));
|
|
line = 32;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ShuntEnabled").Value, ShuntEnabled.ToString(cult));
|
|
line = 33;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "VoltageInsertionCheckEnabled").Value, VoltageInsertionCheckEnabled.ToString(cult));
|
|
line = 34;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "RemoveOffset").Value, RemoveOffset.ToString(cult));
|
|
//writer.WriteAttributeString( attributeExtractor.ExtractAttachedAttributeFromProperty( this, "ZeroMethod" ).Value, this.ZeroMethod .ToString( ) );
|
|
line = 35;
|
|
switch (ZeroMethod)
|
|
{
|
|
case ZeroMethodType.UsePreEventDiagnosticsZero:
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ZeroMethod").Value, "UsePreCalZero");
|
|
break;
|
|
default:
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ZeroMethod").Value, ZeroMethod.ToString());
|
|
break;
|
|
}
|
|
line = 36;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ZeroAverageWindow").Value + BeginTagModifier, ZeroAverageWindow.Begin.ToString(cult));
|
|
line = 37;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ZeroAverageWindow").Value + EndTagModifier, ZeroAverageWindow.End.ToString(cult));
|
|
line = 38;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "InitialEu").Value, InitialEu.ToString(cult));
|
|
line = 39;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "InitialOffset").Value, InitialOffset);
|
|
line = 40;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UnsubsampledSampleRateHz").Value, UnsubsampledSampleRateHz.ToString(cult));
|
|
line = 41;
|
|
if (!string.IsNullOrEmpty(UserValue1))
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UserValue1").Value, UserValue1);
|
|
}
|
|
line = 42;
|
|
if (!string.IsNullOrEmpty(UserValue2))
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UserValue2").Value, UserValue2);
|
|
}
|
|
line = 43;
|
|
if (!string.IsNullOrEmpty(UserValue3))
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UserValue3").Value, UserValue3);
|
|
}
|
|
line = 44;
|
|
// Potentially valid "uninitialized" values need special handling.
|
|
if (_MeasuredShuntDeflectionMv.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "MeasuredShuntDeflectionMv").Value, MeasuredShuntDeflectionMv.ToString(cult));
|
|
line = 45;
|
|
if (_MeasuredGain.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "MeasuredGain").Value, MeasuredGain.ToString(cult));
|
|
line = 46;
|
|
if (_ExpectedGain.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ExpectedGain").Value, ExpectedGain.ToString(cult));
|
|
line = 47;
|
|
if (_TargetShuntDeflectionMv.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TargetShuntDeflectionMv").Value, TargetShuntDeflectionMv.ToString(cult));
|
|
line = 48;
|
|
if (_MeasuredCalSignalMv.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "MeasuredCalSignalMv").Value, MeasuredCalSignalMv.ToString(cult));
|
|
line = 49;
|
|
if (_TargetCalSignalMv.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TargetCalSignalMv").Value, TargetCalSignalMv.ToString(cult));
|
|
line = 50;
|
|
if (_MeasuredExcitationVoltage.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "MeasuredExcitationVoltage").Value, MeasuredExcitationVoltage.ToString(cult));
|
|
line = 51;
|
|
if (_FactoryExcitationVoltage.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "FactoryExcitationVoltage").Value, FactoryExcitationVoltage.ToString(cult));
|
|
line = 52;
|
|
if (_TimeOfFirstSampleSec.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TimeOfFirstSampleSec").Value, TimeOfFirstSampleSec.ToString(cult));
|
|
line = 53;
|
|
// Potentially valid "uninitialized" and/or nullable values need special handling.
|
|
if (_TriggerAboveThresholdEu.IsInitialized && null != TriggerAboveThresholdEu)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TriggerAboveThresholdEu").Value, ((double)TriggerAboveThresholdEu).ToString(cult));
|
|
line = 54;
|
|
if (_TriggerBelowThresholdEu.IsInitialized && null != TriggerBelowThresholdEu)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TriggerBelowThresholdEu").Value, ((double)TriggerBelowThresholdEu).ToString(cult));
|
|
line = 55;
|
|
if (_Multiplier.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Multiplier").Value, Multiplier.ToString(cult));
|
|
line = 56;
|
|
if (_UserOffsetEU.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UserOffsetEU").Value, UserOffsetEU.ToString(cult));
|
|
line = 57;
|
|
if (_UnitConversion.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UnitConversion").Value, UnitConversion.ToString(cult));
|
|
line = 58;
|
|
if (_AtCapacity.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "AtCapacity").Value, AtCapacity.ToString(cult));
|
|
line = 59;
|
|
if (_CapacityOutputIsBasedOn.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "CapacityOutputIsBasedOn").Value, CapacityOutputIsBasedOn.ToString(cult));
|
|
line = 60;
|
|
if (_SensitivityUnits.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SensitivityUnits").Value, SensitivityUnits.ToString());
|
|
line = 61;
|
|
if (_isSquibChannel.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "IsSquibChannel").Value, IsSquibChannel.ToString(cult));
|
|
line = 62;
|
|
if (_sensorCapacity.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SensorCapacity").Value, SensorCapacity.ToString(cult));
|
|
line = 63;
|
|
if (_sensorCapacity.IsInitialized)
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "SensorPolarity").Value, SensorPolarity);
|
|
line = 64;
|
|
if (ExpressDataInlineOnXmlSerialization)
|
|
Data.WriteXml(writer);
|
|
line = 65;
|
|
try
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ChannelGroupName").Value, ChannelGroupName);
|
|
}
|
|
catch (System.Exception) { }
|
|
line = 66;
|
|
if (_Manufacturer.IsInitialized)
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Manufacturer").Value, Manufacturer.ToString(cult));
|
|
}
|
|
line = 67;
|
|
if (_Model.IsInitialized)
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "Model").Value, Model.ToString(cult));
|
|
}
|
|
line = 68;
|
|
try
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "OriginalChannelName").Value, OriginalChannelName?.ToString() ?? "UNKNOWN");
|
|
}
|
|
catch { }
|
|
line = 69;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "IsSupersampled").Value, IsSupersampled.ToString(cult));
|
|
line = 70;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UnsupersampledSampleRateHz").Value, UnsupersampledSampleRateHz.ToString(cult));
|
|
line = 71;
|
|
|
|
if (_UserChannelName.IsInitialized)
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UserChannelName").Value, UserChannelName.ToString());
|
|
}
|
|
|
|
if (_UserCode.IsInitialized)
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UserCode").Value, UserCode.ToString());
|
|
}
|
|
if (_IsoCode.IsInitialized)
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "IsoCode").Value, IsoCode.ToString());
|
|
}
|
|
if (_IsoChannelName.IsInitialized)
|
|
{
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "IsoChannelName").Value, IsoChannelName.ToString());
|
|
}
|
|
|
|
//Since ExtractAttachedAttributeFromProperty fails when passing this.Data, put the value in this.
|
|
UseEUScaler = Data.UseEUScaleFactors;
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UseEUScaler").Value, UseEUScaler.ToString(cult));
|
|
|
|
writer.WriteAttributeString(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ScaleFactorEU").Value, Data.ScaleFactorEU.ToString(cult));
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
throw new Exception("encountered problem converting " + GetType().FullName + " object to XML, Line: " + line.ToString(), ex);
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Read XML serialization for this object from the specified reader.
|
|
/// </summary>
|
|
///
|
|
/// <param name="reader">
|
|
/// The <see cref="XmlReader"/> from which this object's XML serialization
|
|
/// will be read.
|
|
/// </param>
|
|
///
|
|
//Note: This does not read in the parent (Channel) xml
|
|
public override void ReadXml(XmlReader reader)
|
|
{
|
|
try
|
|
{
|
|
var cult = new System.Globalization.CultureInfo("");
|
|
var attributeExtractor = new AttributeExtractor<XmlSerializationTagAttribute>();
|
|
|
|
var xmlAttributeDecoder
|
|
= new PropertyAttributeDecoder<AnalogInputChannel>(this);
|
|
|
|
if (null != reader.GetAttribute("AbsoluteDisplayOrder"))
|
|
{
|
|
try { AbsoluteDisplayOrder = xmlAttributeDecoder.ExtractIntProperty("AbsoluteDisplayOrder", reader); }
|
|
catch (System.Exception) { }
|
|
}
|
|
|
|
if (null != reader.GetAttribute("Multiplier"))
|
|
{
|
|
try { Data.Multiplier = xmlAttributeDecoder.ExtractDoubleProperty("Multiplier", reader); Multiplier = xmlAttributeDecoder.ExtractDoubleProperty("Multiplier", reader); }
|
|
catch (System.Exception ex) { var temp2 = ex.Message; }
|
|
}
|
|
|
|
if (null != reader.GetAttribute("UnitConversion"))
|
|
{
|
|
try { Data.UnitConversion = xmlAttributeDecoder.ExtractDoubleProperty("UnitConversion", reader); UnitConversion = xmlAttributeDecoder.ExtractDoubleProperty("UnitConversion", reader); }
|
|
catch (System.Exception ex) { var temp2 = ex.Message; }
|
|
}
|
|
|
|
|
|
if (null != reader.GetAttribute("UserOffsetEU"))
|
|
{
|
|
try { Data.UserOffsetEU = xmlAttributeDecoder.ExtractDoubleProperty("UserOffsetEU", reader); UserOffsetEU = xmlAttributeDecoder.ExtractDoubleProperty("UserOffsetEU", reader); }
|
|
catch (System.Exception ex) { var temp2 = ex.Message; }
|
|
}
|
|
|
|
if (null != reader.GetAttribute("AtCapacity"))
|
|
{
|
|
try { AtCapacity = xmlAttributeDecoder.ExtractBoolProperty("AtCapacity", reader, false); }
|
|
catch (System.Exception ex) { var temp2 = ex.Message; }
|
|
}
|
|
|
|
if (null != reader.GetAttribute("CapacityOutputIsBasedOn"))
|
|
{
|
|
try { CapacityOutputIsBasedOn = xmlAttributeDecoder.ExtractDoubleProperty("CapacityOutputIsBasedOn", reader); }
|
|
catch (System.Exception ex) { var temp2 = ex.Message; }
|
|
}
|
|
|
|
if (null != reader.GetAttribute("SensitivityUnits"))
|
|
{
|
|
try { SensitivityUnits = (SensorConstants.SensUnits)xmlAttributeDecoder.ExtractEnumProperty("SensitivityUnits", typeof(Common.DAS.Concepts.Test.Module.Channel.Sensor.SensUnits), reader); }
|
|
catch (System.Exception ex) { var temp2 = ex.Message; }
|
|
}
|
|
Number = xmlAttributeDecoder.ExtractIntProperty("Number", reader);
|
|
BridgeResistanceOhms = xmlAttributeDecoder.ExtractDoubleProperty("BridgeResistanceOhms", reader);
|
|
try
|
|
{
|
|
if (null != reader.GetAttribute("ZeroPoint"))
|
|
{
|
|
ZeroPoint = xmlAttributeDecoder.ExtractDoubleProperty("ZeroPoint", reader);
|
|
}
|
|
}
|
|
catch (System.Exception)
|
|
{
|
|
}
|
|
ChannelDescriptionString = xmlAttributeDecoder.ExtractStringProperty("ChannelDescriptionString", reader);
|
|
try
|
|
{
|
|
OriginalChannelName = xmlAttributeDecoder.ExtractStringProperty("OriginalChannelName", reader);
|
|
}
|
|
catch (System.Exception) { }
|
|
try
|
|
{
|
|
ChannelName2 = xmlAttributeDecoder.ExtractStringProperty("ChannelName2", reader);
|
|
}
|
|
catch (System.Exception) { }
|
|
try
|
|
{
|
|
HardwareChannelName = xmlAttributeDecoder.ExtractStringProperty("HardwareChannelName", reader);
|
|
}
|
|
catch (System.Exception) { }
|
|
try
|
|
{
|
|
ChannelId = xmlAttributeDecoder.ExtractStringProperty("ChannelId", reader);
|
|
}
|
|
catch (System.Exception) { }
|
|
try
|
|
{
|
|
ChannelGroupName = xmlAttributeDecoder.ExtractStringProperty("ChannelGroupName", reader);
|
|
}
|
|
catch (System.Exception) { }
|
|
|
|
DesiredRange = xmlAttributeDecoder.ExtractDoubleProperty("DesiredRange", reader);
|
|
Description = xmlAttributeDecoder.ExtractStringProperty("Description", reader);
|
|
Manufacturer = xmlAttributeDecoder.ExtractStringProperty("Manufacturer", reader);
|
|
Model = xmlAttributeDecoder.ExtractStringProperty("Model", reader);
|
|
EngineeringUnits = xmlAttributeDecoder.ExtractStringProperty("EngineeringUnits", reader);
|
|
|
|
try
|
|
{
|
|
InitialOffset = xmlAttributeDecoder.ExtractStringProperty("InitialOffset", reader);
|
|
}
|
|
catch (System.Exception) { }
|
|
|
|
InitialEu = xmlAttributeDecoder.ExtractDoubleProperty("InitialEu", reader);
|
|
ProportionalToExcitation = xmlAttributeDecoder.ExtractBoolProperty("ProportionalToExcitation", reader);
|
|
RemoveOffset = xmlAttributeDecoder.ExtractBoolProperty("RemoveOffset", reader);
|
|
Sensitivity = xmlAttributeDecoder.ExtractDoubleProperty("Sensitivity", reader);
|
|
|
|
try
|
|
{
|
|
if (DateTime.TryParse(xmlAttributeDecoder.ExtractStringProperty("LastCalibrationDate", reader), cult, System.Globalization.DateTimeStyles.None, out DateTime dt))
|
|
{
|
|
LastCalibrationDate = dt;
|
|
}
|
|
}
|
|
catch { }
|
|
|
|
try
|
|
{
|
|
if (DateTime.TryParse(xmlAttributeDecoder.ExtractStringProperty("CalDueDate", reader), cult, System.Globalization.DateTimeStyles.None, out DateTime dt))
|
|
{
|
|
CalDueDate = dt;
|
|
}
|
|
}
|
|
catch { }
|
|
|
|
SerialNumber = xmlAttributeDecoder.ExtractStringProperty("SerialNumber", reader);
|
|
try { CalSignalEnabled = xmlAttributeDecoder.ExtractBoolProperty("CalSignalEnabled", reader, false); }
|
|
catch { CalSignalEnabled = false; }
|
|
ShuntEnabled = xmlAttributeDecoder.ExtractBoolProperty("ShuntEnabled", reader);
|
|
try
|
|
{
|
|
VoltageInsertionCheckEnabled = xmlAttributeDecoder.ExtractBoolProperty("VoltageInsertionCheckEnabled", reader, false);
|
|
}
|
|
catch { VoltageInsertionCheckEnabled = false; }
|
|
SoftwareFilter = xmlAttributeDecoder.ExtractStringProperty("SoftwareFilter", reader);
|
|
|
|
Bridge = (SensorConstants.BridgeType)xmlAttributeDecoder.ExtractEnumProperty("Bridge", typeof(SensorConstants.BridgeType), reader);
|
|
ExcitationVoltage = (ExcitationVoltageOptions.ExcitationVoltageOption)xmlAttributeDecoder.ExtractEnumProperty("ExcitationVoltage", typeof(ExcitationVoltageOptions.ExcitationVoltageOption), reader);
|
|
|
|
var sZeroMethod = xmlAttributeDecoder.ExtractStringProperty("ZeroMethod", reader);
|
|
try
|
|
{
|
|
if (null != sZeroMethod && "UsePreCalZero" == sZeroMethod)
|
|
{
|
|
ZeroMethod = ZeroMethodType.UsePreEventDiagnosticsZero;
|
|
}
|
|
else
|
|
{
|
|
ZeroMethod = (ZeroMethodType)Enum.Parse(typeof(ZeroMethodType), sZeroMethod);
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
var originalZeroMethodType
|
|
= (OriginalZeroMethodType)xmlAttributeDecoder.ExtractEnumProperty("ZeroMethod", typeof(OriginalZeroMethodType), reader);
|
|
switch (originalZeroMethodType)
|
|
{
|
|
case OriginalZeroMethodType.AverageOverTime:
|
|
ZeroMethod = ZeroMethodType.AverageOverTime;
|
|
break;
|
|
|
|
case OriginalZeroMethodType.UsePreCalZero:
|
|
ZeroMethod = ZeroMethodType.UsePreEventDiagnosticsZero;
|
|
break;
|
|
|
|
case OriginalZeroMethodType.None:
|
|
ZeroMethod = ZeroMethodType.None;
|
|
break;
|
|
|
|
default://
|
|
// If we've gotten here, we've changed the enum and forgotten to put in
|
|
// a corresponding conversion.
|
|
//
|
|
|
|
ZeroMethod = ZeroMethodType.None;
|
|
break;
|
|
}
|
|
}
|
|
|
|
try
|
|
{
|
|
UnsubsampledSampleRateHz = float.Parse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UnsubsampledSampleRateHz").Value), cult);
|
|
}
|
|
catch (System.Exception) { UnsubsampledSampleRateHz = ParentModule.SampleRateHz; }
|
|
|
|
try
|
|
{
|
|
UserValue1 = xmlAttributeDecoder.ExtractStringProperty("UserValue1", reader);
|
|
}
|
|
catch (System.Exception) { }
|
|
try
|
|
{
|
|
UserValue2 = xmlAttributeDecoder.ExtractStringProperty("UserValue2", reader);
|
|
}
|
|
catch (System.Exception) { }
|
|
try
|
|
{
|
|
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))
|
|
{
|
|
MeasuredShuntDeflectionMv = temp;
|
|
}
|
|
|
|
}
|
|
catch (System.Exception) { }
|
|
|
|
try
|
|
{
|
|
if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "MeasuredGain").Value), System.Globalization.NumberStyles.Any, cult, out temp))
|
|
{
|
|
MeasuredGain = temp;
|
|
}
|
|
}
|
|
catch (System.Exception) { }
|
|
|
|
try
|
|
{
|
|
if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "ExpectedGain").Value), System.Globalization.NumberStyles.Any, cult, out temp))
|
|
{
|
|
ExpectedGain = temp;
|
|
}
|
|
}
|
|
catch (System.Exception) { }
|
|
|
|
try
|
|
{
|
|
if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TargetShuntDeflectionMv").Value), System.Globalization.NumberStyles.Any, cult, out temp))
|
|
{
|
|
TargetShuntDeflectionMv = temp;
|
|
}
|
|
}
|
|
catch (System.Exception) { }
|
|
|
|
try
|
|
{
|
|
if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "MeasuredCalSignalMv").Value), System.Globalization.NumberStyles.Any, cult, out temp))
|
|
{
|
|
MeasuredCalSignalMv = temp;
|
|
}
|
|
|
|
}
|
|
catch (System.Exception) { }
|
|
|
|
try
|
|
{
|
|
if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TargetCalSignalMv").Value), System.Globalization.NumberStyles.Any, cult, out temp))
|
|
{
|
|
TargetCalSignalMv = temp;
|
|
}
|
|
}
|
|
catch (System.Exception) { }
|
|
|
|
try
|
|
{
|
|
if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TriggerAboveThresholdEu").Value), System.Globalization.NumberStyles.Any, cult, out temp))
|
|
{
|
|
TriggerAboveThresholdEu = temp;
|
|
}
|
|
}
|
|
catch (System.Exception) { }
|
|
|
|
try
|
|
{
|
|
if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "TriggerBelowThresholdEu").Value), System.Globalization.NumberStyles.Any, cult, out temp))
|
|
{
|
|
TriggerBelowThresholdEu = temp;
|
|
}
|
|
}
|
|
catch { }
|
|
|
|
|
|
try
|
|
{
|
|
if (double.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "MeasuredExcitationVoltage").Value), System.Globalization.NumberStyles.Float, cult, out temp))
|
|
{
|
|
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))
|
|
{
|
|
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))
|
|
{
|
|
TimeOfFirstSampleSec = temp;
|
|
}
|
|
}
|
|
catch (System.Exception) { }
|
|
|
|
|
|
try { IsInverted = xmlAttributeDecoder.ExtractBoolProperty("IsInverted", reader, false); }
|
|
catch (System.Exception) { IsInverted = false; }
|
|
|
|
try { IsSubsampled = xmlAttributeDecoder.ExtractBoolProperty("IsSubsampled", reader, false); }
|
|
catch (System.Exception) { IsSubsampled = false; }
|
|
|
|
try
|
|
{
|
|
LinearizationFormula = new DTS.Common.Classes.Sensors.LinearizationFormula();
|
|
LinearizationFormula.FromSerializeString(xmlAttributeDecoder.ExtractStringProperty("LinearizationFormula", reader));
|
|
}
|
|
catch (System.Exception) { LinearizationFormula = null; }
|
|
|
|
try
|
|
{
|
|
DigitalMultiplier = new DigitalInputScaleMultiplier();
|
|
DigitalMultiplier.FromDbSerializeString(xmlAttributeDecoder.ExtractStringProperty("DigitalMultiplier", reader));
|
|
}
|
|
catch (System.Exception) { DigitalMultiplier = new DigitalInputScaleMultiplier(); }
|
|
|
|
try
|
|
{
|
|
var mode = DigitalInputModes.CCNC;
|
|
Enum.TryParse(xmlAttributeDecoder.ExtractStringProperty("DigitalMode", reader), out mode);
|
|
DigitalMode = mode;
|
|
}
|
|
catch (System.Exception) { }
|
|
|
|
try
|
|
{
|
|
if (DateTime.TryParse(reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "LastCalibrationDate").Value), cult, System.Globalization.DateTimeStyles.None, out DateTime calDate))
|
|
{
|
|
LastCalibrationDate = calDate;
|
|
}
|
|
else { LastCalibrationDate = DateTime.MinValue; }
|
|
}
|
|
catch
|
|
{
|
|
LastCalibrationDate = DateTime.MinValue;
|
|
}
|
|
|
|
try { SensorID = xmlAttributeDecoder.ExtractStringProperty("SensorID", reader); }
|
|
catch (System.Exception) { SensorID = ""; }
|
|
|
|
try { OffsetToleranceLowMv = xmlAttributeDecoder.ExtractDoubleProperty("OffsetToleranceLowMv", reader); }
|
|
catch (System.Exception) { OffsetToleranceLowMv = 0; }
|
|
|
|
try { OffsetToleranceHighMv = xmlAttributeDecoder.ExtractDoubleProperty("OffsetToleranceHighMv", reader); }
|
|
catch (System.Exception) { OffsetToleranceHighMv = 0; }
|
|
|
|
try
|
|
{
|
|
DataFlag = xmlAttributeDecoder.ExtractIntProperty("DataFlag", reader);
|
|
}
|
|
catch (System.Exception) { DataFlag = new DataFlagAttributeCoder().DecodeAttributeValue(Common.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 Exception("encountered problem extracting start time value string", ex);
|
|
}
|
|
|
|
try { Start = DateTime.Parse(startTimeString, cult); }
|
|
catch (System.Exception)
|
|
{
|
|
Start = DateTime.Now;
|
|
// throw new Test.Module.AnalogInputChannel.Exception( "encountered problem parsing DateTime value " + ( null != startTimeString ? ( "\"" + startTimeString + "\"" ) : "<<NULL>>" ), ex );
|
|
}
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
throw new 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 Exception("encountered problem extracting ZeroAverageWindow begin value string", ex);
|
|
}
|
|
double zeroAverageWindowBeginValue;
|
|
try { zeroAverageWindowBeginValue = double.Parse(zeroAverageWindowBeginString, cult); }
|
|
catch (System.Exception ex)
|
|
{
|
|
throw new Exception("encountered problem parsing double value " + (null != zeroAverageWindowBeginString ? ("\"" + zeroAverageWindowBeginString + "\"") : "<<NULL>"), 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 Exception("encountered problem extacting ZeroAverageWindow end value string", ex);
|
|
}
|
|
double zeroAverageWindowEndValue;
|
|
try { zeroAverageWindowEndValue = double.Parse(zeroAverageWindowEndString, cult); }
|
|
catch (System.Exception ex)
|
|
{
|
|
throw new Exception("encountered problem parsing double value " + (null != zeroAverageWindowEndString ? ("\"" + zeroAverageWindowEndString + "\"") : "<<NULL>"), ex);
|
|
}
|
|
|
|
try
|
|
{ //
|
|
// Synthesize new zero average window value.
|
|
//
|
|
ZeroAverageWindow = new IntervalSec(zeroAverageWindowBeginValue, zeroAverageWindowEndValue);
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
throw new Exception("encountered problem synthesizing zero average window from begin: " + zeroAverageWindowBeginValue.ToString() + ", end: " + zeroAverageWindowEndValue.ToString(), ex);
|
|
}
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
throw new Exception("encountered problem extracting zero average window property", ex);
|
|
}
|
|
|
|
if (ExpressDataInlineOnXmlSerialization)
|
|
{
|
|
reader.Read();
|
|
short[] dummyValues = { 0 };
|
|
Data = new DataArray<short>(dummyValues);
|
|
Data.ReadXml(reader);
|
|
}
|
|
|
|
try { IsSquibChannel = xmlAttributeDecoder.ExtractBoolProperty("IsSquibChannel", reader, false); }
|
|
catch (System.Exception) { IsSquibChannel = false; }
|
|
|
|
try
|
|
{
|
|
if (xmlAttributeDecoder.ExtractDoubleProperty("SensorCapacity", reader, out double d))
|
|
{
|
|
SensorCapacity = d;
|
|
}
|
|
else
|
|
{
|
|
SensorCapacity = 0D;
|
|
}
|
|
}
|
|
catch (System.Exception) { SensorCapacity = 0; }
|
|
|
|
try
|
|
{
|
|
SensorPolarity = xmlAttributeDecoder.ExtractStringProperty("SensorPolarity", reader);
|
|
}
|
|
catch (System.Exception) { SensorPolarity = ""; }
|
|
|
|
var userCode = reader.GetAttribute("UserCode");
|
|
if (null != userCode)
|
|
{
|
|
UserCode = userCode;
|
|
}
|
|
|
|
var userChannelName = reader.GetAttribute("UserChannelName");
|
|
if (null != userChannelName)
|
|
{
|
|
UserChannelName = userChannelName;
|
|
}
|
|
|
|
var isoCode = reader.GetAttribute("IsoCode");
|
|
if (null != isoCode)
|
|
{
|
|
IsoCode = isoCode;
|
|
}
|
|
|
|
var isoChannelName = reader.GetAttribute("IsoChannelName");
|
|
if (null != isoChannelName)
|
|
{
|
|
IsoChannelName = isoChannelName;
|
|
}
|
|
|
|
try { IsSupersampled = xmlAttributeDecoder.ExtractBoolProperty("IsSupersampled", reader, false); }
|
|
catch (System.Exception) { IsSupersampled = false; }
|
|
|
|
try
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(reader.GetAttribute("UseEUScaler")))
|
|
{
|
|
|
|
Data.UseEUScaleFactors = xmlAttributeDecoder.ExtractBoolProperty("UseEUScaler", reader, false);
|
|
}
|
|
}
|
|
catch (System.Exception) { Data.UseEUScaleFactors = false; }
|
|
|
|
try
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(reader.GetAttribute("ScaleFactorEU")))
|
|
{
|
|
Data.ScaleFactorEU = xmlAttributeDecoder.ExtractDoubleProperty("ScaleFactorEU", reader);
|
|
}
|
|
}
|
|
catch (System.Exception) { Data.ScaleFactorEU = 0; }
|
|
|
|
try
|
|
{
|
|
var val = reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(this, "UnsupersampledSampleRateHz").Value);
|
|
if (string.IsNullOrWhiteSpace(val))
|
|
{
|
|
UnsupersampledSampleRateHz = 0F;
|
|
}
|
|
else { UnsupersampledSampleRateHz = float.Parse(val, cult); }
|
|
}
|
|
catch (System.Exception) { UnsupersampledSampleRateHz = 0F; }
|
|
}
|
|
|
|
catch (System.Exception ex)
|
|
{
|
|
throw new Exception("encountered problem converting XML to " + GetType().FullName + " object", ex);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Test the specified object for equality with this object.
|
|
/// </summary>
|
|
///
|
|
/// <param name="obj">
|
|
/// The <see cref="object"/> to be tested for equality.
|
|
/// </param>
|
|
///
|
|
/// <returns>
|
|
/// <see cref="bool"/> true if the specified object has memeberwise equality with
|
|
/// this object; false otherwise.
|
|
/// </returns>
|
|
///
|
|
public override bool Equals(object obj)
|
|
{
|
|
try
|
|
{
|
|
var that = obj as AnalogInputChannel;
|
|
return null != obj
|
|
|
|
// Must-be-initialized properties.
|
|
&& ChannelId.Equals(that.ChannelId)
|
|
&& ChannelGroupName.Equals(that.ChannelGroupName)
|
|
&& Data.Equals(that.Data)
|
|
&& ExpressDataInlineOnXmlSerialization.Equals(that.ExpressDataInlineOnXmlSerialization)
|
|
&& Number.Equals(that.Number)
|
|
&& Bridge.Equals(that.Bridge)
|
|
&& BridgeResistanceOhms.Equals(that.BridgeResistanceOhms)
|
|
&& ZeroPoint.Equals(that.ZeroPoint)
|
|
&& Description.Equals(that.Description, StringComparison.OrdinalIgnoreCase)
|
|
&& DesiredRange.Equals(that.DesiredRange)
|
|
&& EngineeringUnits.Equals(that.EngineeringUnits, StringComparison.OrdinalIgnoreCase)
|
|
&& ExcitationVoltage.Equals(that.ExcitationVoltage)
|
|
&& InitialEu.Equals(that.InitialEu)
|
|
&& InitialOffset.Equals(that.InitialOffset)
|
|
&& ProportionalToExcitation.Equals(that.ProportionalToExcitation)
|
|
&& IsInverted.Equals(that.IsInverted)
|
|
&& IsSubsampled.Equals(that.IsSubsampled)
|
|
//handle nullable
|
|
&& IsLastCalibrationDateValid && that.IsLastCalibrationDateValid ? LastCalibrationDate.Equals(that.LastCalibrationDate)
|
|
: that.IsLastCalibrationDateValid ? false : true
|
|
&& IsCalDueDateValid && that.IsCalDueDateValid ? CalDueDate.Equals(that.CalDueDate)
|
|
: that.IsCalDueDateValid ? false : true
|
|
&& IsSensorIDValid && that.IsSensorIDValid ? SensorID.Equals(that.SensorID)
|
|
: that.IsSensorIDValid ? false : true
|
|
&& IsOffsetToleranceLowMvValid && that.IsOffsetToleranceLowMvValid ? OffsetToleranceLowMv.Equals(that.OffsetToleranceLowMv)
|
|
: that.IsOffsetToleranceLowMvValid ? false : true
|
|
&& IsOffsetToleranceHighMvValid && that.IsOffsetToleranceHighMvValid ? OffsetToleranceHighMv.Equals(that.OffsetToleranceHighMv)
|
|
: that.IsOffsetToleranceHighMvValid ? false : true
|
|
&& (
|
|
(null == LinearizationFormula && null == that.LinearizationFormula) ||
|
|
(null != LinearizationFormula && LinearizationFormula.Equals(that.LinearizationFormula))
|
|
)
|
|
&& IsoCode.Equals(that.IsoCode, StringComparison.OrdinalIgnoreCase)
|
|
&& RemoveOffset.Equals(that.RemoveOffset)
|
|
&& Sensitivity.Equals(that.Sensitivity)
|
|
&& SerialNumber.Equals(that.SerialNumber, StringComparison.OrdinalIgnoreCase)
|
|
&& ShuntEnabled.Equals(that.ShuntEnabled)
|
|
&& VoltageInsertionCheckEnabled.Equals(that.VoltageInsertionCheckEnabled)
|
|
&& CalSignalEnabled.Equals(that.CalSignalEnabled)
|
|
&& SoftwareFilter.Equals(that.SoftwareFilter)
|
|
&& UnsubsampledSampleRateHz.Equals(that.UnsubsampledSampleRateHz)
|
|
&& ZeroAverageWindow.Equals(that.ZeroAverageWindow)
|
|
&& ZeroMethod.Equals(that.ZeroMethod)
|
|
&& Start.ToString().Equals(that.Start.ToString())
|
|
&& AbsoluteDisplayOrder.Equals(that.AbsoluteDisplayOrder)
|
|
// Potentially valid-as-uninitialized and/or nullable properties.
|
|
&& _MeasuredShuntDeflectionMv.IsInitialized ? MeasuredShuntDeflectionMv.Equals(that.MeasuredShuntDeflectionMv) : _MeasuredShuntDeflectionMv.IsInitialized == that._MeasuredShuntDeflectionMv.IsInitialized
|
|
&& _TargetShuntDeflectionMv.IsInitialized ? TargetShuntDeflectionMv.Equals(that.TargetShuntDeflectionMv) : _TargetShuntDeflectionMv.IsInitialized == that._TargetShuntDeflectionMv.IsInitialized
|
|
&& _TriggerAboveThresholdEu.IsInitialized ? TriggerAboveThresholdEu.Equals(that.TriggerAboveThresholdEu) : _TriggerAboveThresholdEu.IsInitialized == that._TriggerAboveThresholdEu.IsInitialized
|
|
&& _TriggerBelowThresholdEu.IsInitialized ? TriggerBelowThresholdEu.Equals(that.TriggerBelowThresholdEu) : _TriggerBelowThresholdEu.IsInitialized == that._TriggerBelowThresholdEu.IsInitialized
|
|
&& _MeasuredGain.IsInitialized ? MeasuredGain.Equals(that.MeasuredGain) : _MeasuredGain.IsInitialized == that._MeasuredGain.IsInitialized
|
|
&& UserValue1 == that.UserValue1
|
|
&& UserValue2 == that.UserValue2
|
|
&& UserValue3 == that.UserValue3
|
|
&& IsSupersampled.Equals(that.IsSupersampled)
|
|
&& UnsupersampledSampleRateHz.Equals(that.UnsupersampledSampleRateHz)
|
|
&& DigitalMultiplier.ToSerializeDbString() == that.DigitalMultiplier.ToSerializeDbString()
|
|
&& DigitalMode == that.DigitalMode
|
|
&& DataFlag.Equals(that.DataFlag)
|
|
&& _ExpectedGain.IsInitialized ? ExpectedGain.Equals(that.ExpectedGain) : _ExpectedGain.IsInitialized == that._ExpectedGain.IsInitialized
|
|
&& UnitConversion.Equals(that.UnitConversion)
|
|
&& AtCapacity.Equals(that.AtCapacity)
|
|
&& CapacityOutputIsBasedOn.Equals(that.CapacityOutputIsBasedOn)
|
|
&& SensitivityUnits.Equals(that.SensitivityUnits);
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
throw new Exception("encountered problem equality-testing the object " + (null != obj ? "\"" + obj.ToString() + "\"" : "<<NULL>>"), ex);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return the hash code for this object.
|
|
/// </summary>
|
|
///
|
|
/// <returns>
|
|
/// The <see cref="int"/> hash code for this object.
|
|
/// </returns>
|
|
///
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|