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
62 lines
1.6 KiB
Python
62 lines
1.6 KiB
Python
import logging
|
|
from pathlib import Path
|
|
from time import sleep
|
|
from uuid import UUID, uuid4
|
|
|
|
from rich.logging import RichHandler
|
|
|
|
from dynalab_core import Core
|
|
from dynalab_core.config import CoreConfig
|
|
from dynalab_core.protocols.packets.handshake import SignalDescriptor
|
|
|
|
logging.basicConfig(
|
|
level=logging.DEBUG,
|
|
format="%(name)s %(message)s",
|
|
datefmt="%H:%M:%S",
|
|
handlers=[RichHandler(rich_tracebacks=True, show_path=False)],
|
|
force=True,
|
|
)
|
|
log = logging.getLogger(__name__)
|
|
|
|
processing_str = Path(
|
|
"/home/hector/projects/Exergie/dynalab-core/test/manual/process.py"
|
|
).read_text(encoding="utf-8")
|
|
|
|
signal_id_1: UUID = UUID("3f32cea3-d872-4c16-a0a2-54b57171aeb2")
|
|
signal_id_2: UUID = UUID("6578ac37-99d1-410c-b3f7-d049339919b2")
|
|
config = CoreConfig(port=8765)
|
|
log.info("Configured manual core on %s", config.bind_str())
|
|
dl_core = Core(config)
|
|
dl_core.start()
|
|
|
|
|
|
unit_id = dl_core.bind_derive_unit(
|
|
processing_str,
|
|
[
|
|
SignalDescriptor(
|
|
id=signal_id_1, name="Dummy signal 1", type="number", timeout_ms=5000
|
|
),
|
|
SignalDescriptor(
|
|
id=signal_id_2, name="Dummy signal 2", type="number", timeout_ms=5000
|
|
),
|
|
],
|
|
SignalDescriptor(id=uuid4(), name="Dummy sum", type="number", timeout_ms=5000),
|
|
)
|
|
|
|
# for i in range(10):
|
|
# dl_core.wait(1)
|
|
# values = dl_core.get_all_live_values()
|
|
# log.debug(f"Core values: {values}")
|
|
#
|
|
# dl_core.set_mode("playback")
|
|
|
|
|
|
try:
|
|
while True:
|
|
dl_core.wait(1)
|
|
values = dl_core.get_all_live_values()
|
|
log.debug(f"Core values: {values}")
|
|
except KeyboardInterrupt:
|
|
log.info("Received keyboard interrupt")
|
|
dl_core.stop()
|