Revised error codes and functional PlaybackEngine
All internal and public errors have been revised (GPT 5.6 Sol) to return more detail without horrendously long error classes, this has reduced the number of error types but each now carries a reason and a code for differentiation if needed PlaybackEngine has been implemented and is functional, core mode changes what signal descriptors are returned to avoid duplicates, the playback engine currently discards the derived signals that would be recorded in the DLPak and derived signals are reprocessed live Future will require the behavior listed above to be selectable so one of two options are possible: A - Derived signals are reprocessed live by the relevant derive units (current behavior B - Derived signals are played back directly from the PlaybackEngine, this requires turning off the routing to the live derive units to avoid duplicate values This will also require the option to perform offline processing with derive units to be able to create derived signals after the fact, this will likely incur a new 'offline' mode in the core to gate things correctly, this will likely be useful for heavier processing that cannot be done live, filters that require a lookahead, or more precise derived signals using interpolated signals for higher acurracy which also brings the ability to offline process on a fixed timebase instead of following either input signal to the derived signal
This commit is contained in:
+11
-4
@@ -3,6 +3,7 @@ import logging
|
||||
import threading
|
||||
from concurrent.futures import CancelledError as FutureCancelledError
|
||||
from concurrent.futures import TimeoutError as FutureTimeoutError
|
||||
from math import sin, tau
|
||||
from statistics import mean
|
||||
from time import monotonic, monotonic_ns, perf_counter
|
||||
from uuid import UUID, uuid4
|
||||
@@ -27,6 +28,7 @@ PORT = 8765
|
||||
# Set to None to send as quickly as possible.
|
||||
# For a controlled rate, use something like 5_000.0.
|
||||
TARGET_FREQUENCY_HZ: float | None = 1000
|
||||
SINE_FREQUENCY_HZ = 0.5
|
||||
|
||||
FREQUENCY_SAMPLE_SIZE = 20000
|
||||
|
||||
@@ -88,6 +90,7 @@ def value_sender_thread(
|
||||
"""
|
||||
intervals: list[float] = []
|
||||
previous_send_time: float | None = None
|
||||
sine_start_time = perf_counter()
|
||||
|
||||
if TARGET_FREQUENCY_HZ is not None:
|
||||
period = 1.0 / TARGET_FREQUENCY_HZ
|
||||
@@ -117,16 +120,20 @@ def value_sender_thread(
|
||||
|
||||
next_send_time += period
|
||||
|
||||
sine_value = sin(
|
||||
tau * SINE_FREQUENCY_HZ * (perf_counter() - sine_start_time)
|
||||
)
|
||||
timestamp = monotonic_ns()
|
||||
message = ValueBatch(values=[])
|
||||
value1 = ValueDescriptor(
|
||||
signal_id=signal_id_1,
|
||||
value=2.0,
|
||||
timestamp=monotonic_ns(),
|
||||
value=2.0 * sine_value,
|
||||
timestamp=timestamp,
|
||||
)
|
||||
value2 = ValueDescriptor(
|
||||
signal_id=signal_id_2,
|
||||
value=1.0,
|
||||
timestamp=monotonic_ns(),
|
||||
value=sine_value,
|
||||
timestamp=timestamp,
|
||||
)
|
||||
message.values.append(value1)
|
||||
message.values.append(value2)
|
||||
|
||||
Reference in New Issue
Block a user