/*
Test.Module.Channel.cs
Copyright © 2008
Diversified Technical Systems, Inc.
All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using DTS.Utilities;
using DTS.Utilities.DotNetProgrammingConstructs;
using DTS.Utilities.Xml;
namespace DTS.Serialization
{
// *** see Test.cs ***
public partial class Test
{
// *** see Test.Module.cs ***
public partial class Module
{
///
/// Representation of serializable channel information.
///
[XmlSerializationTag( "Channel" )]
public abstract partial class Channel : Exceptional, IXmlSerializable
{
protected Channel()
{
}
public Channel( Test.Module parentModule )
{
try
{
this.ParentModule = parentModule;
}
catch ( System.Exception ex )
{
throw new Test.Module.Channel.Exception( "encountered problem constructing " + this.GetType( ).Name, ex );
}
}
///
/// The that contains this channel.
///
public Test.Module ParentModule
{
get { return _ParentModule.Value; }
private set { _ParentModule.Value = value; }
}
private Property _ParentModule
= new Property(
typeof( Test.Module.Channel ).Namespace + ".Test.Module.Channel.ParentModule",
null,
false
);
///
/// Get/set the channel's ordinal number.
///
[XmlSerializationTag( "Number" )]
public int Number
{
get { return _Number.Value; }
set { _Number.Value = value; }
}
private Property _Number
= new Property(
typeof( Channel ).Namespace + ".Test.Module.Channel.Number",
-1,
false
);
///
/// get/set the absolute display order of the channel (absolutenumber refers to physical number)
///
[XmlSerializationTag("AbsoluteDisplayOrder")]
public int AbsoluteDisplayOrder
{
get
{
if (_absoluteDisplayOrder.IsValueInitialized) { return _absoluteDisplayOrder.Value; }
else { return -1; }
}
set { _absoluteDisplayOrder.Value = value; }
}
private Property _absoluteDisplayOrder = new Property(
typeof(Channel).Namespace + ".Test.Module.Channel.AbsoluteDisplayOrder",
-1, true);
///
/// Get/set the start time for this channel.
///
[XmlSerializationTag( "Start" )]
public DateTime Start
{
get { return _Start.Value; }
set { _Start.Value = value; }
}
private Property _Start
= new Property(
typeof( Channel ).Namespace + ".Test.Module.Channel.Start",
DateTime.Now,
false
);
public bool TimeOfFirstSampleValid
{
get
{
return _TimeOfFirstSampleSec.IsInitialized;
}
}
///
/// Get/set the time of first sample in this test.
///
[XmlSerializationTag( "TimeOfFirstSample" )]
public double TimeOfFirstSampleSec
{
get { return _TimeOfFirstSampleSec.Value; }
set { _TimeOfFirstSampleSec.Value = value; }
}
protected Property _TimeOfFirstSampleSec
= new Property(
typeof( Channel ).Namespace + ".Test.Module.Channel.TimeOfFirstSample",
0.0,
false
);
///
/// Get the type of this channel.
///
[XmlSerializationTag( "ChannelType" )]
public string ChannelType
{
get
{
try
{
return this.GetType( ).FullName;
}
catch ( System.Exception ex )
{
throw new Test.Module.Channel.Exception( "encountered problem getting channel type property", ex );
}
}
}
///
/// Get/set flag that determines whether or not data will be written to/read from XML serialization.
///
public bool ExpressDataInlineOnXmlSerialization
{
get { return _ExpressDataInlineOnXmlSerialization.Value; }
set { _ExpressDataInlineOnXmlSerialization.Value = value; }
}
private Property _ExpressDataInlineOnXmlSerialization
= new Property(
typeof( Channel ).Namespace + ".Test.Module.Channel.ExpressDataInlineOnXmlSerialization",
false,
true
);
///
/// Get/set a user-readable description of this channel object.
///
[XmlSerializationTag( "ChannelDescriptionString" )]
public string ChannelDescriptionString
{
get { return _ChannelDescriptionString.Value; }
set { _ChannelDescriptionString.Value = value; }
}
private Property _ChannelDescriptionString
= new Property(
typeof( Channel ).Namespace + ".Test.Module.Channel.ChannelDescriptionString",
"",
false
);
[XmlSerializationTag("HardwareChannelName")]
public string HardwareChannelName
{
get { return _HardwareChannelName.Value; }
set { _HardwareChannelName.Value = value; }
}
private Property _HardwareChannelName
= new Property(
typeof(Channel).Namespace + ".Test.Module.Channel.HardwareChannelName",
"", true);
///
/// 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
///
[XmlSerializationTag("ChannelId")]
public string ChannelId
{
//get { return _ChannelId.Value; }
get
{
if (!_ChannelId.IsInitialized || null == _ChannelId.Value)
{
return string.Format("{0}_{1}", HardwareChannelName, ChannelName2);
}
else { return _ChannelId.Value; }
}
set { _ChannelId.Value = value; }
}
private Property _ChannelId
= new Property(
typeof(Channel).Namespace + ".Test.Module.Channel.ChannelId",
"", true);
///
/// refers to the Group name for a logical channel in the test
///
[XmlSerializationTag("ChannelGroupName")]
public string ChannelGroupName
{
get { return _ChannelGroupName.Value; }
set { _ChannelGroupName.Value = value; }
}
private Property _ChannelGroupName
= new Property(
typeof(Channel).Namespace + ".Test.Module.Channel.ChannelGroupName",
"", true);
[XmlSerializationTag("ChannelName2")]
public string ChannelName2
{
get { return _ChannelName2.Value; }
set { _ChannelName2.Value = value; }
}
private Property _ChannelName2
= new Property(
typeof(Channel).Namespace + ".Test.Module.Channel.ChannelName2",
"", true);
///
/// Get/set the data values for this channel.
///
[XmlSerializationTag( "Data" )]
public DataArray Data
{
get { return _Data.Value; }
set { _Data.Value = value; }
}
private Property> _Data
= new Property>(
typeof( Channel ).Namespace + ".Test.Module.Channel.Data",
null,
false
);
///
/// Get/set the subsampling indication for this channel's data.
///
[XmlSerializationTag( "IsSubsampled" )]
public bool IsSubsampled
{
get { return _IsSubsampled.Value; }
set { _IsSubsampled.Value = value; }
}
private Property _IsSubsampled
= new Property(
typeof( Channel ).Namespace + ".Test.Module.Channel.IsSubsampled",
false,
true
);
[XmlSerializationTag("LastCalibrationDate")]
public DateTime LastCalibrationDate
{
get { return _lastCalibrationDate.Value; }
set { _lastCalibrationDate.Value = value; }
}
private Property _lastCalibrationDate
= new Property(
typeof(Channel).Namespace + ".Test.Module.Channel.LastCalibrationDate",
DateTime.MinValue,
true
);
public bool IsLastCalibrationDateValid
{
get { return _lastCalibrationDate.IsInitialized; }
}
[XmlSerializationTag("SensorID")]
public string SensorID
{
get { return _sensorID.Value; }
set { _sensorID.Value = value; }
}
private Property _sensorID =
new Property(
typeof(Channel).Namespace + ".Test.Module.Channel.SensorID",
"",
true
);
public bool IsSensorIDValid
{
get { return _sensorID.IsInitialized; }
}
[XmlSerializationTag("OffsetToleranceLowMv")]
public double OffsetToleranceLowMv
{
get { return _offsetToleranceLowMv.Value; }
set { _offsetToleranceLowMv.Value = value; }
}
private Property _offsetToleranceLowMv =
new Property(
typeof(Channel).Namespace + ".Test.Module.Channel.OffsetToleranceLowMv",
0D,
true
);
public bool IsOffsetToleranceLowMvValid
{
get { return _offsetToleranceLowMv.IsInitialized; }
}
[XmlSerializationTag("OffsetToleranceHighMv")]
public double OffsetToleranceHighMv
{
get { return _offsetToleranceHighMv.Value; }
set { _offsetToleranceHighMv.Value = value; }
}
private Property _offsetToleranceHighMv =
new Property(
typeof(Channel).Namespace + ".Test.Module.Channel.OffsetToleranceHighMv",
0D,
true
);
public bool IsOffsetToleranceHighMvValid
{
get { return _offsetToleranceHighMv.IsInitialized; }
}
[XmlSerializationTag("UserValue1")]
public string UserValue1
{
get { return _userValue1.Value; }
set { _userValue1.Value = value; }
}
private Property _userValue1 = new Property(
typeof(Channel).Namespace + ".Test.Module.Channel.UserValue1",
"", true);
[XmlSerializationTag("UserValue2")]
public string UserValue2
{
get { return _userValue2.Value; }
set { _userValue2.Value = value; }
}
private Property _userValue2 = new Property(
typeof(Channel).Namespace + ".Test.Module.Channel.UserValue2",
"", true);
[XmlSerializationTag("UserValue3")]
public string UserValue3
{
get { return _userValue3.Value; }
set { _userValue3.Value = value; }
}
private Property _userValue3 = new Property(
typeof(Channel).Namespace + ".Test.Module.Channel.UserValue3",
"", true);
///
/// Get/set the unsubsampled sample rate for this channel (if applicable).
///
[XmlSerializationTag( "UnsubsampledSampleRateHz" )]
public float UnsubsampledSampleRateHz
{
get { return _UnsubsampledSampleRateHz.Value; }
set { _UnsubsampledSampleRateHz.Value = value; }
}
private Property _UnsubsampledSampleRateHz
= new Property(
typeof( Channel ).Namespace + ".Test.Module.Channel.UnsubsampledSampleRateHz",
0,
true
);
///
/// Get/set noise as percentage of full scale value for this channel.
///
public double NoiseAsPercentageOfFullScale
{
get { return _NoiseAsPercentageOfFullScale.Value; }
set { _NoiseAsPercentageOfFullScale.Value = value; }
}
private Property _NoiseAsPercentageOfFullScale
= new Property(
typeof( Test.Module.Channel ).Namespace + ".Test.Module.Channel.NoiseAsPercentageOfFullScale",
0.0,
false
);
///
/// Get the pre-test zero level (in ADC).
///
public short PreTestZeroLevelAdc
{
get { return _PreTestZeroLevelAdc.Value; }
set { _PreTestZeroLevelAdc.Value = value; }
}
private Property _PreTestZeroLevelAdc
= new Property(
typeof( Test.Module.Channel ).Namespace + ".Test.Module.Channel.PreTestZeroLevelAdc",
0,
false
);
//zeroMvInADC
public short ZeroMvInADC
{
get
{
if (_ZeroMvInADC.IsValueInitialized) { return _ZeroMvInADC.Value; }
else { return 0; }
}
set { _ZeroMvInADC.Value = value; }
}
private Property _ZeroMvInADC
= new Property(
typeof(Test.Module.Channel).Namespace + ".Test.Module.Channel.ZeroMvInADC",
0,
false);
///
/// 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
///
public short WindowAverageADC
{
get
{
if (_WindowAverageADC.IsValueInitialized) { return _WindowAverageADC.Value; }
else { return short.MinValue; }
}
set { _WindowAverageADC.Value = value; }
}
private Property _WindowAverageADC
= new Property(
typeof(Test.Module.Channel).Namespace + ".Test.Module.Channel.WindowAverageADC",
short.MinValue,
false);
public int TriggerAdjustmentSamples
{
get { return _TriggerAdjustmentSamples.Value; }
set { _TriggerAdjustmentSamples.Value = value; }
}
private Property _TriggerAdjustmentSamples
= new Property(
typeof(Test.Module.Channel).Namespace + ".Test.Module.Channel.TriggerAdjustmentSamples",
0,
false);
public short OriginalOffsetADC
{
get { return _OriginalOffsetADC.Value; }
set { _OriginalOffsetADC.Value = value; }
}
private Property _OriginalOffsetADC
= new Property(
typeof(Test.Module.Channel).Namespace + ".Test.Module.Channel.OriginalOffsetADC",
0,
false);
public double Excitation
{
get { return _Excitation.Value; }
set { _Excitation.Value = value; }
}
private Property _Excitation
= new Property(
typeof(Test.Module.Channel).Namespace + ".Test.Module.Channel.Excitation",
5D,
false);
public int RemovedADC
{
get
{
if (_RemovedADC.IsValueInitialized) { return _RemovedADC.Value; }
else { return 0; }
}
set { _RemovedADC.Value = value; }
}
private Property _RemovedADC
= new Property(
typeof(Test.Module.Channel).Namespace + ".Test.Module.Channel.RemovedADC",
0,
true
);
public int RemovedInternalADC
{
get
{
if (_RemovedInternalADC.IsValueInitialized) { return _RemovedInternalADC.Value; }
else { return 0; }
}
set { _RemovedInternalADC.Value = value; }
}
private Property _RemovedInternalADC
= new Property(
typeof(Test.Module.Channel).Namespace + ".Test.Module.Channel.RemovedInternalADC",
0,
true
);
///
/// Get data zero level counts.
///
public abstract short DataZeroLevelAdc
{
get;
}
///
/// Get/set the persistent information for this channel.
///
public DTS.Serialization.SliceRaw.File.PersistentChannel PersistentChannelInfo
{
get { return _PersistentChannelInfo.Value; }
set { _PersistentChannelInfo.Value = value; }
}
private Property _PersistentChannelInfo
= new Property(
typeof( Channel ).Namespace + ".Test.Module.Channel.PersistentChannelInfo",
null,
false
);
///
/// Get/set the persistent information for this channel.
///
public DTS.Serialization.TDAS.File.PersistentChannel TDASPersistentChannelInfo
{
get { return _TDASPersistentChannelInfo.Value; }
set { _TDASPersistentChannelInfo.Value = value; }
}
private Property _TDASPersistentChannelInfo
= new Property(
typeof(Channel).Namespace + ".Test.Module.Channel.TDASPersistentChannelInfo",
null,
false
);
[XmlSerializationTag("DataFlag")]
public int DataFlag
{
get { return _DataFlag.Value; }
set { _DataFlag.Value = value; }
}
private Property _DataFlag = new Property(
typeof(Test.Module.Channel).Namespace + ".Test.Module.Channel.DataFlag",
1, true);
public bool IsDataFlagValid
{
get { return _DataFlag.IsInitialized; }
}
//public DTS.Slice.Control.Event.Module.Channel emc;
public object emc;
///
/// Write XML serialization for this object to the specified writer.
///
///
///
/// The to which this object's XML serialization
/// will be written.
///
///
public abstract void WriteXml( XmlWriter writer );
///
/// Read XML serialization for this object from the specified reader.
///
///
///
/// The from which this object's XML serialization
/// will be read.
///
///
public abstract void ReadXml( XmlReader reader );
///
/// Should normally return a schema representing the form of the XML
/// generated/consumed by WriteXml/ReadXml, but it never called during
/// the serialization process so ours just returns null.
///
///
///
/// Null reference, always.
///
///
public virtual XmlSchema GetSchema( )
{
// This method is never invoked during XML object serialization.
return null;
}
///
/// Test the specified object for equality with this object.
///
///
///
/// The to be tested for equality.
///
///
///
/// true if the specified object has memeberwise equality with
/// this object; false otherwise.
///
///
public override bool Equals( object obj )
{
try
{
Test.Module.Channel that = obj as Test.Module.Channel;
return null != obj
&& this.ChannelId.Equals(that.ChannelId)
&& this.Data.Equals(that.Data)
&& this.ExpressDataInlineOnXmlSerialization.Equals(that.ExpressDataInlineOnXmlSerialization)
&& this.Number.Equals(that.Number)
&& this.PreTestZeroLevelAdc.Equals(that.PreTestZeroLevelAdc)
&& this.NoiseAsPercentageOfFullScale.Equals(that.NoiseAsPercentageOfFullScale)
&& this.IsSubsampled.Equals(that.IsSubsampled)
&& this.UnsubsampledSampleRateHz.Equals(that.UnsubsampledSampleRateHz)
&& this._TimeOfFirstSampleSec.IsInitialized == that._TimeOfFirstSampleSec.IsInitialized && (this._TimeOfFirstSampleSec.IsInitialized ? this.TimeOfFirstSampleSec == that.TimeOfFirstSampleSec : true)
&& this.Start.ToString().Equals(that.Start.ToString())
&& this.UserValue1.Equals(that.UserValue1)
&& this.UserValue2.Equals(that.UserValue2)
&& this.UserValue3.Equals(that.UserValue3)
&& this.AbsoluteDisplayOrder.Equals(that.AbsoluteDisplayOrder);
}
catch ( System.Exception ex )
{
throw new Exception( "encountered problem equality-testing the object " + ( null != obj ? "\"" + obj.ToString( ) + "\"" : "<>" ), ex );
}
}
///
/// Return the hash code for this object.
///
///
///
/// The hash code for this object.
///
///
public override int GetHashCode( )
{
return base.GetHashCode( );
}
public override string ToString()
{
return ChannelDescriptionString;
}
}
}
}
}