6.6 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||
|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T03:57:34.431495+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 9e76f2c3f64de0c9 |
InputRangeAttributes
Documentation: Input Range Attribute Classes
1. Purpose
This module defines a set of custom attribute classes used to annotate gain enumerations (likely in an input range configuration system) with metadata that controls gain behavior, availability, and interface constraints. Specifically, it enables fine-grained control over gain disablement, maximum/minimum input ranges (in mV), firmware-specific input ranges, and availability for unmodified hardware variants (e.g., Gen 3 SPS). These attributes are applied at compile-time via reflection and queried at runtime to enforce system-level constraints without hardcoding logic, supporting flexibility for calibration, hardware variants, and future tuning.
2. Public Interface
All classes reside in the DTS.DASLib.Service namespace and derive from System.Attribute. Each provides a static method to query the attribute value from an enum field (passed as object), and a constructor to set the attribute’s value.
-
GainDisabledAttributeGainDisabledAttribute(bool disabled)
Constructor. Sets_bDisabledto the provided value.static bool IsGainDisabled(object o)
Returnstrueifois non-null, represents a valid enum field, and that field has aGainDisabledAttributewith_bDisabled == true. Returnsfalseotherwise (including fornull, missing members, or missing attribute).
-
MaxInputRangeAttributeMaxInputRangeAttribute(double maxInputRangemV)
Constructor. Sets_maximumInputRangemVto the provided value (in mV).static double GetMaxInputRangemV(object o)
Returns_maximumInputRangemVifois non-null, represents a valid enum field, and that field has aMaxInputRangeAttribute. Returns0Dotherwise.
-
GainAvailableUnmodifiedAttributeGainAvailableUnmodifiedAttribute(bool available)
Constructor. Sets_bAvailableto the provided value.static bool IsGainAvailableToUnmodified(object o)
Returnsfalseonly ifois non-null, represents a valid enum field, and that field has aGainAvailableUnmodifiedAttributewith_bAvailable == false. Returnstrueotherwise (including fornull, missing members, or missing attribute).
-
MinInputRangeAttributeMinInputRangeAttribute(double minInputRangemV)
Constructor. Sets_minimumInputRangemVto the provided value (in mV).static double GetMinInputRangemV(object o)
Returns_minimumInputRangemVifois non-null, represents a valid enum field, and that field has aMinInputRangeAttribute. Returns0Dotherwise.
-
FirmwareInputRangeAttributeFirmwareInputRangeAttribute(double firmwareInputRangemV)
Constructor. Sets_firmwareInputRangeAttributeto the provided value (in mV).static double GetFirmwareInputRangemV(object o)
Returns_firmwareInputRangeAttributeifois non-null, represents a valid enum field, and that field has aFirmwareInputRangeAttribute. Returns0Dotherwise.
3. Invariants
- All attributes are optional by design: if an enum field lacks a given attribute, default values apply (e.g.,
IsGainDisabled→false,IsGainAvailableToUnmodified→true, range getters →0D). - The static query methods assume the input
ois an enum value (ornull). They useo.ToString()to look up the correspondingMemberInfovia reflection (GetMember(o.ToString())). - Attribute values are immutable after construction (
_bDisabled,_maximumInputRangemV, etc. arereadonly). - Range values are interpreted as millivolts (mV).
- The
FirmwareInputRangeAttributeis intended to represent a firmware-selectable range, possibly derived from neighboring gain steps (e.g., midpoint between adjacent gains), to avoid unintended gain-step changes during operation.
4. Dependencies
- Dependencies:
System(forAttribute,Type, reflection APIs).- Implicit dependency on the enum type(s) that these attributes annotate (e.g.,
InputRangeGainor similar). These attributes are meaningless without such enums.
- Depended upon by:
- Unknown from source alone. Likely used by input configuration, calibration, or firmware interface modules that inspect gain enums at runtime via reflection (e.g., to determine valid ranges or skip disabled gains).
- All attributes reference the same FogBugz ticket (
10080), suggesting a shared context (likely gain/range configuration for a specific hardware platform).
5. Gotchas
- Reflection-based lookup is fragile:
GetMember(o.ToString())assumes the enum field name matchesToString(). If the enum usesDisplayattributes or customToString()overrides, this may fail or return incorrect members.- If
o.ToString()returns a non-field name (e.g., due toFlagsenum formatting like"A, B"),GetMembermay return an empty array → default values.
FirmwareInputRangeAttributefield name typo:- The private field is named
_firmwareInputRangeAttribute(note: Attribute suffix), while the property/constructor parameter usesfirmwareInputRangemV. This is likely a typo but is preserved as-is in the source.
- The private field is named
- No validation of range values:
- No checks ensure
MinInputRangeAttribute≤MaxInputRangeAttribute, or thatFirmwareInputRangeAttributelies between them. Consumers must enforce this.
- No checks ensure
0Das sentinel value:- A return value of
0Dfrom range getters could mean either: (a) the attribute is absent, or (b) the attribute was explicitly set to0. Ambiguity may cause misinterpretation.
- A return value of
- No documentation of enum usage:
- The source files do not show how these attributes are applied (e.g.,
public enum Gain { [GainDisabled(true)] High = 3 }). Without concrete examples, it is unclear if attributes are applied to fields, values, or types.
- The source files do not show how these attributes are applied (e.g.,
- No thread-safety guarantees:
- Reflection calls (
GetMember,GetCustomAttribute) are not inherently thread-safe in older .NET versions, though modern runtimes typically handle this robustly. Not explicitly documented.
- Reflection calls (
- None identified from source alone.