99 lines
6.5 KiB
Markdown
99 lines
6.5 KiB
Markdown
---
|
|
source_files:
|
|
- DTS Viewer/DTS.Viewer.Reports/DTS.Viewer.PSDReportSettings/Model/PSDReportSettingsModel.cs
|
|
generated_at: "2026-04-16T11:01:19.271156+00:00"
|
|
model: "zai-org/GLM-5-FP8"
|
|
schema_version: 1
|
|
sha256: "b9213b8d6a0e210e"
|
|
---
|
|
|
|
# Documentation: PSDReportSettingsModel
|
|
|
|
## 1. Purpose
|
|
|
|
`PSDReportSettingsModel` is a model class that stores and manages configuration settings for Power Spectral Density (PSD) report generation within the DTS Viewer application. It encapsulates filter parameters (low-pass and high-pass), windowing configuration (width, type, averaging, overlapping), and data range boundaries. The class implements `INotifyPropertyChanged` via `BasePropertyChanged` and coordinates with a parent view model through the `IPSDReportSettingsModel` interface, automatically notifying the parent of changes when `CanPublishChanges` is enabled.
|
|
|
|
---
|
|
|
|
## 2. Public Interface
|
|
|
|
### Properties
|
|
|
|
| Property | Type | Default Value | Description |
|
|
|----------|------|---------------|-------------|
|
|
| `Parent` | `IPSDReportSettingsViewModel` | `null` | Reference to the parent view model. Setter includes equality check to avoid redundant updates. |
|
|
| `CanPublishChanges` | `bool` | `true` | Controls whether property changes trigger `Parent.PublishChanges()` notification. |
|
|
| `LowPassFilterEnabled` | `bool` | `false` | Enables/disables low-pass filter. Sets `ReadData = true` on change. |
|
|
| `LowPassFilterFrequency` | `double` | `2000` | Low-pass filter cutoff frequency. Sets `ReadData = true` on change. |
|
|
| `LowPassFilterType` | `PassFilterType` | `PassFilterType.Butterworth` | Low-pass filter algorithm type. Sets `ReadData = true` on change. |
|
|
| `LowPassFilterOrder` | `int` | `8` | Low-pass filter order. Sets `ReadData = true` on change. |
|
|
| `HighPassFilterEnabled` | `bool` | `false` | Enables/disables high-pass filter. Sets `ReadData = true` on change. |
|
|
| `HighPassFilterFrequency` | `double` | `5` | High-pass filter cutoff frequency. Sets `ReadData = true` on change. |
|
|
| `HighPassFilterType` | `PassFilterType` | `PassFilterType.Butterworth` | High-pass filter algorithm type. Sets `ReadData = true` on change. |
|
|
| `HighPassFilterOrder` | `int` | `8` | High-pass filter order. Sets `ReadData = true` on change. |
|
|
| `WindowWidth` | `WindowWidth` | `WindowWidth.FortyNinetySix` | Window width for spectral analysis. Sets `ReadData = true` on change. |
|
|
| `WindowType` | `WindowType` | `WindowType.Hanning` | Window function type. Sets `ReadData = true` on change. |
|
|
| `WindowAveragingType` | `WindowAveragingType` | `WindowAveragingType.Averaging` | Averaging method for windows. Sets `ReadData = true` on change. |
|
|
| `WindowOverlappingPercent` | `double` | `50` | Window overlap percentage. Sets `ReadData = true` on change. |
|
|
| `ShowEnvelope` | `bool` | `false` | Controls envelope display. Sets `ReadData = true` on change. |
|
|
| `IsSaved` | `bool` | *(not visible)* | Read-only property indicating save state. No setter visible in source. |
|
|
| `ReadData` | `bool` | `false` | Flag indicating whether data should be re-read. |
|
|
| `DataStart` | `double` | `0D` | Start boundary for data range. Sets `ReadData = true` on change. |
|
|
| `DataEnd` | `double` | `0D` | End boundary for data range. Sets `ReadData = true` on change. |
|
|
|
|
### Methods
|
|
|
|
| Method | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| `OnPropertyChanged` | `void OnPropertyChanged(string propertyName)` | Override that raises `PropertyChanged` event and conditionally calls `Parent?.PublishChanges()` unless the property is `CanPublishChanges`, `Parent`, or `ReadData`. |
|
|
|
|
### Events
|
|
|
|
| Event | Type | Description |
|
|
|-------|------|-------------|
|
|
| `PropertyChanged` | `PropertyChangedEventHandler` | Override of base event; raised when any property value changes. |
|
|
|
|
---
|
|
|
|
## 3. Invariants
|
|
|
|
1. **ReadData Side Effect**: The following properties always set `ReadData = true` when modified:
|
|
- `LowPassFilterEnabled`, `LowPassFilterFrequency`, `LowPassFilterType`, `LowPassFilterOrder`
|
|
- `HighPassFilterEnabled`, `HighPassFilterFrequency`, `HighPassFilterType`, `HighPassFilterOrder`
|
|
- `WindowWidth`, `WindowType`, `WindowAveragingType`, `WindowOverlappingPercent`, `ShowEnvelope`
|
|
- `DataStart`, `DataEnd`
|
|
|
|
2. **Publishing Exclusion**: Changes to `CanPublishChanges`, `Parent`, or `ReadData` do **not** trigger `Parent.PublishChanges()`.
|
|
|
|
3. **Publishing Gate**: `Parent?.PublishChanges()` is only invoked when `CanPublishChanges == true`.
|
|
|
|
4. **Parent Equality Check**: The `Parent` property setter checks `_parent != null && _parent.Equals(value)` before updating, preventing redundant property change notifications.
|
|
|
|
5. **IsSaved Immutability**: `IsSaved` has no setter visible in the source; its value is determined externally (possibly via constructor or reflection).
|
|
|
|
---
|
|
|
|
## 4. Dependencies
|
|
|
|
### This Module Depends On:
|
|
- `DTS.Common.Enums.Viewer.Reports` — Provides `PassFilterType`, `WindowWidth`, `WindowType`, `WindowAveragingType` enums
|
|
- `DTS.Common.Interface` — Provides `IPSDReportSettingsViewModel` interface
|
|
- `Common.Base.BasePropertyChanged` — Base class providing `SetProperty` method and `INotifyPropertyChanged` infrastructure
|
|
|
|
### Consumers (Inferred):
|
|
- Any module implementing `IPSDReportSettingsViewModel` (the parent view model)
|
|
- Any code referencing `IPSDReportSettingsModel` interface
|
|
|
|
---
|
|
|
|
## 5. Gotchas
|
|
|
|
1. **ReadData Never Auto-Resets**: Setting `ReadData = true` via property changes never automatically resets it back to `false`. The consuming code must manage this flag's lifecycle.
|
|
|
|
2. **IsSaved Has No Setter**: The `IsSaved` property is read-only with no initialization visible in this file. Its value must be set through a mechanism not shown in the source (possibly constructor injection, reflection, or partial class extension).
|
|
|
|
3. **Parent Can Be Null**: The `Parent` property is not validated for null before use in `OnPropertyChanged`. While `Parent?.PublishChanges()` uses null-conditional operator, if `Parent` is null during other operations, behavior is undefined.
|
|
|
|
4. **Inconsistent Setter Patterns**: The `Parent` setter uses manual equality checking and `OnPropertyChanged("Parent")`, while most other properties use `SetProperty()`. The `CanPublishChanges` setter uses direct field assignment with `OnPropertyChanged("CanPublishChanges")`. This inconsistency may lead to subtle behavioral differences.
|
|
|
|
5. **No Validation on Numeric Inputs**: Properties like `LowPassFilterFrequency`, `HighPassFilterFrequency`, `WindowOverlappingPercent`, `DataStart`, and `DataEnd` accept any `double` value without bounds checking. Invalid values (e.g., negative frequencies, overlapping > 100) are not prevented at the model level. |