133 lines
9.3 KiB
Markdown
133 lines
9.3 KiB
Markdown
|
|
---
|
|||
|
|
source_files:
|
|||
|
|
- Common/DTS.CommonCore/Interface/Hardware/AddEditHardware/IAddEditHardwareView.cs
|
|||
|
|
- Common/DTS.CommonCore/Interface/Hardware/AddEditHardware/IAddEditHardwareDASModule.cs
|
|||
|
|
- Common/DTS.CommonCore/Interface/Hardware/AddEditHardware/IAddEditHardwareViewModel.cs
|
|||
|
|
- Common/DTS.CommonCore/Interface/Hardware/AddEditHardware/IAddEditHardwareHardware.cs
|
|||
|
|
generated_at: "2026-04-16T02:30:45.767318+00:00"
|
|||
|
|
model: "Qwen/Qwen3-Coder-Next-FP8"
|
|||
|
|
schema_version: 1
|
|||
|
|
sha256: "8c9d2e027679c71f"
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
# Documentation: AddEditHardware Module Interface
|
|||
|
|
|
|||
|
|
## 1. Purpose
|
|||
|
|
This module provides the interface layer for a UI-driven hardware configuration and editing workflow—specifically for adding or editing DAS (Data Acquisition System) hardware units and their associated modules in the SLICE6 ecosystem. It defines contracts for the view, view model, hardware model, and DAS module representations, enabling separation of concerns between UI presentation and business logic while supporting both physical hardware and "stand-in" (placeholder) entries. The module integrates with the broader diagnostics and hardware list subsystems, and supports persistence via conversion to `IISOHardware`.
|
|||
|
|
|
|||
|
|
## 2. Public Interface
|
|||
|
|
|
|||
|
|
### `IAddEditHardwareView`
|
|||
|
|
- **`void Activated();`**
|
|||
|
|
Notifies the view it has been activated; the view should perform any post-activation initialization or UI updates.
|
|||
|
|
- **`int ViewDbVersion { get; set; }`**
|
|||
|
|
Gets or sets the database version associated with the view’s current data context; likely used for concurrency or versioning checks during save.
|
|||
|
|
|
|||
|
|
### `IAddEditHardwareDASModule`
|
|||
|
|
- **`HardwareTypes ModuleType { get; set; }`**
|
|||
|
|
Gets or sets the type of the DAS module (e.g., analog input, digital I/O).
|
|||
|
|
- **`string SerialNumber { get; set; }`**
|
|||
|
|
Gets or sets the serial number of the module.
|
|||
|
|
- **`ImageSource DASImage { get; }`**
|
|||
|
|
Gets an image (WPF `ImageSource`) representing the module visually.
|
|||
|
|
- **`IAddEditHardwareHardware OwningHardware { get; set; }`**
|
|||
|
|
Gets or sets the parent hardware unit that owns this module.
|
|||
|
|
- **`SLICEBridgeTypes SLICEBridgeType { get; set; }`**
|
|||
|
|
Gets or sets the bridge type used by the module (e.g., for SLICE6 connectivity).
|
|||
|
|
- **`string GetSerialNumberPrefix();`**
|
|||
|
|
Returns the expected prefix for serial numbers of modules of this `ModuleType`; used for validation.
|
|||
|
|
|
|||
|
|
### `IAddEditHardwareViewModel`
|
|||
|
|
- **`IAddEditHardwareView View { get; set; }`**
|
|||
|
|
Gets or sets the associated view instance (MVVM pattern).
|
|||
|
|
- **`void Unset();`**
|
|||
|
|
Cleans up references and state, typically called when the view model is being discarded.
|
|||
|
|
- **`IAddEditHardwareHardware Hardware { get; set; }`**
|
|||
|
|
Gets or sets the hardware instance being edited or added.
|
|||
|
|
- **`int? TestId { get; set; }`**
|
|||
|
|
Gets or sets an optional test ID associated with the hardware (e.g., for test-specific configuration).
|
|||
|
|
- **`void SetHardware(IDASHardware hw, IISOHardware isoHW);`**
|
|||
|
|
Initializes the view model with existing hardware data from the diagnostics (`IDASHardware`) and ISO layer (`IISOHardware`).
|
|||
|
|
- **`bool NotificationsOn { get; set; }`**
|
|||
|
|
Enables or disables change notifications (e.g., to suppress UI updates during bulk initialization).
|
|||
|
|
- **`bool Validate(IISOHardware isoHW, ref List<string> errors, ref List<string> warnings, bool displayWindow, bool IsAdd);`**
|
|||
|
|
Validates the current hardware state against `isoHW`. Returns `true` if valid; populates `errors` and `warnings` lists. If `displayWindow` is `true`, may show UI dialogs for warnings/errors. `IsAdd` indicates if this is a new hardware entry.
|
|||
|
|
- **`void Save();`**
|
|||
|
|
Commits changes made in the view model to persistent storage (e.g., database).
|
|||
|
|
- **`IISOHardware GetISOHardware();`**
|
|||
|
|
Returns the current hardware state as an `IISOHardware` instance (used for persistence or propagation to other layers).
|
|||
|
|
- **`bool AllowStandin { get; set; }`**
|
|||
|
|
Gets or sets whether "stand-in" (non-physical) hardware entries are permitted.
|
|||
|
|
- **`void SetSLICE6TreeView(ISLICE6TreeView treeView, IHardwareListViewModel treeViewModel);`**
|
|||
|
|
Injects references to the SLICE6 tree view and its view model for integration (e.g., updating tree selection or state).
|
|||
|
|
- **`ISLICE6TreeView SLICE6TreeView { get; }`**
|
|||
|
|
Gets the currently assigned SLICE6 tree view instance.
|
|||
|
|
|
|||
|
|
### `IAddEditHardwareHardware`
|
|||
|
|
- **`HardwareTypes HardwareType { get; set; }`**
|
|||
|
|
Gets or sets the type of the DAS hardware unit.
|
|||
|
|
- **`string SerialNumber { get; set; }`**
|
|||
|
|
Gets or sets the serial number of the hardware unit.
|
|||
|
|
- **`string FirmwareVersion { get; set; }`**
|
|||
|
|
Gets or sets the firmware version of the hardware unit.
|
|||
|
|
- **`string IPAddress { get; set; }`**
|
|||
|
|
Gets or sets the IP address (if supported).
|
|||
|
|
- **`bool SupportsIPAddress { get; }`**
|
|||
|
|
Indicates whether the hardware type supports IP addressing.
|
|||
|
|
- **`bool SupportsRackSize { get; }`**
|
|||
|
|
Indicates whether the hardware type supports rack size configuration.
|
|||
|
|
- **`bool SupportsConfiguration { get; }`**
|
|||
|
|
Indicates whether the hardware type supports SLICE configuration options.
|
|||
|
|
- **`SLICEConfigurations SLICEConfiguration { get; set; }`**
|
|||
|
|
Gets or sets the SLICE configuration (e.g., rack layout, module positions).
|
|||
|
|
- **`RackSizes RackSize { get; set; }`**
|
|||
|
|
Gets or sets the rack size (e.g., 1U, 2U).
|
|||
|
|
- **`ImageSource DASImage { get; }`**
|
|||
|
|
Gets an image representing the hardware unit visually.
|
|||
|
|
- **`ObservableCollection<IAddEditHardwareDASModule> Modules { get; set; }`**
|
|||
|
|
Gets or sets the collection of modules installed in the hardware unit.
|
|||
|
|
- **`void RemoveModule(IAddEditHardwareDASModule module);`**
|
|||
|
|
Removes a module from the `Modules` collection.
|
|||
|
|
- **`void AddModule();`**
|
|||
|
|
Adds a new module instance to the `Modules` collection (implementation likely creates a default module of appropriate type).
|
|||
|
|
- **`IISOHardware ToISOHardware();`**
|
|||
|
|
Converts the current state into an `IISOHardware` instance for persistence or external use.
|
|||
|
|
- **`bool StandIn { get; set; }`**
|
|||
|
|
Indicates whether this entry represents placeholder/stand-in hardware (not physical).
|
|||
|
|
- **`bool IsModule { get; set; }`**
|
|||
|
|
Indicates whether this instance represents a module (vs. a top-level hardware unit).
|
|||
|
|
- **`bool IsAdd { get; set; }`**
|
|||
|
|
Indicates whether this hardware record is new (`true`) or pre-existing (`false`).
|
|||
|
|
|
|||
|
|
## 3. Invariants
|
|||
|
|
- **`HardwareType` and `ModuleType` must be valid enum values** from `DTS.Common.Enums.Hardware.HardwareTypes` and `DTS.Common.Enums.Hardware.SLICEBridgeTypes`, respectively.
|
|||
|
|
- **`Modules` collection must be initialized before use** (via `ObservableCollection<IAddEditHardwareDASModule>`), as `AddModule()` and `RemoveModule()` assume non-null.
|
|||
|
|
- **`DASImage` is read-only** (`get` only) for both `IAddEditHardwareHardware` and `IAddEditHardwareDASModule`; images must be set internally (e.g., via constructor or factory).
|
|||
|
|
- **`IsAdd` must be set before validation or save**, as `Validate()` uses it to determine behavior (e.g., uniqueness checks).
|
|||
|
|
- **`StandIn` and `IsModule` are mutually orthogonal flags**—a hardware unit can be `StandIn == true` and `IsModule == false`, or vice versa.
|
|||
|
|
- **`ViewDbVersion` must be synchronized with the underlying database version** during activation and save operations to prevent stale writes.
|
|||
|
|
|
|||
|
|
## 4. Dependencies
|
|||
|
|
- **Depends on**:
|
|||
|
|
- `DTS.Common.Base` (`IBaseView`, `IBaseViewModel`)
|
|||
|
|
- `DTS.Common.Interface.DASFactory.Diagnostics` (`IDASHardware`, `IISOHardware`)
|
|||
|
|
- `DTS.Common.Interface.DASFactory.Diagnostics.HardwareList` (`IHardwareListViewModel`, `ISLICE6TreeView`)
|
|||
|
|
- `DTS.Common.Interface.DataRecorders` (likely for ISO layer integration)
|
|||
|
|
- `DTS.Common.Enums.Hardware` (`HardwareTypes`, `SLICEBridgeTypes`, `SLICEConfigurations`, `RackSizes`)
|
|||
|
|
- WPF UI types (`System.Windows.Media.ImageSource`)
|
|||
|
|
- **Depended on by**:
|
|||
|
|
- UI layer implementations (e.g., WPF views and view models) for hardware configuration.
|
|||
|
|
- Persistence layers that consume `IISOHardware` (via `ToISOHardware()` and `GetISOHardware()`).
|
|||
|
|
- SLICE6 tree view integrations (`SetSLICE6TreeView()` suggests coupling with `HardwareListViewModel`).
|
|||
|
|
|
|||
|
|
## 5. Gotchas
|
|||
|
|
- **`DASImage` is read-only**—consumers cannot assign images directly; initialization must occur in concrete implementations (e.g., via factory or constructor).
|
|||
|
|
- **`NotificationsOn` is a blunt instrument**—disabling it suppresses *all* change notifications, which may mask unintended side effects if not carefully managed around initialization.
|
|||
|
|
- **`Validate()` mutates `errors` and `warnings` via `ref`**—callers must initialize these lists before invoking.
|
|||
|
|
- **`AddModule()` does not specify module type**—implementation likely infers type from `HardwareType` or defaults to a generic module, which may cause ambiguity.
|
|||
|
|
- **`IsAdd` and `IsModule` are both `bool` properties**—no validation ensures `IsModule == true` implies `IsAdd == false` (or vice versa); logic may rely on external context.
|
|||
|
|
- **`GetSerialNumberPrefix()` is not guaranteed to return a non-empty string**—callers should handle empty/whitespace prefixes.
|
|||
|
|
- **No explicit thread-safety guarantees**—all interfaces assume single-threaded UI access (common in WPF MVVM but not stated).
|
|||
|
|
- **`StandIn` hardware may lack full functionality**—e.g., `ToISOHardware()` may produce incomplete or placeholder data.
|
|||
|
|
|
|||
|
|
*None identified from source alone.*
|