@cw.on_synchronized is an approximate time synchronizer for edge workers that need to fuse data from multiple sensors with temporal guarantees.
Usage
Callback signature
How it works
- For each channel in the list, a separate data-layer subscription is created.
- A shared
latest_samplesbuffer (one entry per channel) is maintained under a lock. - On each incoming sample the buffer is updated, then checked: if all channels are present and
max(timestamps) - min(timestamps) <= tolerance_ms / 1000, the callback fires with a copy of the buffer. - Exceptions in the callback are logged; the runtime continues.
Cross-twin mode
For multi-camera or cross-device fusion, usetwin_channels to synchronize channels from different twins:
@cw.on_synchronized(twin_uuid, channels)) continues to work unchanged.
See Multi-Camera Detection Routing for an end-to-end example.