--- source_files: - Common/DTS.Common/Interface/RegionOfInterest/RegionOfInterestChannels/IRegionOfInterestChannelsView.cs - Common/DTS.Common/Interface/RegionOfInterest/RegionOfInterestChannels/IRegionOfInterestChannelsViewModel.cs generated_at: "2026-04-16T03:04:42.623188+00:00" model: "Qwen/Qwen3-Coder-Next-FP8" schema_version: 1 sha256: "02546da4f9d34015" --- # RegionOfInterestChannels ## 1. Purpose This module defines the core interfaces for the *Region of Interest (ROI) Channels* feature, which manages the mapping and filtering of physical channels (e.g., sensor or signal paths) to user-defined regions of interest within the test setup UI. It serves as the MVVM (Model-View-ViewModel) contract layer between the UI (`IRegionOfInterestChannelsView`) and the business logic/data (`IRegionOfInterestChannelsViewModel`), enabling dynamic display, filtering, sorting, and validation of channel-group associations for ROI configuration. ## 2. Public Interface ### `IRegionOfInterestChannelsView` - **Inherits**: `IBaseView` - **Purpose**: Marker interface for the view layer (e.g., WPF UserControl or page) implementing the ROI channels UI. No additional members defined—relies on `IBaseView` contract. ### `IRegionOfInterestChannelsViewModel` - **Inherits**: `IBaseViewModel` - **Properties**: - `IRegionOfInterestChannelsView View { get; set; }` - Binds to the associated view instance (MVVM pattern). - `BindingList RegionsOfInterest { get; set; }` - Mutable list of ROI definitions; implements change notification via `BindingList`. - `string[] AllChannelSSNs { get; }` - Read-only array of serial numbers (SSNs) for *all* channels available in the current context. - `List AllChannelsUnfiltered { get; set; }` - Mutable list of all physical channels (as `GroupChannel` objects), *before* filtering. - **Methods**: - `void SetParent(object o)` - Sets the parent context (e.g., main view model or window) for navigation/coordination. - `void SetGroups(ITestSetup testSetup, Dictionary serialNumberToHardware, IsoViewMode viewMode)` - Initializes the ROI channel list based on a test setup, hardware lookup (by serial number), and view mode. - `void SetTest(string path, IsoViewMode viewMode)` - Loads ROI channel data from a test definition at `path`, applying the specified `viewMode`. - `void Filter(object tag, string term)` - Filters channels using a `tag` (e.g., column/group identifier) and search `term`. - `void Filter(string term)` - Filters channels *across all channels* (unqualified filter) by `term` (e.g., SSN, name, description). - `void Sort(object o, bool columnClick)` - Sorts the ROI list; `o` likely identifies the sort key (e.g., column header), `columnClick` indicates UI-initiated sort. - `void SelectAll(int roiIndex, bool selection)` - Sets selection state (`true`/`false`) for *all channels* in the ROI at `roiIndex`. - `bool Validate(ref List errors)` - Validates ROI configuration; returns `false` and populates `errors` if invalid. ## 3. Invariants - `RegionsOfInterest` must be a non-null `BindingList` (enforced by property setter). - `AllChannelSSNs` is read-only and derived from `AllChannelsUnfiltered` (implementation detail not visible, but implied by naming and usage). - `AllChannelsUnfiltered` must be populated *before* filtering/sorting operations (`Filter`, `Sort`, `SelectAll`) are called. - `SetGroups` or `SetTest` must be called before `Validate`, `Filter`, or `Sort` to initialize state. - `ISOViewMode` (inherited via `IBaseViewModel` or implied) must be consistent with the `IsoViewMode` parameter in `SetGroups`/`SetTest`. ## 4. Dependencies - **Depends on**: - `DTS.Common.Base` (for `IBaseView`, `IBaseViewModel`) - `System.Collections.Generic`, `System.Collections.ObjectModel`, `System.ComponentModel` (for `BindingList`) - `DTS.Common.Interface.DataRecorders` (`IDASHardware`) - `DTS.Common.Interface.Groups` (`GroupChannel`) - `DTS.Common.Interface.GroupTemplate` (likely `ITestObjectTemplate`, though commented out in `SetGroups`) - `DTS.Common.Interface.TestSetups.TestSetupsList` (`ITestSetup`) - `DTS.Common.Enums` (`IsoViewMode`) - **Implied dependents**: - View layer (e.g., WPF/XAML) implementing `IRegionOfInterestChannelsView`. - Main application view model or test setup controller instantiating `IRegionOfInterestChannelsViewModel`. - Unit tests for ROI channel logic. ## 5. Gotchas - The `SetGroups` method signature includes commented-out parameters (`ITestObject[] groups`, `Dictionary hardwareLookup`, `ITestObjectTemplate[] groupTemplates`), suggesting an older or refactored API. The current active signature uses `ITestSetup` and `serialNumberToHardware`—developers must avoid mixing old/new usage. - `AllChannelsUnfiltered` is mutable (`set` accessor present), but its contents likely must not be modified directly (only via `SetGroups`/`SetTest`); direct mutation may cause inconsistencies with `AllChannelSSNs` or `RegionsOfInterest`. - `Filter(string term)` performs a *global* filter, while `Filter(object tag, string term)` is *scoped* (e.g., per column/group). Confusing these may lead to unexpected filtering behavior. - `SelectAll(int roiIndex, bool selection)` operates on *channels within a specific ROI*, not all ROIs—index out-of-bounds may cause runtime errors (no validation in interface). - `Validate(ref List errors)` returns `false` on failure but does not specify *when* it succeeds (`true` implies no errors, but edge cases like empty ROIs may require explicit handling). - `IsoViewMode` is used in `SetGroups`/`SetTest` but not exposed as a property in the interface—its value must be tracked externally or inferred from `ISOViewMode` (case-sensitive naming mismatch noted: `ISOViewMode` vs. `IsoViewMode`).