Files
DP44/Common/DTS.Common.Serialization/SliceRaw/SliceRaw.File.PersistentEuChannel.cs
2026-04-17 14:55:32 -04:00

130 lines
4.4 KiB
C#

/*
* SliceRaw.File.PersistentEuChannel.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using DTS.Common.DAS.Concepts;
using DTS.Common.Utilities;
using DTS.Common.Utilities.DotNetProgrammingConstructs;
namespace DTS.Serialization.SliceRaw
{
public partial class File
{
public class PersistentEuChannel : ExceptionalList<double>
{
/// <summary>
/// Initialize an instance of the DTS.Serialization.SliceRaw.File.PersistentEuChannel class.
/// </summary>
///
/// <param name="persistentChannel">
/// The <see cref="DTS.Serialization.SliceRaw.File.PersistentChannel"/> to be wrapped by this
/// "to EU" conversion class.
/// </param>
///
/// <param name="scaler">
/// The <see cref="DTS.Common.DAS.ConceptsDataScalar"/> object that defines the conversion from
/// ADC to EU for the wrapped data.
/// </param>
///
public PersistentEuChannel(PersistentChannel persistentChannel, DataScaler scaler)
{
try
{
BasePersistentChannel = persistentChannel;
EuDataScaler = scaler;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem constructing " + GetType().FullName, ex);
}
}
/// <summary>
/// Get/set the base persistent channel of this EU-ifying wrapper.
/// </summary>
public PersistentChannel BasePersistentChannel
{
get => _BasePersistentChannel.Value;
set => _BasePersistentChannel.Value = value;
}
private readonly Property<PersistentChannel> _BasePersistentChannel
= new Property<PersistentChannel>(
typeof(PersistentEuChannel).Namespace + ".PersistentEuChannel.BasePersistentChannel",
null,
false
);
/// <summary>
/// Get/set the data scaler for converting the ADC data wrapped by this class to EU.
/// </summary>
public DataScaler EuDataScaler
{
get => _EuDataScaler.Value;
set => _EuDataScaler.Value = value;
}
private readonly Property<DataScaler> _EuDataScaler
= new Property<DataScaler>(
typeof(PersistentEuChannel).Namespace + ".PersistentEuChannel.EuDataScaler",
null,
false
);
public double this[ulong i]
{
get
{
try
{
return EuDataScaler.GetEU(BasePersistentChannel[i]);
}
catch (System.Exception ex)
{
throw new Exception("encountered problem getting value at index " + i.ToString(), ex);
}
}
set
{
try
{
throw new NotSupportedException("SliceRaw::File::PersistentEuChannel::[] values are read-only");
}
catch (System.Exception ex)
{
throw new Exception("encountered problem setting value at index " + i.ToString(), ex);
}
}
}
/// <summary>
/// Get the <see cref="long"/> length of this persistent channel's data.
/// </summary>
public long Length => BasePersistentChannel.Length;
/// <summary>
/// Dispose of this object's Disposables.
/// </summary>
public void Dispose()
{
try
{
BasePersistentChannel.Dispose();
}
catch (System.Exception ex)
{
throw new PersistentChannel.Exception("encountered problem disposing of " + GetType().FullName, ex);
}
}
}
}
}