Files
2026-04-17 14:55:32 -04:00

150 lines
8.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
source_files:
- Common/DTS.Common.Serialization/Control/Event/Module/ReviewableDasSerialNumberAttribute.cs
- Common/DTS.Common.Serialization/Control/Event/Module/ReviewableAttribute.cs
- Common/DTS.Common.Serialization/Control/Event/Module/ReviewableSampleRateAttribute.cs
- Common/DTS.Common.Serialization/Control/Event/Module/Module.cs
generated_at: "2026-04-16T03:41:50.953091+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "ac685bc8f1311025"
---
# Documentation: `DTS.Slice.Control.Event.Module.ReviewableAttribute` and Related Classes
## 1. Purpose
This module provides a framework for defining *reviewable attributes*—read-only, human-readable metadata properties attached to a specific `Event.Module` instance—that can be used during test review or reporting workflows. Specifically, it defines an abstract base class `ReviewableAttribute` and several concrete subclasses (e.g., `ReviewableDasSerialNumberAttribute`, `ReviewableSampleRateAttribute`, `ReviewableHardwareFrequencyAttribute`, `ReviewableTestDescriptionAttribute`) that expose module-level data (such as DAS serial number, sample rate, hardware anti-aliasing filter rate, and test description) in a standardized, reviewable format. These attributes are intended to be consumed by downstream review UIs or export tools that need to display or validate module-level metadata.
## 2. Public Interface
### `ReviewableAttribute` (Abstract Base Class)
- **Namespace**: `DTS.Slice.Control.Event.Module`
- **Inherits from**: `Slice.Control.ReviewableAttribute` (external type, not shown in provided sources)
- **Purpose**: Base class for all reviewable attributes attached to a `Module`.
#### Constructors
- `protected ReviewableAttribute(string name, DetermineValueString calculateValue)`
- **Parameters**:
- `name`: `string` The display name of the attribute.
- `calculateValue`: `DetermineValueString` A delegate (function pointer) that returns the attributes value as a `string`.
- **Behavior**: Initializes the base class with the provided name and value calculation delegate. This is the *only* constructor intended for use by subclasses.
- `public ReviewableAttribute(Event.Module module)` *(non-functional)*
- **Behavior**: Throws a `NotImplementedException` wrapped in a `Module.ReviewableAttribute.Exception`. This constructor exists only to enforce that subclasses must use the parameterized constructor.
#### Nested Exception Type
- `public class Exception : Exception`
- **Purpose**: Custom exception type used internally by `ReviewableAttribute` for constructor failures.
---
### `ReviewableDasSerialNumberAttribute`
- **Namespace**: `DTS.Slice.Control.Event.Module`
- **Inherits from**: `ReviewableAttribute`
- **Purpose**: Exposes the DAS serial number of the parent `Module`.
#### Constructor
- `public ReviewableDasSerialNumberAttribute(Event.Module module)`
- **Parameters**:
- `module`: `Event.Module` The module to which this attribute is attached.
- **Behavior**: Calls the base constructor with:
- `name = "DAS Serial Number"`
- `calculateValue = () => module.DasSerialNumber`
- **Result**: The attributes value is the string value of `module.DasSerialNumber`.
---
### `ReviewableSampleRateAttribute`
- **Namespace**: `DTS.Slice.Control.Event.Module`
- **Inherits from**: `ReviewableAttribute`
- **Purpose**: Exposes the sample rate of the module, formatted with thousand separators.
#### Constructor
- `public ReviewableSampleRateAttribute(Event.Module module)`
- **Parameters**:
- `module`: `Event.Module`
- **Behavior**: Calls base constructor with:
- `name = "Sample Rate"`
- `calculateValue = () => module.SampleRateHz.ToString("N")`
- **Result**: The attributes value is `module.SampleRateHz.ToString("N")` (e.g., `"10,000.00"`).
---
### `ReviewableTestDescriptionAttribute`
- **Namespace**: `DTS.Slice.Control.Event.Module`
- **Inherits from**: `ReviewableAttribute`
- **Purpose**: Exposes the description of the *parent event* (not the module itself).
#### Constructor
- `public ReviewableTestDescriptionAttribute(Event.Module module)`
- **Parameters**:
- `module`: `Event.Module`
- **Behavior**: Calls base constructor with:
- `name = "Test Description"`
- `calculateValue = () => module.ParentEvent.Description`
- **Result**: The attributes value is `module.ParentEvent.Description`.
---
### `ReviewableHardwareFrequencyAttribute`
- **Namespace**: `DTS.Slice.Control.Event.Module`
- **Inherits from**: `ReviewableAttribute`
- **Purpose**: Exposes the hardware anti-aliasing filter rate, formatted to two decimal places.
#### Constructor
- `public ReviewableHardwareFrequencyAttribute(Event.Module module)`
- **Parameters**:
- `module`: `Event.Module`
- **Behavior**: Calls base constructor with:
- `name = "HW AAF"`
- `calculateValue = () => module.AaFilterRateHz.ToString("N2")`
- **Result**: The attributes value is `module.AaFilterRateHz.ToString("N2")` (e.g., `"5,000.00"`).
---
## 3. Invariants
- **Attribute Name Consistency**: Each subclass hardcodes its `name` in the base constructor call. The names used are:
- `"DAS Serial Number"`
- `"Sample Rate"`
- `"Test Description"`
- `"HW AAF"`
- **Value Calculation Must Not Be Null**: The `calculateValue` delegate passed to the base constructor must return a non-null `string`. If `module.DasSerialNumber`, `module.SampleRateHz`, etc., are `null` or `0`, the `ToString()` call may produce `"0"` or empty string, but no validation is performed.
- **Parent Module Must Be Non-null**: The `module` parameter passed to any subclass constructor must be non-null; otherwise, dereferencing `module.DasSerialNumber`, `module.SampleRateHz`, etc., will throw `NullReferenceException`.
- **No Runtime Validation**: There is no validation in the constructors or elsewhere to ensure the attribute name or value format conforms to any external schema—only formatting is applied via `ToString()`.
## 4. Dependencies
### Dependencies *of* this module:
- **`DTS.Slice.Control.Event.Module`** (`Module.cs`): Provides the `Module` class whose properties (`DasSerialNumber`, `SampleRateHz`, `AaFilterRateHz`, `ParentEvent.Description`) are accessed by the attribute subclasses.
- **`DTS.Slice.Control.ReviewableAttribute`** (external): Base class for `ReviewableAttribute`. Its `DetermineValueString` delegate type is assumed to be defined there.
- **`DTS.Utilities`**: Used only for logging (not directly used in these files, but imported).
- **`System`**: Standard .NET types (`string`, `delegate`, `Exception`, etc.).
### Dependencies *on* this module:
- **Unknown from source alone**: No direct callers are visible in the provided files. However, the naming and structure suggest this is used by a review/reporting subsystem (e.g., UI or export tool) that instantiates these attributes and calls into the base `ReviewableAttribute` API (e.g., to retrieve `Name` and `Value`).
## 5. Gotchas
- **Misleading XML Comments**: `ReviewableSampleRateAttribute` and `ReviewableHardwareFrequencyAttribute` are documented as “A reviewable filter frequency attribute attached to a specific channel.” — but they are attached to a `Module`, not a `Channel`. This is likely copy-paste error in comments.
- **`ReviewableTestDescriptionAttribute` accesses `ParentEvent.Description`**, not `module.Description`. This may be intentional (e.g., to avoid duplication if description is event-level), but its non-obvious and could cause confusion.
- **`ReviewableAttribute` constructor with `module` parameter is non-functional**: The constructor throws `NotImplementedException`. Subclasses *must* use the `protected` constructor with `name` and `calculateValue`. This is a safeguard, but could mislead developers into thinking the single-parameter constructor is usable.
- **No `ToString()` formatting validation**: If `module.SampleRateHz` or `module.AaFilterRateHz` is `NaN` or `Infinity`, `ToString("N")` or `ToString("N2")` may produce `"NaN"`, `"Infinity"`, or `"Infinity"`—which may not be desired for review displays.
- **`StartRecordTimestampNanoSec` bug in `FromDtsSerializationTestModule`**: In `Module.cs`, line `TriggerTimestampNanoSec = that.StartRecordTimestampNanoSec;` appears to be a typo (should be `that.TriggerTimestampNanoSec`). While not directly in this module, it suggests potential data inconsistency risk in related code.
- **No `Equals`/`GetHashCode` override in `ReviewableAttribute` subclasses**: Since these are likely used as keys or in collections, lack of value-based equality may cause subtle bugs. However, this is not evident from the source alone—no usage patterns are shown.
> **Note**: No usage of `ReviewableAttribute` beyond construction is visible in the provided files. The actual mechanism for invoking `calculateValue` (e.g., via a public `Value` property inherited from `Slice.Control.ReviewableAttribute`) is not documented here and must be assumed from the base class.