Continuous acquisition & playback¶
record() / record_polled() stream a continuous input task as DaqBlocks;
play() drives a continuous analog-output task from a waveform source. See
Continuous acquisition and
Waveform output for the narrative.
Recorders, playback, and policies¶
dtollib.streaming ¶
Streaming surface — the recorders, the player, and their shared types.
- :func:
record— hardware-clocked continuous block acquisition. - :func:
record_polled— software-timed scalar polling. - :func:
play— hardware-clocked continuous analog-output (waveform playback).
AcquisitionSummary
dataclass
¶
AcquisitionSummary(
started_at,
finished_at=None,
payloads_emitted=0,
payloads_dropped=0,
errors_observed=0,
overruns_observed=0,
underruns_observed=0,
extra=_empty_extra(),
)
Mutable summary of one recording session.
Updated in place by the recorder; finished_at is set on context exit.
The :class:Recording[T] handle exposes this so consumers can read
progress without poking at the recorder's internals.
overruns_observed and underruns_observed are SDK-level,
distinguishable from payloads_dropped (which counts
consumer-side losses under DROP_* overflow policies). See
docs/design.md §14.1 for the rationale.
ErrorPolicy ¶
Bases: StrEnum
How a recorder reacts to a backend error mid-stream.
Attributes:
| Name | Type | Description |
|---|---|---|
RAISE |
Cancel the recorder; the exception propagates out of the
|
|
RETURN |
Emit a payload with |
|
SKIP |
Drop the failed payload silently. Increments
|
OverflowPolicy ¶
Bases: StrEnum
How a recorder reacts when its outgoing stream buffer fills.
Attributes:
| Name | Type | Description |
|---|---|---|
BLOCK |
Backpressure — the producer awaits buffer space. Default; preserves every payload at the cost of stalling the upstream buffer pool. Slow consumers risk SDK-level OVERRUN. |
|
DROP_OLDEST |
Discard the head of the buffer to make room. Trades
payload completeness for producer liveness. Increments
|
|
DROP_NEWEST |
Discard the incoming payload. Same trade-off as
|
Recording
dataclass
¶
Active-recording handle returned by :func:record / :func:record_polled.
Attributes:
| Name | Type | Description |
|---|---|---|
stream |
MemoryObjectReceiveStream[T]
|
AnyIO receive stream of payloads. Closes when the recorder context manager exits. |
summary |
AcquisitionSummary
|
Mutable :class: |
rate_hz |
float | None
|
Configured cadence of the active recording. |
play
async
¶
Drive continuous analog output from source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
DtolSession
|
A session for an analog-output continuous task — every
channel an :class: |
required |
source
|
PlaybackSource
|
For |
required |
confirm
|
bool
|
Operator confirmation for the §18 safety gate, exactly as
:meth: |
False
|
error_policy
|
ErrorPolicy
|
How SDK errors reaching the producer loop are surfaced
( |
RAISE
|
Yields:
| Type | Description |
|---|---|
AsyncGenerator[AcquisitionSummary]
|
The mutable :class: |
Raises:
| Type | Description |
|---|---|
DtolCapabilityError
|
The subsystem's D/A is single-value only
( |
DtolTaskStateError
|
Wrong data-flow / wrap mode, or a non-AO task. |
DtolValidationError
|
Source shape mismatch, or a sample outside the device range (raised before any waveform reaches the DAC). |
DtolConfirmationRequiredError
|
Safety gate tripped without |
Source code in src/dtollib/streaming/playback.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
record
async
¶
record(
session,
*,
timeout=10.0,
stream_buffer_size=16,
error_policy=ErrorPolicy.RAISE,
overflow=OverflowPolicy.DROP_OLDEST,
)
Hardware-clocked continuous block acquisition.
Drives the §12.3.2 callback bridge. The session MUST be opened with
autostart=False — the bridge needs to register notification and
queue buffers BEFORE olDaConfig (the recorder calls
session.commit() internally after wiring the bridge).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
DtolSession
|
Session opened via |
required |
timeout
|
float
|
Reserved for shutdown timeout in a future revision. Currently informational. |
10.0
|
stream_buffer_size
|
int
|
AnyIO memory-object-stream size — the
consumer-side back-pressure window. Distinct from
|
16
|
error_policy
|
ErrorPolicy
|
How to surface SDK errors that reach the producer loop. See docs/design.md §14.3. |
RAISE
|
overflow
|
OverflowPolicy
|
How to react when the consumer stream is full. Default
|
DROP_OLDEST
|
Yields:
| Type | Description |
|---|---|
AsyncGenerator[Recording[DaqBlock]]
|
class: |
AsyncGenerator[Recording[DaqBlock]]
|
|
AsyncGenerator[Recording[DaqBlock]]
|
class: |
Raises:
| Type | Description |
|---|---|
DtolTaskStateError
|
If |
Source code in src/dtollib/streaming/block.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
record_polled
async
¶
record_polled(
source,
*,
rate_hz,
error_policy=ErrorPolicy.RAISE,
overflow=OverflowPolicy.BLOCK,
buffer_size=64,
)
Software-timed polling at rate_hz.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
DtolSession | DtolManager
|
A :class: |
required |
rate_hz
|
float
|
Target poll rate, in Hz. Must be > 0. |
required |
error_policy
|
ErrorPolicy
|
:attr: |
RAISE
|
overflow
|
OverflowPolicy
|
Consumer back-pressure policy. Default |
BLOCK
|
buffer_size
|
int
|
AnyIO send-stream capacity in payload slots. |
64
|
Yields:
| Type | Description |
|---|---|
AsyncGenerator[Recording[_PolledItem]]
|
class: |
AsyncGenerator[Recording[_PolledItem]]
|
payloads and |
Raises:
| Type | Description |
|---|---|
DtolTaskStateError
|
|
ValueError
|
|
Source code in src/dtollib/streaming/recorder.py
Block and reading payloads¶
DaqBlock, DaqReading, and DaqSample are documented under
Task specs → models. block_to_long_rows reshapes a block into
tidy per-sample rows for sinks.