Files
DP44/docs/ai/Common/DTS.Common.Serialization/Control/Event.md
2026-04-17 14:55:32 -04:00

158 lines
8.0 KiB
Markdown

---
source_files:
- Common/DTS.Common.Serialization/Control/Event/DasModuleAccessor.cs
- Common/DTS.Common.Serialization/Control/Event/DasChannelAccessor.cs
- Common/DTS.Common.Serialization/Control/Event/ChannelAccessor.cs
- Common/DTS.Common.Serialization/Control/Event/ModuleChannelAccessor.cs
- Common/DTS.Common.Serialization/Control/Event/DasModuleChannelAccessor.cs
- Common/DTS.Common.Serialization/Control/Event/TestInformation.cs
- Common/DTS.Common.Serialization/Control/Event/Event.cs
generated_at: "2026-04-17T15:34:59.374836+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "e395c2fc0bedf773"
---
# Documentation: DTS.Slice.Control.Event
## 1. Purpose
This module provides the core `Event` class for the Slice Control subsystem, representing all information related to a data acquisition system (DAS) event. It serves as the primary data structure for managing test events, including their modules, channels, and associated metadata. The module provides multiple nested accessor classes for efficient lookup of modules and channels by DAS identifiers, and supports bidirectional conversion between Slice Control event representations and `DTS.Serialization.Test` objects for persistence and interchange.
---
## 2. Public Interface
### Event Class (`DTS.Slice.Control.Event`)
**Inheritance:** `Exceptional`, `Test.IConvertable`
#### Constructors
| Signature | Description |
|-----------|-------------|
| `Event()` | Default constructor. |
| `Event(string id, string description)` | Initializes with specified ID and description. |
| `Event(string id, string description, List<Module> modules)` | Initializes with ID, description, and module list. |
| `Event(Test test, Test.ReportErrors reportErrors)` | Initializes from a `DTS.Serialization.Test` object. |
| `Event(List<IDASCommunication> dases, EventInfoAggregate info)` | Initializes from a list of connected DAS devices; builds internal accessor structures. |
#### Properties
| Name | Type | Access | Description |
|------|------|--------|-------------|
| `Id` | `string` | get/set | Event identifier string. |
| `Description` | `string` | get/set | Event description string. |
| `Guid` | `Guid` | get/set | Globally unique identifier; defaults to empty GUID. |
| `FaultFlags` | `UInt16` | get/set | Global fault flags; defaults to `0`. |
| `InceptionDate` | `DateTime` | get/private set | Creation date; defaults to `DateTime.Now`. |
| `Modules` | `List<Module>` | get/set | List of modules associated with this event. |
| `CalculatedChannels` | `List<Module.Channel>` | get/set | List of calculated channels. |
| `DasModules` | `DasModuleAccessor` | get/private set | Accessor for modules keyed by DAS ID. |
| `DasChannels` | `DasChannelAccessor` | get/private set | Accessor for channels keyed by DAS ID. |
| `DasModuleChannels` | `DasModuleChannelAccessor` | get/private set | Accessor for channels keyed by DAS ID/module number/channel number triplet. |
| `LastAbsoluteChannelNumberInEvent` | `int` | get | Highest absolute channel number in the event; returns `-1` if none found. |
| `TooLargeFor32BitVisualizationBytesPerSampleThreshold` | `double` | get/private set | Threshold for 32-bit visualization check; defaults to `2.0`. |
| `IsTooLargeFor32BitVisualization` | `bool` | get | Indicates if combined channel data exceeds 32-bit addressable memory. |
| `ContainsChannelsActiveInvalidZeroingWindows` | `bool` | get | Indicates if any channels have active but invalid zeroing windows. |
| `ChannelsWithActiveInvalidZeroingWindows` | `List<Module.Channel>` | get | List of channels with invalid zeroing window configurations. |
| `BaseSerializationDirectory` | `string` | get/set (static) | Base path for event serialization directories. |
#### Methods
| Signature | Description |
|-----------|-------------|
| `static bool IsG5(IDASCommunication idas)` | Returns `true` if DAS serial number starts with `"5M"`. |
| `static bool IsSlice6DBModule(Module module)` | Returns `true` if module description equals `"slice6db module"` (case-insensitive). |
| `Test ToDtsSerializationTest()` | Converts this event to a `DTS.Serialization.Test` object; purges unconfigured channels. |
| `void FromDtsSerializationTest(Test that, Test.ReportErrors reportErrors)` | Populates this event from a `DTS.Serialization.Test` object. |
| `static implicit operator Test(Event sliceControlEvent)` | Implicit conversion to `DTS.Serialization.Test`. |
| `static string GetEventSerializationDirectory(string eventId)` | Returns the serialization directory path for a given event ID. |
| `override bool Equals(object obj)` | Memberwise equality comparison. |
| `override int GetHashCode()` | Returns base hash code. |
---
### Nested Accessor Classes
#### DasModuleAccessor
```
Inherits: ExceptionalDictionary<Common.DAS.Concepts.DAS.Id, List<Module>>
```
- **Constructor:** `DasModuleAccessor()`
- **Purpose:** Provides access to event modules by DAS ID/module number pair.
#### DasChannelAccessor
```
Inherits: ExceptionalDictionary<Common.DAS.Concepts.DAS.Id, List<Module.Channel>>
```
- **Constructor:** `DasChannelAccessor()`
- **Purpose:** Provides access to event channels by DAS ID/channel number pair.
#### ChannelAccessor
```
Inherits: ExceptionalDictionary<int, Module.Channel>
```
- **Constructor:** `ChannelAccessor()`
- **Purpose:** Component of `DasModuleChannelAccessor`; maps channel numbers to channels.
#### ModuleChannelAccessor
```
Inherits: ExceptionalDictionary<int, ChannelAccessor>
```
- **Constructor:** `ModuleChannelAccessor()`
- **Purpose:** Component of `DasModuleChannelAccessor`; maps module numbers to `ChannelAccessor` instances.
#### DasModuleChannelAccessor
```
Inherits: ExceptionalDictionary<Common.DAS.Concepts.DAS.Id, ModuleChannelAccessor>
```
- **Constructor:** `DasModuleChannelAccessor()`
- **Purpose:** Provides access to channels by DAS ID/module number/channel number triplet.
---
### TestInformation (Private Nested Class)
- **Access:** `private`
- **Inheritance:** `Exceptional`
- **Properties:** `Id` (string), `Description` (string)
- **Constructors:**
- `TestInformation()` — leaves properties uninitialized
- `TestInformation(string id, string description)`
---
## 3. Invariants
1. **GUID Default:** The `Guid` property initializes to `00000000-0000-0000-0000-000000000000` when unset.
2. **FaultFlags Default:** The `FaultFlags` property initializes to `0`.
3. **InceptionDate Default:** The `InceptionDate` property initializes to `DateTime.Now` at construction time.
4. **Visualization Threshold:** `TooLargeFor32BitVisualizationBytesPerSampleThreshold` defaults to `2.0` bytes per sample.
5. **Test ID Consistency:** When constructing from multiple DAS devices, all devices must report matching test IDs (case-insensitive comparison); otherwise an exception is thrown.
6. **Module Array Alignment:** The constructor maintains the invariant `DasModules[das.SerialNumber].Count - 1 == dasModule.ModuleArrayIndex` (enforced via `Debug.Assert`).
7. **Empty Slot Handling:** Empty slots in TDAS racks are filled with placeholder `Module` instances to maintain correct array indexing.
8. **Invalid Window Average Sentinel:** The constant `InvalidWindowAverage = short.MinValue` is used to detect uninitialized window averages.
---
## 4. Dependencies
### This Module Depends On
| Namespace/Assembly | Usage |
|--------------------|-------|
| `System` | Core types, `Guid`, `DateTime`, `InvalidOperationException` |
| `System.Collections.Generic` | `List<T>` collections |
| `System.Diagnostics` | `Debug.Assert` |
| `DTS.DASLib.Service` | `IDASCommunication`, `DASModule`, `DASChannel`, `EthernetTDAS`, `OutputSquibChannel` |
| `DTS.Serialization` | `Test` class, serialization types |
| `DTS.Common.Utilities` | `Exceptional` base class, `Exception`, `UserException` |
| `DTS.Common.Utilities.DotNetProgrammingConstructs` | `Property<T>` wrapper |
| `DTS.Common.Utilities.Logging` | `APILogger.Log` |
| `DTS.Serialization.StringResources` | Localized error strings (`Strings` class) |
| `DTS.Common.DAS.Concepts` | `DAS.Id`, `Test.Module.Channel.Sensor.ZeroMethodType` |
### Consumers (Inferred)
- Test serialization/deserialization systems (via