Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions clients/cpp/Teleplot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<typename T>
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
Expand All @@ -236,6 +239,14 @@ class Teleplot {
updateData(key, nowMs, value, 0, flags, maxFrequencyHz, unit);
}

template<typename T>
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<typename T1, typename T2>
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
Expand Down Expand Up @@ -385,6 +396,7 @@ class Teleplot {

int sockfd_;
std::string address_;
unsigned int udpPort_;
sockaddr_in serv_;
unsigned int bufferingFrequencyHz_;
};
Expand Down