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

93 lines
6.1 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/Events/Sensors/CalibrationBehaviorSettingChangedEvent.cs
- Common/DTS.Common/Events/Sensors/ExportCalibrationBehaviorSettingChangedEvent.cs
- Common/DTS.Common/Events/Sensors/SensorFilterTypeChangedEvent.cs
generated_at: "2026-04-16T03:24:51.949729+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "0b8580fe5a59ce51"
---
# Sensors
## Documentation: Sensor Configuration Event Definitions
---
### 1. **Purpose**
This module defines event types used to propagate changes in sensor configuration settings across the application, leveraging the Prism EventAggregator pattern for decoupled communication. Specifically, it publishes notifications when calibration behavior settings change (for both general and export contexts) and when the filter type applied to a sensor changes—enabling UI components and business logic modules to react to these changes without tight coupling. These events are part of the shared `DTS.Common` library and are intended for use across modules that manage sensor data acquisition, filtering, and calibration.
---
### 2. **Public Interface**
#### `CalibrationBehaviorSettingChangedEvent`
- **Signature**:
`public class CalibrationBehaviorSettingChangedEvent : PubSubEvent<DTS.Common.Enums.Sensors.CalibrationBehaviors> { }`
- **Behavior**:
Publishes a change in the *general* calibration behavior setting. Payload is a value of the `CalibrationBehaviors` enum, representing the new behavior.
#### `ExportCalibrationBehaviorSettingChangedEvent`
- **Signature**:
`public class ExportCalibrationBehaviorSettingChangedEvent : PubSubEvent<DTS.Common.Enums.Sensors.CalibrationBehaviors> { }`
- **Behavior**:
Publishes a change in the *export-specific* calibration behavior setting. Payload is a value of the `CalibrationBehaviors` enum, representing the new behavior for export operations.
#### `SensorFilterTypeChangedEvent`
- **Signature**:
`public class SensorFilterTypeChangedEvent : PubSubEvent<SensorFilterTypeChangedEventArgs> { }`
- **Behavior**:
Publishes a change in the filter type applied to a sensor. Payload is a `SensorFilterTypeChangedEventArgs` object containing details about the change (e.g., ISO code character, filter class, associated sensor/calibration objects, and configuration flags).
#### `SensorFilterTypeChangedEventArgs`
- **Properties**:
- `char ISOCodeChar` — The ISO code character used when `EventType == EventTypes.ISOCodeChar`.
- `EventTypes EventType` — Indicates whether the change was triggered by an ISO code character (`ISOCodeChar`) or a filter class (`FilterClass`).
- `FilterClassType FilterClass` — The new filter class type used when `EventType == EventTypes.FilterClass`.
- `ISensorCalibration Calibration` — The calibration object associated with the sensor at the time of change.
- `ISensorData Sensor` — The sensor instance whose filter type changed.
- `bool UseISOCodeFilterMapping` — Flag indicating whether ISO code filtering is enabled/mapped.
- `bool UseZeroForUnfiltered` — Flag indicating whether zero should be used for unfiltered values.
- **Constructors**:
- `SensorFilterTypeChangedEventArgs(char code, ISensorData sensor, ISensorCalibration sensorCalibration, bool useISOCodeFilterMapping, bool bUseZeroForUnfiltered)`
Initializes for ISO codebased filter changes (`EventType = EventTypes.ISOCodeChar`).
- `SensorFilterTypeChangedEventArgs(FilterClassType filterClassType, ISensorData sensor, ISensorCalibration sensorCalibration, bool useISOCodeFilterMapping, bool bUseZeroForUnfiltered)`
Initializes for filter classbased changes (`EventType = EventTypes.FilterClass`).
---
### 3. **Invariants**
- `SensorFilterTypeChangedEventArgs` must be constructed with **exactly one** of `ISOCodeChar` or `FilterClass` populated, depending on `EventType`. The other field remains default (`\0` or `default(FilterClassType)`).
- `EventType` is immutable after construction and is set based on which constructor overload is used.
- All `SensorFilterTypeChangedEventArgs` instances must include non-null `Sensor` and `Calibration` references (no null checks are performed in the source, implying callers are expected to ensure validity).
- `UseISOCodeFilterMapping` and `UseZeroForUnfiltered` are boolean flags passed directly from the caller and are not validated or normalized.
---
### 4. **Dependencies**
- **Depends on**:
- `Prism.Events` (for `PubSubEvent<T>` base class).
- `DTS.Common.Enums.Sensors` (for `CalibrationBehaviors`, `SensorFilterTypeChangedEventArgs.EventTypes`, and `FilterClassType`).
- `DTS.Common.Interface.Sensors` (for `ISensorCalibration` and `ISensorData` interfaces).
- **Used by**:
- Modules consuming sensor configuration changes (e.g., UI views, data processing pipelines, export services).
- Likely subscribed to by components that update filter UI, reconfigure sensor pipelines, or regenerate filtered data exports.
---
### 5. **Gotchas**
- **Namespace inconsistency**:
`CalibrationBehaviorSettingChangedEvent` and `ExportCalibrationBehaviorSettingChangedEvent` reside in `DTS.Common.Events`, while `SensorFilterTypeChangedEvent` resides in `DTS.Common.Events.Sensors`. This may cause confusion when registering/subscribing (e.g., `eventAggregator.GetEvent<SensorFilterTypeChangedEvent>()` vs `GetEvent<CalibrationBehaviorSettingChangedEvent>()`).
- **No validation in constructor**:
The constructors do not enforce that `sensor` or `sensorCalibration` are non-null. Callers must ensure this, or risk `NullReferenceException` at event handling time.
- **Ambiguous `FilterClassType` usage**:
The type `FilterClassType` is referenced but not defined in the provided source—its possible values and semantics are unknown here.
- **Dual constructor overloads**:
The two `SensorFilterTypeChangedEventArgs` constructors are not symmetric in naming or parameter order (e.g., `code` vs `filterClassType` first), increasing risk of misuse.
- **No documentation on `CalibrationBehaviors` enum**:
The meaning of specific `CalibrationBehaviors` values is not included in this module and must be inferred from elsewhere.
---
*Documentation generated from provided source files only.*