This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
---
source_files:
- DataPRO/Modules/SensorsList/SensorSettingsModule/Properties/Settings.Designer.cs
- DataPRO/Modules/SensorsList/SensorSettingsModule/Properties/AssemblyInfo.cs
generated_at: "2026-04-16T04:53:05.459294+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "76809d77f0815bad"
---
# Properties
## Documentation Page: SensorSettingsModule.Properties.Settings
---
### 1. **Purpose**
This module provides a strongly-typed settings class (`SensorSettingsModule.Properties.Settings`) for managing application-level configuration values in a .NET Framework 4.0 Windows Forms or WPF application. It serves as the runtime accessor for user- or application-scoped settings defined elsewhere (e.g., in `app.config` or via the Visual Studio Settings Designer), leveraging the built-in `ApplicationSettingsBase` infrastructure. The module itself contains only the auto-generated wrapper class and assembly metadata; it does not define or persist settings values directly—those are expected to be declared in the corresponding `Settings.settings` file (not provided here) and compiled into the `Settings.Designer.cs` class.
---
### 2. **Public Interface**
- **`Settings.Default` (static property)**
```csharp
public static Settings Default { get; }
```
Returns the singleton instance of the `Settings` class, synchronized for thread safety via `ApplicationSettingsBase.Synchronized`. This is the primary entry point for reading or writing settings values. All settings properties (e.g., `string SomeSetting { get; set; }`) are defined in the designer-generated class body (not visible in the provided source), but their access is mediated through this instance.
> **Note**: The provided `Settings.Designer.cs` file contains *no explicit settings properties*—only the `Default` property and boilerplate attributes. Actual settings (e.g., `public string SensorTimeout { get; set; }`) must be declared in the corresponding `.settings` file and regenerated into this class. Their signatures and behaviors cannot be inferred from the current source.
---
### 3. **Invariants**
- The `Settings` class is **sealed** and **partial**, with thread-safe singleton access via `Synchronized`.
- The `Default` property is guaranteed to return a non-null instance (initialized lazily in a static constructor).
- The class inherits from `System.Configuration.ApplicationSettingsBase`, which enforces:
- Settings values are persisted per-user (user-scoped) or per-application (application-scoped) based on `UserScopedSettingAttribute`/`ApplicationScopedSettingAttribute` applied to individual properties (not visible here).
- Settings are loaded on first access and saved explicitly via `Save()` (not shown in this file).
- No validation or business logic is present in the provided source—only infrastructure.
---
### 4. **Dependencies**
- **Dependencies *of* this module**:
- `System.Configuration.dll` (for `ApplicationSettingsBase`, `SettingsProperty`, etc.)
- `System.dll` (for core types like `System.Object`, `System.Runtime.CompilerServices.CompilerGeneratedAttribute`, etc.)
- Visual Studios `Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator` (used at design time to generate this file; not a runtime dependency).
- **Dependencies *on* this module**:
- Other modules in `SensorSettingsModule` (e.g., UI or logic layers) likely consume `Settings.Default` to read/write configuration (e.g., `Settings.Default.SensorPollingInterval = 5000;`).
- The assembly `SensorSettingsModule` (GUID `32dfec83-bdc6-4d9c-be01-be5441e3d8e6`) depends on this `Properties.Settings` class for configuration management.
---
### 5. **Gotchas**
- **Settings properties are not visible in the provided source**: The actual settings (e.g., names, types, default values) are generated from `Properties/Settings.settings` and embedded in the `Settings.Designer.cs` file *after* build. Without that file, the API surface is incomplete.
- **Thread safety is shallow**: While `Synchronized()` wraps the instance in a `SyncRoot`-based lock, `ApplicationSettingsBase` does *not* guarantee atomicity for compound operations (e.g., read-modify-write). Concurrent writes may require external locking.
- **No persistence logic here**: This class only *accesses* settings; saving requires explicit calls to `Settings.Default.Save()`, typically from UI or lifecycle events (e.g., `Application.Exit`).
- **Auto-generated warning is literal**: Manual edits to `Settings.Designer.cs` will be overwritten on next settings change or build.
- **Assembly version is fixed at `1.0.0.0`**: Both `AssemblyVersion` and `AssemblyFileVersion` are hardcoded, which may cause binding issues if the module is versioned independently elsewhere.
> **None identified from source alone** beyond the above—specific settings behaviors (e.g., default values, scopes) require inspection of `Settings.settings` or `app.config`.

View File

@@ -0,0 +1,58 @@
---
source_files:
- DataPRO/Modules/SensorsList/SensorSettingsModule/Resources/TranslateExtension.cs
- DataPRO/Modules/SensorsList/SensorSettingsModule/Resources/StringResources.Designer.cs
generated_at: "2026-04-16T04:52:55.321656+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "5a131daf903208d8"
---
# Resources
## Documentation: `TranslateExtension` Class
### 1. Purpose
The `TranslateExtension` class provides a XAML markup extension for localizing UI strings within the `SensorSettingsModule`. It enables declarative binding of localized text in XAML resources by resolving a given string key against the modules embedded resource manager (`StringResources`). Its role is to decouple UI text from code logic, supporting multi-language deployments by fetching culture-specific strings at runtime.
### 2. Public Interface
#### `TranslateExtension(string key)`
- **Signature**: `public TranslateExtension(string key)`
- **Behavior**: Constructor. Stores the resource key (`_key`) used to look up a localized string. Throws no exceptions on invalid input; invalid keys are handled at `ProvideValue` time.
#### `ProvideValue(IServiceProvider serviceProvider)`
- **Signature**: `public override object ProvideValue(IServiceProvider serviceProvider)`
- **Behavior**:
- Returns `#stringnotfound#` if `_key` is `null` or empty.
- Otherwise, attempts to retrieve the string from `StringResources.ResourceManager.GetString(_key)`.
- If the key exists in resources, returns the localized string.
- If the key does *not* exist, returns `#stringnotfound# <key>` (e.g., `#stringnotfound# MyKey`).
- Does *not* throw exceptions for missing keys—gracefully degrades via placeholder text.
### 3. Invariants
- `_key` is never validated for format (e.g., no requirement to match resource names like `CamelCase` or `PascalCase`).
- The returned value is always a `string` (per `[MarkupExtensionReturnType(typeof(string))]`).
- Missing keys *never* cause exceptions; fallback is always a placeholder string.
- Resource lookup uses the current threads `CurrentUICulture` unless overridden via `StringResources.Culture`.
- `StringResources.ResourceManager` is lazily initialized and cached per AppDomain.
### 4. Dependencies
- **Depends on**:
- `System.Windows.Markup.MarkupExtension` (WPF framework)
- `System.Resources.ResourceManager` (via `StringResources.ResourceManager`)
- `SensorSettingsModule.Resources.StringResources` (strongly-typed resource class, auto-generated)
- **Used by**:
- XAML files in `SensorSettingsModule` (e.g., `<TextBlock Text="{local:Translate MyKey}" />`)
- No other C# code appears to reference `TranslateExtension` directly in the provided sources.
### 5. Gotchas
- **Placeholder format is non-standard**: Missing keys yield `#stringnotfound# <key>`, which may be confusing in production if not caught during testing.
- **No caching of resolved values**: Each `ProvideValue` call re-invokes `ResourceManager.GetString`, which *is* internally cached by .NET, but repeated calls for the same key in a tight loop may still incur overhead.
- **No support for parameterized resources**: The extension only supports static key lookup; no interpolation (e.g., `{Translate Key, arg0}`) is possible.
- **Auto-generated resource class**: `StringResources.Designer.cs` is regenerated on build—manual edits will be lost. Resource keys must be managed via `.resx` files.
- **No null-safety for `serviceProvider`**: While not explicitly used, if `serviceProvider` is `null`, the base `MarkupExtension.ProvideValue` behavior applies (typically safe in WPF).
- **No culture fallback logic**: If a key is missing in the current `Culture`, it returns the placeholder—even if the key exists in the default culture (e.g., `en-US`). Developers must ensure all keys exist in all target cultures.
- **Hardcoded placeholder**: `#stringnotfound#` is a magic string; if UI designers accidentally use this as a key, it will be misinterpreted as an error.
None identified beyond the above.

View File

@@ -0,0 +1,56 @@
---
source_files:
- DataPRO/Modules/SensorsList/SensorSettingsModule/View/SensorSettingsView.xaml.cs
generated_at: "2026-04-16T04:53:07.506286+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "97b808679cb582c0"
---
# View
### **Purpose**
This module provides the UI view layer for configuring sensor settings, specifically handling user interaction related to filter frequency selection. It implements the `ISensorSettingsView` interface and integrates with the Prism event aggregation system to publish filter frequency values when the user finishes editing the filter option field. Its role is to capture transient user input (e.g., ad-hoc filter frequency values) and propagate them as events for downstream persistence or processing logic.
---
### **Public Interface**
The class `SensorSettingsView` implements the `ISensorSettingsView` interface (defined in `DTS.Common.Interface.Sensors.SensorSettingsModule`). However, the source file does **not** show the interface definition or any other public methods beyond the constructor and event handler. Based on the source:
- **`SensorSettingsView()`**
Public constructor. Initializes the WPF component (`InitializeComponent()`), resolves the `IEventAggregator` service from `ContainerLocator.Container`, and stores it in the private field `_eventAggregator`. No parameters.
- **`CbFilterOption_LostFocus(object sender, RoutedEventArgs e)`**
Private event handler (WPF `RoutedEventHandler`) attached to the `LostFocus` event of a UI element named `cbFilterOption` (presumably a `ComboBox`). When triggered, it attempts to parse the current text of `cbFilterOption` as a `double`. If successful, it publishes the parsed value (`freq`) via the `SensorSavedEvent` using the `_eventAggregator`.
---
### **Invariants**
- The `SensorSettingsView` instance **must** be constructed after `ContainerLocator.Container` has been initialized with a registered `IEventAggregator` implementation; otherwise, resolution will fail.
- The `cbFilterOption.Text` value is only published if it can be successfully parsed as a `double`; invalid or empty input results in no event being published.
- The `freq` field is reused across invocations of `CbFilterOption_LostFocus`, but only the most recently parsed value is published.
- The `SensorSavedEvent` is assumed to accept a `double` payload (based on usage), and its subscribers are responsible for interpreting and persisting the value.
---
### **Dependencies**
**Imports / External Types Used:**
- `DTS.Common.Events.Sensors.SensorsList.SensorSavedEvent` — event type used to publish the parsed frequency.
- `DTS.Common.Interface.Sensors.SensorSettingsModule.ISensorSettingsView` — interface implemented by this class.
- `Prism.Ioc.IContainerLocator` and `Prism.Events.IEventAggregator` — Prism framework services for dependency resolution and event aggregation.
- `System.Windows` — WPF UI framework (e.g., `RoutedEventArgs`, `Window` base types).
**Assumed Dependencies (from usage):**
- A WPF `ComboBox` named `cbFilterOption` must exist in the corresponding `SensorSettingsView.xaml` (not shown), with its `LostFocus` event wired to `CbFilterOption_LostFocus`.
- `ContainerLocator.Container` must be set up with a registered `IEventAggregator` (standard Prism pattern).
- At least one subscriber must exist for `SensorSavedEvent` to handle the published `double` value.
---
### **Gotchas**
- **Race/State Issue**: The `freq` field is a class-level field reused across multiple `LostFocus` invocations. While harmless in this specific case (since only the latest value is published), it is unnecessary and could mislead maintainers. A local variable would be clearer.
- **Parsing Behavior**: `double.TryParse` uses the current threads culture settings. If `cbFilterOption.Text` is user-entered and culture-sensitive (e.g., `"3.14"` vs `"3,14"`), parsing may fail unexpectedly on non-US locales unless UI or thread culture is explicitly normalized.
- **Event Name Ambiguity**: `SensorSavedEvent` suggests persistence to a database, but the handler only publishes the value — it does not itself save to DB. The comment `//FB 13120 Identify the AdHoc filter to get saved later on if it's not already saved to db` implies downstream logic handles persistence, but this is not visible in the source.
- **No Validation**: No explicit validation of the parsed frequency (e.g., range checks, non-negative constraints) is performed before publishing.
- **No Null/Empty Handling**: If `cbFilterOption.Text` is null or whitespace, `TryParse` fails silently and no event is published — this may be intentional but is not documented.
- **Tight Coupling to Prism**: Reliance on `ContainerLocator.Container` (a static locator) rather than constructor injection makes unit testing harder and violates modern DI best practices.

View File

@@ -0,0 +1,137 @@
---
source_files:
- DataPRO/Modules/SensorsList/SensorSettingsModule/ViewModel/SensorSettingsViewModel.cs
generated_at: "2026-04-16T04:52:53.608461+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "ee04bd3c1edeb80f"
---
# ViewModel
### **1. Purpose**
The `SensorSettingsViewModel` class serves as the central view model for the Sensor Settings UI module, coordinating user interactions with various sensor configuration defaults (e.g., squib, digital output, analog, UART, CAN, IEPESensor, calibration policy, stream output). It implements Prisms `INavigationAware`-like lifecycle methods (e.g., `OnSetActive`, `Unset`, `Cleanup`) to manage state when the view is activated or deactivated, and handles validation, persistence, and restoration of user-specific and global sensor defaults via dedicated default interfaces and database operations. It also mediates UI notifications (via `InteractionRequest`) and busy state via Prisms `EventAggregator`.
---
### **2. Public Interface**
#### **Constructor**
```csharp
public SensorSettingsViewModel(
ISensorSettingsView view,
IRegionManager regionManager,
IEventAggregator eventAggregator,
IUnityContainer unityContainer)
```
Initializes the view model by assigning the view, registering event subscriptions (`RaiseNotification`, `BusyIndicatorChangeNotification`), and storing dependencies. Sets `View.DataContext = this`.
#### **Lifecycle Methods**
- `void OnSetActive()`
Loads all sensor default settings (e.g., `SquibSettings`, `AnalogDefaults`, `UartIODefaults`) from their respective static default factories (e.g., `SquibSettingDefaults.GetSquibSettingsDefault(User)`) using the current `User`/`UserID`, and raises `PropertyChanged` for each property. Called when the view becomes active.
- `void Unset()`
Invokes `ValidateAndSave()` to persist any pending changes before the view is deactivated.
- `void Cleanup()` / `Task CleanupAsync()` / `void Initialize()` / `void Initialize(object)` / `void Initialize(object, object)` / `Task InitializeAsync()` / `Task InitializeAsync(object)` / `void Activated()`
No-op stubs; no implementation present in source.
#### **Public Methods**
- `void RestoreOriginalSettings()`
Resets all sensor default settings to their factory defaults using corresponding `RestoreDefaults()` methods (e.g., `AnalogSettingDefaults.RestoreDefaults(AnalogDefaults)`), then re-applies them via `Save()` or `CommitChange()` where applicable (e.g., `UartSettingDefaults.CommitChange(...)`), and raises `PropertyChanged` for modified properties.
- `bool ValidateAndSave()`
Validates all sensor defaults via their `Validate()` methods, and persists valid changes to the database (e.g., `UartSettingDefaults.CommitChange(...)`, `IEPESensorDefault.Save(...)`, `CalibrationPolicy.WriteCalibrationPolicyToDb(...)`). If calibration policy changes, calls `InvalidateAllTestSetups()` to mark all test setups as dirty. Returns `true` only if *all* validations and saves succeed; catches exceptions and publishes `PageErrorEvent`.
- `void InvalidateAllTestSetups()`
Executes raw SQL `UPDATE [TestSetups] SET [Dirty]=1, [Complete]=0` to invalidate all test setups when calibration policy changes.
#### **Properties**
- `ISensorSettingsView View { get; set; }`
Reference to the associated view.
- `IDigitalInputDefaults DigitalInputDefaults { get; set; }`
- `ISquibSettingDefaults SquibSettings { get; set; }`
- `IDigitalOutDefaults DigitalOutSettings { get; set; }`
- `IIEPESensorDefaults IEPESensorDefaults { get; set; }`
- `ICalibrationPolicy SensorCalibrationDefaults { get; set; }`
- `IAnalogDefaults AnalogDefaults { get; set; }`
- `IUartSettingDefaults UartIODefaults { get; set; }`
- `ICanSettingDefaults CanIODefaults { get; set; }`
- `IStreamOutputSettingDefaults StreamOutputSettings { get; set; }`
Public properties holding current sensor configuration defaults (assigned in `OnSetActive()`).
- `string User { get; set; }`
- `int UserID { get; set; }`
User identity context used for user-specific defaults.
- `bool IsDirty => false`
Always returns `false`; no dynamic dirty tracking implemented.
- `bool IsBusy { get; set; }`
Bound to UI busy indicator; updated via `OnBusyIndicatorNotification`.
- `bool IsMenuIncluded { get; set; }`
- `bool IsNavigationIncluded { get; set; }`
UI layout flags; no usage logic beyond property change notification.
#### **Events & Requests**
- `event PropertyChangedEventHandler PropertyChanged`
Standard `INotifyPropertyChanged` implementation.
- `InteractionRequest<Notification> NotificationRequest { get; }`
- `InteractionRequest<Confirmation> ConfirmationRequest { get; }`
Prism `InteractionRequest` instances used to trigger modal notifications/confirmations.
#### **Private Event Handlers**
- `void OnBusyIndicatorNotification(bool eventArg)`
Updates `IsBusy` property.
- `void OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle)`
Converts `NotificationContentEventArgs` to `Notification` and raises `NotificationRequest`.
---
### **3. Invariants**
- `User` and `UserID` must be set before `OnSetActive()` is called; otherwise, defaults may be loaded incorrectly or fail (e.g., `SquibSettingDefaults.GetSquibSettingsDefault(User)` uses `User`).
- `ValidateAndSave()` requires all sensor default properties (`SquibSettings`, `AnalogDefaults`, etc.) to be non-null and of the correct concrete type (e.g., `SquibSettingDefaults`) to succeed; otherwise, it returns `false` early.
- Calibration policy changes trigger `InvalidateAllTestSetups()`, marking all test setups as dirty and incomplete.
- `IsDirty` is hardcoded to `false`; no actual dirty state tracking occurs.
- `RestoreOriginalSettings()` and `ValidateAndSave()` perform database writes synchronously (no async/await).
- `OnSetActive()` must be called before other methods that rely on initialized default properties (e.g., `ValidateAndSave()`).
---
### **4. Dependencies**
#### **Imports/Usings (External)**
- `Prism.Events`, `Prism.Regions`, `Prism.Ioc` → Prism framework for event aggregation, region management, and container resolution.
- `Unity` → Unity container (`IUnityContainer`).
- `DTS.Common.*` → Internal libraries for events (`RaiseNotification`, `BusyIndicatorChangeNotification`, `PageErrorEvent`), interactivity (`InteractionRequest`), interfaces (`ISensorSettingsViewModel`, `IDigitalInputDefaults`, etc.), storage (`DbOperations`, `CalibrationPolicy`), and channel settings (`ChannelSettingBase`).
- `DTS.SensorDB` → Database layer for defaults (e.g., `UartSettingDefaults`, `CalibrationPolicy`).
#### **Key Dependencies**
- **Interfaces**: `ISensorSettingsView`, `IDigitalInputDefaults`, `ISquibSettingDefaults`, `IDigitalOutDefaults`, `IIEPESensorDefaults`, `ICalibrationPolicy`, `IAnalogDefaults`, `IUartSettingDefaults`, `ICanSettingDefaults`, `IStreamOutputSettingDefaults`.
- **Static Classes/Methods**: `SquibSettingDefaults`, `DigitalOutputDefaults`, `AnalogSettingDefaults`, `UartSettingDefaults`, `StreamOutputSettingDefaults`, `CanSettingDefaults`, `IEPESensorDefault`, `DigitalInputSensorDefault`, `CalibrationPolicy`, `DbOperations`, `ChannelSettingBase`.
- **Prism Abstractions**: `IEventAggregator`, `IRegionManager`, `IUnityContainer`, `InteractionRequest<T>`.
#### **Depended Upon By**
- The view (`ISensorSettingsView`) binds to this view model (via `View.DataContext = this`).
- Other modules likely publish `RaiseNotification`/`BusyIndicatorChangeNotification` events consumed here.
- `PageErrorEvent` is published on exceptions, consumed by error-handling modules.
---
### **5. Gotchas**
- **Hardcoded `IsDirty = false`**: The `IsDirty` property is constant and never reflects actual state changes, misleading UI or logic that relies on it.
- **Type casting in `ValidateAndSave()`**: Uses pattern matching (`is T`) to cast interface properties to concrete types (e.g., `SquibSettings is SquibSettingDefaults squib`). If any property is not the expected concrete type, validation fails silently (returns `false`).
- **Partial `ValidateAndSave()` failure**: If validation fails for *any* setting (e.g., UART), the method still attempts to validate/save other settings before returning `false`. No transactional rollback occurs.
- **Calibration policy change detection**: Compares *all* fields of `CalibrationPolicy` manually; if new fields are added later, they wont trigger `InvalidateAllTestSetups()`.
- **`User`/`UserID` initialization**: No validation ensures `User`/`UserID` are set before `OnSetActive()`; defaults may load incorrectly or throw if `User` is `null`.
- **Synchronous DB writes**: `ValidateAndSave()` and `RestoreOriginalSettings()` perform blocking database operations (e.g., `ExecuteNonQuery()`), risking UI freezes.
- **`Cleanup()`/`CleanupAsync()` are empty**: No cleanup logic is implemented, potentially leaving resources or subscriptions unmanaged.
- **`NotificationRequest` conversion**: `OnRaiseNotification` creates a new `NotificationContentEventArgs` with empty `SubTitle` and `Footer`; this may discard intended UI content.
- **No async support in lifecycle methods**: `InitializeAsync`, `CleanupAsync` return `Task.CompletedTask`; no actual async work is performed.
- **No error handling in `RestoreOriginalSettings()`**: Exceptions during restore (e.g., DB commit failures) are not caught or reported.
None identified beyond these.