Files
DP44/Common/DTS.Common.Serialization/Control/Event/Module/AnalogInputChannel/AnalogInputChannel.cs
2026-04-17 14:55:32 -04:00

2559 lines
129 KiB
C#

/*
* DTS.Slice.Control.Event.Module.AnalogInputChannel.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using DTS.Common.DAS.Concepts;
using DTS.DASLib.Service;
using DTS.Common.Utilities;
using DTS.Common.Utilities.DotNetProgrammingConstructs;
using DTS.Common.Utilities.Logging;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module
{
public partial class SquibEventChannel
: Channel,
Common.DAS.Concepts.DAS.Channel.IEngineeringUnitAware,
Common.DAS.Concepts.DAS.Channel.IIsoCodeAware
{
public OutputSquibChannel.SquibMeasurementType MeasurementType
{
get;
set;
}
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event.Module.SquibEventChannel class.
/// </summary>
///
/// <param name="parentModule">
/// The <see cref="DTS.Slice.Control.Event.Module"/> that contains this channel.
/// </param>
///
/// <param name="absoluteNumber">
/// The unique "absolute" <see cref="int"/> number of the channel with respect to all other channels
/// on all other DASes in the system.
/// </param>
///
protected SquibEventChannel(Module parentModule, int absoluteNumber)
: base(parentModule, absoluteNumber)
{ //
// Intended only for constructing implicit conversion instances, hence the
// restrictive access modifier.
} //
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event.Module.SquibEventChannel class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="DTS.DASLib.Service.DASChannel"/> with which to initialize this object.
/// </param>
///
/// <param name="parentModule">
/// The <see cref="DTS.Slice.Control.Event.Module"/> that contains this channel.
/// </param>
///
/// <param name="absoluteNumber">
/// The unique "absolute" <see cref="int"/> number of the channel with respect to all other channels
/// on all other DASes in the system.
/// </param>
///
public SquibEventChannel(DASChannel channel, Module parentModule, int absoluteNumber)
: base(channel, parentModule, absoluteNumber)
{
try
{ //
// Initialize this object's analog input-specific values with whatever we can
// squeeze out of the specified channel object.
// channel.
//
MvPerEu = 1.0;
ScaleFactorMv = 1.0;
SetPropertyValuesFrom(channel);
}
catch (System.Exception ex)
{
throw new Exception("encountered problem constructing " + GetType().FullName, ex);
}
}
/// <summary>
/// Get/set this object's engineering unit description <see cref="string"/>.
/// </summary>
public string EngineeringUnits
{
get
{
switch (MeasurementType)
{
case OutputSquibChannel.SquibMeasurementType.CURRENT:
return "A";
case OutputSquibChannel.SquibMeasurementType.INIT_SIGNAL:
return "V";
case OutputSquibChannel.SquibMeasurementType.VOLTAGE:
return "V";
case OutputSquibChannel.SquibMeasurementType.NONE:
return "";
default:
throw new NotSupportedException("SquibEventChannel::EngineeringUnits Unknown MeasurementType " + MeasurementType.ToString());
}
}
set { ;}
}
/// <summary>
/// Get/set this object's IsoCode <see cref="string"/>.
/// </summary>
public string IsoCode
{
get;
set;
}
/// <summary>
/// Convert this object to a DTS.Serialization.Test.Module.Channel.
/// </summary>
///
/// <returns>
/// A <see cref="DTS.Serialization.Test.Module.Channel"/> equivalent for this object.
/// </returns>
///
public override Serialization.Test.Module.Channel ToDtsSerializationTestModuleChannel(
Serialization.Test.Module parentModule)
{
try
{
var that
= new Serialization.Test.Module.AnalogInputChannel(parentModule);
if (!IsConfigured)
throw new Exception("cannot serialize unconfigured analog input channel");
that.ChannelId = ChannelId;
//that.AverageAdcOverTime = 0;
//that.AverageAdcOverTime = this.AverageAdcOverTime;
that.Bridge = Test.Module.Channel.Sensor.BridgeType.SQUIB;
that.BridgeResistanceOhms = 0;
that.ZeroPoint = 0;
that.UserValue1 = UserValue1;
that.UserValue2 = UserValue2;
that.UserValue3 = UserValue3;
//that.Bridge = this.Bridge;
//that.BridgeResistanceOhms = this.BridgeResistanceOhms;
that.ChannelDescriptionString = ChannelDescriptionString;
that.ChannelName2 = ChannelName2;
that.Description = ChannelDescriptionString;
that.Manufacturer = Manufacturer;
that.Model = Model;
that.HardwareChannelName = HardwareChannelName;
that.ChannelId = ChannelId;
that.ChannelGroupName = ChannelGroupName;
that.DesiredRange = 1;
that.EngineeringUnits = EngineeringUnits;
that.ExcitationVoltage = Test.Module.Channel.Sensor.ExcitationVoltageOption.Volt5;
that.InitialEu = 0;
that.IsInverted = false;
that.IsSubsampled = false;
if (IsLastCalibrationDateValid) { that.LastCalibrationDate = LastCalibrationDate; }
if (IsSensorIDValid) { that.SensorID = SensorID; }
if (IsOffsetToleranceLowMvValid) { that.OffsetToleranceLowMv = OffsetToleranceLowMv; }
if (IsOffsetToleranceHighMvValid) { that.OffsetToleranceHighMv = OffsetToleranceHighMv; }
that.IsoCode = IsoCode;
that.NoiseAsPercentageOfFullScale = NoiseAsPercentageOfFullScale;
that.Number = Number;
that.AbsoluteDisplayOrder = AbsoluteDisplayOrder;
that.PreTestZeroLevelAdc = PreTestZeroLevelAdc;
that.ZeroMvInADC = ZeroMvInADC;
that.WindowAverageADC = WindowAverageADC;
//that.PreTestZeroLevelmV = this.PreTestZeroLevelMv;
that.RemovedADC = RemovedADC;
that.ProportionalToExcitation = false;
that.RemoveOffset = false;
that.Sensitivity = 1D;
that.SerialNumber = "";
that.ShuntEnabled = false;
that.VoltageInsertionCheckEnabled = false;
that.CalSignalEnabled = false;
that.Start = Start;
that.PreTestZeroLevelAdc = PreTestZeroLevelAdc;
that.ZeroMvInADC = ZeroMvInADC;
that.WindowAverageADC = WindowAverageADC; //I'm not entirely sure why this is being set twice ... but why break with tradition!
//that.PreTestZeroLevelmV = this.PreTestZeroLevelMv;
that.RemovedADC = RemovedADC;
that.AbsoluteDisplayOrder = AbsoluteDisplayOrder;
that.ZeroAverageWindow = new Serialization.Test.IntervalSec(-1, 1);
that.ZeroMethod = Test.Module.Channel.Sensor.ZeroMethodType.UsePreEventDiagnosticsZero;
that.RemoveOffset = true;
that.UnitConversion = 1.0;
that.AtCapacity = false;
that.CapacityOutputIsBasedOn = 1.000;
that.SensitivityUnits = Test.Module.Channel.Sensor.SensUnits.NONE;
try
{
if (TimeOfFirstSampleSecValid)
{
that.TimeOfFirstSampleSec = TimeOfFirstSampleSec;
}
}
catch { };
that.SoftwareFilter = CurrentFilter.ToBaseString();
that.Data = new Serialization.Test.Module.Channel.DataArray<short>(); // this.UnfilteredData.ToArray( ) );
that.Data.MvPerEu = GetMvPerEu();
that.Data.ScaleFactorMv = GetScaleFactorMv();
that.Data.Multiplier = Multiplier;
that.Data.UnitConversion = UnitConversion;
that.AtCapacity = AtCapacity;
that.CapacityOutputIsBasedOn = CapacityOutputIsBasedOn;
that.SensitivityUnits = SensitivityUnits;
that.Data.UserOffsetEU = UserOffsetEU;
if (UnfilteredData is Serialization.SliceRaw.File.PersistentChannel)
that.PersistentChannelInfo = UnfilteredData as Serialization.SliceRaw.File.PersistentChannel;
return that;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem converting " + GetType().FullName + " to " + typeof(Serialization.Test.Module.AnalogInputChannel), ex);
}
}
/// <summary>
/// Initialize this object from the specified DTS.Serialization.Test.Module.Channel.
/// </summary>
///
/// <param name="that">
/// A <see cref="DTS.Serialization.Test.Module.Channel"/> from which to initialize this object.
/// </param>
///
public override void FromDtsSerializationTestModuleChannel(
Serialization.Test.Module.Channel that)
{
throw new NotImplementedException("SquibEventChannel::FromDtsSerializationTestModuleChannel");
}
//DataPROWin7.Properties.Settings.Default.UseISOCodesInReview
private bool UseISOCodesInReview = false;
/*
/// <summary>
/// Method to allow derived classes to initialize their own reviewable attributes.
/// </summary>
///
/// <param name="reviewableAttributes">
/// The <see cref="List"/> or <see cref="ReviewableAttribute"/>s to be initialized.
/// </param>
///
/// <summary>
/// Initialize this object's list of reviewable attributes.
/// </summary>
protected override void InitializeReviewableAttributes(List<ReviewableAttribute> reviewableAttributes)
{
try
{
try { reviewableAttributes.Add(new ReviewableDescriptionAttribute(this)); }
catch { }
if (true == UseISOCodesInReview)
{
try { reviewableAttributes.Add(new ReviewableIsoCodeAttribute(this)); }
catch { }
}
try { reviewableAttributes.Add(new ReviewableUnitsAttribute(this)); }
catch { }
try { reviewableAttributes.Add(new ReviewableMinMaxEuAttribute(this)); }
catch { }
}
catch (System.Exception ex)
{
throw new Event.Module.AnalogInputChannel.Exception("encountered problem initializing reviewiable attribute list", ex);
}
}
/// <summary>
/// A reviewable min/max EU attribute attached to a specific channel.
/// </summary>
public class ReviewableMinMaxEuAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableMinMaxEuAttribute(Event.Module.Channel channel)
: base("Max/Min (EU)", delegate { return channel.DataMaxFilteredEu.ToString("F1") + "/" + channel.DataMinFilteredEu.ToString("F1"); })
{
}
}
/// <summary>
/// A reviewable engineering units attribute attached to a specific channel.
/// </summary>
public class ReviewableUnitsAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableUnitsAttribute(Event.Module.Channel channel)
: base("Units", delegate { return (channel as DTS.Common.DAS.Concepts.DAS.Channel.IEngineeringUnitAware).EngineeringUnits.ToString(); })
{
}
}
/// <summary>
/// A reviewable serial number attribute attached to a specific channel.
/// </summary>
public class ReviewableIsoCodeAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableIsoCodeAttribute(Event.Module.Channel channel)
: base("ISO Code", delegate { return (channel as AnalogInputChannel).IsoCode.ToString(); })
{
}
}
/// <summary>
/// A reviewable CFC attribute attached to a specific channel.
/// </summary>
public class ReviewableDescriptionAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableDescriptionAttribute(Event.Module.Channel channel)
: base("Description", delegate { return channel.ChannelDescriptionString; })
{
}
}
*/
public override List<double> GetUnfilteredDataEu() { throw new NotImplementedException("SquibEventChannel::GetUnfilteredDataEu"); }
public override List<double> GetUnfilteredDataMV()
{
throw new NotImplementedException("SquibEventChannel::GetUnfilteredDataMV");
}
/// <summary>
/// Get <see cref="bool"/> value indicating whether or not the specified channel is configured.
/// </summary>
public override bool IsConfigured
{
get;
set;
}
/// <summary>
/// Get the actual available maximum EU range based on scaling factor and bit resolution.
/// </summary>
public override double ActualMaxRangeEu => throw new NotImplementedException("SquibEventChannel::ActualMaxRangeEu");
/// <summary>
/// Get the actual available minimum EU range based on scaling factor and bit resolution.
/// </summary>
public override double ActualMinRangeEu => throw new NotImplementedException("SquibEventChannel::ActualMinRangeEu");
public override double DesiredRangeEU => throw new NotImplementedException("SquibEventChannel::DesiredRangeEu");
public override double SensorCapacityEU => throw new NotImplementedException("SquibEventChannel::SensorCapacityEU");
/// <summary>
/// Get the <see cref="double"/> data min in EU.
/// </summary>
public override double DataMinEu => throw new NotImplementedException("SquibEventChannel::DataMinEu");
/// <summary>
/// Get the <see cref="double"/> data max in EU.
/// </summary>
public override double DataMaxEu => throw new NotImplementedException("SquibEventChannel::DataMaxEu");
/// <summary>
/// Get the <see cref="double"/> data range in EU.
/// </summary>
public override double DataRangeEu => throw new NotImplementedException("SquibEventChannel::DataRangeEu");
/// <summary>
/// Get the <see cref="double"/> data range/2 in EU.
/// </summary>
public override double DataHalfRangeValueEu => throw new NotImplementedException("SquibEventChannel::DataHalfRangeValueEu");
/// <summary>
/// Get data zero level counts.
/// </summary>
public override short DataZeroLevelAdc => throw new NotImplementedException("SquibEventChannel::DataZeroLevelAdc");
/// <summary>
/// Set the appropriate properties in this class from the equivalent properties
/// of the specified object.
/// </summary>
///
///<param name="dasChannel">
/// The <see cref="DTS.DASLib.Service.DASChannel"/> object containing the
/// property values to be copied.
/// </param>
///
public override void SetPropertyValuesFrom(DASChannel dasChannel)
{
try
{
if (null == dasChannel)
throw new ArgumentNullException("could not initialize from null das channel reference");
var squib = dasChannel as OutputSquibChannel;
if (null == squib)
throw new ArgumentException("could not interpret " + dasChannel.GetType().FullName +
" initialization object as " +
typeof(OutputSquibChannel).FullName);
OffsetToleranceLowMv = double.NaN;
OffsetToleranceHighMv = double.NaN;
//this.SensorID = null != analogChannel.IDs && analogChannel.IDs.Length > 0 ? analogChannel.IDs[0].ID : "";
SensorID = squib.IDs[0].ID.ToString();
LastCalibrationDate = (DateTime) System.Data.SqlTypes.SqlDateTime.MinValue;
ChannelDescriptionString = string.IsNullOrWhiteSpace(squib.UserValue1)
? squib.SquibDescription
: squib.UserValue1;
ChannelName2 = squib.ChannelName2;
switch (MeasurementType)
{
case OutputSquibChannel.SquibMeasurementType.CURRENT:
if (ChannelDescriptionString.EndsWith(".1"))
{
ChannelDescriptionString =
ChannelDescriptionString.Substring(0,
ChannelDescriptionString.Length - 2) + ".2";
}
ChannelDescriptionString += " (Current)";
if (ChannelName2 != null)
{
if (ChannelName2.EndsWith(".1"))
{
ChannelName2 = ChannelName2.Substring(0, ChannelName2.Length - 2) + ".2";
}
ChannelName2 += " (Current)";
}
break;
case OutputSquibChannel.SquibMeasurementType.INIT_SIGNAL:
ChannelDescriptionString += " (Init Signal)";
ChannelName2 += " (Init Signal)";
break;
case OutputSquibChannel.SquibMeasurementType.VOLTAGE:
ChannelDescriptionString += " (Voltage)";
ChannelName2 += " (Voltage)";
break;
case OutputSquibChannel.SquibMeasurementType.NONE:
ChannelDescriptionString += " (NONE)";
ChannelName2 += " (NONE)";
break;
default:
throw new NotSupportedException(
"unknown measurement type " + MeasurementType.ToString());
}
//this.Description = squib.SquibDescription;
IsConfigured = squib.IsConfigured();
IsoCode = squib.ISOCode;
Number = squib.ModuleChannelNumber;
AbsoluteDisplayOrder = dasChannel.AbsoluteDisplayOrder;
UnitConversion = dasChannel.UnitConverision;
MvPerEu = 1; // analogChannel.SensitivityMilliVoltsPerEU;
ScaleFactorMv = squib.ScaleFactorMv;
PreTestZeroLevelAdc = squib.PreTestDataZeroLevelADC;
Start = squib.EventStartTime;
UserValue1 = squib.UserValue1;
UserValue2 = squib.UserValue2;
UserValue3 = squib.UserValue3;
HardwareChannelName = squib.HardwareChannelName;
if (squib.SoftwareFilterFrequency > 0)
{
CurrentFilter = new DefaultSaeJ211Filter(squib.SoftwareFilterFrequency);
DefaultFilter = new DefaultSaeJ211Filter(squib.SoftwareFilterFrequency);
}
}
catch (System.Exception ex)
{
throw new Exception(
"encountered problem setting property values from " +
(null != dasChannel ? dasChannel.GetType().FullName : "<<NULL>>") + " object", ex);
}
}
}
public partial class SquibDigitalChannel
: Channel
{
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event.Module.SquibEventChannel class.
/// </summary>
///
/// <param name="parentModule">
/// The <see cref="DTS.Slice.Control.Event.Module"/> that contains this channel.
/// </param>
///
/// <param name="absoluteNumber">
/// The unique "absolute" <see cref="int"/> number of the channel with respect to all other channels
/// on all other DASes in the system.
/// </param>
///
protected SquibDigitalChannel(Module parentModule, int absoluteNumber)
: base(parentModule, absoluteNumber)
{ //
// Intended only for constructing implicit conversion instances, hence the
// restrictive access modifier.
} //
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event.Module.SquibEventChannel class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="DTS.DASLib.Service.DASChannel"/> with which to initialize this object.
/// </param>
///
/// <param name="parentModule">
/// The <see cref="DTS.Slice.Control.Event.Module"/> that contains this channel.
/// </param>
///
/// <param name="absoluteNumber">
/// The unique "absolute" <see cref="int"/> number of the channel with respect to all other channels
/// on all other DASes in the system.
/// </param>
///
public SquibDigitalChannel(DASChannel channel, Module parentModule, int absoluteNumber)
: base(channel, parentModule, absoluteNumber)
{
try
{ //
// Initialize this object's analog input-specific values with whatever we can
// squeeze out of the specified channel object.
// channel.
//
MvPerEu = 1.0;
ScaleFactorMv = 1.0;
SetPropertyValuesFrom(channel);
}
catch (System.Exception ex)
{
throw new Exception("encountered problem constructing " + GetType().FullName, ex);
}
}
/// <summary>
/// Convert this object to a DTS.Serialization.Test.Module.Channel.
/// </summary>
///
/// <returns>
/// A <see cref="DTS.Serialization.Test.Module.Channel"/> equivalent for this object.
/// </returns>
///
public override Serialization.Test.Module.Channel ToDtsSerializationTestModuleChannel(
Serialization.Test.Module parentModule)
{
throw new NotImplementedException("SquibDigitalChannel::ToDtsSerializationTestModuleChannel");
}
/// <summary>
/// Initialize this object from the specified DTS.Serialization.Test.Module.Channel.
/// </summary>
///
/// <param name="that">
/// A <see cref="DTS.Serialization.Test.Module.Channel"/> from which to initialize this object.
/// </param>
///
public override void FromDtsSerializationTestModuleChannel(
Serialization.Test.Module.Channel that)
{
throw new NotImplementedException("SquibDigitalChannel::FromDtsSerializationTestModuleChannel");
}
/*
/// <summary>
/// Method to allow derived classes to initialize their own reviewable attributes.
/// </summary>
///
/// <param name="reviewableAttributes">
/// The <see cref="List"/> or <see cref="ReviewableAttribute"/>s to be initialized.
/// </param>
///
/// <summary>
/// Initialize this object's list of reviewable attributes.
/// </summary>
protected override void InitializeReviewableAttributes(List<ReviewableAttribute> reviewableAttributes)
{
try
{
}
catch (System.Exception ex)
{
throw new Event.Module.AnalogInputChannel.Exception("encountered problem initializing reviewiable attribute list", ex);
}
}
*/
public override List<double> GetUnfilteredDataEu() { throw new NotImplementedException("SquibDigitalChannel::GetUnfilteredDataEu"); }
public override List<double> GetUnfilteredDataMV()
{
throw new NotImplementedException("SquibDigitalChannel::GetUnFilteredDataMV");
}
/// <summary>
/// Get <see cref="bool"/> value indicating whether or not the specified channel is configured.
/// </summary>
public override bool IsConfigured
{
get;
set;
}
/// <summary>
/// Get the actual available maximum EU range based on scaling factor and bit resolution.
/// </summary>
public override double ActualMaxRangeEu => throw new NotImplementedException("SquibDigitalChannel::ActualMaxRangeEu");
public override double DesiredRangeEU => throw new NotImplementedException("SquibDigitalChannel:DesiredRangeEu");
public override double SensorCapacityEU => throw new NotImplementedException("SquibDigitalChannel:SensorCapacityEu");
/// <summary>
/// Get the actual available minimum EU range based on scaling factor and bit resolution.
/// </summary>
public override double ActualMinRangeEu => throw new NotImplementedException("SquibDigitalChannel::ActualMinRangeEu");
/// <summary>
/// Get the <see cref="double"/> data min in EU.
/// </summary>
public override double DataMinEu => throw new NotImplementedException("SquibDigitalChannel::DataMinEu");
/// <summary>
/// Get the <see cref="double"/> data max in EU.
/// </summary>
public override double DataMaxEu => throw new NotImplementedException("SquibDigitalChannel::DataMaxEu");
/// <summary>
/// Get the <see cref="double"/> data range in EU.
/// </summary>
public override double DataRangeEu => throw new NotImplementedException("SquibDigitalChannel::DataRangeEu");
/// <summary>
/// Get the <see cref="double"/> data range/2 in EU.
/// </summary>
public override double DataHalfRangeValueEu => throw new NotImplementedException("SquibDigitalChannel::DataHalfRangeValueEu");
/// <summary>
/// Get data zero level counts.
/// </summary>
public override short DataZeroLevelAdc => throw new NotImplementedException("SquibDigitalChannel::DataZeroLevelAdc");
/// <summary>
/// Set the appropriate properties in this class from the equivalent properties
/// of the specified object.
/// </summary>
///
///<param name="dasChannel">
/// The <see cref="DTS.DASLib.Service.DASChannel"/> object containing the
/// property values to be copied.
/// </param>
///
public override void SetPropertyValuesFrom(DASChannel dasChannel)
{
try
{
}
catch (System.Exception ex)
{
throw new Exception("encountered problem setting property values from " + (null != dasChannel ? dasChannel.GetType().FullName : "<<NULL>>") + " object", ex);
}
}
}
public partial class IEPEInputChannel : AnalogInputChannel
{
public IEPEInputChannel(DASChannel channel, Module parentModule, int absoluteNumber)
: base(channel, parentModule, absoluteNumber) { }
}
/// <summary>
/// Representation of the DTS.Slice.Control.Event.Module.AnalogInputChannel class.
/// </summary>
public partial 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.ILevelTriggerable,
Common.DAS.Concepts.DAS.Channel.ILinearized
{
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event.Module.AnalogInputChannel class.
/// </summary>
///
/// <param name="parentModule">
/// The <see cref="DTS.Slice.Control.Event.Module"/> that contains this channel.
/// </param>
///
/// <param name="absoluteNumber">
/// The unique "absolute" <see cref="int"/> number of the channel with respect to all other channels
/// on all other DASes in the system.
/// </param>
///
protected AnalogInputChannel(Module parentModule, int absoluteNumber)
: base(parentModule, absoluteNumber)
{ //
// Intended only for constructing implicit conversion instances, hence the
// restrictive access modifier.
} //
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event.Module.AnalogInputChannel class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="DTS.DASLib.Service.DASChannel"/> with which to initialize this object.
/// </param>
///
/// <param name="parentModule">
/// The <see cref="DTS.Slice.Control.Event.Module"/> that contains this channel.
/// </param>
///
/// <param name="absoluteNumber">
/// The unique "absolute" <see cref="int"/> number of the channel with respect to all other channels
/// on all other DASes in the system.
/// </param>
///
public AnalogInputChannel(DASChannel channel, Module parentModule, int absoluteNumber)
: base(channel, parentModule, absoluteNumber)
{
try
{ //
// Initialize this object's analog input-specific values with whatever we can
// squeeze out of the specified channel object.
// channel.
//
MvPerEu = 1.0;
ScaleFactorMv = 1.0;
SetPropertyValuesFrom(channel);
DoRoundOffLevelTriggerThresholdValues = true;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem constructing " + GetType().FullName, ex);
}
}
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event.Module.AnalogInputChannel class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="DTS.Serialization.Test.Module.Channel"/> with which to initialize this object.
/// </param>
///
/// <param name="parentModule">
/// The <see cref="DTS.Slice.Control.Event.Module"/> that contains this channel.
/// </param>
///
/// <param name="absoluteNumber">
/// The unique "absolute" <see cref="int"/> number of the channel with respect to all other channels
/// on all other DASes in the system.
/// </param>
///
public AnalogInputChannel(Serialization.Test.Module.Channel channel, Module parentModule, int absoluteNumber)
: base(channel, parentModule, absoluteNumber)
{
try
{ //
// Initialize this object's analog input-specific values with whatever we can
// squeeze out of the specified channel object.
//
if (channel is Serialization.Test.Module.AnalogInputChannel)
{
Scaler.IEPE = (channel as Serialization.Test.Module.AnalogInputChannel).Bridge == Test.Module.Channel.Sensor.BridgeType.IEPE;
Scaler.Digital = (channel as Serialization.Test.Module.AnalogInputChannel).Bridge == Test.Module.Channel.Sensor.BridgeType.DigitalInput;
InitialOffset = (channel as Serialization.Test.Module.AnalogInputChannel).InitialOffset;
}
MvPerEu = channel.Data.MvPerEu;
ScaleFactorMv = channel.Data.ScaleFactorMv;
if (channel.Data.UseTDASScaleFactors)
{
try
{
ScaleFactorEU = channel.Data.ScaleFactorEU;
}
catch (System.Exception)
{
ScaleFactorEU = 0;
}
}
Scaler.SetUseTDASScaleFactors(channel.Data.UseTDASScaleFactors);
RemovedADC = channel.RemovedADC;
ChannelId = channel.ChannelId;
ChannelGroupName = channel.ChannelGroupName;
AbsoluteDisplayOrder = channel.AbsoluteDisplayOrder;
UnitConversion = (channel as Serialization.Test.Module.AnalogInputChannel).UnitConversion;
AtCapacity = (channel as Serialization.Test.Module.AnalogInputChannel).AtCapacity;
CapacityOutputIsBasedOn = (channel as Serialization.Test.Module.AnalogInputChannel).CapacityOutputIsBasedOn;
SensitivityUnits = (channel as Serialization.Test.Module.AnalogInputChannel).SensitivityUnits;
FromDtsSerializationTestModuleChannel(channel);
try
{
if (channel.Data.UseTDASScaleFactors)
{
Scaler.SetDataZeroLevelADC((short)channel.TDASPersistentChannelInfo.DataZeroLevelInCnts);
}
else
{
Scaler.SetDataZeroLevelADC(DataZeroLevelAdc);
//if we have a linearized value and are set for none, the the datazeroleveladc shouldn't be used
//we should be using only the zeromvinadc...
var aic = channel as Serialization.Test.Module.AnalogInputChannel;
if (null != aic)
{
if (aic.LinearizationFormula.IsValid() &&
aic.ZeroMethod == Test.Module.Channel.Sensor.ZeroMethodType.None)
{
Scaler.SetDataZeroLevelADC(0);
}
}
}
}
catch (System.Exception)
{
Scaler.SetDataZeroLevelADC(PreTestZeroLevelAdc);
}
Scaler.SetRemovedADC(channel.RemovedADC);
Scaler.SetRemovedInternalADC(channel.RemovedInternalADC);
var aveOverTime = double.NaN;
try
{
if (channel.Data.UseTDASScaleFactors)
{
aveOverTime = Convert.ToDouble(channel.TDASPersistentChannelInfo.DataZeroLevelInCnts);
}
else
{
aveOverTime = Convert.ToDouble(DataZeroLevelAdc);
}
}
catch (System.Exception) { }
var diagnosticsADC = double.NaN;
try { diagnosticsADC = Convert.ToDouble(PreTestZeroLevelAdc); }
catch (System.Exception) { }
/*try { Scaler.SetIRTraccZeros(aveOverTime, diagnosticsADC); }
catch (System.Exception) { }
*/
try
{
Scaler.SetZeroMvInADC(ZeroMvInADC);
}
catch (System.Exception) { }
try
{
Scaler.SetWindowAverageADC(WindowAverageADC);
}
catch (System.Exception) { }
}
catch (System.Exception ex)
{
throw new Exception("encountered problem constructing " + GetType().FullName, ex);
}
}
private bool UseISOCodesInReview = false;
private bool UseShuntDeflectionInReview = false;
private bool ReviewForm_UseCalSigInReview = false;
/*
/// <summary>
/// Initialize this object's list of reviewable attributes.
/// </summary>
protected override void InitializeReviewableAttributes(List<ReviewableAttribute> reviewableAttributes)
{
try
{
try { reviewableAttributes.Add(new ReviewableSerialNumberAttribute(this)); }
catch { }
try { reviewableAttributes.Add(new ReviewableDescriptionAttribute(this)); }
catch { }
if (true == UseISOCodesInReview)
{
try { reviewableAttributes.Add(new ReviewableIsoCodeAttribute(this)); }
catch { }
}
if (true == UseShuntDeflectionInReview)
{
try { reviewableAttributes.Add(new ReviewableTargetShuntDeflectionAttribute(this)); }
catch { }
try { reviewableAttributes.Add(new ReviewableMeasuredShuntDeflectionAttribute(this)); }
catch { }
try { reviewableAttributes.Add(new ReviewableShuntDeflectionPercentageAttribute(this)); }
catch { }
}
if (true == ReviewForm_UseCalSigInReview)
{
//if (CalSignalEnabled)
{
try { reviewableAttributes.Add(new ReviewableTargetCalSignalAttribute(this)); }
catch { }
try { reviewableAttributes.Add(new ReviewableMeasuredCalSignalAttribute(this)); }
catch { }
try { reviewableAttributes.Add(new ReviewableCalSignalPercentageAttribute(this)); }
catch { }
}
}
try { reviewableAttributes.Add(new ReviewableUnitsAttribute(this)); }
catch { }
try { reviewableAttributes.Add(new ReviewableFilterFrequencyAttribute(this)); }
catch { }
try { reviewableAttributes.Add(new ReviewableCfcAttribute(this)); }
catch { }
try { reviewableAttributes.Add(new ReviewableMinMaxEuAttribute(this)); }
catch { }
}
catch (System.Exception ex)
{
throw new Event.Module.AnalogInputChannel.Exception("encountered problem initializing reviewiable attribute list", ex);
}
}
*/
/// <summary>
/// Get/set the <see cref="Test.Module.Channel.Sensor.BridgeType"/> bridge configuration of this channel.
/// </summary>
public Test.Module.Channel.Sensor.BridgeType Bridge
{
get => _Bridge.Value;
set => _Bridge.Value = value;
}
private readonly Property<Test.Module.Channel.Sensor.BridgeType> _Bridge
= new Property<Test.Module.Channel.Sensor.BridgeType>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.BridgeType",
Test.Module.Channel.Sensor.BridgeType.FullBridge,
false
);
private readonly Property<double> _ZeroPoint
= new Property<double>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.ZeroPoint",
0D,
false);
public double ZeroPoint
{
get
{
if (_ZeroPoint.IsValueInitialized)
{
return _ZeroPoint.Value;
}
return 0D;
}
set => _ZeroPoint.Value = value;
}
/// <summary>
/// Get/set the bridge resistance for this channel.
/// </summary>
public double BridgeResistanceOhms
{
get => _BridgeResistanceOhms.Value;
set => _BridgeResistanceOhms.Value = value;
}
private readonly Property<double> _BridgeResistanceOhms
= new Property<double>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.BridgeResistanceOhms",
0.0,
false
);
/// <summary>
/// Get/set the description for this channel.
/// </summary>
public string Description
{
get => null != _Description.Value ? _Description.Value : "";
set => _Description.Value = value;
}
private readonly Property<string> _Description
= new Property<string>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.Description",
"",
true
);
/// <summary>
/// Get/set the manufacturer for this channel.
/// </summary>
public string Manufacturer
{
get => null != _Manufacturer.Value ? _Manufacturer.Value : "";
set => _Manufacturer.Value = value;
}
private readonly Property<string> _Manufacturer
= new Property<string>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.Manufacturer",
"",
true
);
/// <summary>
/// Get/set the description for this channel.
/// </summary>
public string Model
{
get => null != _Model.Value ? _Model.Value : "";
set => _Model.Value = value;
}
private readonly Property<string> _Model
= new Property<string>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.Model",
"",
true
);
/// <summary>
/// Get/set the desired range for this channel.
/// </summary>
public double DesiredRange
{
get => _DesiredRange.Value;
set => _DesiredRange.Value = value;
}
private readonly Property<double> _DesiredRange
= new Property<double>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.DesiredRange",
0.0,
false
);
/// <summary>
/// Get/set the sensor capacity for this channel.
/// </summary>
public double SensorCapacity
{
get => _SensorCapacity.Value;
set => _SensorCapacity.Value = value;
}
private readonly Property<double> _SensorCapacity
= new Property<double>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.SensorCapacity",
0.0,
false
);
/// <summary>
/// Get/set the sensitivity for this channel.
/// </summary>
public double Sensitivity
{
get => _Sensitivity.Value;
set => _Sensitivity.Value = value;
}
private readonly Property<double> _Sensitivity
= new Property<double>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.Sensitivity",
0.0,
false
);
/// <summary>
/// Get/set the descriptor indiciating whether or not this channel is
/// proportional to excitation.
/// </summary>
public bool ProportionalToExcitation
{
get
{
try { return Scaler.ProportionalToExcitation; }
catch (System.Exception ex)
{
throw new Exception("encountered problem getting " + typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.ProportionalToExcitation property value", ex);
}
}
set
{
try { Scaler.ProportionalToExcitation = value; }
catch (System.Exception ex)
{
throw new Exception("encountered problem setting " + typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.ProportionalToExcitation property value", ex);
}
}
}
/// <summary>
/// Get/set the nominal excitation voltage for this channel.
/// </summary>
public Test.Module.Channel.Sensor.ExcitationVoltageOption ExcitationVoltage
{
get
{
try
{
return Scaler.NominalExcitationVoltage;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem getting " + typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.NominalExcitationVoltage property value", ex);
}
}
set
{
try
{
Scaler.NominalExcitationVoltage = (value == Test.Module.Channel.Sensor.ExcitationVoltageOption.Undefined
? ParentModule.NominalExcitationVoltage
: value);
}
catch (System.Exception ex)
{
throw new Exception("encountered problem setting " + typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.NominalExcitationVoltage property value", ex);
}
}
}
/// <summary>
/// Get/set the measured excitation voltage for this channel.
/// </summary>
public double MeasuredExcitationVoltage
{
get
{
try
{
return Scaler.MeasuredExcitationVoltage;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem setting " + typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.MeasuredExcitationVoltage property value", ex);
}
}
set
{
try
{
Scaler.MeasuredExcitationVoltage = value;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem getting " + typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.MeasuredExcitationVoltage property value", ex);
}
}
}
public bool FactoryExcitationVoltageValid
{
get
{
if (null == Scaler || !Scaler.FactoryExcitationVoltageValid)
{
return false;
}
return true;
}
}
/// <summary>
/// Get/set the factory excitation voltage for this channel.
/// </summary>
public double FactoryExcitationVoltage
{
get
{
try
{
return Scaler.FactoryExcitationVoltage;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem setting " + typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.FactoryExcitationVoltage property value", ex);
}
}
set
{
try
{
Scaler.FactoryExcitationVoltage = value;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem getting " + typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.FactoryExcitationVoltage property value", ex);
}
}
}
/// <summary>
/// Get/set the engineering units for this channel.
/// </summary>
public string EngineeringUnits
{
get => _EngineeringUnits.Value;
set => _EngineeringUnits.Value = value;
}
private readonly Property<string> _EngineeringUnits
= new Property<string>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.EngineeringUnits",
null,
false
);
/// <summary>
/// Get/set the <see cref="bool"/> flag indicating whether or not this channel is
/// actually configured.
/// </summary>
public override bool IsConfigured
{
get => _IsConfigured.Value;
set => _IsConfigured.Value = value;
}
private readonly Property<bool> _IsConfigured
= new Property<bool>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.IsConfigured",
false,
false
);
/// <summary>
/// Get/set channel inversion status.
/// </summary>
public bool IsInverted
{
get
{
try
{
return Scaler.IsInverted;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem getting " + typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.IsInverted property value", ex);
}
}
set
{
try
{
Scaler.IsInverted = value;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem setting " + typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.IsInverted property value", ex);
}
}
}
/// <summary>
/// Get/set channel inversion status.
/// </summary>
public LinearizationFormula LinearizationFormula
{
get
{
try
{
return Scaler.GetLinearizationFormula();
}
catch (System.Exception ex)
{
throw new Exception("encountered problem getting " + typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.LinearizationFormula property value", ex);
}
}
set
{
try
{
Scaler.SetLinearizationFormula(value);
}
catch (System.Exception ex)
{
throw new Exception("encountered problem setting " + typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.LinearizationFormula property value", ex);
}
}
}
public DigitalInputScaleMultiplier DigitalMultiplier
{
get
{
try
{
return Scaler.GetDigitalMultiplier();
}
catch (System.Exception ex)
{
throw new Exception("encountered problem getting " + typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.DigitalMultiplier property value", ex);
}
}
set
{
try
{
Scaler.SetDigitalMultiplier(value);
Scaler.Digital = Bridge == Test.Module.Channel.Sensor.BridgeType.DigitalInput;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem setting " + typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.DigitalMultiplier property value", ex);
}
}
}
public DigitalInputScaleMultiplier.InputModes DigitalMode
{
get => Scaler.DigitalMode;
set
{
try
{
Scaler.DigitalMode = value;
}
catch (System.Exception) { }
}
}
/// <summary>
/// Get/set the ISO code for this channel's data source.
/// </summary>
public string IsoCode
{
get => _IsoCode.Value;
set => _IsoCode.Value = value;
}
private readonly Property<string> _IsoCode
= new Property<string>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.IsoCode",
null,
false
);
/// <summary>
/// Get/set the <see cref="double"/> measured shunt deflection value.
/// </summary>
public double MeasuredShuntDeflectionMv
{
get => _MeasuredShuntDeflectionMv.Value;
set => _MeasuredShuntDeflectionMv.Value = value;
}
private readonly Property<double> _MeasuredShuntDeflectionMv
= new Property<double>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.MeasuredShuntDeflectionMv",
0.0,
false
);
/// <summary>
/// Get/set the <see cref="double"/> target shunt deflection value.
/// </summary>
public double TargetShuntDeflectionMv
{
get => _TargetShuntDeflectionMv.Value;
set => _TargetShuntDeflectionMv.Value = value;
}
private readonly Property<double> _TargetShuntDeflectionMv
= new Property<double>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.TargetShuntDeflectionMv",
0.0,
false
);
/// <summary>
/// Get/set the <see cref="double"/> measured shunt deflection value.
/// </summary>
public double MeasuredCalSignalMv
{
get => _MeasuredCalSignalMv.Value;
set => _MeasuredCalSignalMv.Value = value;
}
private readonly Property<double> _MeasuredCalSignalMv
= new Property<double>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.MeasuredCalSignalMv",
0.0,
false
);
/// <summary>
/// Get/set the <see cref="double"/> target shunt deflection value.
/// </summary>
public double TargetCalSignalMv
{
get => _TargetCalSignalMv.Value;
set => _TargetCalSignalMv.Value = value;
}
private readonly Property<double> _TargetCalSignalMv
= new Property<double>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.TargetCalSignalMv",
0.0,
false
);
/// <summary>
/// Get/set the serial number for this channel's data source.
/// </summary>
public string SerialNumber
{
get => _SerialNumber.Value;
set => _SerialNumber.Value = value;
}
private readonly Property<string> _SerialNumber
= new Property<string>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.SerialNumber",
null,
false
);
/// <summary>
/// Get/set the shunt enable indicator for this channel.
/// </summary>
public bool CalSignalEnabled
{
get
{
if (_CalSignalEnabled.IsInitialized) { return _CalSignalEnabled.Value; }
return false;
}
set => _CalSignalEnabled.Value = value;
}
private readonly Property<bool> _CalSignalEnabled
= new Property<bool>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.CalSignalEnabled",
false,
false
);
/// <summary>
/// Get/set the shunt enable indicator for this channel.
/// </summary>
public bool ShuntEnabled
{
get => _ShuntEnabled.Value;
set => _ShuntEnabled.Value = value;
}
private readonly Property<bool> _ShuntEnabled
= new Property<bool>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.ShuntEnabled",
false,
false
);
/// <summary>
/// Get/set the shunt enable indicator for this channel.
/// </summary>
public bool VoltageInsertionCheckEnabled
{
get => _VoltageInsertionCheckEnabled.Value;
set => _VoltageInsertionCheckEnabled.Value = value;
}
private readonly Property<bool> _VoltageInsertionCheckEnabled
= new Property<bool>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.VoltageInsertionCheckEnabled",
false,
false
);
/// <summary>
/// Get/set the remove offset option for this channel.
/// </summary>
public bool RemoveOffset
{
get => _RemoveOffset.Value;
set => _RemoveOffset.Value = value;
}
private readonly Property<bool> _RemoveOffset
= new Property<bool>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.RemoveOffset",
false,
false
);
/// <summary>
/// Get/set the zero method option for this channel.
/// </summary>
public Test.Module.Channel.Sensor.ZeroMethodType ZeroMethod
{
get => _ZeroMethod.Value;
set
{
_ZeroMethod.Value = value;
Scaler.ZeroMethodType = value;
}
}
private readonly Property<Test.Module.Channel.Sensor.ZeroMethodType> _ZeroMethod
= new Property<Test.Module.Channel.Sensor.ZeroMethodType>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.ZeroMethod",
Test.Module.Channel.Sensor.ZeroMethodType.AverageOverTime,
false
);
/// <summary>
/// Get/set zero average window definition.
/// </summary>
public IntervalSec ZeroAverageWindow
{
get => _ZeroAverageWindow.Value;
set => _ZeroAverageWindow.Value = value;
}
private readonly Property<IntervalSec> _ZeroAverageWindow
= new Property<IntervalSec>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.ZeroAverageWindow",
null,
false
);
/// <summary>
/// Get/set the initial EU value.
/// </summary>
public double InitialEu
{
get => _InitialEu.Value;
set => _InitialEu.Value = value;
}
private readonly Property<double> _InitialEu
= new Property<double>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.InitialEu",
0.0,
false
);
public string InitialOffset
{
get => _initialOffset.Value??"";
set
{
_initialOffset.Value = value;
Scaler.SetInitialOffset(value);
}
}
private readonly Property<string> _initialOffset
= new Property<string>(
typeof(AnalogInputChannel).Namespace + ".Event.Module.AnalogInputChannel.InitalOffset",
"",
true);
/// <summary>
/// Get/set whether or not level trigge threshold values are automatically rounded.
/// </summary>
public bool DoRoundOffLevelTriggerThresholdValues { get; set; }
/// <summary>
/// Get/set the number of decimal places level trigger threshold values will automatically
/// be rounded to if DoRoundOffValues property is true.
/// </summary>
public int NumberOfLevelTriggerThresholdValueRoundingDecimalPlaces
{
get => _NumberOfLevelTriggerThresholdValueRoundingDecimalPlaces.Value;
set => _NumberOfLevelTriggerThresholdValueRoundingDecimalPlaces.Value = value;
}
private readonly Property<int> _NumberOfLevelTriggerThresholdValueRoundingDecimalPlaces =
new Property<int>(
typeof(AnalogInputChannel).Namespace + ".NumberOfLevelTriggerThresholdValueRoundingDecimalPlaces",
6,
true
);
/// <summary>
/// Get/set the "trigger below" threshold. Set to "null" to deactivate.
/// </summary>
public double? TriggerBelowThresholdEu
{
get => (DoRoundOffLevelTriggerThresholdValues && null != _TriggerBelowThreshold.Value)
? Math.Round((double)_TriggerBelowThreshold.Value, NumberOfLevelTriggerThresholdValueRoundingDecimalPlaces)
: _TriggerBelowThreshold.Value;
set => _TriggerBelowThreshold.Value = value;
}
private readonly Property<double?> _TriggerBelowThreshold
= new Property<double?>(
typeof(AnalogInputChannel).FullName + ".TriggerBelowThresholdEu",
null,
false
);
/// <summary>
/// Get/set the "trigger above" threshold. Set to "null" to deactivate.
/// </summary>
public double? TriggerAboveThresholdEu
{
get => (DoRoundOffLevelTriggerThresholdValues && null != _TriggerAboveThreshold.Value)
? Math.Round((double)_TriggerAboveThreshold.Value, NumberOfLevelTriggerThresholdValueRoundingDecimalPlaces)
: _TriggerAboveThreshold.Value;
set => _TriggerAboveThreshold.Value = value;
}
private readonly Property<double?> _TriggerAboveThreshold
= new Property<double?>(
typeof(AnalogInputChannel).FullName + ".TriggerAboveThresholdEu",
null,
false
);
private readonly Property<Common.DAS.Concepts.DAS.Channel.LevelTriggerTypes> _LevelTriggerType
= new Property<Common.DAS.Concepts.DAS.Channel.LevelTriggerTypes>(
typeof(AnalogInputChannel).FullName + ".LevelTriggerType",
Common.DAS.Concepts.DAS.Channel.LevelTriggerTypes.NONE,
true);
public Common.DAS.Concepts.DAS.Channel.LevelTriggerTypes LevelTriggerType
{
get => _LevelTriggerType.Value;
set => _LevelTriggerType.Value = value;
}
/// <summary>
/// Get data zero level counts.
/// </summary>
public override short DataZeroLevelAdc
{
get
{
if (null == _DataZeroLevelCounts)
switch (ZeroMethod)
{
case Test.Module.Channel.Sensor.ZeroMethodType.AverageOverTime:
if ((ZeroAverageWindow.Begin == 0) && (ZeroAverageWindow.End == 0))
{
_DataZeroLevelCounts = PreTestZeroLevelAdc;
}
else
//if we have Average Over Time we do two things, if we have a known average via WindowAverageADC we use it
//otherwise we try to calculate it on the fly, we can handle older data and newer and it's done in a way
//similar to the other zeroing methods
//if (WindowAverageADC != InvalidWindowAverage) { _DataZeroLevelCounts = WindowAverageADC; }
//else
{
var preTriggerTime = 0D;
if (null != ParentModule.TriggerSampleNumbers)
{
preTriggerTime = ((double) ParentModule.TriggerSampleNumbers[0] -
(double) ParentModule.StartRecordSampleNumber)/
(double) ParentModule.SampleRateHz;
}
if (preTriggerTime < 0)
{
preTriggerTime = 0;
}
try
{
var numSamples =
(ulong)
((ZeroAverageWindow.End - ZeroAverageWindow.Begin)*
ParentModule.SampleRateHz) + 1;
var windowSamples = new double[numSamples];
var startingIndex =
((ulong)
((preTriggerTime + ZeroAverageWindow.Begin)*
ParentModule.SampleRateHz));
var pc =
UnfilteredData as Serialization.SliceRaw.File.PersistentChannel;
var insertPoint = 0;
for (var i = startingIndex; i < startingIndex + numSamples; i++)
{
//windowSamples[i] = this[i];
windowSamples[insertPoint ++] = Convert.ToDouble(pc[i]);
}
//PER TJK, and MB, don't use filtering for the averaging window, since it's double work
//if( null != CurrentFilter && CurrentFilter.Type != ChannelFilter.Unfiltered)
//{
// double averageNoFilter = windowSamples.Average();
// windowSamples = CurrentFilter.Apply(windowSamples, ParentModule.SampleRateHz);
// _DataZeroLevelCounts = Convert.ToInt16(windowSamples.Average());
// System.Diagnostics.Trace.WriteLine("unfiltered average: " + averageNoFilter.ToString() + " filtered average: " + windowSamples.Average());
//}
//else
//{
_DataZeroLevelCounts = Convert.ToInt16(windowSamples.Average());
//}
//calculating the average requires that we filter the data set,
//since we just loaded all the data to calculate it, now go and unload it all ...
// unsetting takes time and we are likely to reuse this data
// have something else unset it
//if (this is Slice.Control.Event.Module.Channel)
//{
// (this as Slice.Control.Event.Module.Channel).UnSet();
//}
}
catch (System.Exception ex)
{
APILogger.Log(ex);
_DataZeroLevelCounts = PreTestZeroLevelAdc;
}
}
break;
case
Test.Module.Channel.Sensor.ZeroMethodType
.UsePreEventDiagnosticsZero:
_DataZeroLevelCounts = PreTestZeroLevelAdc;
break;
case Test.Module.Channel.Sensor.ZeroMethodType.None:
//all NonLinear sensors use GetMv() which already makes an adjustment for ZeroMvInADC, so we don't want to double adjust ...
//if (null != LinearizationFormula && LinearizationFormula.IsValid()) { _DataZeroLevelCounts = 0; }
//else { _DataZeroLevelCounts = ZeroMvInADC; }
//if (!RemoveOffset) { _DataZeroLevelCounts = ZeroMvInADC; }
//else { _DataZeroLevelCounts = 0;}
//per RJW, ZeroMvInADC is not what we want to use, we want to use FinalOffsetADC, which I don't seem to have, but I do have
//PreTestZeroLevelADC
if (RemoveOffset)
{
_DataZeroLevelCounts = PreTestZeroLevelAdc;
}
else
{
_DataZeroLevelCounts = ZeroMvInADC;
}
break;
default:
throw new NotImplementedException("Data zero level count generation for zero method \"" + ZeroMethod.ToString() + "\" is not implemented");
}
return (short)_DataZeroLevelCounts;
}
}
private short? _DataZeroLevelCounts = 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>
/// Set applicable analog input channel values from the corresponding
/// <see cref="DTS.DASLib.Serivce.CalibrationResult"/>-borne properties.
/// </summary>
///
/// <param name="calibrationResults">
/// The <see cref="DTS.DASLib.Service.CalibrationResult"/> containing values to be transfered
/// to this channel.
/// </param>
///
public override void SetPropertyValuesFrom(DiagnosticsResult calibrationResults)
{
try
{
if (null != calibrationResults.MeasuredExcitationMilliVolts)
MeasuredExcitationVoltage = (double)(calibrationResults.MeasuredExcitationMilliVolts) / 1000.0;
FactoryExcitationVoltage = calibrationResults.ExpectedExcitationMilliVolts / 1000.0;
base.SetPropertyValuesFrom(calibrationResults);
}
catch (System.Exception ex)
{
throw new Exception("encountered problem setting analog input channel property values from calibration results", ex);
}
}
/// <summary>
/// Set the appropriate properties in this class from the equivalent properties
/// of the specified object.
/// </summary>
///
///<param name="dasChannel">
/// The <see cref="DTS.DASLib.Service.DASChannel"/> object containing the
/// property values to be copied.
/// </param>
///
public override void SetPropertyValuesFrom(DASChannel dasChannel)
{
try
{
if (null == dasChannel)
throw new ArgumentNullException("could not initialize from null das channel reference");
var analogChannel = dasChannel as AnalogInputDASChannel;
if (null == analogChannel)
throw new ArgumentException("could not interpret " + dasChannel.GetType().FullName + " initialization object as " + typeof(AnalogOutputDASChannel).FullName);
Scaler.Digital = analogChannel.TypeOfBridge == Test.Module.Channel.Sensor.BridgeType.DigitalInput;
Scaler.IEPE = analogChannel.IEPEChannel;
OffsetToleranceLowMv = analogChannel.OffsetToleranceLowMilliVolts;
OffsetToleranceHighMv = analogChannel.OffsetToleranceHighMilliVolts;
//this.SensorID = null != analogChannel.IDs && analogChannel.IDs.Length > 0 ? analogChannel.IDs[0].ID : "";
SensorID = analogChannel.SensorID;
LastCalibrationDate = analogChannel.LastCalibrationDate;
Bridge = analogChannel.TypeOfBridge;
BridgeResistanceOhms = analogChannel.BridgeResistanceOhms;
ZeroPoint = analogChannel.ZeroPoint;
ChannelDescriptionString = analogChannel.ToString();
ChannelName2 = analogChannel.ChannelName2;
ChannelId = analogChannel.ChannelId;
ChannelGroupName = analogChannel.ChannelGroupName;
HardwareChannelName = analogChannel.HardwareChannelName;
UserValue1 = analogChannel.UserValue1;
UserValue2 = analogChannel.UserValue2;
UserValue3 = analogChannel.UserValue3;
Description = analogChannel.Description;
Manufacturer = analogChannel.Manufacturer;
Model = analogChannel.Model;
DesiredRange = analogChannel.SensorCapacityEU;
SensorCapacity = analogChannel.SensorCapacity;
EngineeringUnits = analogChannel.EngineeringUnits;
ExcitationVoltage = analogChannel.Excitation;
IsConfigured = analogChannel.IsConfigured();
IsInverted = analogChannel.IsInverted;
LinearizationFormula = analogChannel.LinearizationFormula;
DigitalMultiplier = analogChannel.DigitalMultiplier;
DigitalMode = analogChannel.DigitalMode;
InitialEu = analogChannel.InitialEU;
ZeroMvInADC = analogChannel.ZeromVInADC;
InitialOffset = analogChannel.InitialOffset;
IsoCode = analogChannel.ISOCode;
Number = analogChannel.ModuleChannelNumber;
AbsoluteDisplayOrder = analogChannel.AbsoluteDisplayOrder;
ProportionalToExcitation = analogChannel.IsProportionalToExcitation;
AtCapacity = analogChannel.AtCapacity;
CapacityOutputIsBasedOn = analogChannel.CapacityOutputIsBasedOn;
SensitivityUnits = analogChannel.SensitivityUnits;
RemoveOffset = analogChannel.RemoveOffset;
MvPerEu = analogChannel.SensitivityMilliVoltsPerEU;// *(analogChannel.IsProportionalToExcitation ? DTS.Common.DAS.Concepts.Test.Module.Channel.Sensor.GetExcitationVoltageMagnitudeFromEnum(analogChannel.Excitation) : 1);
ScaleFactorMv = analogChannel.ScalefactorMilliVoltsPerADC;
UnitConversion = analogChannel.UnitConverision;
Sensitivity = analogChannel.SensitivityMilliVoltsPerEU;
SerialNumber = analogChannel.SerialNumber;
ShuntEnabled = analogChannel.ShuntIsEnabled;
VoltageInsertionCheckEnabled = analogChannel.VoltageInsertionCheckEnabled;
CalSignalEnabled = analogChannel.CalSignalIsEnabled;
Start = analogChannel.EventStartTime;
NoiseAsPercentageOfFullScale = analogChannel.NoiseAsPercentOfFullScale;
// Note that we'll have to change this logic when ISO codes are introduced, so
// we'll know to create a CFC filter instead of an ad hoc which appropriate, and
// vice versa.
CurrentFilter = analogChannel.SoftwareFilterFrequency > 0
? new SaeJ211Filter(analogChannel.SoftwareFilterFrequency)
: new SaeJ211Filter(ChannelFilter.Unfiltered);
if (!AvailableFilters.Contains(CurrentFilter))
AvailableFilters.Add(CurrentFilter);
UserValue1 = analogChannel.UserValue1;
UserValue2 = analogChannel.UserValue2;
UserValue3 = analogChannel.UserValue3;
ZeroAverageWindow = new IntervalSec(analogChannel.ZeroAverageStartSeconds,
analogChannel.ZeroAverageStopSeconds);
ZeroMethod = analogChannel.ZeroMethod;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem setting property values from " + (null != dasChannel ? dasChannel.GetType().FullName : "<<NULL>>") + " object", ex);
}
}
/// <summary>
/// Convert this object to a DTS.Serialization.Test.Module.Channel.
/// </summary>
///
/// <returns>
/// The <see cref="DTS.Serialization.Test.Module.Channel"/> equivalent to this object.
/// </returns>
///
public override Serialization.Test.Module.Channel ToDtsSerializationTestModuleChannel(Serialization.Test.Module parentModule)
{
try
{
var that
= new Serialization.Test.Module.AnalogInputChannel(parentModule);
if (!IsConfigured)
throw new Exception("cannot serialize unconfigured analog input channel");
that.AverageAdcOverTime = AverageAdcOverTime;
that.Bridge = Bridge;
that.BridgeResistanceOhms = BridgeResistanceOhms;
that.ZeroPoint = ZeroPoint;
that.ChannelDescriptionString = ChannelDescriptionString;
that.ChannelId = ChannelId;
that.ChannelGroupName = ChannelGroupName;
that.ChannelName2 = ChannelName2 != null
? ChannelName2
: "N/A";
that.HardwareChannelName = HardwareChannelName != null
? HardwareChannelName
: "N/A";
that.Description = Description;
that.Manufacturer = Manufacturer;
that.Model = Model;
that.DesiredRange = DesiredRange;
that.EngineeringUnits = EngineeringUnits;
that.ExcitationVoltage = ExcitationVoltage;
that.InitialOffset = InitialOffset;
that.InitialEu = InitialEu;
that.DigitalMultiplier = DigitalMultiplier;
that.DigitalMode = DigitalMode;
that.LinearizationFormula = LinearizationFormula;
that.IsInverted = IsInverted;
that.IsSubsampled = IsSubsampled;
if (IsLastCalibrationDateValid) { that.LastCalibrationDate = LastCalibrationDate; }
if (IsSensorIDValid) { that.SensorID = SensorID; }
if (IsOffsetToleranceLowMvValid) { that.OffsetToleranceLowMv = OffsetToleranceLowMv; }
if (IsOffsetToleranceHighMvValid) { that.OffsetToleranceHighMv = OffsetToleranceHighMv; }
that.UserValue1 = UserValue1;
that.UserValue2 = UserValue2;
that.UserValue3 = UserValue3;
that.IsoCode = IsoCode;
that.NoiseAsPercentageOfFullScale = NoiseAsPercentageOfFullScale;
that.Number = Number;
that.AbsoluteDisplayOrder = AbsoluteDisplayOrder;
that.PreTestZeroLevelAdc = PreTestZeroLevelAdc;
that.ZeroMvInADC = ZeroMvInADC;
that.AbsoluteDisplayOrder = AbsoluteDisplayOrder;
that.WindowAverageADC = WindowAverageADC;
if (RemoveOffset) { that.RemovedADC = RemovedADC; }
else { that.RemovedADC = 0; }
that.ProportionalToExcitation = ProportionalToExcitation;
that.AtCapacity = AtCapacity;
that.CapacityOutputIsBasedOn = CapacityOutputIsBasedOn;
that.SensitivityUnits = SensitivityUnits;
that.RemoveOffset = RemoveOffset;
that.Sensitivity = Sensitivity;
that.SerialNumber = SerialNumber;
that.ShuntEnabled = ShuntEnabled;
that.VoltageInsertionCheckEnabled = VoltageInsertionCheckEnabled;
that.CalSignalEnabled = CalSignalEnabled;
that.Start = Start;
that.ZeroAverageWindow = ZeroAverageWindow;
that.ZeroMethod = ZeroMethod;
if (_MeasuredShuntDeflectionMv.IsInitialized)
{
try { that.MeasuredShuntDeflectionMv = MeasuredShuntDeflectionMv; }
catch { }; // *** potentially unitialized ***
}
if (_TargetShuntDeflectionMv.IsInitialized)
{
try { that.TargetShuntDeflectionMv = TargetShuntDeflectionMv; }
catch { }; //
}
if (_MeasuredCalSignalMv.IsInitialized)
{
try { that.MeasuredCalSignalMv = MeasuredCalSignalMv; }
catch { }; // *** potentially unitialized ***
}
if (_TargetCalSignalMv.IsInitialized)
{
try { that.TargetCalSignalMv = TargetCalSignalMv; }
catch { }; //
}
if (_TriggerAboveThreshold.IsInitialized)
{
try { that.TriggerAboveThresholdEu = TriggerAboveThresholdEu; }
catch { }; //
}
if (_TriggerBelowThreshold.IsInitialized)
{
try { that.TriggerBelowThresholdEu = TriggerBelowThresholdEu; }
catch { }; //
}
if (_LevelTriggerType.IsInitialized)
{
try { that.LevelTriggerType = LevelTriggerType; }
catch { };
}
if (Scaler.MeasuredExcitationVoltageValid)
{
try { that.MeasuredExcitationVoltage = MeasuredExcitationVoltage; }
catch { };
}
if (Scaler.FactoryExcitationVoltageValid)
{
try { that.FactoryExcitationVoltage = FactoryExcitationVoltage; }
catch { };
}
try
{
if (TimeOfFirstSampleSecValid)
{
that.TimeOfFirstSampleSec = TimeOfFirstSampleSec;
}
}
catch { };
that.SoftwareFilter = CurrentFilter.ToBaseString();
that.UnitConversion = UnitConversion;
that.AtCapacity = AtCapacity;
that.CapacityOutputIsBasedOn = CapacityOutputIsBasedOn;
that.SensitivityUnits = SensitivityUnits;
that.Data = new Serialization.Test.Module.Channel.DataArray<short>
{
MvPerEu = GetMvPerEu(),
ScaleFactorMv = GetScaleFactorMv(),
Multiplier = Multiplier,
UserOffsetEU = UserOffsetEU
}; // this.UnfilteredData.ToArray( ) );
that.UserOffsetEU = UserOffsetEU;
that.Multiplier = Multiplier;
if (UnfilteredData is Serialization.SliceRaw.File.PersistentChannel)
that.PersistentChannelInfo = UnfilteredData as Serialization.SliceRaw.File.PersistentChannel;
that.SensorCapacity = SensorCapacity;
return that;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem converting " + GetType().FullName + " to " + typeof(Serialization.Test.Module.AnalogInputChannel), ex);
}
}
/// <summary>
/// Initialize this object from a DTS.Serialization.Test.Module.Channel.
/// </summary>
///
/// <param name="that">
/// The <see cref="DTS.Serialization.Test.Module.Channel"/> from which to initialize this object.
/// </param>
///
public override void FromDtsSerializationTestModuleChannel(Serialization.Test.Module.Channel that)
{
try
{
if (null == that)
throw new ArgumentNullException("cannot initialize " + GetType().FullName + " object from a null test module channel reference");
if ((that is Serialization.Test.Module.AnalogInputChannel) || (that is Serialization.Test.Module.CalculatedChannel))
{
var thatAnalogChannel = that as Serialization.Test.Module.AnalogInputChannel;
AverageAdcOverTime = thatAnalogChannel.AverageAdcOverTime;
Bridge = thatAnalogChannel.Bridge;
BridgeResistanceOhms = thatAnalogChannel.BridgeResistanceOhms;
ZeroPoint = thatAnalogChannel.ZeroPoint;
ChannelId = thatAnalogChannel.ChannelId;
ChannelGroupName = thatAnalogChannel.ChannelGroupName;
ChannelDescriptionString = thatAnalogChannel.ChannelDescriptionString;
ChannelName2 = thatAnalogChannel.ChannelName2;
HardwareChannelName = thatAnalogChannel.HardwareChannelName;
UserValue1 = thatAnalogChannel.UserValue1;
UserValue2 = thatAnalogChannel.UserValue2;
UserValue3 = thatAnalogChannel.UserValue3;
Description = thatAnalogChannel.Description;
Manufacturer = thatAnalogChannel.Manufacturer;
Model = thatAnalogChannel.Model;
DesiredRange = thatAnalogChannel.DesiredRange;
try
{
SensorCapacity = thatAnalogChannel.SensorCapacity;
}
catch (System.Exception ex)
{
APILogger.Log("could not get sensorcapacity, ", ex);
}
EngineeringUnits = thatAnalogChannel.EngineeringUnits;
ExcitationVoltage = thatAnalogChannel.ExcitationVoltage;
IsConfigured = true;
IsInverted = thatAnalogChannel.IsInverted;
LinearizationFormula = thatAnalogChannel.LinearizationFormula;
DigitalMultiplier = thatAnalogChannel.DigitalMultiplier;
DigitalMode = thatAnalogChannel.DigitalMode;
IsSubsampled = thatAnalogChannel.IsSubsampled;
if (thatAnalogChannel.IsLastCalibrationDateValid) { LastCalibrationDate = thatAnalogChannel.LastCalibrationDate; }
if (thatAnalogChannel.IsSensorIDValid) { SensorID = thatAnalogChannel.SensorID; }
if (thatAnalogChannel.IsOffsetToleranceLowMvValid) { OffsetToleranceLowMv = thatAnalogChannel.OffsetToleranceLowMv; }
if (thatAnalogChannel.IsOffsetToleranceHighMvValid) { OffsetToleranceHighMv = thatAnalogChannel.OffsetToleranceHighMv; }
InitialOffset = thatAnalogChannel.InitialOffset;
InitialEu = thatAnalogChannel.InitialEu;
if (thatAnalogChannel.IsIsoCodeValid) { IsoCode = thatAnalogChannel.IsoCode; }
NoiseAsPercentageOfFullScale = thatAnalogChannel.NoiseAsPercentageOfFullScale;
Number = thatAnalogChannel.Number;
PreTestZeroLevelAdc = thatAnalogChannel.PreTestZeroLevelAdc;
WindowAverageADC = thatAnalogChannel.WindowAverageADC;
ZeroMvInADC = thatAnalogChannel.ZeroMvInADC;
//try { this.ZeroMvInADC = thatAnalogChannel.ZeroMvInADC; }
AbsoluteDisplayOrder = thatAnalogChannel.AbsoluteDisplayOrder;
//this.PreTestZeroLevelMv = thatAnalogChannel.PreTestZeroLevelmV;
if (thatAnalogChannel.RemoveOffset) { RemovedADC = thatAnalogChannel.RemovedADC; }
else { RemovedADC = 0; }
ProportionalToExcitation = thatAnalogChannel.ProportionalToExcitation;
RemoveOffset = thatAnalogChannel.RemoveOffset;
Sensitivity = thatAnalogChannel.Sensitivity;
SerialNumber = thatAnalogChannel.SerialNumber;
ShuntEnabled = thatAnalogChannel.ShuntEnabled;
VoltageInsertionCheckEnabled = thatAnalogChannel.VoltageInsertionCheckEnabled;
CalSignalEnabled = thatAnalogChannel.CalSignalEnabled;
Start = thatAnalogChannel.Start;
ZeroAverageWindow = thatAnalogChannel.ZeroAverageWindow;
ZeroMethod = thatAnalogChannel.ZeroMethod;
UnitConversion = thatAnalogChannel.UnitConversion;
AtCapacity = thatAnalogChannel.AtCapacity;
CapacityOutputIsBasedOn = thatAnalogChannel.CapacityOutputIsBasedOn;
SensitivityUnits = thatAnalogChannel.SensitivityUnits;
var bWorked = false;
try
{
if (thatAnalogChannel.MeasureShuntDeflectionMvValid)
{
MeasuredShuntDeflectionMv = thatAnalogChannel.MeasuredShuntDeflectionMv;
bWorked = true;
}
if (!thatAnalogChannel.ShuntEnabled)
{
bWorked = false;
}
}
catch { bWorked = false; }
if (!bWorked)
{
/*ReviewableAttributes.RemoveAll(
delegate(ReviewableAttribute attribute)
{
return attribute is ReviewableMeasuredShuntDeflectionAttribute // Can't display it, so remove it
|| attribute is ReviewableShuntDeflectionPercentageAttribute; //
}
);*/
}
bWorked = false;
try
{
if (thatAnalogChannel.TargetShuntDeflectionMvValid)
{
TargetShuntDeflectionMv = thatAnalogChannel.TargetShuntDeflectionMv;
bWorked = true;
}
if (!thatAnalogChannel.ShuntEnabled)
{
bWorked = false;
}
}
catch { bWorked = false; }
if (!bWorked)
{
/*ReviewableAttributes.RemoveAll(
delegate(ReviewableAttribute attribute)
{
return attribute is ReviewableTargetShuntDeflectionAttribute // Can't display it, so remove it
|| attribute is ReviewableShuntDeflectionPercentageAttribute;
}
);*/
}
bWorked = false;
try
{
if (thatAnalogChannel.MeasuredCalSignalMvValid)
{
MeasuredCalSignalMv = thatAnalogChannel.MeasuredCalSignalMv;
bWorked = true;
}
}
catch { bWorked = false; }
if (!bWorked)
{
/*ReviewableAttributes.RemoveAll(
delegate(ReviewableAttribute attribute)
{
return attribute is ReviewableMeasuredCalSignalAttribute // Can't display it, so remove it
|| attribute is ReviewableCalSignalPercentageAttribute; //
}
);*/
}
bWorked = false;
try
{
if (thatAnalogChannel.TargetCalSignalMvValid)
{
TargetCalSignalMv = thatAnalogChannel.TargetCalSignalMv;
bWorked = true;
}
}
catch { bWorked = false; }
if (!bWorked)
{
/*ReviewableAttributes.RemoveAll(
delegate(ReviewableAttribute attribute)
{
return attribute is ReviewableTargetCalSignalAttribute // Can't display it, so remove it
|| attribute is ReviewableCalSignalPercentageAttribute;
}
);*/
}
try
{
if (thatAnalogChannel.TriggerAboveThresholdValid)
{
TriggerAboveThresholdEu = thatAnalogChannel.TriggerAboveThresholdEu;
}
}
catch { }
try
{
if (thatAnalogChannel.TriggerBelowThresholdValid)
{
TriggerBelowThresholdEu = thatAnalogChannel.TriggerBelowThresholdEu;
}
}
catch { }
try
{
if (thatAnalogChannel.LevelTriggerTypeValid)
{
LevelTriggerType = thatAnalogChannel.LevelTriggerType;
}
}
catch { }
//try { this.TriggerBelowThresholdEu = thatAnalogChannel.TriggerBelowThresholdEu; }
//catch { /* no reviewable attributes to remove... yet */ }
try
{
if (thatAnalogChannel.MeasuredExcitationVoltageValid)
{
MeasuredExcitationVoltage = thatAnalogChannel.MeasuredExcitationVoltage;
}
}
catch { /* leave it uninitialized */ }
try
{
if (thatAnalogChannel.FactoryExcitationVoltageValid)
{
FactoryExcitationVoltage = thatAnalogChannel.FactoryExcitationVoltage;
}
}
catch { /* leave it uninitialized */ }
//try { this.TimeOfFirstSampleSec = thatAnalogChannel.TimeOfFirstSampleSec; }
//catch { /* leave it uninitialized */ }
try
{
if (thatAnalogChannel.TimeOfFirstSampleValid)
{
TimeOfFirstSampleSec = thatAnalogChannel.TimeOfFirstSampleSec;
}
}
catch { }
CurrentFilter = SaeJ211Filter.Parse(thatAnalogChannel.SoftwareFilter);
if (!AvailableFilters.Contains(CurrentFilter))
AvailableFilters.Add(CurrentFilter);
MvPerEu = that.Data.MvPerEu;
ScaleFactorMv = that.Data.ScaleFactorMv;
if (thatAnalogChannel.PersistentChannelInfo == null)
{
UnfilteredData = thatAnalogChannel.TDASPersistentChannelInfo;
}
else
{
UnfilteredData = thatAnalogChannel.PersistentChannelInfo; // new List<short>( that.Data.Values );
}
FileName = thatAnalogChannel.FileName ?? string.Empty;
//double windowAve = double.NaN;
//Scaler.SetIRTraccZeros(windowAve, thatAnalogChannel.OriginalOffsetADC);
}
else
{
throw new ArgumentException("Can't initialize from a " + that.GetType().FullName + " object");
}
}
catch (System.Exception ex)
{
throw new Exception("encountered problem initializing from " + GetType().FullName + " to " + typeof(Serialization.Test.Module.Channel).FullName, ex);
}
}
/// <summary>
/// Generate a <see cref="string"/> representation for this object.
/// </summary>
///
/// <returns>
/// The <see cref="string"/> representation of this object.
/// </returns>
///
public override string ToString()
{
try
{
return !string.IsNullOrEmpty(ChannelDescriptionString) ? ChannelDescriptionString : Description;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem getting string representation", ex);
}
}
/// <summary>
/// Get the <see cref="double"/> data range in EU.
/// </summary>
public override double DataRangeEu => Math.Abs(Scaler.GetEU(DataRangeAdc));
/// <summary>
/// Get the <see cref="double"/> data range/2 in EU.
/// </summary>
public override double DataHalfRangeValueEu => Scaler.GetEU(DataHalfRangeValueAdc);
/// <summary>
/// Get the <see cref="double"/> data min in EU.
/// </summary>
public override double DataMinEu => (Scaler.GetAdcToEuScalingFactor() >= 0) ?
Scaler.GetEU(DataMinAdc) :
Scaler.GetEU(DataMaxAdc);
/// <summary>
/// Get the <see cref="double"/> data max in EU.
/// </summary>
public override double DataMaxEu => (Scaler.GetAdcToEuScalingFactor() >= 0) ?
Scaler.GetEU(DataMaxAdc) :
Scaler.GetEU(DataMinAdc);
/// <summary>
/// Get the actual available maximum EU range based on scaling factor and bit resolution.
/// </summary>
public override double ActualMaxRangeEu
{
get
{
try
{
var min = Scaler.GetEU(ActualMinRangeAdc);
var max = Scaler.GetEU(ActualMaxRangeAdc);
if (double.IsNaN(min) || double.IsNaN(max))
{
min = -150;
max = 150;
}
else if (min > max)
{
var temp = min;
min = max;
max = temp;
}
if ((Scaler.GetAdcToEuScalingFactor() >= 0 || ((true == IsInverted) ^ (Sensitivity < 0))))
{
return max;
}
return min;
//return (Scaler.GetAdcToEuScalingFactor() >= 0) ? max : min;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem calculating actual max EU range", ex);
}
}
}
/// <summary>
/// Get the actual available minimum EU range based on scaling factor and bit resolution.
/// </summary>
public override double ActualMinRangeEu
{
get
{
try
{
var min = Scaler.GetEU(ActualMinRangeAdc);
var max = Scaler.GetEU(ActualMaxRangeAdc);
if (double.IsNaN(min) || double.IsNaN(max))
{
min = -150;
max = 150;
}
else if (min > max)
{
var temp = min;
min = max;
max = temp;
}
if ((Scaler.GetAdcToEuScalingFactor() >= 0 || ((true == IsInverted) ^ (Sensitivity < 0))))
{
return min;
}
return max;
//return (Scaler.GetAdcToEuScalingFactor() >= 0) ? min : max;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem calculating actual min EU range", ex);
}
}
}
public void PersistentChannelUnset()
{
if (UnfilteredData is Serialization.SliceRaw.File.PersistentChannel)
{
(UnfilteredData as Serialization.SliceRaw.File.PersistentChannel).UnSet();
}
else
{
//Viewing TDC data
(UnfilteredData as Serialization.TDAS.File.PersistentChannel).UnSet();
}
}
public override List<double> GetUnfilteredDataEu()
{
if (UnfilteredData is Serialization.SliceRaw.File.PersistentChannel)
{
using (var persistentUnfilteredData = UnfilteredData as Serialization.SliceRaw.File.PersistentChannel)
{
var dataCount = persistentUnfilteredData.Count;
var Unfiltered_Data_Eu = new List<double>(dataCount);
for (var i = 0; i < dataCount; i++)
{
try
{
//Unfiltered_Data_Eu.Add(Scaler.GetEU(persistentUnfilteredData[i]));
var temp = Scaler.GetEU(persistentUnfilteredData[i]);
Unfiltered_Data_Eu.Add(temp);
}
catch (System.Exception ex)
{
APILogger.Log("problem getting SliceRAW unfiltered data ", ex);
}
}
//persistentUnfilteredData.Dispose();
return Unfiltered_Data_Eu;
}
}
using (var persistentUnfilteredData = UnfilteredData as Serialization.TDAS.File.PersistentChannel)
{
var dataCount = persistentUnfilteredData.Count;
var Unfiltered_Data_Eu = new List<double>(dataCount);
for (var i = 0; i < dataCount; i++)
{
try
{
var temp = Scaler.GetEU(persistentUnfilteredData[i]);
Unfiltered_Data_Eu.Add(temp);
}
catch (System.Exception ex)
{
APILogger.Log("problem getting TDAS unfiltered data ", ex);
}
}
//persistentUnfilteredData.Dispose();
return Unfiltered_Data_Eu;
}
}
public override List<double> GetUnfilteredDataMV()
{
if (UnfilteredData is Serialization.SliceRaw.File.PersistentChannel)
{
using (var persistentUnfilteredData = UnfilteredData as Serialization.SliceRaw.File.PersistentChannel)
{
var dataCount = persistentUnfilteredData.Count;
var Unfiltered_Data_MV = new List<double>(dataCount);
for (var i = 0; i < dataCount; i++)
{
try
{
//Unfiltered_Data_Eu.Add(Scaler.GetEU(persistentUnfilteredData[i]));
var temp = Scaler.GetMv(persistentUnfilteredData[i]);
Unfiltered_Data_MV.Add(temp);
}
catch (System.Exception ex)
{
APILogger.Log("problem getting SliceRAW unfiltered data ", ex);
}
}
//persistentUnfilteredData.Dispose();
return Unfiltered_Data_MV;
}
}
using (var persistentUnfilteredData = UnfilteredData as Serialization.TDAS.File.PersistentChannel)
{
var dataCount = persistentUnfilteredData.Count;
var Unfiltered_Data_MV = new List<double>(dataCount);
for (var i = 0; i < dataCount; i++)
{
try
{
var temp = Scaler.GetMv(persistentUnfilteredData[i]);
Unfiltered_Data_MV.Add(temp);
}
catch (System.Exception ex)
{
APILogger.Log("problem getting TDAS unfiltered data ", ex);
}
}
//persistentUnfilteredData.Dispose();
return Unfiltered_Data_MV;
}
}
public override double DesiredRangeEU => DesiredRange;
public override double SensorCapacityEU => SensorCapacity;
}
}
}
}