Files
DP44/enriched-qwen3-coder-next/Common/DTS.Common/Interface/Hardware/AddEditHardware.md
2026-04-17 14:55:32 -04:00

9.5 KiB
Raw Blame History

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
Common/DTS.Common/Interface/Hardware/AddEditHardware/IAddEditHardwareView.cs
Common/DTS.Common/Interface/Hardware/AddEditHardware/IAddEditHardwareDASModule.cs
Common/DTS.Common/Interface/Hardware/AddEditHardware/IAddEditHardwareViewModel.cs
Common/DTS.Common/Interface/Hardware/AddEditHardware/IAddEditHardwareHardware.cs
2026-04-16T03:05:48.722310+00:00 Qwen/Qwen3-Coder-Next-FP8 1 9dcf1285946405bb

AddEditHardware

Documentation: AddEditHardware Module


1. Purpose

This module provides the core data and UI abstractions for the Add/Edit Hardware functionality within the DAS (Data Acquisition System) factory diagnostics workflow. It enables users to create or modify hardware configurations—including DAS units and their associated modules (e.g., SLICE bridges)—by encapsulating state, validation, and persistence logic. The module follows the MVVM pattern, with interfaces defining clear contracts between view, view model, hardware model, and DAS module representations. It integrates with the broader diagnostics and ISO hardware subsystems to support both physical and “stand-in” hardware entries.


2. Public Interface

IAddEditHardwareView

  • void Activated();
    Notifies the view that it has been activated (e.g., brought to foreground or initialized), prompting it to perform post-activation work (e.g., UI refresh, focus management).
  • int ViewDbVersion { get; set; }
    Gets or sets the database version associated with the current view state—likely used for concurrency control or version-specific UI behavior.

IAddEditHardwareDASModule

  • HardwareTypes ModuleType { get; set; }
    Gets or sets the type of the DAS module (e.g., SLICE6, SLICEPROSIM).
  • string SerialNumber { get; set; }
    Gets or sets the modules serial number.
  • ImageSource DASImage { get; }
    Gets an ImageSource representing the module visually (e.g., for UI rendering).
  • IAddEditHardwareHardware OwningHardware { get; set; }
    Gets or sets the parent hardware object to which this module belongs.
  • SLICEBridgeTypes SLICEBridgeType { get; set; }
    Gets or sets the SLICE bridge type (e.g., SLICE6, SLICEPROSIM), likely used for module-specific configuration.
  • string GetSerialNumberPrefix();
    Returns the expected prefix for serial numbers of modules of this ModuleType (e.g., "S6-" for SLICE6 modules).

IAddEditHardwareViewModel

  • IAddEditHardwareView View { get; set; }
    Gets or sets the associated view instance (MVVM binding).
  • void Unset();
    Cleans up references (e.g., to view, tree views) to prevent memory leaks or stale bindings.
  • IAddEditHardwareHardware Hardware { get; set; }
    Gets or sets the hardware object being edited.
  • int? TestId { get; set; }
    Gets or sets the optional test ID associated with this hardware entry.
  • void SetHardware(IDASHardware hw, IISOHardware isoHW);
    Initializes the view model with existing hardware (hw) and ISO representation (isoHW) for editing.
  • bool NotificationsOn { get; set; }
    Gets or sets whether property change notifications are enabled (e.g., disabled 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 business rules. Populates errors/warnings lists and optionally displays a dialog (displayWindow). Returns true if valid.
  • void PublishPageError(bool displayWindow, List<string> errors, List<string> warnings);
    Displays validation errors/warnings (e.g., via UI dialog or status bar) if displayWindow is true.
  • void Save();
    Commits changes to the underlying data store (e.g., database).
  • IISOHardware GetISOHardware();
    Returns the current IISOHardware representation of the edited hardware.
  • bool AllowStandin { get; set; }
    Gets or sets whether “stand-in” (non-physical) hardware entries are permitted.
  • void SetSLICE6TreeView(ISLICE6TreeView treeView, IHardwareListViewModel treeViewModel);
    Injects the SLICE6 tree view and its view model for integration (e.g., module selection).
  • ISLICE6TreeView SLICE6TreeView { get; }
    Gets the currently assigned SLICE6 tree view instance.

IAddEditHardwareHardware

  • HardwareTypes HardwareType { get; set; }
    Gets or sets the DAS hardware type (e.g., SLICE6, SLICEPROSIM).
  • string SerialNumber { get; set; }
    Gets or sets the DAS serial number.
  • string FirmwareVersion { get; set; }
    Gets or sets the DAS firmware version.
  • string IPAddress { get; set; }
    Gets or sets the DAS IP address (if supported).
  • bool SupportsIPAddress { get; }
    Gets whether the DAS type supports IP addressing.
  • bool SupportsRackSize { get; }
    Gets whether the DAS type supports rack size configuration.
  • bool SupportsConfiguration { get; }
    Gets whether the DAS type supports generic configuration.
  • bool SupportsSLICEPROSIMConfiguration { get; }
    Gets whether SLICEPROSIM-specific configuration is supported.
  • bool SupportsSLICETCConfiguration { get; }
    Gets whether SLICETC-specific configuration is supported.
  • SLICEPROSIMConfigurations SLICEPROSIMConfiguration { get; set; }
    Gets or sets the SLICEPROSIM configuration.
  • SLICETCConfigurations SLICETCConfiguration { get; set; }
    Gets or sets the SLICETC configuration.
  • RackSizes RackSize { get; set; }
    Gets or sets the rack size (if supported).
  • ImageSource DASImage { get; }
    Gets an ImageSource representing the DAS unit visually.
  • ObservableCollection<IAddEditHardwareDASModule> Modules { get; set; }
    Gets or sets the collection of modules attached to this DAS.
  • void RemoveModule(IAddEditHardwareDASModule module);
    Removes a module from the Modules collection.
  • void AddModule();
    Adds a new module to the Modules collection (type inferred from HardwareType).
  • IISOHardware ToISOHardware();
    Converts the current state to an IISOHardware instance for persistence or downstream use.
  • bool StandIn { get; set; }
    Gets or sets whether this is a stand-in (non-physical) hardware entry.
  • bool IsModule { get; set; }
    Gets or sets whether this instance represents a module (vs. a top-level DAS).
  • bool IsAdd { get; set; }
    Gets or sets whether this entry is new (true) or an update to an existing record (false).

3. Invariants

  • HardwareType and ModuleType must be consistent with SLICEBridgeType (e.g., a SLICE6 module must have SLICEBridgeType == SLICE6).
  • SerialNumber must begin with the prefix returned by GetSerialNumberPrefix() for the modules ModuleType (enforced during validation, per Validate()).
  • Modules collection must not contain duplicate serial numbers (implied by Validate() and RemoveModule/AddModule semantics).
  • IsAdd and IsModule flags must be set correctly before calling Save() (e.g., IsAdd = true for new entries, IsModule = true for child modules).
  • StandIn hardware entries must not require physical attributes like firmware version or IP address (handled via Supports* properties and validation).
  • ViewDbVersion must match the database version at time of save (implied by naming and typical MVVM patterns for concurrency control).

4. Dependencies

  • Depends on:
    • DTS.Common.Base (IBaseView, IBaseViewModel)
    • DTS.Common.Enums.Hardware (HardwareTypes, RackSizes, SLICEPROSIMConfigurations, SLICETCConfigurations, SLICEBridgeTypes)
    • DTS.Common.Interface.DASFactory.Diagnostics (IDASHardware, IISOHardware)
    • DTS.Common.Interface.DASFactory.Diagnostics.HardwareList (IHardwareListViewModel, ISLICE6TreeView)
    • System.Windows.Media (ImageSource)
  • Depended on by:
    • Likely concrete implementations of IAddEditHardwareView, IAddEditHardwareViewModel, and IAddEditHardwareHardware (e.g., WPF views, view models, and domain models in DTS.App or similar).
    • The broader diagnostics workflow (e.g., DASFactory.Diagnostics) consumes ToISOHardware() and Save() outputs.

5. Gotchas

  • NotificationsOn is critical for avoiding spurious UI updates during initialization—failing to set it to false during SetHardware() may cause validation errors or infinite loops.
  • AddModule() does not take parameters—module type is inferred from Hardware.HardwareType, so callers must ensure HardwareType is set before calling AddModule().
  • DASImage and Module.DASImage are read-only properties—images are likely computed/loaded internally (e.g., from resource paths) and cannot be directly assigned.
  • IsModule is distinct from IsAdd: IsModule = true indicates a child module, while IsAdd indicates whether the record is new. A module can be new (IsAdd = true) or updated (IsAdd = false).
  • Validate() modifies errors/warnings by reference—callers must initialize these lists before passing them.
  • SLICE6TreeView is optionalSetSLICE6TreeView() must be called explicitly for tree view integration; otherwise, SLICE6TreeView remains null.
  • No explicit thread-safety guarantees—all interfaces assume single-threaded UI usage (standard for WPF MVVM).

None identified beyond the above.