/*
Test.Module.Channel.Sensor.ExcitationVoltage.cs
Copyright © 2008
Diversified Technical Systems, Inc.
All Rights Reserved
*/
using System;
using System.ComponentModel;
using DTS.Common.Enums;
using DTS.Common.Utilities;
using DTS.Common.Utilities.Logging;
namespace DTS.Common.DAS.Concepts
{
// *** see Test.cs ***
public partial class Test
{
///
/// A container for DTS generic module concepts.
///
public sealed partial class Module
{
// *** see Test.Module.Channel.cs ***
public partial class Channel
{
//*** see DTS.Common.DAS.Concepts.Test.Module.Channel.Sensor.cs ***
public partial class Sensor
{
/////
///// All available excitation voltages.
/////
//public enum ExcitationVoltageOption
//{
// ///
// /// undefined excitation voltage
// ///
// [VoltageMagnitude(0.0)]
// [Description("Undefined")]
// Undefined=1,
// ///
// /// 2V
// ///
// [VoltageMagnitude(2.0)]
// [Description("2.0")]
// Volt2=2,
// ///
// /// 2.5V
// ///
// [VoltageMagnitude(2.5)]
// [Description("2.5")]
// Volt2_5=4,
// ///
// /// 3.0V
// ///
// [VoltageMagnitude(3.0)]
// [Description("3.0")]
// Volt3=8,
// ///
// /// 5V
// ///
// [VoltageMagnitude( 5.0 )]
// [Description("5.0")]
// Volt5=16,
// ///
// /// 10V
// ///
// [VoltageMagnitude( 10.0 )]
// [Description("10.0")]
// Volt10=32,
// ///
// /// 1V
// ///
// [VoltageMagnitude(1.0)]
// [Description("1.0")]
// Volt1 = 64
//}
///
/// Converts a specified excitation voltage option into its associated numeric value.
///
///
///
/// The value
/// to be converted.
///
///
///
/// The magnitude associated with the specified voltage option.
///
///
public static double GetExcitationVoltageMagnitudeFromEnum(ExcitationVoltageOptions.ExcitationVoltageOption target)
{
try
{
return new ExcitationVoltageOptions.VoltageMagnitudeAttributeCoder().DecodeAttributeValue(target);
}
catch (Exception ex)
{
throw new ArgumentException("encountered problem attempting to get excitation voltage magnitude from enum", ex);
}
}
///
/// Converts a specified voltage magnitude to the associated numeric value (if it exists;
/// otherwise an exception is thrown).
///
///
///
/// The magnitude to be converted.
///
///
///
/// The value
/// associated with the specified magnitude (if it exists).
///
///
public static ExcitationVoltageOptions.ExcitationVoltageOption GetExcitationVoltageEnumFromMagnitude(double magnitude)
{
try
{
return new ExcitationVoltageOptions.VoltageMagnitudeAttributeCoder().EncodeAttributeValue(magnitude);
}
catch (Exception ex)
{
APILogger.Log("encountered problem attempting to get excitation voltage enum from magnitude", ex);
return ExcitationVoltageOptions.ExcitationVoltageOption.Undefined;
}
}
/////
///// Attribute for specifying the numerical magnitude of the attached field's
///// "representation". Intended to be used with enumerations whose members represent
///// voltage magnitude options so that the enum item can have a corresponding numerical
///// value that can be extracted and used in calculations.
/////
//[AttributeUsage(AttributeTargets.Field)]
//public class VoltageMagnitudeAttribute: Attribute
//{
// ///
// /// returns voltage magnitude
// ///
// public double Value { get; }
// ///
// /// constructs a
// /// with a given value
// ///
// ///
// public VoltageMagnitudeAttribute(double value) { Value = value; }
//}
/////
///// Object for manipulating voltage option enumeration-attached
///// magnitude values.
/////
//public class VoltageMagnitudeAttributeCoder
// : AttributeCoder
//{
// ///
// /// Initializes a object.
// ///
// public VoltageMagnitudeAttributeCoder()
// : base(attribute => attribute.Value, null)
// {
// }
//}
}
}
}
}
}