From fec9e3eb9be91493ae98efa7cc85522a5bdc97cf Mon Sep 17 00:00:00 2001 From: trns1997 Date: Mon, 27 Apr 2026 09:52:29 +0200 Subject: [PATCH] add couple enhancement from lokiledev --- clients/cpp/Teleplot.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/clients/cpp/Teleplot.h b/clients/cpp/Teleplot.h index e682a3b..69c590a 100644 --- a/clients/cpp/Teleplot.h +++ b/clients/cpp/Teleplot.h @@ -201,6 +201,7 @@ class Teleplot { Teleplot(std::string address, unsigned int port=47269, unsigned int bufferingFrequencyHz = 30) : sockfd_(-1) , address_(std::move(address)) + , udpPort_(port) , bufferingFrequencyHz_(bufferingFrequencyHz) { #ifdef TELEPLOT_DISABLE @@ -222,10 +223,12 @@ class Teleplot { #endif if (sockfd_ >= 0) { (void)::close(sockfd_); sockfd_ = -1; } } - // Static localhost instance static Teleplot &localhost() {static Teleplot teleplot("127.0.0.1"); return teleplot;} - + + std::string const& destinationHost() const { return address_; } + unsigned int destinationPort() const { return udpPort_; } + template void update(std::string const& key, T const& value, std::string unit = "", unsigned int maxFrequencyHz = 0, std::string flags = TELEPLOT_FLAG_DEFAULT) { #ifdef TELEPLOT_DISABLE @@ -236,6 +239,14 @@ class Teleplot { updateData(key, nowMs, value, 0, flags, maxFrequencyHz, unit); } + template + void updateAt(std::string const& key, double timestamp_ms, T const& value, std::string unit = "", unsigned int maxFrequencyHz = 0, std::string flags = TELEPLOT_FLAG_DEFAULT) { + #ifdef TELEPLOT_DISABLE + return ; + #endif + updateData(key, timestamp_ms, value, 0, flags, maxFrequencyHz, unit); + } + template void update2D(std::string const& key, T1 const& valueX, T2 const& valueY, unsigned int maxFrequencyHz = 0, std::string flags = TELEPLOT_FLAG_2D) { #ifdef TELEPLOT_DISABLE @@ -385,6 +396,7 @@ class Teleplot { int sockfd_; std::string address_; + unsigned int udpPort_; sockaddr_in serv_; unsigned int bufferingFrequencyHz_; };