8.5 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T03:59:44.857737+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 358379cedd1a8fff |
Documentation: Slice<T> Trigger Check Module
1. Purpose
This module implements the trigger check functionality for the Slice<T> DAS (Data Acquisition System) service class, providing asynchronous and synchronous methods to prepare, execute, and cancel hardware-level trigger and start-record integrity checks. It validates hardware input line states (e.g., short circuits on trigger/start inputs) before arming the system, and supports configurable polarity inversion for trigger and start signals. The module ensures safe pre-arm conditions by querying hardware via InitializeHardwareLines and reporting status via ArmStatus, while integrating with the broader Slice<T> service infrastructure for async callbacks and state management.
2. Public Interface
The interface is implemented explicitly via ITriggerCheckActions. All methods follow an async pattern using LaunchAsyncWorker and SliceServiceAsyncInfo for callback reporting.
void ITriggerCheckActions.PreStartTriggerCheck(ServiceCallback callback, object userData)
- Behavior: Performs pre-startup configuration before trigger checks. If supported, sets
StartRecordPolarityandTriggerPolarityattributes based onInvertStartandInvertTriggerproperties usingSetSystemAttribute. Logs exceptions but does not fail the operation on error. - Async worker:
AsyncPreStartTriggerCheck
void ITriggerCheckActions.PostStartTriggerCheck(ServiceCallback callback, object userData)
- Behavior: No-op placeholder; immediately reports success. Presumably reserved for future or subclass use.
void ITriggerCheckActions.StartTriggerCheck(ServiceCallback callback, object userData)
- Behavior: Initiates the main trigger check sequence. Executes
AsyncStartTriggerCheck, which:- Runs
InitializeHardwareLines(if supported). - Checks for
TriggerInputShortedorStartRecordShortedconditions; reports specific errors if detected. - Handles
CanceledExceptionand other exceptions viainfo.Error/info.Cancel.
- Runs
- Async worker:
AsyncStartTriggerCheck
void ITriggerCheckActions.DoStartCheck(ServiceCallback callback, object userData)
- Behavior: Performs a start-record-only check. Executes
AsyncDoStartCheck, which:- Queries hardware via
InitializeHardwareLines. - Sets
ArmStatus.IsArmed = !ihl.TriggerInputShorted - Sets
ArmStatus.IsRecording = ihl.StartRecordShorted - Calls
SetDASArmStatus(status, true)to persist status.
- Queries hardware via
- Async worker:
AsyncDoStartCheck
void ITriggerCheckActions.DoTriggerCheck(ServiceCallback callback, object userData)
- Behavior: Performs a full trigger check. Executes
AsyncDoTriggerCheck, which internally callsDoTriggerCheckSync(). Reports success/failure/cancel viaSliceServiceAsyncInfo.
void ITriggerCheckActions.DoTriggerCheckSync()
- Behavior: Synchronous variant of
DoTriggerCheck. Directly queries hardware viaInitializeHardwareLines(no async wrapper), constructs anArmStatusobject with:IsTriggered = ihl.TriggerInputShortedIsArmed = !ihl.TriggerInputShortedIsTriggerShorted = ihl.TriggerInputShortedIsStartShorted = ihl.StartRecordShorted
- Calls
SetDASArmStatus(status, true)to update internal and persistent state.
void ITriggerCheckActions.CancelTriggerCheck(ServiceCallback callback, object userData)
- Behavior: Cancels any pending trigger check. Currently a no-op; reports success immediately via
AsyncCancelTriggerCheck.
Supporting Types (from Slice<T> base class)
protected virtual void AsyncPreStartTriggerCheck(object asyncInfo)
- Actual worker method for
PreStartTriggerCheck. ValidatesasyncInfoisSliceServiceAsyncInfo, configures polarity attributes if supported, logs exceptions, and callsinfo.Success().
protected virtual void AsyncStartTriggerCheck(object asyncInfo)
- Actual worker for
StartTriggerCheck. ExecutesInitializeHardwareLines, checks for shorted inputs, and reports errors ("TriggerInputShorted","StartInputShorted") or success.
private void AsyncDoTriggerCheck(object asyncInfo)
- Wraps
DoTriggerCheckSync()in async callback handling.
private void AsyncDoStartCheck(object asyncInfo)
- Wraps synchronous start-check logic in async callback handling.
private void AsyncCancelTriggerCheck(object asyncInfo)
- Wraps no-op cancellation logic.
3. Invariants
- Hardware Query Dependency: Trigger checks rely on
InitializeHardwareLinescommand support. IfIsCommandSupported(DFConstantsAndEnums.ProtocolLimitedCommands.InitHardwareInputLines)returnsfalse, the check is skipped (no error), but shorted-line detection is bypassed. - Polarity Configuration:
InvertStartandInvertTriggerare only applied ifSupportsStartInversion()andSupportsTriggerInversion()returntrue, respectively. Default implementations returntrue. - State Consistency: After
DoTriggerCheckSyncorDoStartCheck,SetDASArmStatus(status, true)is called, ensuringDASArmStatusreflects current hardware state.IsArmedis always!ihl.TriggerInputShorted. - Error Reporting: Shorted inputs (
TriggerInputShorted,StartRecordShorted) result in immediateinfo.Error()with a literal string message; no exception is thrown. - Callback Safety: All async workers wrap callback invocations in
try/catchblocks to prevent unhandled exceptions from crashing the worker thread.
4. Dependencies
Dependencies on:
DTS.DASLib.Command.SLICE.InitializeHardwareLines— for querying hardware input line states.DTS.DASLib.Command.SLICE.SetSystemAttribute— for polarity configuration.DTS.Common.Interface.DASFactory.IArmStatusDataandArmStatus— for status reporting.DTS.Common.Interface.Connection.IConnection(viaCommunication<T>) — for transport.DTS.Common.Enums.DASFactory.DFConstantsAndEnums.ProtocolLimitedCommands— to check command support.DTS.Common.Interface.DASFactory.IDASCommunication— base interface.DTS.Common.Utilities.Logging.APILogger— for error logging.SliceServiceAsyncInfo— for async callback handling.
Dependencies of:
- This module is used by higher-level arming workflows (e.g.,
IArmActions,IRealTimeActions) to ensure safe pre-arm conditions. - Subclasses (
WinUSBSlice6Air,EthernetTsrAir, etc.) inherit this behavior unless overridden.
5. Gotchas
DoTriggerCheckSyncis synchronous but used in async wrappers:DoTriggerCheckSync()performs blocking I/O; its async wrappers (AsyncDoTriggerCheck) do not offload the actual hardware query — only the callback dispatch. This may cause UI thread blocking if invoked on the UI thread.- No cancellation support in hardware checks:
AsyncStartTriggerCheckandAsyncDoStartCheckcatchCanceledException, but there is no mechanism to cancel a pendingInitializeHardwareLines.SyncExecute()call — cancellation only affects post-query callback dispatch. - Polarity inversion is hardware-dependent:
SupportsStartInversion()andSupportsTriggerInversion()are virtual and returntrueby default, but subclasses may override. If overridden tofalse, polarity settings are silently ignored. PostStartTriggerCheckis a stub: Its implementation does nothing; relying on it for post-check cleanup may be unsafe.DoStartCheckconflates armed and recording states:IsArmed = !ihl.TriggerInputShorted, butIsRecording = ihl.StartRecordShorted. This implies a device can be armed but not recording (e.g., trigger armed, start not yet pressed), which may be counterintuitive.TriggerResultis public but not populated: TheITriggerCheckResult TriggerResultproperty is declared but never set by this module — callers must interpretDASArmStatusinstead.- No timeout configuration:
SliceServiceAsyncInfohas aMaxTimeoutproperty, but it is never used or propagated to the underlyingSyncExecute()calls — all hardware commands use fixed timeouts. InvertStart/InvertTriggerdefaults tofalse: If not explicitly set, polarity remains non-inverted. No validation ensures these are set consistently with hardware wiring.
None identified beyond those above.