acquisition: drive a DataSource from the registry; --source and --source-opt
This commit is contained in:
1 parent
46076312cc
commit
504bc193ea
8 files changed
+156
-164
No files matched your search
+15
-17
@@ -8,21 +8,22 @@
|
||||
#include "model.hpp"
|
||||
#include "trigger.hpp"
|
||||
|
||||
#include <udps_client.h>
|
||||
#include "source/data_source.hpp"
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
namespace udpscope {
|
||||
|
||||
/// Owns the UDPStreamer client and the producer thread that feeds the model's
|
||||
/// Owns the data source and the producer thread that feeds the model's
|
||||
/// acquisition buffer. Everything it touches from the thread is serialised on
|
||||
/// `ScopeModel::mutex()`, so a UI-side structural change cannot race a frame.
|
||||
class Acquisition {
|
||||
class Acquisition : private SourceSink {
|
||||
public:
|
||||
Acquisition(ScopeModel& model, const Config& cfg);
|
||||
~Acquisition();
|
||||
@@ -62,22 +63,19 @@ class Acquisition {
|
||||
/// read by a packet whose engine was still disarmed, and then dropped.
|
||||
void request_force() noexcept { force_want_.store(true, std::memory_order_release); }
|
||||
|
||||
/// The source this acquisition drives, for the UI's capability panels: it may only call
|
||||
/// `post()` on it. Null until `start()`.
|
||||
DataSource* source() noexcept { return source_.get(); }
|
||||
|
||||
/// The capture, for the popover's row and the probe. Counters and errors are read
|
||||
/// cross-thread through PacketCapture's own published fields.
|
||||
const PacketCapture& capture() const noexcept { return capture_; }
|
||||
|
||||
private:
|
||||
void run();
|
||||
void on_config(const udps_signal_t* signals, std::uint32_t count, std::uint8_t publish_mode);
|
||||
void on_data(const udps_frame_t* frame);
|
||||
void on_event(int event, const char* detail);
|
||||
|
||||
static void config_trampoline(const udps_signal_t* signals, std::uint32_t count,
|
||||
std::uint8_t publish_mode, void* user);
|
||||
static void data_trampoline(const udps_frame_t* frame, void* user);
|
||||
static void event_trampoline(udps_event_t event, const char* detail, void* user);
|
||||
static void datagram_trampoline(const std::uint8_t* bytes, std::size_t len,
|
||||
double recv_time, void* user);
|
||||
void on_config(const std::vector<SignalInfo>& signals, std::uint8_t publish_mode) override;
|
||||
void on_data(const Frame& frame) override;
|
||||
void on_event(SourceEvent event, const char* detail) override;
|
||||
/// Drops the producer state that is per *connection*: the counter mark, the time
|
||||
/// anchors and the clock choice. A reconnect re-sends the CONFIG and the stream may
|
||||
/// have restarted its numbering; carrying the old session's marks across makes the
|
||||
@@ -89,9 +87,9 @@ class Acquisition {
|
||||
void on_datagram(const std::uint8_t* bytes, std::size_t len, double recv_time);
|
||||
|
||||
/// Fills `stamps_` with this frame's base-tick timestamps, in stream seconds,
|
||||
/// and returns how many were written (`frame->num_samples` unless the frame is
|
||||
/// and returns how many were written (`frame.num_samples` unless the frame is
|
||||
/// malformed).
|
||||
std::uint32_t build_stamps(const udps_frame_t* frame, int time_signal,
|
||||
std::uint32_t build_stamps(const Frame& frame, int time_signal,
|
||||
bool counter_gap_refused);
|
||||
|
||||
/// Pushes NaN for the `missing` packets' worth of samples that were never delivered,
|
||||
@@ -104,7 +102,7 @@ class Acquisition {
|
||||
/// Writes a late frame's values into the NaN-filled holes their counter addresses,
|
||||
/// amending the value ring directly (producer path) and queuing pyramid amends for
|
||||
/// `ChannelBuffer::acquire()` to apply on the consumer thread.
|
||||
void backfill_from(const udps_frame_t* frame, const Partition& part,
|
||||
void backfill_from(const Frame& frame, const Partition& part,
|
||||
const std::vector<ChannelInfo>& channels, BufferStore& store, u64 g);
|
||||
|
||||
/// Keeps the wire's own cadence up to date from the arrival times, in the modes where
|
||||
@@ -118,7 +116,7 @@ class Acquisition {
|
||||
|
||||
ScopeModel& model_;
|
||||
Config cfg_;
|
||||
udps_client* client_ = nullptr;
|
||||
std::unique_ptr<DataSource> source_;
|
||||
std::thread thread_;
|
||||
std::atomic<bool> running_{false};
|
||||
std::atomic<bool> paused_{false};
|
||||
|
||||
Reference in new issue
Block a user