9.0 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T04:01:39.522280+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 13ae579216023a96 |
Realtime
Documentation: Realtime Parameters and Status Module
1. Purpose
This module encapsulates the configuration (RealtimeParameters) and runtime state management (RealtimeStatusInformation) for initiating and controlling realtime data acquisition in the DAS (Distributed Acoustic Sensing) system. It serves as the interface between the state machine and the underlying RealtimeService, handling parameter propagation, sample rate/AAF (Anti-Alias Filter) configuration, and synchronization primitives for starting/stopping realtime acquisition across multiple DAS units. It enables both single-sample and multi-sample polling modes, with configurable delays, channel selection, and hardware-specific AAF computation.
2. Public Interface
RealtimeParameters (class)
-
List<IDASCommunication> UnitsToStartRealtime { get; set; }
List of DAS units to be started in realtime mode. -
int RealtimeDelayBetweenPollsInMilliSecond { get; set; }
Delay (in ms) between successive polling attempts during realtime acquisition. -
bool AllowMultipleSampleRealtime { get; set; }
Flag indicating whether multiple samples per poll are allowed. -
bool UseSingleSampleMode { get; set; }
Flag to enable single-sample mode (overrides multi-sample behavior). -
List<int> ModuleIndices { get; set; }
List of module indices to be used in realtime acquisition. -
Dictionary<IDASCommunication, byte[]> IdasToActiveChannels { get; set; }
Mapping from DAS unit to its active channel bitmask (each byte represents 8 channels). -
double RealtimeSampleRate { get; set; }
Target sample rate (Hz) for realtime acquisition. -
byte RealtimeSampleRateAAFilterRatio { get; set; }
Ratio used to compute AAF cutoff:AAF = sampleRate / RealtimeSampleRateAAFilterRatio. -
bool SliceTurnOffAAFRealtime { get; set; }
Flag to override AAF and disable it for hardware that supports it (seeDFConstantsAndEnums.SupportsTurnOffAAFRealtime). -
void Reset()
Initializes all properties to default values (empty collections, zero numerics,falsebooleans).
RealtimeStatusInformation (class)
-
bool IsInRealtime { get; }
Returnstrueif realtime acquisition is currently active (based onstopRealtimeEventstate). Uses a 2ms timeout for non-blocking check. -
void StopRealtime()
Signals termination of realtime acquisition by settingstopRealtimeEvent. -
void StartRealtime()
Overload that reads parameters fromStates.Instance.Realtime.Status.RealtimeParamsand invokes the fullStartRealtime(...)overload on a backgroundTask. -
void StartRealtime(List<IDASCommunication> ldas, List<int> moduleArrayIndicies, bool useSingleSampleMode, double realtimeSampleRate, int realtimeDelayBetweenPolls, bool allowMultipleSampleRealtime, Action<double, double> SetRealtimeSampleRateAAF, Action CompleteAction, Dictionary<IDASCommunication, byte[]> idasToActiveChannels, Callback StartRealtimeCallback)
Core method that:- Wraps
StartRealtimeCallbackin aCallbackdelegate and appends status completion/failure handlers. - Resets
stopRealtimeEventand instantiatesRealtimeService. - If
useSingleSampleModeistrue: callsRealtimeService.StartActivePolling(...). - Else: calls
RealtimeService.Start(...)with computed AAF viaGetRealtimeAAFForHardware. - Invokes
SetRealtimeSampleRateAAFwith(sampleRate, AAF)for the first DAS (orNaN, NaNif no DAS). - Waits for either
stopRealtimeEvent(external stop) ormr(service availability), then waits forrealtimeDoneFromService(service completion). - Logs exceptions, sets
CouldNotStartRealtime = true, and always invokesCompleteActioninfinally.
- Wraps
-
Action<double, double> SetRealtimeSampleRateAAF { get; set; }
Callback to notify caller of current sample rate and computed AAF (used for UI updates or validation). -
Action CompleteAction { get; set; }
Action invoked upon completion (success or failure) ofStartRealtime(...). -
bool CouldNotStartRealtime { get; set; }
Set totrueif an exception occurs duringStartRealtime(...). -
Callback StartRealtimeCallback { get; set; }
User-provided callback invoked byRealtimeServiceduring acquisition. -
private float GetRealtimeAAFForHardware(IDASCommunication idas, double samplerate)
Computes AAF cutoff based on:- If
SliceTurnOffAAFRealtimeistrueand hardware supports it → returnsCommon.Constants.SLICE2_NO_AAF_REALTIME_RATE. - Else if
RealtimeSampleRateAAFilterRatio == 0→ returnssamplerate. - Else → returns
samplerate / RealtimeSampleRateAAFilterRatio.
- If
-
void Reset()
ClearsCompleteAction, resetsrealtimeDoneFromService, setsstopRealtimeEvent, and clearsCouldNotStartRealtime.
3. Invariants
RealtimeDelayBetweenPollsInMilliSecondmust be ≥ 0 (no validation enforced in code; assumed caller responsibility).RealtimeSampleRateAAFilterRatiomust be ≥ 0 (zero implies AAF = sample rate).RealtimeSampleRatemust be > 0 whenUseSingleSampleMode == false, otherwise behavior is undefined (no explicit check).UnitsToStartRealtimeandIdasToActiveChannelsmust be consistent: everyIDASCommunicationinUnitsToStartRealtimemust have an entry inIdasToActiveChannels(no enforcement; caller responsibility).ModuleIndicesis only used whenUseSingleSampleMode == false.IsInRealtimeistrueiffstopRealtimeEventis not signaled (i.e.,WaitOne(2, false)returnsfalse).CompleteActionis always invoked inStartRealtime(...)’sfinallyblock, regardless of success/failure.realtimeDoneFromService.WaitOne()is called afterstopRealtimeEvent.Set()inStartRealtime(...), ensuring the service has fully stopped before proceeding.
4. Dependencies
Dependencies of this module:
DTS.Common.Interface.DASFactory.IDASCommunication: Interface for DAS units.DTS.Common.Enums.DASFactory.DFConstantsAndEnums: Used forSupportsTurnOffAAFRealtime.DTS.Common.Constants.SLICE2_NO_AAF_REALTIME_RATE: Hardcoded AAF value when AAF is disabled.DTS.DASLib.Service.StateMachine.States: Access to global state (States.Instance.Realtime.Status.RealtimeParams).DTS.DASLib.Service.RealtimeService: Core service for starting/stopping acquisition.DTS.Common.Interface.StatusAndProgressBar.Callback&CallbackData: For async completion callbacks.DTS.Common.Utilities.Logging.APILogger: For exception logging.System.Threading:ManualResetEvent,Task,Thread.
Dependencies on this module:
RealtimeStatusInformation.StartRealtime()is invoked by the state machine (likely viaStates.Instance.Realtime.Status.RealtimeStatus.StartRealtime()).RealtimeParametersis used asRealtimeStatus.RealtimeParams(inferred from usage inRealtimeStatusInformation).SetRealtimeSampleRateAAFcallback is likely implemented by UI or monitoring components to update sample rate/AAF displays.
5. Gotchas
RealtimeDelayBetweenPollsInMilliSecondis passed asintbut may be interpreted asmsbyRealtimeService— ensure caller uses integer milliseconds (no fractional values).GetRealtimeAAFForHardwareuses only the first DAS (ldas[0]) to compute AAF when settingSetRealtimeSampleRateAAF, even if multiple DAS units are present. This assumes identical AAF behavior across units (not validated).UseSingleSampleModebypasses AAF computation and callsStartActivePolling, which may have different behavior thanStart(e.g., no AAF, no module indices).RealtimeService.ServiceAvailableevent is subscribed insideStartRealtime(...), but the wait loop (mr.WaitOne) may exit prematurely ifmris set beforestopRealtimeEventis signaled, potentially leading to race conditions ifRealtimeServicebecomes available slowly.stopRealtimeEventis set twice — once inStopRealtime()and again inStartRealtime(...)’sfinallyblock. While idempotent forManualResetEvent, this could confuse debugging.- No validation of
IdasToActiveChannelsentries — e.g., mismatched channel counts or invalid bitmasks are not caught. CouldNotStartRealtimeis set on any exception, but thecatchblock does not rethrow or provide structured error info — callers must inspect this flag afterStartRealtime.Reset()does not clearSetRealtimeSampleRateAAF,CompleteAction, orStartRealtimeCallback— onlyCompleteActionis cleared inReset(). Other properties retain their values unless explicitly overwritten.
None identified beyond these.