36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using System;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace DTS.DASLib.Service
|
|
{
|
|
/// <inheritdoc />
|
|
/// <summary>
|
|
/// this attribute allows us to associate a max input range in mV for a gain
|
|
/// note that this can be computed using the gain itself and the input range
|
|
/// but this allows us to more tightly control things (say by using 2450 instead of 2500 for full range or something similar)
|
|
/// http://fogbugz/fogbugz/default.asp?10080
|
|
/// </summary>
|
|
public class MaxInputRangeAttribute : Attribute
|
|
{
|
|
/// <summary>
|
|
/// returns the max input range in mV for gain
|
|
/// http://fogbugz/fogbugz/default.asp?10080
|
|
/// </summary>
|
|
/// <param name="o"></param>
|
|
/// <returns></returns>
|
|
public static double GetMaxInputRangemV(object o)
|
|
{
|
|
if (o == null) return 0D;
|
|
var mi = o.GetType().GetMember(o.ToString());
|
|
if (mi.Length <= 0) return 0D;
|
|
return GetCustomAttribute(mi[0], typeof(MaxInputRangeAttribute)) is MaxInputRangeAttribute attr ? attr._maximumInputRangemV : 0D;
|
|
}
|
|
|
|
private readonly double _maximumInputRangemV;
|
|
public MaxInputRangeAttribute(double maxInputRangemV)
|
|
{
|
|
_maximumInputRangemV = maxInputRangemV;
|
|
}
|
|
}
|
|
}
|