Files
DP44/Common/DTS.Common.Serialization/.svn/pristine/7c/7c587c21da2dff8a141a5da650015a956331ef69.svn-base

815 lines
34 KiB
Plaintext
Raw Normal View History

2026-04-17 14:55:32 -04:00
/*
Test.Module.Channel.cs
Copyright © 2008
Diversified Technical Systems, Inc.
All Rights Reserved
*/
using System;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using DTS.Common.Utilities;
using DTS.Common.Utilities.DotNetProgrammingConstructs;
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 serializable channel information.
/// </summary>
[XmlSerializationTag("Channel")]
public abstract partial class Channel : Exceptional, IXmlSerializable
{
protected Channel()
{
}
public Channel(Module parentModule)
{
try
{
ParentModule = parentModule;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem constructing " + GetType().Name, ex);
}
}
/// <summary>
/// The <see cref="DTS.Serialization.Test.Module"/> that contains this channel.
/// </summary>
public Module ParentModule
{
get => _ParentModule.Value;
private set => _ParentModule.Value = value;
}
private readonly Property<Module> _ParentModule
= new Property<Module>(
typeof(Channel).Namespace + ".Test.Module.Channel.ParentModule",
null,
false
);
/// <summary>
/// Get/set the channel's ordinal number.
/// </summary>
[XmlSerializationTag("Number")]
public int Number
{
get => _Number.Value;
set => _Number.Value = value;
}
private readonly Property<int> _Number
= new Property<int>(
typeof(Channel).Namespace + ".Test.Module.Channel.Number",
-1,
false
);
/// <summary>
/// get/set the absolute display order of the channel (absolutenumber refers to physical number)
/// </summary>
[XmlSerializationTag("AbsoluteDisplayOrder")]
public int AbsoluteDisplayOrder
{
get
{
if (_absoluteDisplayOrder.IsValueInitialized) { return _absoluteDisplayOrder.Value; }
return -1;
}
set => _absoluteDisplayOrder.Value = value;
}
private readonly Property<int> _absoluteDisplayOrder = new Property<int>(
typeof(Channel).Namespace + ".Test.Module.Channel.AbsoluteDisplayOrder",
-1, true);
/// <summary>
/// Get/set the start time for this channel.
/// </summary>
[XmlSerializationTag("Start")]
public DateTime Start
{
get => _Start.Value;
set => _Start.Value = value;
}
private readonly Property<DateTime> _Start
= new Property<DateTime>(
typeof(Channel).Namespace + ".Test.Module.Channel.Start",
DateTime.Now,
false
);
public bool TimeOfFirstSampleValid => _TimeOfFirstSampleSec.IsInitialized;
/// <summary>
/// Get/set the time of first sample in this test.
/// </summary>
[XmlSerializationTag("TimeOfFirstSample")]
public double TimeOfFirstSampleSec
{
get => _TimeOfFirstSampleSec.Value;
set => _TimeOfFirstSampleSec.Value = value;
}
protected Property<double> _TimeOfFirstSampleSec
= new Property<double>(
typeof(Channel).Namespace + ".Test.Module.Channel.TimeOfFirstSample",
0.0,
false
);
/// <summary>
/// Get the type of this channel.
/// </summary>
[XmlSerializationTag("ChannelType")]
public string ChannelType
{
get
{
try
{
return GetType().FullName;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem getting channel type property", ex);
}
}
}
/// <summary>
/// Get/set flag that determines whether or not data will be written to/read from XML serialization.
/// </summary>
public bool ExpressDataInlineOnXmlSerialization
{
get => _ExpressDataInlineOnXmlSerialization.Value;
set => _ExpressDataInlineOnXmlSerialization.Value = value;
}
private readonly Property<bool> _ExpressDataInlineOnXmlSerialization
= new Property<bool>(
typeof(Channel).Namespace + ".Test.Module.Channel.ExpressDataInlineOnXmlSerialization",
false,
true
);
/// <summary>
/// Get/set a user-readable description of this channel object.
/// </summary>
[XmlSerializationTag("ChannelDescriptionString")]
public string ChannelDescriptionString
{
get => _ChannelDescriptionString.Value;
set => _ChannelDescriptionString.Value = value;
}
private readonly Property<string> _ChannelDescriptionString
= new Property<string>(
typeof(Channel).Namespace + ".Test.Module.Channel.ChannelDescriptionString",
"",
false
);
[XmlSerializationTag("HardwareChannelName")]
public string HardwareChannelName
{
get => _HardwareChannelName.Value;
set => _HardwareChannelName.Value = value;
}
private readonly Property<string> _HardwareChannelName
= new Property<string>(
typeof(Channel).Namespace + ".Test.Module.Channel.HardwareChannelName",
"", true);
/// <summary>
/// refers to a unique id for a logical channel in the test
/// for now this is using TestObjectChannel.GetId()
/// which is in the form of TestObjectSerial_ChannelType_ChannelId
/// </summary>
[XmlSerializationTag("ChannelId")]
public string ChannelId
{
//get { return _ChannelId.Value; }
get
{
if (!_ChannelId.IsInitialized || null == _ChannelId.Value)
{
return $"{HardwareChannelName}_{ChannelName2}";
}
return _ChannelId.Value;
}
set => _ChannelId.Value = value;
}
private readonly Property<string> _ChannelId
= new Property<string>(
typeof(Channel).Namespace + ".Test.Module.Channel.ChannelId",
"", true);
/// <summary>
/// refers to the Group name for a logical channel in the test
/// </summary>
[XmlSerializationTag("ChannelGroupName")]
public string ChannelGroupName
{
get => _ChannelGroupName.Value;
set => _ChannelGroupName.Value = value;
}
private readonly Property<string> _ChannelGroupName
= new Property<string>(
typeof(Channel).Namespace + ".Test.Module.Channel.ChannelGroupName",
"", true);
/// <summary>
/// This is the name of the channel before it was changed in the Display Name UI (if it was)
/// </summary>
[XmlSerializationTag("OriginalChannelName")]
public string OriginalChannelName
{
get => _OriginalChannelName.Value;
set => _OriginalChannelName.Value = value;
}
private readonly Property<string> _OriginalChannelName
= new Property<string>(
typeof(Channel).Namespace + ".Test.Module.Channel.OriginalChannelName",
"", true);
[XmlSerializationTag("ChannelName2")]
public string ChannelName2
{
get => _ChannelName2.Value;
set => _ChannelName2.Value = value;
}
private readonly Property<string> _ChannelName2
= new Property<string>(
typeof(Channel).Namespace + ".Test.Module.Channel.ChannelName2",
"", true);
/// <summary>
/// Get/set the data values for this channel.
/// </summary>
[XmlSerializationTag("Data")]
public DataArray<short> Data
{
get => _Data.Value;
set => _Data.Value = value;
}
private readonly Property<DataArray<short>> _Data
= new Property<DataArray<short>>(
typeof(Channel).Namespace + ".Test.Module.Channel.Data",
null,
false
);
/// <summary>
/// Get/set the subsampling indication for this channel's data.
/// </summary>
[XmlSerializationTag("IsSubsampled")]
public bool IsSubsampled
{
get => _IsSubsampled.Value;
set => _IsSubsampled.Value = value;
}
private readonly Property<bool> _IsSubsampled
= new Property<bool>(
typeof(Channel).Namespace + ".Test.Module.Channel.IsSubsampled",
false,
true
);
/// <summary>
/// Get/set whether or not to use EU for scaling.
/// </summary>
[XmlSerializationTag("UseEUScaler")]
public bool UseEUScaler
{
get => _UseEUScaler.Value;
set => _UseEUScaler.Value = value;
}
private readonly Property<bool> _UseEUScaler
= new Property<bool>(
typeof(Channel).Namespace + ".Test.Module.Channel.UseEUScaler",
false,
true
);
[XmlSerializationTag("LastCalibrationDate")]
public DateTime LastCalibrationDate
{
get => _lastCalibrationDate.Value;
set => _lastCalibrationDate.Value = value;
}
private readonly Property<DateTime> _lastCalibrationDate
= new Property<DateTime>(
typeof(Channel).Namespace + ".Test.Module.Channel.LastCalibrationDate",
DateTime.MinValue,
true
);
public bool IsLastCalibrationDateValid => _lastCalibrationDate.IsInitialized;
[XmlSerializationTag("CalDueDate")]
public DateTime CalDueDate
{
get => _calDueDate.Value;
set => _calDueDate.Value = value;
}
private readonly Property<DateTime> _calDueDate
= new Property<DateTime>(
typeof(Channel).Namespace + ".Test.Module.Channel.CalDueDate",
DateTime.MinValue,
true
);
public bool IsCalDueDateValid => _calDueDate.IsInitialized;
[XmlSerializationTag("IsoChannelName")]
public String IsoChannelName
{
get => _isoChannelName.Value;
set => _isoChannelName.Value = value;
}
private readonly Property<string> _isoChannelName
= new Property<string>(
typeof(Channel).Namespace + ".Test.Module.Channel.IsoChannelName",
"",
true
);
public bool IsIsoChannelNameValid => _isoChannelName.IsInitialized;
[XmlSerializationTag("UserChannelName")]
public String UserChannelName
{
get => _userChannelName.Value;
set => _userChannelName.Value = value;
}
private readonly Property<string> _userChannelName
= new Property<string>(
typeof(Channel).Namespace + ".Test.Module.Channel.UserChannelName",
"",
true
);
public string LinearSensorCalibration
{
get => _linearSensorCalibration.Value;
set => _linearSensorCalibration.Value = value;
}
private readonly Property<string> _linearSensorCalibration
= new Property<string>(
typeof(Channel).Namespace + ".Test.Module.Channel.LinearSensorCalibration",
"",
true
);
public bool IsUserChannelNameValid => _userChannelName.IsInitialized;
[XmlSerializationTag("UserCode")]
public String UserCode
{
get => _userCode.Value;
set => _userCode.Value = value;
}
private readonly Property<string> _userCode
= new Property<string>(
typeof(Channel).Namespace + ".Test.Module.Channel.UserCode",
"",
true
);
public bool IsUserCodeValid => _userCode.IsInitialized;
[XmlSerializationTag("SensorID")]
public string SensorID
{
get => _sensorID.Value;
set => _sensorID.Value = value;
}
private readonly Property<String> _sensorID =
new Property<string>(
typeof(Channel).Namespace + ".Test.Module.Channel.SensorID",
"",
true
);
public bool IsSensorIDValid => _sensorID.IsInitialized;
[XmlSerializationTag("OffsetToleranceLowMv")]
public double OffsetToleranceLowMv
{
get => _offsetToleranceLowMv.Value;
set => _offsetToleranceLowMv.Value = value;
}
private readonly Property<double> _offsetToleranceLowMv =
new Property<double>(
typeof(Channel).Namespace + ".Test.Module.Channel.OffsetToleranceLowMv",
0D,
true
);
public bool IsOffsetToleranceLowMvValid => _offsetToleranceLowMv.IsInitialized;
[XmlSerializationTag("OffsetToleranceHighMv")]
public double OffsetToleranceHighMv
{
get => _offsetToleranceHighMv.Value;
set => _offsetToleranceHighMv.Value = value;
}
private readonly Property<double> _offsetToleranceHighMv =
new Property<double>(
typeof(Channel).Namespace + ".Test.Module.Channel.OffsetToleranceHighMv",
0D,
true
);
public bool IsOffsetToleranceHighMvValid => _offsetToleranceHighMv.IsInitialized;
[XmlSerializationTag("UserValue1")]
public string UserValue1
{
get => _userValue1.Value;
set => _userValue1.Value = value;
}
private readonly Property<string> _userValue1 = new Property<string>(
typeof(Channel).Namespace + ".Test.Module.Channel.UserValue1",
"", true);
[XmlSerializationTag("UserValue2")]
public string UserValue2
{
get => _userValue2.Value;
set => _userValue2.Value = value;
}
private readonly Property<string> _userValue2 = new Property<string>(
typeof(Channel).Namespace + ".Test.Module.Channel.UserValue2",
"", true);
[XmlSerializationTag("UserValue3")]
public string UserValue3
{
get => _userValue3.Value;
set => _userValue3.Value = value;
}
private readonly Property<string> _userValue3 = new Property<string>(
typeof(Channel).Namespace + ".Test.Module.Channel.UserValue3",
"", true);
/// <summary>
/// Get/set the unsubsampled sample rate for this channel (if applicable).
/// </summary>
[XmlSerializationTag("UnsubsampledSampleRateHz")]
public float UnsubsampledSampleRateHz
{
get => _UnsubsampledSampleRateHz.Value;
set => _UnsubsampledSampleRateHz.Value = value;
}
private readonly Property<float> _UnsubsampledSampleRateHz
= new Property<float>(
typeof(Channel).Namespace + ".Test.Module.Channel.UnsubsampledSampleRateHz",
0,
true
);
/// <summary>
/// Get/set <see cref="double"/> noise as percentage of full scale value for this channel.
/// </summary>
public double NoiseAsPercentageOfFullScale
{
get => _NoiseAsPercentageOfFullScale.Value;
set => _NoiseAsPercentageOfFullScale.Value = value;
}
private readonly Property<double> _NoiseAsPercentageOfFullScale
= new Property<double>(
typeof(Channel).Namespace + ".Test.Module.Channel.NoiseAsPercentageOfFullScale",
0.0,
false
);
/// <summary>
/// Get the pre-test zero level (in ADC).
/// </summary>
public short PreTestZeroLevelAdc
{
get => _PreTestZeroLevelAdc.Value;
set => _PreTestZeroLevelAdc.Value = value;
}
private readonly Property<short> _PreTestZeroLevelAdc
= new Property<short>(
typeof(Channel).Namespace + ".Test.Module.Channel.PreTestZeroLevelAdc",
0,
false
);
//zeroMvInADC
public short ZeroMvInADC
{
get
{
if (_ZeroMvInADC.IsValueInitialized) { return _ZeroMvInADC.Value; }
return 0;
}
set => _ZeroMvInADC.Value = value;
}
private readonly Property<short> _ZeroMvInADC
= new Property<short>(
typeof(Channel).Namespace + ".Test.Module.Channel.ZeroMvInADC",
0,
false);
/// <summary>
/// WindowAverageADC is the average ADC over the averaging zero window for the channel
/// WindowAverageADC is initialized to short.MinValue, so this value is considered
/// an uninitialized or invalid value
/// </summary>
public short WindowAverageADC
{
get
{
if (_WindowAverageADC.IsValueInitialized) { return _WindowAverageADC.Value; }
return short.MinValue;
}
set => _WindowAverageADC.Value = value;
}
private readonly Property<short> _WindowAverageADC
= new Property<short>(
typeof(Channel).Namespace + ".Test.Module.Channel.WindowAverageADC",
short.MinValue,
false);
public int TriggerAdjustmentSamples
{
get => _TriggerAdjustmentSamples.Value;
set => _TriggerAdjustmentSamples.Value = value;
}
private readonly Property<int> _TriggerAdjustmentSamples
= new Property<int>(
typeof(Channel).Namespace + ".Test.Module.Channel.TriggerAdjustmentSamples",
0,
false);
public short OriginalOffsetADC
{
get => _OriginalOffsetADC.Value;
set => _OriginalOffsetADC.Value = value;
}
private readonly Property<short> _OriginalOffsetADC
= new Property<short>(
typeof(Channel).Namespace + ".Test.Module.Channel.OriginalOffsetADC",
0,
false);
public double Excitation
{
get => _Excitation.Value;
set => _Excitation.Value = value;
}
private readonly Property<double> _Excitation
= new Property<double>(
typeof(Channel).Namespace + ".Test.Module.Channel.Excitation",
5D,
false);
public int RemovedADC
{
get
{
if (_RemovedADC.IsValueInitialized) { return _RemovedADC.Value; }
return 0;
}
set => _RemovedADC.Value = value;
}
private readonly Property<int> _RemovedADC
= new Property<int>(
typeof(Channel).Namespace + ".Test.Module.Channel.RemovedADC",
0,
true
);
public int RemovedInternalADC
{
get
{
if (_RemovedInternalADC.IsValueInitialized) { return _RemovedInternalADC.Value; }
return 0;
}
set => _RemovedInternalADC.Value = value;
}
private readonly Property<int> _RemovedInternalADC
= new Property<int>(
typeof(Channel).Namespace + ".Test.Module.Channel.RemovedInternalADC",
0,
true
);
/// <summary>
/// Get/set the sample rate for this test module.
/// </summary>
[XmlSerializationTag("IsSupersampled")]
public bool IsSupersampled
{
get => _IsSupersampled.Value;
set => _IsSupersampled.Value = value;
}
private readonly Property<bool> _IsSupersampled
= new Property<bool>(
typeof(Module).Namespace + ".Test.Module.Channel.IsSupersampled",
false,
false
);
/// <summary>
/// Get/set the EU Scale Factor.
/// </summary>
[XmlSerializationTag("ScaleFactorEU")]
public double ScaleFactorEU
{
get => _ScaleFactorEU.Value;
set => _ScaleFactorEU.Value = value;
}
private readonly Property<double> _ScaleFactorEU
= new Property<double>(
typeof(Module).Namespace + ".Test.Module.Channel.ScaleFactorEU",
0D,
false
);
/// <summary>
/// Get/set the sample rate for this test module.
/// </summary>
[XmlSerializationTag("UnsupersampledSampleRateHz")]
public float UnsupersampledSampleRateHz
{
get => _UnsupersampledSampleRateHz.Value;
set => _UnsupersampledSampleRateHz.Value = value;
}
private readonly Property<float> _UnsupersampledSampleRateHz
= new Property<float>(
typeof(Module).Namespace + ".Test.Module.Channel.UnsupersampledSampleRateHz",
0,
false
);
/// <summary>
/// Get data zero level counts.
/// </summary>
public abstract short DataZeroLevelAdc
{
get;
}
/// <summary>
/// Get/set the persistent information for this channel.
/// </summary>
public SliceRaw.File.PersistentChannel PersistentChannelInfo
{
get => _PersistentChannelInfo.Value;
set => _PersistentChannelInfo.Value = value;
}
private readonly Property<SliceRaw.File.PersistentChannel> _PersistentChannelInfo
= new Property<SliceRaw.File.PersistentChannel>(
typeof(Channel).Namespace + ".Test.Module.Channel.PersistentChannelInfo",
null,
false
);
/// <summary>
/// Get/set the persistent information for this channel.
/// </summary>
public TDAS.File.PersistentChannel TDASPersistentChannelInfo
{
get => _TDASPersistentChannelInfo.Value;
set => _TDASPersistentChannelInfo.Value = value;
}
private readonly Property<TDAS.File.PersistentChannel> _TDASPersistentChannelInfo
= new Property<TDAS.File.PersistentChannel>(
typeof(Channel).Namespace + ".Test.Module.Channel.TDASPersistentChannelInfo",
null,
false
);
[XmlSerializationTag("DataFlag")]
public int DataFlag
{
get => _DataFlag.Value;
set => _DataFlag.Value = value;
}
private readonly Property<int> _DataFlag = new Property<int>(
typeof(Channel).Namespace + ".Test.Module.Channel.DataFlag",
1, true);
public bool IsDataFlagValid => _DataFlag.IsInitialized;
//public DTS.Slice.Control.Event.Module.Channel emc;
public object emc;
/// <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 abstract void WriteXml(XmlWriter writer);
/// <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>
///
public abstract void ReadXml(XmlReader reader);
/// <summary>
/// Should normally return a schema representing the form of the XML
/// generated/consumed by WriteXml/ReadXml, but it never called during
/// the serialization process so ours just returns null.
/// </summary>
///
/// <returns>
/// Null <see cref="XmlSchema"/> reference, always.
/// </returns>
///
public virtual XmlSchema GetSchema()
{
// This method is never invoked during XML object serialization.
return null;
}
/// <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 Channel;
return null != obj
&& ChannelId.Equals(that.ChannelId)
&& Data.Equals(that.Data)
&& ExpressDataInlineOnXmlSerialization.Equals(that.ExpressDataInlineOnXmlSerialization)
&& Number.Equals(that.Number)
&& PreTestZeroLevelAdc.Equals(that.PreTestZeroLevelAdc)
&& NoiseAsPercentageOfFullScale.Equals(that.NoiseAsPercentageOfFullScale)
&& IsSubsampled.Equals(that.IsSubsampled)
&& UnsubsampledSampleRateHz.Equals(that.UnsubsampledSampleRateHz)
&& IsSupersampled.Equals(that.IsSupersampled)
&& UnsupersampledSampleRateHz.Equals(that.UnsupersampledSampleRateHz)
&& _TimeOfFirstSampleSec.IsInitialized == that._TimeOfFirstSampleSec.IsInitialized && (_TimeOfFirstSampleSec.IsInitialized ? TimeOfFirstSampleSec == that.TimeOfFirstSampleSec : true)
&& Start.ToString().Equals(that.Start.ToString())
&& UserValue1.Equals(that.UserValue1)
&& UserValue2.Equals(that.UserValue2)
&& UserValue3.Equals(that.UserValue3)
&& AbsoluteDisplayOrder.Equals(that.AbsoluteDisplayOrder);
}
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();
}
public override string ToString()
{
return ChannelDescriptionString;
}
}
}
}
}