88 lines
10 KiB
Markdown
88 lines
10 KiB
Markdown
---
|
|
source_files:
|
|
- Common/DTS.Common.SerializationPlus/Control/Event/Module/AnalogInputChannel/ReviewableShuntDeflectionAttribute.cs
|
|
- Common/DTS.Common.SerializationPlus/Control/Event/Module/AnalogInputChannel/ReviewableFilterFrequencyAttribute.cs
|
|
- Common/DTS.Common.SerializationPlus/Control/Event/Module/AnalogInputChannel/ReviewableIsoCodeAttribute.cs
|
|
- Common/DTS.Common.SerializationPlus/Control/Event/Module/AnalogInputChannel/ReviewableDescriptionAttribute.cs
|
|
- Common/DTS.Common.SerializationPlus/Control/Event/Module/AnalogInputChannel/ReviewableSerialNumberAttribute.cs
|
|
- Common/DTS.Common.SerializationPlus/Control/Event/Module/AnalogInputChannel/ReviewableUnitsAttribute.cs
|
|
- Common/DTS.Common.SerializationPlus/Control/Event/Module/AnalogInputChannel/ReviewableMinMaxEuAttribute.cs
|
|
- Common/DTS.Common.SerializationPlus/Control/Event/Module/AnalogInputChannel/ReviewableCfcAttribute.cs
|
|
- Common/DTS.Common.SerializationPlus/Control/Event/Module/AnalogInputChannel/ReviewableTargetShuntDeflectionAttribute.cs
|
|
- Common/DTS.Common.SerializationPlus/Control/Event/Module/AnalogInputChannel/ReviewableMeasuredShuntDeflectionAttribute.cs
|
|
- Common/DTS.Common.SerializationPlus/Control/Event/Module/AnalogInputChannel/ReviewableShuntDeflectionPercentageAttribute.cs
|
|
generated_at: "2026-04-16T03:31:33.249057+00:00"
|
|
model: "Qwen/Qwen3-Coder-Next-FP8"
|
|
schema_version: 1
|
|
sha256: "248b93b117b62a27"
|
|
---
|
|
|
|
# `DTS.Slice.Control.Event.Module.AnalogInputChannel.ReviewableAttribute` Derivatives
|
|
|
|
## 1. Purpose
|
|
|
|
This module defines a set of concrete `ReviewableAttribute` subclasses used to expose specific channel metadata and calibration-related values for review in the DTS Slice control event system. Each attribute encapsulates a human-readable label and a delegate that dynamically computes a formatted string representation of a channel property at runtime—primarily for inclusion in audit trails, calibration reports, or diagnostic UIs. These attributes are attached to `AnalogInputChannel` instances and provide a standardized way to surface configuration, calibration, and measurement data without hardcoding display logic elsewhere in the system.
|
|
|
|
## 2. Public Interface
|
|
|
|
All classes are nested within `DTS.Slice.Control.Event.Module.AnalogInputChannel` and inherit from `Slice.Control.Event.Module.Channel.ReviewableAttribute`. Each constructor takes a single parameter of type `Event.Module.Channel` and passes a label string and a `Func<string>` (via `delegate { ... }`) to the base constructor.
|
|
|
|
| Class | Constructor Signature | Label | Behavior |
|
|
|-------|------------------------|-------|----------|
|
|
| `ReviewableShuntDeflectionAttribute` | `ReviewableShuntDeflectionAttribute(Event.Module.Channel channel)` | `"Shunt Deflection (mV)"` | Returns `MeasuredShuntDeflectionMv.ToString("F1")`, where `MeasuredShuntDeflectionMv` is accessed via `(channel as IShuntAware).MeasuredShuntDeflectionMv`. |
|
|
| `ReviewableFilterFrequencyAttribute` | `ReviewableFilterFrequencyAttribute(Event.Module.Channel channel)` | `"Filter Frequency"` | Returns `(int)(channel.CurrentFilter as SaeJ211Filter).CutoffFrequencyHz` formatted with `ToString("N")`. |
|
|
| `ReviewableIsoCodeAttribute` | `ReviewableIsoCodeAttribute(Event.Module.Channel channel)` | `"ISO Code"` | Returns `(channel as AnalogInputChannel).IsoCode.ToString()`. |
|
|
| `ReviewableDescriptionAttribute` | `ReviewableDescriptionAttribute(Event.Module.Channel channel)` | `"Description"` | Returns `channel.ChannelDescriptionString`. |
|
|
| `ReviewableSerialNumberAttribute` | `ReviewableSerialNumberAttribute(Event.Module.Channel channel)` | `"Serial Number"` | Returns `(channel as AnalogInputChannel).SerialNumber.ToString()`. |
|
|
| `ReviewableUnitsAttribute` | `ReviewableUnitsAttribute(Event.Module.Channel channel)` | `"Units"` | Returns `(channel as IEngineeringUnitAware).EngineeringUnits.ToString()`. |
|
|
| `ReviewableMinMaxEuAttribute` | `ReviewableMinMaxEuAttribute(Event.Module.Channel channel)` | `"Max/Min (EU)"` | Returns `"${DataMaxFilteredEu:F1}/${DataMinFilteredEu:F1}"`. |
|
|
| `ReviewableCfcAttribute` | `ReviewableCfcAttribute(Event.Module.Channel channel)` | `"CFC"` | Returns `"N/A"` if `channel.CurrentFilter.Type == ChannelFilter.AdHoc`; otherwise returns `new CfcValueAttributeCoder().DecodeAttributeValue((channel.CurrentFilter as SaeJ211Filter).Type).ToString()`. |
|
|
| `ReviewableTargetShuntDeflectionAttribute` | `ReviewableTargetShuntDeflectionAttribute(Event.Module.Channel channel)` | `"Target Shunt Deflection (mV)"` | Returns `TargetShuntDeflectionMv.ToString("F1")`, via `(channel as IShuntAware).TargetShuntDeflectionMv`. |
|
|
| `ReviewableTargetCalSignalAttribute` | `ReviewableTargetCalSignalAttribute(Event.Module.Channel channel)` | `"Target Calibration Signal (mV)"` | Returns `TargetCalSignalMv.ToString("F1")`, via `(channel as ICalSignalAware).TargetCalSignalMv`. |
|
|
| `ReviewableMeasuredShuntDeflectionAttribute` | `ReviewableMeasuredShuntDeflectionAttribute(Event.Module.Channel channel)` | `"Measured Shunt Deflection (mV)"` | Same as `ReviewableShuntDeflectionAttribute`. |
|
|
| `ReviewableMeasuredCalSignalAttribute` | `ReviewableMeasuredCalSignalAttribute(Event.Module.Channel channel)` | `"Measured Calibration Signal (mV)"` | Same as `ReviewableTargetCalSignalAttribute` but for measured values: `(channel as ICalSignalAware).MeasuredCalSignalMv.ToString("F1")`. |
|
|
| `ReviewableShuntDeflectionPercentageAttribute` | `ReviewableShuntDeflectionPercentageAttribute(Event.Module.Channel channel)` | `"Shunt Error (%)"` | Computes `(100.0 * (MeasuredShuntDeflectionMv - TargetShuntDeflectionMv) / TargetShuntDeflectionMv).ToString("F1")`. |
|
|
| `ReviewableCalSignalPercentageAttribute` | `ReviewableCalSignalPercentageAttribute(Event.Module.Channel channel)` | `"Calibration Signal Error (%)"` | Computes `(100.0 * (MeasuredCalSignalMv - TargetCalSignalMv) / TargetCalSignalMv).ToString("F1")`. |
|
|
|
|
> **Note**: `IShuntAware`, `ICalSignalAware`, and `IEngineeringUnitAware` are interfaces defined in `DTS.DAS.Concepts.DAS.Channel`. `SaeJ211Filter`, `CfcValueAttributeCoder`, and `ChannelFilter` are defined in `DTS.Utilities`.
|
|
|
|
## 3. Invariants
|
|
|
|
- **All attributes require the `channel` parameter to be non-null**, and to support the specific interface(s) accessed in their delegate (e.g., `IShuntAware` for shunt-related attributes). Failure to meet this requirement will cause a runtime `InvalidCastException` or `NullReferenceException`.
|
|
- **Format consistency**: All numeric outputs use `"F1"` (1 decimal place) or `"N"` (thousands separator, no decimals) formatting as shown. No validation or range checking is performed on the underlying values.
|
|
- **No side effects**: The delegates are pure functions; they do not mutate state.
|
|
- **No ordering guarantees**: The module does not define or enforce any ordering among these attributes when used collectively (e.g., in a list or collection).
|
|
- **Type assumptions**: The code assumes `channel.CurrentFilter` is always a `SaeJ211Filter` when accessing `.Type` or `.CutoffFrequencyHz`. If `CurrentFilter` is not a `SaeJ211Filter`, this will throw at runtime.
|
|
|
|
## 4. Dependencies
|
|
|
|
### Internal Dependencies (from source):
|
|
- `DTS.Slice.Control.Event.Module.Channel.ReviewableAttribute` — base class (not shown, but referenced).
|
|
- `DTS.DAS.Concepts.DAS.Channel.IShuntAware` — for `MeasuredShuntDeflectionMv`, `TargetShuntDeflectionMv`.
|
|
- `DTS.DAS.Concepts.DAS.Channel.ICalSignalAware` — for `MeasuredCalSignalMv`, `TargetCalSignalMv`.
|
|
- `DTS.DAS.Concepts.DAS.Channel.IEngineeringUnitAware` — for `EngineeringUnits`.
|
|
- `DTS.Utilities.SaeJ211Filter` — used in `ReviewableFilterFrequencyAttribute` and `ReviewableCfcAttribute`.
|
|
- `DTS.Utilities.CfcValueAttributeCoder` — used in `ReviewableCfcAttribute`.
|
|
- `DTS.Utilities.ChannelFilter` — used in `ReviewableCfcAttribute` (specifically `ChannelFilter.AdHoc` constant).
|
|
- `DTS.Slice.Control.Event.Module.AnalogInputChannel` — for `IsoCode`, `SerialNumber`, and `ChannelDescriptionString` properties.
|
|
|
|
### External Dependencies:
|
|
- `System` (core namespaces: `System`, `System.Linq`, `System.Text`, `System.Collections.Generic`).
|
|
- `DTS.Utilities` — assembly reference required.
|
|
|
|
### Inferred Consumers:
|
|
- Likely consumed by UI or reporting layers that enumerate `ReviewableAttribute` instances on channels (e.g., for serialization, audit logging, or calibration review forms).
|
|
- May be used in conjunction with `DTS.Slice.Control.Event` infrastructure (e.g., event logging, data export).
|
|
|
|
## 5. Gotchas
|
|
|
|
- **Redundant classes**: `ReviewableShuntDeflectionAttribute` and `ReviewableMeasuredShuntDeflectionAttribute` have identical implementation and labels. Same for `ReviewableTargetCalSignalAttribute` and `ReviewableMeasuredCalSignalAttribute`. This duplication may cause confusion or inconsistency if one is updated but not the other.
|
|
- **Unsafe casts**: Multiple attributes use `as` casts without null checks (e.g., `(channel as IShuntAware)`). If the channel does not implement the interface, the cast yields `null`, leading to `NullReferenceException` when accessing `.MeasuredShuntDeflectionMv`.
|
|
- **Assumed filter type**: `ReviewableFilterFrequencyAttribute` and `ReviewableCfcAttribute` assume `channel.CurrentFilter` is always a `SaeJ211Filter`. If `CurrentFilter` is another type (e.g., `AdHoc`), a runtime `InvalidCastException` occurs.
|
|
- **Division by zero risk**: `ReviewableShuntDeflectionPercentageAttribute` and `ReviewableCalSignalPercentageAttribute` divide by `TargetShuntDeflectionMv` or `TargetCalSignalMv` without checking for zero. If the target is `0.0`, this throws `DivideByZeroException`.
|
|
- **Missing null guard in `ReviewableCfcAttribute`**: The commented-out line suggests prior use of `CfcValueAttributeCoder`, but the current logic only handles `AdHoc` explicitly. If `CurrentFilter.Type` is neither `AdHoc` nor a valid `SaeJ211Filter.Type`, `CfcValueAttributeCoder.DecodeAttributeValue(...)` may throw or return unexpected results.
|
|
- **Inconsistent casing**: `ReviewableDescriptionAttribute.cs` file header incorrectly labels it as `"ReviewableCfcAttribute.cs"` — likely a copy-paste artifact.
|
|
- **No documentation of `IsoCode`, `SerialNumber`, `ChannelDescriptionString`**: These properties are used but not defined in the provided source; their existence and type must be inferred from usage.
|
|
- **No documentation of `CfcValueAttributeCoder` behavior**: The behavior of `DecodeAttributeValue(...)` (e.g., what it returns for invalid inputs) is unknown from this source.
|
|
|
|
> **Recommendation**: Add runtime null checks and guard against zero denominators in percentage attributes. Consider consolidating duplicate classes or clarifying their intended distinction. |