7.5 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T04:37:06.260294+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 05acdd30203849a0 |
Model
Documentation: DASModule.cs
1. Purpose
The DASModule class models a hardware module in a Data Acquisition System (DAS) for use in a WPF-based UI for adding or editing hardware configurations. It encapsulates module-specific metadata—including type, bridge configuration (for SLICE modules), serial number, and associated visual representation—and exposes this data through a property-changed-aware model suitable for data binding. It serves as a view-model-like abstraction for hardware modules in the AddEditHardware workflow, implementing IAddEditHardwareDASModule and inheriting from BasePropertyChanged to support UI updates via INotifyPropertyChanged.
2. Public Interface
public bool Disabled { get; set; } = false;
- Indicates whether this module instance is disabled (e.g., not in use). Default is
false.
public SLICEBridgeTypes SLICEBridgeType { get; set; }
- Gets or sets the bridge type for SLICE modules (e.g.,
Bridge,IEPE,ARS,ACC). - Behavior: On change, triggers
SetProperty, then callsSetImage()to update the image based on the new type.
public HardwareTypes ModuleType { get; set; }
- Gets or sets the high-level hardware type (e.g.,
SLICE_Bridge,TOM,SIM,DIM,UNDEFINED). - Behavior: On change, triggers
SetProperty, then callsSetImage().
public string SerialNumber { get; set; }
- Gets or sets the module’s serial number (empty string by default). No validation or prefix enforcement is performed in this property.
public ImageSource DASImage { get; set; }
- Gets or sets the
ImageSourceused to display the module’s image in the UI. - Behavior: Set via
SetImage()based onModuleTypeand (forSLICE_Bridge)SLICEBridgeType. May benullif image loading fails or no matching asset is found.
public SLICEBridgeTypes[] AvailableNanoBridges { get; }
- Returns a read-only array of valid
SLICEBridgeTypesfor nano-form-factor SLICE modules:
SLICEBridgeTypes.Bridge,SLICEBridgeTypes.IEPE.
public SLICEBridgeTypes[] AvailableMicroBridges { get; }
- Returns a read-only array of valid
SLICEBridgeTypesfor micro-form-factor SLICE modules:
SLICEBridgeTypes.Bridge,SLICEBridgeTypes.IEPE,SLICEBridgeTypes.ARS,SLICEBridgeTypes.ACC.
public HardwareTypes[] AvailableRACKModules { get; }
- Returns a read-only array of valid hardware types for rack-mounted modules:
HardwareTypes.UNDEFINED,HardwareTypes.SIM,HardwareTypes.TOM,HardwareTypes.DIM.
public IAddEditHardwareHardware OwningHardware { get; set; }
- Reference to the parent hardware object (e.g., chassis or device) that owns this module. Used for contextual navigation or validation.
public string GetSerialNumberPrefix()
- Returns a short string prefix used for generating or validating serial numbers based on module type:
"DIM"forHardwareTypes.DIM"SIM"forHardwareTypes.SIM"TOM"forHardwareTypes.TOM- For
HardwareTypes.SLICE_Bridge, returns a 2-letter prefix based onSLICEBridgeType:"AC"forACC"AR"forARS"BR"forBridge"IEPE"forIEPE
- Returns
string.EmptyforUNDEFINEDor unrecognized types.
public DASModule()
- Default constructor. Initializes
Disabled = false,_sliceBridgeType = Bridge,_moduleType = UNDEFINED.
3. Invariants
- Image Consistency:
DASImageis always derived fromModuleTypeand (if applicable)SLICEBridgeType. Changing either triggersSetImage()and updatesDASImage. - Image Source URI: All image paths are relative to the pack URI
pack://application:,,,/ResourceFile.xaml. - Image Loading Failure Handling: If image loading fails (e.g., missing file),
DASImageis set tonull, and an error is logged viaAPILogger. - Image Freezing: Loaded
BitmapImageinstances are frozen for thread-safety and performance. - Module Type Constraints:
SLICEBridgeTypeis only meaningful whenModuleType == HardwareTypes.SLICE_Bridge.AvailableNanoBridgesandAvailableMicroBridgesare static and immutable; they define allowed values but are not enforced by property setters.
- Serial Number Prefix:
GetSerialNumberPrefix()returnsstring.Emptyfor unrecognized orUNDEFINEDmodule types.
4. Dependencies
Imports/Usings
System,System.Windows,System.Windows.Input,System.Windows.Media,System.Windows.Media.ImagingDTS.Common.Base→BasePropertyChangedDTS.Common.Enums.Hardware→SLICEBridgeTypes,HardwareTypesDTS.Common.Interface.Hardware.AddEditHardware→IAddEditHardwareDASModule,IAddEditHardwareHardwareDTS.Common.Utilities.Logging→APILogger
External Dependencies
- WPF: Uses
ImageSource,BitmapImage,Uri,pack://URIs. - Common Libraries:
DTS.Common.BaseforBasePropertyChanged(likely implementsINotifyPropertyChanged).DTS.Common.Enums.Hardwarefor type definitions.DTS.Common.Interface.Hardware.AddEditHardwarefor interface contracts.DTS.Common.Utilities.Loggingfor error logging.
Consumers
- UI components bound to
DASModule(e.g.,DataGrid,UserControl) for editing hardware configurations. - Any class implementing or consuming
IAddEditHardwareDASModule. - Likely instantiated and managed by a parent
IAddEditHardwareHardware(viaOwningHardware).
5. Gotchas
-
No Validation on
ModuleType/SLICEBridgeTypeCombinations:
The class allows settingModuleType = SLICE_BridgeandSLICEBridgeType = ACC, but also allowsModuleType = TOMwithSLICEBridgeType = IEPE, which is semantically invalid. Validation (if any) must occur elsewhere (e.g., in UI or service layer). -
DisabledProperty Has No Side Effects:
SettingDisabled = truedoes not affect image loading, serial number generation, or any other logic in this class. -
Image Paths Are Hardcoded and Fragile:
SetImage()uses hardcoded relative paths (e.g.,@"Assets/Hardware/SLICEIEPE_Side.png"). If assets are renamed or moved, image loading silently fails (logs error, setsDASImage = null). -
GetSerialNumberPrefix()Returns"IEPE"(4 chars) While Others Are 2–3 chars:
Inconsistent prefix length may cause downstream parsing issues if consumers assume fixed-width prefixes. -
No Null/Empty Handling for
SerialNumber:
The property accepts any string, includingnullor whitespace. No validation or trimming is applied. -
OwningHardwareIs Not Initialized:
The property is nullable and must be set externally; no constructor overloads or defaults are provided. -
_baseUriIs Static and Fixed:
Assumes all images are in the same resource file (ResourceFile.xaml). Not configurable at runtime. -
Exception Handling in
SetImage()Is Broad:
Catches all exceptions during image loading but logs only the message (no stack trace or context), making debugging harder. -
No Explicit Interface Implementation:
The class implementsIAddEditHardwareDASModuleimplicitly; if the interface defines additional members, they are not visible in this file. -
None identified from source alone. (Note: The above are inferred from observed behavior, not documented quirks.)