Fixed-Rate Source
- class gpype.backend.sources.base.fixed_rate_source.FixedRateSource[source]
Bases:
SourceFixed-rate source for continuous data generation at sampling rate.
Generates data at fixed sampling rate using background thread with precise timing control and drift compensation.
The pacing thread runs one cycle per sample, not per frame. A subclass whose
step()returnsframe_sizesamples per call must therefore setdecimation_factor=frame_size, so thatstep()runs on everyframe_size-th cycle and the stream leaves at its declared rate. A subclass that omits this emitsframe_sizetimes too much data, and nothing reports it: the frames are individually well-formed, the declared sampling rate is unchanged, and only wall-clock measurement reveals it. Measured on a reader before this was applied: 1.01x at frame_size 1, 5.02x at 5, 24.98x at 25, 50.03x at 50.Every subclass here does this –
Generator,CsvReaderandRecordingReader– and a fourth must too. Two exemptions, both real:Batch mode. A batch reader starts no pacing thread; the driver calls
cycle()once for the whole recording. A decimation factor there would make that single cycle emit nothing.Externally driven sources. An amplifier is clocked by its own device callback rather than by this thread, so it emits one frame per callback and needs a factor of one. Those extend
Sourcedirectly.
- class Configuration[source]
Bases:
ConfigurationConfiguration class for FixedRateSource parameters.
- class Keys[source]
Bases:
KeysConfiguration keys for fixed-rate source settings.
- SAMPLING_RATE = 'sampling_rate'
Configuration key for sampling rate in Hz
- __init__(sampling_rate, **kwargs)[source]
Initialize configuration with sampling rate validation.
- Parameters:
sampling_rate (
float) – Sampling rate in Hz. Must be positive.**kwargs – Additional configuration parameters.
- Raises:
ValueError – If sampling_rate is not positive.
- __init__(sampling_rate, output_ports=None, **kwargs)[source]
Initialize fixed-rate source with sampling configuration.
- Parameters:
sampling_rate (
float) – Sampling rate in Hz for data generation.output_ports (
Optional[list[Configuration]]) – List of output port configurations. Defaults to default port configuration if None.**kwargs – Additional arguments for parent Source class.
- start()[source]
Start fixed-rate source and begin data generation.
Initializes parent source and starts background thread for continuous data generation at specified sampling rate.
- stop()[source]
Stop fixed-rate source and terminate data generation.
Signals background thread to stop and waits for completion.
- master_candidacy()[source]
Claim as a counted stream.
Contiguous by construction and with a declared rate, so it is a valid timeline – but not a loss-aware one, since a source that reports no counter cannot say what it dropped. A numbered device therefore outranks it.
- Returns:
(rate, COUNTED), or None if no usable rate is set.