Files
DP44/enriched-qwen3-coder-next/DataPRO/IService/StateMachine/StatusAndParameters/HardwareDiscovery.md
2026-04-17 14:55:32 -04:00

100 lines
8.4 KiB
Markdown

---
source_files:
- DataPRO/IService/StateMachine/StatusAndParameters/HardwareDiscovery/HardwareDiscoveryParameters.cs
generated_at: "2026-04-16T04:01:01.723717+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "d09b358f05b11ecc"
---
# HardwareDiscovery
## Documentation: `HardwareDiscoveryParameters`
---
### **Purpose**
The `HardwareDiscoveryParameters` class encapsulates configuration and control flags for the hardware discovery phase within the state machine of the DAS (Data Acquisition System) service. It defines *how* hardware devices (SLICE and TDAS units) are discovered—via explicit IPs, IP ranges, or multicast—and *what* actions should follow discovery (e.g., hardware validation, connection, firmware checks). It serves as the input contract for the discovery state, allowing callers to customize discovery behavior (e.g., skip connection, require specific devices, trigger post-discovery transitions) without modifying the discovery logic itself.
---
### **Public Interface**
#### **Properties**
| Property | Type | Default | Description |
|---------|------|---------|-------------|
| `ReadIds` | `bool` | `false` | Whether to read device identifiers (e.g., serial, firmware) after connection. |
| `Addresses` | `string[]` | `new string[0]` | Explicit IP addresses to attempt connection to. If not in known lists, tried as both SLICE and TDAS. |
| `AddressRanges` | `Tuple<string, string>[]` | `new Tuple<string, string>[0]` | IP ranges to ping (inclusive on last octet). Format: `("aaa.bbb.ccc.ddd", "aaa.bbb.ccc.eee")`. Responding IPs added to connection list. |
| `KnownTDASIPAddresses` | `string[]` | `new string[0]` | IPs *confirmed* to be TDAS units. Only tried as TDAS (not SLICE). |
| `KnownSLICEIPAddresses` | `string[]` | `new string[0]` | IPs *confirmed* to be SLICE units. Only tried as SLICE (not TDAS). |
| `ProceedWhenDone` | `bool` | `false` | If `false`, remain in discovery state after completion (e.g., for inspection). If `true`, proceed to next state. |
| `RequireAllDASFound` | `bool` | `false` | If `true`, discovery fails if any device in `Addresses`, `AddressRanges`, or `RequiredSerials` is not found. |
| `GoToDownload` | `bool` | `false` | If `true`, transition to *Download* state after successful discovery (implies `ProceedWhenDone = true`). |
| `Connect` | `bool` | `false` | If `false`, only perform ICMP ping (no socket connection). If `true`, attempt full connection. |
| `UseMulticastDiscover` | `bool` | `false` | Whether to use UDP/Multicast discovery protocol (e.g., SSDP-like). |
| `ConnectTimeoutMS` | `int` | `30000` | Timeout (ms) for connection attempts. |
| `RunAutoSense` | `bool` | `true` | Whether to run auto-sense logic (e.g., fallback discovery). *Note:* Overridden if `DisableAutoSense` is set elsewhere (not in this class). |
| `RequeryDevice` | `IDASCommunication` | `null` | A specific device to re-query (e.g., after config change). If non-null, discovery targets only this device. |
| `RequiredSerials` | `string[]` | `new string[0]` | Serial numbers of devices *required* to be discovered. Used for validation (`RequireAllDASFound` may apply). |
| `DoHardwareChecks` | `bool` | `false` | Whether to perform hardware validation (voltage, memory, firmware) *after* connection. |
| `ExpectedHardware` | `IDASHardware[]` | `new IDASHardware[0]` | Hardware expected to be present post-discovery. Used in `DoHardwareChecks`. |
| `DoVoltageChecks` | `bool` | `true` | Whether to include input/battery voltage checks as part of `DoHardwareChecks`. |
| `UnitIsInDbQuery` | `UnitIsInDbDelegate` | `null` | Callback: `bool UnitIsInDb(IDASCommunication das)` — checks if device is registered in DB. |
| `UnitExpectedFirmwareQuery` | `FirmwareExpectedVersionDelegate` | `null` | Callback: `string ExpectedFirmware(IDASCommunication das)` — returns expected firmware version for device. |
| `CalDateExpiredQuery` | `IsCalDateExpiredDelegate` | `null` | Callback: `bool IsCalExpired(IDASCommunication das)` — checks if calibration date is expired. |
| `UnitExpectedMaxMemoryDelegate` | `UnitExpectedMaxMemoryDelegate` | `null` | Callback: `long ExpectedMaxMemory(IDASCommunication das)` — returns expected max memory for device. |
| `UpdateMaxMemoryAction` | `UpdateMaxMemoryDelegate` | `null` | Callback: `void UpdateMaxMemory(IDASCommunication das)` — updates max memory metadata (e.g., after reflash). |
#### **Methods**
| Method | Signature | Description |
|--------|-----------|-------------|
| `Reset()` | `public void Reset()` | Resets all properties to default values (e.g., empty arrays, `false` flags, `null` delegates). Does *not* reset `ConnectTimeoutMS` (remains `30000`). |
| `ToString()` | `public override string ToString()` | Returns a human-readable summary of all properties, including delegate presence (`[null]`/`[defined]`). |
---
### **Invariants**
- **IP Format**: `Addresses`, `AddressRanges.Item1/Item2`, `KnownTDASIPAddresses`, and `KnownSLICEIPAddresses` must be valid IPv4 strings (`aaa.bbb.ccc.ddd`). Invalid formats may cause ping/connection failures but are *not validated* by this class.
- **Range Validity**: For `AddressRanges`, `Item1` and `Item2` must share the first three octets; otherwise, iteration logic may behave unexpectedly (no validation enforced).
- **Mutual Exclusivity**: `RequeryDevice != null` implies discovery is *device-centric*; `Addresses`, `AddressRanges`, `Known*IPAddresses`, and `RequiredSerials` are likely ignored (behavior depends on consumer).
- **Delegate Consistency**: If `DoHardwareChecks = true`, at least one of `UnitIsInDbQuery`, `UnitExpectedFirmwareQuery`, `CalDateExpiredQuery`, `UnitExpectedMaxMemoryQuery`, or `UpdateMaxMemoryAction` *should* be non-null for meaningful checks—but this is not enforced.
- **Timeout**: `ConnectTimeoutMS` must be ≥ 0. Negative values are not validated and may cause undefined behavior in connection logic.
---
### **Dependencies**
#### **Imports/References**
- `DTS.Common.Interface.DASFactory` → Provides `IDASCommunication` and `IDASHardware`.
- `DTS.Common.Interface.DataRecorders` → Likely provides additional DAS-related interfaces (used via `IDASCommunication`/`IDASHardware`).
- `System` → Core types (`Tuple`, `StringBuilder`, `Delegate`).
#### **Consumers (Inferred)**
- State machine logic in `DTS.DASLib.Service.StateMachine` (namespace implies usage).
- Discovery-related state handlers (e.g., `HardwareDiscoveryState`) that consume this class to configure discovery behavior.
- UI or service layer that populates this class before invoking discovery.
#### **Dependencies on External Types**
- `IDASCommunication`: Interface for device communication (used in delegates and `RequeryDevice`).
- `IDASHardware`: Interface for hardware metadata (used in `ExpectedHardware`).
---
### **Gotchas**
- **`RequeryDevice` takes precedence**: If `RequeryDevice` is non-null, discovery may *ignore* `Addresses`, `AddressRanges`, `Known*IPAddresses`, and `RequiredSerials`. This is implied by the summary but not enforced—consumers must handle this.
- **`GoToDownload` implies `ProceedWhenDone`**: While not enforced in this class, `GoToDownload = true` logically requires `ProceedWhenDone = true` (to transition states). Consumers must ensure this.
- **`RunAutoSense` is *not* overridable here**: The summary notes `DisableAutoSense` overrules `RunAutoSense`, but `DisableAutoSense` is *not a property of this class*. Likely set elsewhere (e.g., in discovery state logic).
- **No validation of IP ranges**: `AddressRanges` items are used as-is. If `Item1` > `Item2` in the last octet, iteration may produce no results or throw (source not shown).
- **`ToString()` omits `ConnectTimeoutMS` and `UseMulticastDiscover`**: These properties are *not* included in the `ToString()` output despite being public—potential debugging pitfall.
- **`Reset()` does not reset `ConnectTimeoutMS`**: Despite resetting other properties, `ConnectTimeoutMS` remains `30000` after `Reset()`. Intentional? Unclear from source.
- **`Known*IPAddresses` are *additive* to discovery scope**: IPs in `KnownTDASIPAddresses`/`KnownSLICEIPAddresses` are *not* exclusive—they are *preferred* paths, but discovery may still try other methods if `Connect = true` and `Addresses`/`AddressRanges` are also set.
---
*Documentation generated from `HardwareDiscoveryParameters.cs` alone. Behavior of discovery logic (e.g., how `AddressRanges` are iterated, how `RequeryDevice` is handled) is inferred from comments and property names but not verifiable without consumer code.*