--- source_files: - DataPRO/IService/Classes/SLICEService/SLICE Service.TriggerCheck.cs - DataPRO/IService/Classes/SLICEService/SLICE Service.cs - DataPRO/IService/Classes/SLICEService/SLICE Service.Public.cs generated_at: "2026-04-17T15:33:52.687420+00:00" model: "zai-org/GLM-5-FP8" schema_version: 1 sha256: "8cfeb92a23080dfc" --- # SLICE Service Module Documentation ## 1. Purpose The `Slice` class is a generic partial class that serves as the primary service abstraction for DTS data acquisition system (DAS) hardware communication. It implements multiple interfaces (`IDASCommunication`, `IConfigurationActions`, `IDiagnosticsActions`, `ITriggerCheckActions`, `IRealTimeActions`, `IArmActions`, `IDownloadActions`) to provide a unified API for configuring, arming, monitoring, and downloading data from various SLICE hardware variants. The class is designed with a generic type parameter `T` constrained to `IConnection`, enabling support for different transport mechanisms (USB, Ethernet) while sharing common functionality. --- ## 2. Public Interface ### Trigger Check Actions (from `ITriggerCheckActions`) | Method | Signature | Description | |--------|-----------|-------------| | `PreStartTriggerCheck` | `void ITriggerCheckActions.PreStartTriggerCheck(ServiceCallback callback, object userData)` | Asynchronously prepares hardware for trigger check by setting start record and trigger polarity attributes if supported. | | `PostStartTriggerCheck` | `void ITriggerCheckActions.PostStartTriggerCheck(ServiceCallback callback, object userData)` | Immediately reports success; no additional post-processing performed. | | `StartTriggerCheck` | `void ITriggerCheckActions.StartTriggerCheck(ServiceCallback callback, object userData)` | Asynchronously initializes hardware input lines and checks for shorted trigger/start inputs. Returns error "TriggerInputShorted" or "StartInputShorted" if detected. | | `DoStartCheck` | `void ITriggerCheckActions.DoStartCheck(ServiceCallback callback, object userData)` | Asynchronously checks start record input status and updates `ArmStatus.IsArmed` and `ArmStatus.IsRecording`. | | `DoTriggerCheck` | `void ITriggerCheckActions.DoTriggerCheck(ServiceCallback callback, object userData)` | Asynchronously executes trigger check; callback may be null. | | `DoTriggerCheckSync` | `void ITriggerCheckActions.DoTriggerCheckSync()` | Synchronously checks trigger/start input status and sets `ArmStatus` with `IsTriggered`, `IsArmed`, `IsTriggerShorted`, `IsStartShorted`. | | `CancelTriggerCheck` | `void ITriggerCheckActions.CancelTriggerCheck(ServiceCallback callback, object userData)` | Asynchronously cancels trigger check operation. | ### Protected/Virtual Methods (Trigger Check) | Method | Signature | Description | |--------|-----------|-------------| | `AsyncPreStartTriggerCheck` | `protected virtual void AsyncPreStartTriggerCheck(object asyncInfo)` | Worker method that sets `StartRecordPolarity` and `TriggerPolarity` system attributes based on `InvertStart` and `InvertTrigger` properties. | | `AsyncStartTriggerCheck` | `protected virtual void AsyncStartTriggerCheck(object asyncInfo)` | Worker method that executes `InitializeHardwareLines` command and validates input states. | ### Core Service Methods (from main partial class) | Method | Signature | Description | |--------|-----------|-------------| | `LaunchAsyncWorker` | `public void LaunchAsyncWorker(string Invoker, WaitCallback cb, object asyncInfo)` | Queues an async work item to the thread pool. Throws `NotConnectedException` if not connected, or `Exception` if queue fails. | | `GetRequestedRange` | `protected static double GetRequestedRange(AnalogInputDASChannel analog, double MvPerEU)` | Calculates requested range for analog channel, adjusting for nonlinear polynomial formulas. | | `SetRemoveSeconds` | `protected void SetRemoveSeconds()` | Sets leap second removal attribute if `ProtocolLimitedCommands.RemoveLeapSeconds` is supported. | | `GetExtendedFaultFlags` | `protected virtual QATSExtendedFault[] GetExtendedFaultFlags()` | Queries extended fault flags from arm attributes; returns array of active faults. | | `SetADCSamplesPerPacket` | `protected void SetADCSamplesPerPacket(int adcPerPacket)` | Configures ADC samples per packet via `S6A_IrigStreamBufferConfig` system attribute. | | `SurfaceApplicationError` | `protected static void SurfaceApplicationError(string msg)` | Surfaces error to application via `PageErrorEvent.SurfaceApplicationError`. | ### Public Properties (from SLICE Service.Public.cs) | Property | Type | Description | |----------|------|-------------| | `ConfigData` | `IConfigurationData` | Public configuration data accessor. | | `ChannelDiagnostics` | `IDiagnosticActions[]` | Array of channel diagnostic actions. | | `ChannelDiagnosticsResults` | `IDiagnosticResult[]` | Array of channel diagnostic results. | | `ModuleDiagnosticsResults` | `IModuleDiagnosticsResult[]` | Module-level diagnostic results. | | `TriggerResult` | `ITriggerCheckResult` | Public trigger check result. | | `RealtimeDASChannels` | `List` | List of real-time DAS channels. | | `TiltAxisData` | `List` | Tilt axis data for real-time display. | | `DASFlashEraseStatus` | `FlashEraseStatus` | Flash erase operation status. | | `DASArmStatus` | `IArmStatusData` | Current arm status data. | | `AutoArmStatus` | `DFConstantsAndEnums.CommandStatus` | Auto-arm operation status (default: `StatusNoError`). | | `DASClockSyncStatus` | `IDictionary` | Clock sync status per input source. | | `WhatToDownload` | `virtual IDownloadRequest` | Download request specification. | | `EventInfo` | `IDownloadReport` | Event download report. | | `EventDownloadedStatus` | `bool[]` | Per-event download status array. | | `EventGuids` | `Guid[]` | Event GUID array. | | `FaultFlags` | `ushort[]` | Event fault flags. | | `ArmAttempts` | `byte[]` | Event arm attempt counts. | | `InvertTrigger` | `bool` | Trigger polarity inversion flag. | | `InvertStart` | `bool` | Start record polarity inversion flag. | | `IgnoreShortedStart` | `bool` | Flag to ignore shorted start input. | | `IgnoreShortedTrigger` | `bool` | Flag to ignore shorted trigger input. | | `SerialNumber` | `string` | Device serial number (inherited). | | `MACAddress` | `string` | Device MAC address. | | `FirstUseDate` | `DateTime?` | First use date; null if not used since calibration. | | `IsFirstUseDateSupported` | `bool` | Whether hardware supports first use date. | | `IsStreamingSupported` | `bool` | Whether streaming feature is supported. | | `ExcitationStatus` | `ExcitationStatus` | Current excitation status (default: `Unknown`). | | `RecordId` | `int` | Record ID (default: `INVALID_IDASCOMMUNICATION_RECORD_ID`). | ### Hardware Identification Methods | Method | Signature | Description | |--------|-----------|-------------| | `GetHardwareType` | `public virtual HardwareTypes GetHardwareType()` | Returns hardware type based on serial number prefix ("BA5"→Nano, "BA0"→Micro, "SG5"→SLICE1_G5Stack). | | `SupportsTriggerInversion` | `public virtual bool SupportsTriggerInversion()` | Returns `true` (overrideable). | | `SupportsStartInversion` | `public virtual bool SupportsStartInversion()` | Returns `true` (overrideable). | | `IsEthernetDistributor` | `public virtual bool IsEthernetDistributor()` | Returns `false`. | | `IsSlice6Distributor` | `public virtual bool IsSlice6Distributor()` | Returns `false`. | | `IsBattery` | `public virtual bool IsBattery()` | Returns `false`. | | `IsTSRAIR` | `public virtual bool IsTSRAIR()` | Returns `false`. | | `IsSlice6Air` | `public virtual bool IsSlice6Air()` | Returns `false`. | | `IsSlice6AirTc` | `public virtual bool IsSlice6AirTc()` | Returns `false`. | ### Arm Status Methods | Method | Signature | Description | |--------|-----------|-------------| | `GetIsInArm` | `public bool GetIsInArm()` | Returns `DASArmStatus.IsArmed` or `false` if null. | | `GetIsInRealtime` | `public bool GetIsInRealtime()` | Returns `DASArmStatus.IsInRealtime` or `false` if null. | | `GetIsStreaming` | `public virtual bool GetIsStreaming()` | Returns `false`; overrideable for streaming-capable hardware. | | `SetInArm` | `public void SetInArm(bool WriteToDb)` | Sets `IsArmed = true` in arm status. | | `SetInRealtime` | `public void SetInRealtime(bool WriteToDb, bool ExitRealtimeIfPossible)` | Sets realtime mode; queries arm status first and may exit realtime mode. | | `SetDASArmStatus` | `public void SetDASArmStatus(IArmStatusData status, bool bSetInDb)` | Sets arm status with optional DB persistence. | | `SetDASArmStatus` | `public void SetDASArmStatus()` | Persists current `DASArmStatus` to DB; queries `MaxEventsPossible` for TSR AIR devices. | ### Nested Classes | Class | Purpose | |-------|---------| | `SliceServiceAsyncInfo` | Base async info container with `callback`, `userData`, `functionData`, `PreOrPost`, `MaxTimeout`. Methods: `Error()`, `Progress()`, `NewData()`, `Success()`, `Cancel()`. | | `SliceServiceQueryConfigAsyncInfo` | Extends `SliceServiceAsyncInfo` with `CRC`, `ConfigString`, `ReadIds`, `DeviceScaleFactors`, `DifferentModuleCountsAreOK`. | | `SliceServiceQueryTestSetupAsyncInfo` | Extends `SliceServiceAsyncInfo` with `TestSetupGuid`. | | `SliceServiceSetTestSetupAsyncInfo` | Extends `SliceServiceAsyncInfo` with `TestSetupXML`. | | `AutoDetectServiceAsyncInfo` | Extends `SliceServiceAsyncInfo` with `QueryConfiguration` flag. | | `GainCodesSLICE6IEPE` | Enum with 16 gain codes (G1-G16) with attributes for input ranges. | ### Hardware Subclasses | Class | Connection Type | Hardware Type | |-------|-----------------|---------------| | `WinUSBSlice` | WINUSB | SLICE_Base | | `CDCUSBSlice` | WINUSB | SLICE2 | | `WinUSBSlice1_5` | WINUSB | SLICE1_5 | | `WinUSBSlice6` | WINUSB | SLICE6 | | `WinUSBSlice6Air` | WINUSB | SLICE6_AIR | | `WinUSBSlice6AirBridge` | WINUSB | SLICE6_AIR_BR | | `WinUSBTsrAir` | WINUSB | DIR/DKR (based on hardware revision) | | `WinUSBSlice6AirThermocoupler` | WINUSB | SLICE6_AIR_TC | | `EthernetSlice` | Ethernet | SLICE_Base | | `EthernetSlice2` | Ethernet | SLICE2 | | `EthernetSlice6` | Ethernet | SLICE6_Base | | `EthernetSlice6Air` | Ethernet | S6A_EthernetRecorder or SLICE6_AIR | | `EthernetSlice6AirBridge` | Ethernet | SLICE6_AIR_BR | | `EthernetSlice6DB` | Ethernet | SLICE6DB or SLICE6DB_InDummy | | `EthernetPowerPro` | Ethernet | PowerPro | | `EthernetTsrAir` | Ethernet | TSR_AIR or TSR_AIR_RevB | | `EthernetSlice6DB3` | Ethernet | SLICE6DB3 | | `EthernetSlicePRODB` | Ethernet | SLICE_Pro_Distributor | | `EthernetSlice1_5` | Ethernet | SLICE1_5 | | `EthernetSliceDB` | Ethernet | SliceDB | | `EthernetSlice6AirThermocoupler` | Ethernet | SLICE6_AIR_TC | --- ## 3. Invariants 1. **Connection Requirement**: `LaunchAsyncWorker` requires `Connected == true`; otherwise throws `NotConnectedException`. 2. **Type Constraint**: Generic type `T` must implement `IConnection` and have a parameterless constructor (`new()`). 3. **Async Info Type Safety**: Methods like `AsyncPreStartTriggerCheck`, `AsyncStartTriggerCheck`, `AsyncDoTriggerCheck`, `AsyncDoStartCheck`, and `AsyncCancelTriggerCheck` perform type checking with `is SliceServiceAsyncInfo` and return early if type mismatch. 4. **Command Support Checks**: Hardware-specific commands (e.g., `InitHardwareInputLines`, `RemoveLeapSeconds`, `ADCSamplesPerPacket`, `ExtendedFaultIds`) are only executed if `IsCommandSupported` returns `true`. 5. **Equality Based on SerialNumber**: Two `Slice` instances are equal if and only if their `SerialNumber` properties are equal (case-sensitive). 6. **Arm Status Null Safety**: Methods like `GetIsInArm()` and `GetIsInRealtime()` return `false` if `DASArmStatus` is null rather than throwing. 7. **MaxEventsPossible Query**: For TSR AIR devices, `MaxEventsPossible` is set to 0 before querying to trigger calculation per firmware requirements. --- ## 4. Dependencies ### Direct Dependencies (Imports) | Namespace | Purpose | |-----------|---------| | `DTS.DASLib.Command.SLICE` | SLICE command classes (`InitializeHardwareLines`, `SetSystemAttribute`, `QueryArmAttribute`, `QueryEventAttribute`, `QuerySystemAttribute`, `SetSystemAttributeSLICE6AIR`, `QueryArmAndTriggerStatus`, `EndRealtimeMode`) | | `DTS.Common.ICommunication` | Communication interfaces (`ServiceCallback`, `ServiceCallbackData`) | | `DTS.Common.Utilities.Logging` | Logging via `APILogger` | | `DTS.Common.Interface.Connection` | Connection interfaces (`IConnection`, `EthernetConnection`, `WINUSBConnection`) | | `DTS.Common.Classes.Connection` | Connection implementations | | `DTS.Common.Enums.DASFactory` | Enums (`DFConstantsAndEnums`, `ProtocolLimitedCommands`, `AttributeTypes`, `QATSExtendedFault`) | | `DTS.Common.Interface.DASFactory` | DAS factory interfaces (`IDASCommunication`, `IConfigurationActions`, `IDiagnosticsActions`, `ITriggerCheckActions`, `IRealTimeActions`, `IArmActions`, `IDownloadActions`) | | `DTS.Common.Enums` | General enums (`ExcitationStatus`, `InputClockSource`, `ClockSyncProfile`) | | `DTS.Common.Enums.Sensors` | Sensor enums (`NonLinearStyles`) | | `DTS.Common.Enums.Hardware` | Hardware enums (`HardwareTypes`) | | `DTS.Common.Events` | Event classes (`PageErrorEvent`) | | `DTS.Common.DASResource` | DAS resource classes (`AnalogInputDASChannel`) | | `DTS.Common.Interface.DASFactory.Diagnostics` | Diagnostic interfaces | | `DTS.Common.Interface.DASFactory.ARM` | ARM interfaces (`IArmStatusData`, `IArmCheckActions`, `IArmCheckResults`, `IOptimizationValues`) | | `DTS.Common.Interface.DASFactory.Download` | Download interfaces (`IDownloadRequest`, `IDownloadReport`) | | `DTS.Common.Interface.DASFactory.Config` | Configuration interfaces (`IConfigurationData`) | | `DTS.DASLib.Service.Classes.Diagnostics` | Diagnostic implementation classes | | `DTS.DASLib.Command.SLICE.RealtimeCommands` | Real-time command classes | ### Depended On By *Not determinable from source alone* - The module exposes interfaces that other components would consume, but no direct consumers are shown in these files. --- ## 5. Gotchas 1. **Silent Failures in AsyncPreStartTriggerCheck**: The `AsyncPreStartTriggerCheck` method catches all exceptions and only logs them via `APILogger.Log`, then calls `info.Success()`. This means polarity configuration failures are not surfaced to the caller. 2. **Null Callback Handling**: `DoTriggerCheck` accepts a null `callback` parameter and creates `SliceServiceAsyncInfo` as null in that case. The `AsyncDoTriggerCheck` method uses null-conditional operators (`info?.Success()`) to handle this. 3. **Hardware Revision Query Side Effect**: `WinUSBTsrAir.GetHardwareType()` and `EthernetTsrAir.GetHardwareType()` call `QueryHardwareRevision()` if `_hardwareRevision` equals `UNKNOWN_REVISION`, which may cause I/O during what appears to be a simple property getter. 4. **KeepAliveReset Requirement**: Several Ethernet subclasses (`EthernetSlice6`, `EthernetSlice6Air`, `EthernetSlice6AirBridge`, `EthernetTsrAir`, `EthernetSlice6AirThermocoupler`) set `RequiresKeepAliveReset = true` on the transport, indicating these devices require special connection handling. 5. **TSR AIR Protocol Removal**: `WinUSBTsrAir` constructor removes `PTPSyncStatus` and `PTPTimestamp` from `TSRAIR_MinimumProtocols`, indicating USB-connected TSR AIR devices do not support network time sync. 6. **Multiple Sample Realtime Flag**: Different subclasses set `_bSupportsMultipleSampleRealtime` differently (WinUSBSlice/EthernetSlice = true, most others = false), affecting real-time data handling behavior. 7. **SetInRealtime Queries Hardware**: `SetInRealtime` executes `QueryArmAndTriggerStatus` synchronously before setting status, which may have performance implications. 8. **MaxEventsPossible Calculation Requirement**: For TSR AIR devices, the firmware requires setting `MaxEventsPossible` to 0 before querying to trigger internal calculation (per comment referencing case 26817).