Files
DP44/Common/DTS.CommonCore/.svn/pristine/d5/d5d2fe071ba2497cb15f000348ea9000403f3cd5.svn-base

100 lines
3.2 KiB
Plaintext
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DTS.Common.Utilities;
namespace DTS.Common.Enums
{
public class ExcitationVoltageOptions
{
/// <summary>
/// All available excitation voltages.
/// </summary>
public enum ExcitationVoltageOption
{
/// <summary>
/// undefined excitation voltage
/// </summary>
[VoltageMagnitude(0.0)]
[Description("Undefined")]
Undefined = 1,
/// <summary>
/// 2V
/// </summary>
[VoltageMagnitude(2.0)]
[Description("2.0")]
Volt2 = 2,
/// <summary>
/// 2.5V
/// </summary>
[VoltageMagnitude(2.5)]
[Description("2.5")]
Volt2_5 = 4,
/// <summary>
/// 3.0V
/// </summary>
[VoltageMagnitude(3.0)]
[Description("3.0")]
Volt3 = 8,
/// <summary>
/// 5V
/// </summary>
[VoltageMagnitude(5.0)]
[Description("5.0")]
Volt5 = 16,
/// <summary>
/// 10V
/// </summary>
[VoltageMagnitude(10.0)]
[Description("10.0")]
Volt10 = 32,
/// <summary>
/// 1V
/// </summary>
[VoltageMagnitude(1.0)]
[Description("1.0")]
Volt1 = 64
}
/// <summary>
/// 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.
/// </summary>
[AttributeUsage(AttributeTargets.Field)]
public class VoltageMagnitudeAttribute : Attribute
{
/// <summary>
/// returns voltage magnitude
/// </summary>
public double Value { get; }
/// <summary>
/// constructs a <see cref="ExcitationVoltageOptions.VoltageMagnitudeAttribute" />
/// with a given value
/// </summary>
/// <param name="value"></param>
public VoltageMagnitudeAttribute(double value) { Value = value; }
}
/// <summary>
/// Object for manipulating voltage option enumeration-attached
/// <see cref="double"/> magnitude values.
/// </summary>
public class VoltageMagnitudeAttributeCoder
: AttributeCoder<ExcitationVoltageOptions.ExcitationVoltageOption, VoltageMagnitudeAttribute, double>
{
/// <summary>
/// Initializes a <see cref="ExcitationVoltageOptions.VoltageMagnitudeAttributeCoder"/> object.
/// </summary>
public VoltageMagnitudeAttributeCoder()
: base(attribute => attribute.Value, null)
{
}
}
}
}