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,43 @@
---
source_files:
- DataPRO/StateMachine.Tests/Properties/AssemblyInfo.cs
generated_at: "2026-04-16T04:24:14.930332+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "dc37aa5b03a67b87"
---
# Properties
## 1. Purpose
This module is the assembly metadata configuration file for a .NET test project named `IService.Tests`. It does not contain executable logic or test cases itself; rather, it defines assembly-level attributes used by the .NET runtime and build tools for identification, versioning, and COM interop configuration. Its role is to provide metadata that supports deployment, discovery, and compatibility of the test assembly within the broader `DataPRO` codebase.
## 2. Public Interface
**No public API surface is exposed by this file.**
This file (`AssemblyInfo.cs`) is a metadata configuration file and contains no classes, methods, properties, or other public members. All content consists of assembly-level attributes applied via `Assembly*` attributes.
## 3. Invariants
- The assembly is marked as **non-CLoSable** (`ComVisible(false)`), meaning its types are not exposed to COM clients by default.
- The assembly GUID is fixed at `a535dd8a-4959-4ffc-827f-06f7ee345efd`, used for COM type library identification if exposed.
- Versioning is fixed at `1.0.0.0` for both `AssemblyVersion` and `AssemblyFileVersion`.
- The assembly title and product are both `"IService.Tests"`, indicating its purpose as a test harness.
- No runtime invariants or stateful constraints apply, as this file contributes only compile-time metadata.
## 4. Dependencies
- **Depends on**:
- `System.Reflection`
- `System.Runtime.CompilerServices`
- `System.Runtime.InteropServices`
(All standard .NET runtime namespaces; no external or project-specific dependencies.)
- **Depended on by**:
- None directly — this file is consumed by the .NET build system (e.g., MSBuild) and runtime to generate assembly metadata.
- Test runners (e.g., MSTest, NUnit, xUnit) may use the assembly identity (e.g., title, version) for reporting or discovery, but do not depend on its contents programmatically.
## 5. Gotchas
- **No executable code**: This file should not be modified expecting runtime behavior changes; it only affects assembly metadata.
- **COM interop disabled**: `ComVisible(false)` means this assembly cannot be consumed by COM clients unless explicitly overridden at the type level (which is not done here).
- **Versioning is static**: Both `AssemblyVersion` and `AssemblyFileVersion` are hardcoded to `1.0.0.0`. If versioning is managed elsewhere (e.g., via CI/CD), this file may be redundant or cause version conflicts.
- **Title mismatch**: `AssemblyTitle` is `"IService.Tests"` while `AssemblyProduct` is also `"IService.Tests"` — this may reflect legacy naming but could cause confusion if the actual product name differs.
- **No unit test logic**: Developers should not expect to find test methods or assertions here; test code resides in other files (not provided).
None identified beyond the above.

View File

@@ -0,0 +1,104 @@
---
source_files:
- DataPRO/StateMachine.Tests/States/RealtimeShould.cs
- DataPRO/StateMachine.Tests/States/ConfigureShould.cs
- DataPRO/StateMachine.Tests/States/RealtimeStartShould.cs
- DataPRO/StateMachine.Tests/States/DiagnoseShould.cs
- DataPRO/StateMachine.Tests/States/HardwareDiscoveryStartShould.cs
generated_at: "2026-04-16T04:24:35.181988+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "19e719e00bdf4549"
---
# StateMachine Module Documentation
## 1. Purpose
This module implements a finite state machine (FSM) for managing the operational states of a data acquisition system (DAS), with states such as `HardwareDiscovery`, `Configure`, `Diagnose`, `Realtime`, and their transition points (e.g., `RealtimeStart`, `HardwareDiscoveryStart`). It enables deterministic state transitions based on runtime status and configuration parameters, ensuring the system progresses through initialization, configuration, diagnostics, and real-time operation phases in a controlled manner. The tests validate the behavior of individual state classes and their `StateSelector()` logic, which determines the next state based on current status flags and parameters.
## 2. Public Interface
The following classes are defined in the `DTS.DASLib.Service.StateMachine` namespace (inferred from test imports). Each class represents a state in the state machine and exposes a `StateSelector()` method to determine the next state.
### `Realtime`
- **Constructor**: `Realtime()`
Initializes the state; sets `State` property to `State.Realtime`.
- **Property**: `State``State`
Returns the current state identifier (`State.Realtime`).
- **Method**: `StateSelector()``DASState` *(not tested directly, but implied by pattern)*
*Behavior inferred from other states: returns the next state based on status/params. Not directly exercised in provided tests.*
### `Configure`
- **Constructor**: `Configure()`
Initializes the state.
- **Method**: `StateSelector()``DASState`
Returns a `DASState` with `State` set to `State.ConfigureStart`.
### `RealtimeStart`
- **Constructor**: `RealtimeStart()`
Initializes the state.
- **Property**: `Status``Status` *(exposes `RealtimeStatus`)*
Contains `RealtimeStatus.CouldNotStartRealtime` (boolean).
- **Method**: `StateSelector()``DASState`
- If `RealtimeStatus.CouldNotStartRealtime == true`, returns `State.RealtimeStart`.
- If `RealtimeStatus.CouldNotStartRealtime == false`, returns `State.Realtime`.
### `Diagnose`
- **Constructor**: `Diagnose()`
Initializes the state.
- **Property**: `Status``Status` *(exposes `DiagnoseParams`)*
Contains:
- `DiagnoseParams.ProceedToRealtimeWhenDone` (bool)
- `DiagnoseParams.RequireAllUnitsPassDiagnostic` (bool)
- `DiagnoseParams.AllUnitsPassedDiagnostic` (bool)
- **Method**: `StateSelector()``DASState`
Returns:
- `State.RealtimeStart` if `ProceedToRealtimeWhenDone == true` **and**
(`RequireAllUnitsPassDiagnostic == false` **or** `AllUnitsPassedDiagnostic == true`).
- `State.Diagnose` otherwise (e.g., when `ProceedToRealtimeWhenDone == false`, or when `RequireAllUnitsPassDiagnostic == true` and `AllUnitsPassedDiagnostic == false`).
### `HardwareDiscoveryStart`
- **Constructor**: `HardwareDiscoveryStart()`
Initializes the state; sets `State` property to `State.HardwareDiscoveryStart`.
- **Property**: `State``State`
Returns `State.HardwareDiscoveryStart`.
- **Property**: `Status``Status` *(exposes `HardwareDiscoveryParams` and `HardwareDiscoveryStatusInfo`)*
Contains:
- `HardwareDiscoveryParams.ProceedWhenDone` (bool)
- `HardwareDiscoveryParams.RequireAllDASFound` (bool)
- `HardwareDiscoveryParams.GoToDownload` (bool)
- `HardwareDiscoveryStatusInfo.AllDASFound` (bool)
- `HardwareDiscoveryStatusInfo.SomeUnitsInArmState` (bool)
- **Method**: `StateSelector()``DASState`
Returns the next state based on:
- If `ProceedWhenDone == true`:
- `State.Download` if `GoToDownload == true` and `AllDASFound == true` (and `RequireAllDASFound == true`).
- `State.Configure` if `GoToDownload == false` and either `AllDASFound == true` or `RequireAllDASFound == false`.
- `State.Arm` if `AllDASFound == false`, `RequireAllDASFound == true`, `GoToDownload == false`, and `SomeUnitsInArmState == true`.
- `State.HardwareDiscovery` if `AllDASFound == false`, `RequireAllDASFound == true`, `GoToDownload == false`, and `SomeUnitsInArmState == false`.
## 3. Invariants
- Each state classs `State` property (where exposed) must return the corresponding `State` enum value (e.g., `Realtime.State == State.Realtime`).
- `StateSelector()` must return a non-null `DASState` object with a valid `State` field.
- Transitions are deterministic: given identical `Status` and parameter values, `StateSelector()` must return the same next state.
- `HardwareDiscoveryStart.StateSelector()` only evaluates transitions when `ProceedWhenDone == true` (based on test arrangements); behavior when `ProceedWhenDone == false` is not specified in tests.
## 4. Dependencies
- **Internal Dependencies**:
- `DTS.DASLib.Service.StateMachine` namespace (contains state classes and `State` enum).
- `Status` type (contains nested `RealtimeStatus`, `DiagnoseParams`, `HardwareDiscoveryParams`, `HardwareDiscoveryStatusInfo`).
- `DASState` type (returned by `StateSelector()`).
- `State` enum (defines state identifiers: `Realtime`, `ConfigureStart`, `RealtimeStart`, `Diagnose`, `HardwareDiscoveryStart`, `HardwareDiscovery`, `Arm`, `Download`, `Configure`).
- **Test Dependencies**:
- `NUnit` for test framework (`[TestFixture]`, `[Test]`, `Assert.That`).
- `NSubstitute` (used in `HardwareDiscoveryStartShould` tests, though not instantiated in provided snippets).
- **Inferred Consumers**:
A higher-level state machine controller (not shown) likely instantiates these state classes and calls `StateSelector()` to drive transitions.
## 5. Gotchas
- **Ambiguous `Status` Type**: The `Status` propertys full structure (e.g., `RealtimeStatus`, `DiagnoseParams`, `HardwareDiscoveryParams`) is inferred from test usage but not defined in the source. Its exact shape and default values are unknown.
- **Missing `StateSelector()` Implementation Details**: The tests do not cover edge cases (e.g., `ProceedWhenDone == false` in `HardwareDiscoveryStart`, or invalid parameter combinations). Behavior in untested scenarios is unspecified.
- **Redundant Test for `DiagnoseShould.State_ShouldBeRealtime`**: This test instantiates `new Realtime()` but asserts `sut.State == State.Realtime`, which is identical to `RealtimeShould.State_ShouldBeRealtime`. Likely a copy-paste error in tests.
- **No Error Handling Tests**: No tests verify behavior when `Status` is null, or when parameters conflict (e.g., `RequireAllUnitsPassDiagnostic == true` and `AllUnitsPassedDiagnostic == true` but `ProceedToRealtimeWhenDone == false`—though this is covered in `DiagnoseShould`).
- **State Names vs. Class Names**: The class `RealtimeStart` corresponds to `State.RealtimeStart`, but `Configure` class returns `State.ConfigureStart` (not `State.Configure`). This mismatch may cause confusion.
None identified beyond the above.

View File

@@ -0,0 +1,125 @@
---
source_files:
- DataPRO/StateMachine.Tests/StatusAndParameters/GlobalStatusInformationShould.cs
generated_at: "2026-04-16T04:24:23.201570+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "cdc9e7fc7b8b72ec"
---
# StatusAndParameters
## Documentation: `GlobalStatusInformation` Class
### 1. Purpose
The `GlobalStatusInformation` class serves as a centralized in-memory registry for tracking the current state and membership of communication-enabled devices (`IDASCommunication` instances) across four distinct operational contexts: *realtime*, *arm*, *low power*, and *high power*. It maintains disjoint sets of devices per context and enforces uniqueness per context (i.e., a device instance may appear in at most one context at a time). This class is used within the state machine logic to manage and query device status during system operation, particularly during initialization, reconfiguration, or power-state transitions.
---
### 2. Public Interface
#### `class GlobalStatusInformation`
A concrete class (no interface declaration visible in test file) managing device groupings by operational context.
##### Methods
- **`List<IDASCommunication> GetUnitsInRealtime()`**
Returns a *copy* (as `List<IDASCommunication>`) of the current set of devices registered in the *realtime* context. Initially empty.
- **`void AddUnitInRealtime(IDASCommunication device)`**
Adds the given `device` to the *realtime* set *if not already present* in that set. Does *not* remove the device from other contexts (e.g., *arm*, *low power*, *high power*).
*Note: Tests confirm uniqueness is enforced per context only.*
- **`List<IDASCommunication> GetUnitsInArm()`**
Returns a *copy* of the current set of devices registered in the *arm* context. Initially empty.
- **`void AddUnitInArm(IDASCommunication device)`**
Adds the given `device` to the *arm* set *if not already present* in that set. Does *not* remove the device from other contexts.
- **`List<IDASCommunication> GetUnitsAtLowPower()`**
Returns a *copy* of the current set of devices registered in the *low power* context. Initially empty.
- **`void AddUnitAtLowPower(IDASCommunication device)`**
Adds the given `device` to the *low power* set *if not already present* in that set.
*Crucially*, if the same device instance is *already* in the *high power* set, it is **automatically removed** from *high power* before being added to *low power*.
→ Tests confirm this *mutual exclusion* only between *low power* and *high power*.
- **`List<IDASCommunication> GetUnitsAtHighPower()`**
Returns a *copy* of the current set of devices registered in the *high power* context. Initially empty.
- **`void AddUnitAtHighPower(IDASCommunication device)`**
Adds the given `device` to the *high power* set *if not already present* in that set.
*Crucially*, if the same device instance is *already* in the *low power* set, it is **automatically removed** from *low power* before being added to *high power*.
→ Tests confirm this *mutual exclusion* only between *low power* and *high power*.
- **`void Reset()`**
Clears *all* device collections (realtime, arm, low power, high power) and sets `ExcitationOn` to `false`. Does *not* dispose or modify the `IDASCommunication` instances themselves.
##### Properties
- **`bool ExcitationOn`**
A boolean flag indicating whether excitation (likely a measurement or calibration signal) is active. Initialized to `false`. Cleared to `false` on `Reset()`.
---
### 3. Invariants
- **Contextual Uniqueness (Per Context)**
Within any *single* context (e.g., *realtime*, *arm*, *low power*, *high power*), a given `IDASCommunication` instance may appear **at most once**. Attempting to add the same instance again has no effect.
- **Mutual Exclusivity (Low Power ↔ High Power)**
A device instance **cannot be in both *low power* and *high power* simultaneously**. Adding a device to one automatically removes it from the other *if present*.
→ This is the *only* cross-context constraint enforced.
- **No Cross-Context Exclusivity**
A device may appear in *any combination* of the following contexts: *realtime*, *arm*, *low power*, *high power**except* the *low power*/*high power* pair.
Example: A device may be in *realtime* + *low power* + *arm* concurrently.
- **State Reset**
`Reset()` guarantees all device collections are empty and `ExcitationOn` is `false`.
---
### 4. Dependencies
#### Dependencies *on* `GlobalStatusInformation`
- **`DTS.DASLib.Service.StateMachine`** (namespace) — The class resides in this namespace, implying integration with the state machine subsystem.
- **`DTS.Common.Interface.DASFactory.IDASCommunication`** — The core interface for device communication objects used as inputs/outputs.
- **`NSubstitute`** — Used in tests for mocking `IDASCommunication`; not a runtime dependency.
#### Dependencies *of* `GlobalStatusInformation`
- **`DTS.Common.Interface.DASFactory.IDASCommunication`** — Required for method signatures.
- **`System.Collections.Generic.List<T>`** — Used as return type for all `Get*()` methods.
#### Inferred Consumers
- State machine logic (e.g., transitions, state queries) — implied by test namespace `StateMachine.Tests.StatusAndParameters`.
- Any module needing to track or query device presence in specific operational modes.
---
### 5. Gotchas
- **Shallow Copies Returned**
`GetUnits*()` methods return `List<IDASCommunication>`*not* a defensive copy of the underlying collections *contents*. Modifications to the returned list (e.g., `Clear()`, `Remove()`) will affect the internal state. Tests do *not* verify immutability of the returned list, and the class does not clone devices.
**Recommendation**: Callers should treat the returned list as read-only or clone it explicitly.
- **Only Low/High Power Are Mutually Exclusive**
Developers may incorrectly assume *all* contexts are disjoint. In reality, a device can be in *realtime* and *low power* simultaneously — only *low power**high power* are mutually exclusive.
- **Reference Equality Used for Uniqueness**
Uniqueness is enforced via *reference equality* (e.g., `thirdDevice = secondDevice` in tests). Two distinct `IDASCommunication` instances with identical `SerialNumber` are treated as different devices.
→ Serial number is *not* used for deduplication.
- **No Explicit Thread Safety**
No synchronization primitives or concurrency guarantees are evident. Concurrent access may lead to race conditions.
- **No Validation on `device` Parameter**
Methods accept `null` without visible checks (tests use mocked non-null devices). Passing `null` may cause `NullReferenceException` (e.g., accessing `.SerialNumber`).
*Not explicitly tested; behavior undefined.*
- **`Reset()` Does Not Notify Consumers**
Clearing state via `Reset()` has no side effects (e.g., no events, callbacks). Downstream logic relying on `GlobalStatusInformation` state must re-query after `Reset()`.
---
*Documentation derived solely from test file `GlobalStatusInformationShould.cs`. Implementation details (e.g., internal storage, constructor) are not visible and thus not documented.*

View File

@@ -0,0 +1,87 @@
---
source_files:
- DataPRO/StateMachine.Tests/StatusAndParameters/Realtime/RealtimeStatusInformationShould.cs
generated_at: "2026-04-16T04:24:39.879915+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "98f63d1d76a0b743"
---
# Realtime
## Documentation: `RealtimeStatusInformation` Class
### 1. Purpose
This class encapsulates state and control logic for managing real-time data acquisition operations within the DAS (Data Acquisition System) framework. It serves as a status tracker and coordinator for initiating and monitoring real-time sampling, exposing properties such as `CouldNotStartRealtime` and `IsInRealtime` to reflect the current operational state. It is used by test suites to validate behavior of real-time startup workflows and status reporting, and likely forms part of a larger state machine managing DAS communication sessions.
### 2. Public Interface
The following members are *publicly accessible* based on usage in tests (i.e., `public` or `internal` with test visibility, but only these are referenced in the provided source):
- **`RealtimeStatusInformation()`**
*Constructor.* Initializes a new instance of the `RealtimeStatusInformation` class.
- **`void StartRealtime(...)`**
*Method.* Initiates a real-time acquisition session.
**Signature (inferred from test call):**
```csharp
void StartRealtime(
List<IDASCommunication> dasList,
List<int> moduleIndices,
bool useSingleSampleMode,
int realtimeSampleRate,
int realtimeDelayBetweenPollsInMilliSecond,
bool allowMultipleSampleRealtime,
Action<double, double> SetRealtimeSampleRateAAF,
Action CompleteAction,
Dictionary<IDASCommunication, byte[]> idasToActiveChannels,
ServiceBase.Callback StartRealtimeCallback
);
```
**Behavior:**
Executes the real-time startup sequence. Based on the test assertion, this method *always* sets `CouldNotStartRealtime` to `true` after invocation in the current implementation (suggesting either incomplete implementation, a known failure mode, or intentional test stubbing). The method triggers callbacks (`CompleteAction`, `StartRealtimeCallback`) and passes parameters to `SetRealtimeSampleRateAAF`.
- **`bool CouldNotStartRealtime { get; }`**
*Read-only property.* Indicates whether real-time acquisition failed to start.
**Behavior:**
Returns `true` after `StartRealtime` is invoked (per test assertion), regardless of actual success/failure semantics. Its value is likely set internally during `StartRealtime`.
- **`bool IsInRealtime { get; }`**
*Read-only property.* Indicates whether the system is currently in a real-time acquisition state.
**Behavior:**
Returns `false` for a newly constructed instance (per test). Likely updated during `StartRealtime` and/or `StopRealtime` (not shown here), but current source only confirms initial state.
> **Note:** No other public methods, properties, or fields are referenced or observable in the provided test file.
### 3. Invariants
- `CouldNotStartRealtime` is set to `true` *immediately after* `StartRealtime` completes (as verified by test assertion).
- `IsInRealtime` is `false` for a freshly instantiated `RealtimeStatusInformation` object.
- The `StartRealtime` method requires non-null inputs for `dasList`, `moduleIndices`, `idasToActiveChannels`, `SetRealtimeSampleRateAAF`, `CompleteAction`, and `StartRealtimeCallback`; passing `null` may cause runtime exceptions (not validated in tests).
- `moduleIndices` must contain indices corresponding to valid entries in `dasList` (e.g., `moduleIndices[0] == 0` maps to `dasList[0]`), as implied by test setup.
### 4. Dependencies
- **Direct Dependencies (from imports):**
- `DTS.Common.Interface.DASFactory.IDASCommunication` Interface for DAS communication abstraction.
- `DTS.DASLib.Service.ServiceBase` Provides `ServiceBase.Callback` delegate and `CallbackData` type.
- `DTS.DASLib.Service.StateMachine` Likely contains `RealtimeStatusInformation` and related state machine components.
- `NSubstitute` mocking framework (test-only).
- `NUnit` test framework (test-only).
- **Inferred Usage:**
- `IDASCommunication` instances are used to represent physical/logical DAS devices.
- `idasToActiveChannels` maps each `IDASCommunication` to a `byte[]` (likely channel bitmask).
- `SetRealtimeSampleRateAAF` is a callback to configure AAF (Anti-Aliasing Filter) parameters.
- `ServiceBase.Callback` is used for progress/status updates during acquisition (`NewData`, `AllFinished`).
- **Depended upon by:**
- Test suite (`StateMachine.Tests`) sole consumer in provided source.
- Likely used by higher-level state machine components (e.g., in `DTS.DASLib.Service.StateMachine`) not shown here.
### 5. Gotchas
- **`CouldNotStartRealtime` always `true` after `StartRealtime`**: The test asserts this unconditionally, suggesting either incomplete implementation, intentional stubbing for testing, or a known limitation where real-time startup *always* fails in the current build. This is likely a placeholder or work-in-progress behavior.
- **No `StopRealtime` or reset mechanism visible**: The class exposes no method to clear `CouldNotStartRealtime` or transition `IsInRealtime` to `true`, implying state may be sticky or managed externally.
- **Callback semantics not fully specified**: While `StartRealtimeCallback` is invoked with `CallbackData`, the test only logs status; actual data handling, error reporting, or cancellation behavior is not documented here.
- **No validation on `moduleIndices` vs. `dasList` length**: Passing mismatched indices (e.g., `moduleIndices.Count != dasList.Count`) may cause runtime errors (e.g., `IndexOutOfRangeException`).
- **Hardcoded test values**: `realtimeDelayBetweenPollsInMilliSecond = 4` and `realtimeSampleRate = 1000` are used in tests; their validity (e.g., minimum/maximum ranges) is not enforced in the test and may be undocumented.
- **No thread-safety guarantees**: The class is used synchronously in tests; concurrent access may cause race conditions (not addressed in source).
> **Note:** Since only test code is provided, internal implementation details (e.g., private fields, state transitions) are unknown. Behavior beyond what is exercised in tests is speculative.