44#ifndef TELEPLOT_H
55#define TELEPLOT_H
66
7- #include < iostream>
8- #include < iomanip>
97#include < arpa/inet.h>
108#include < cerrno>
9+ #include < chrono>
10+ #include < cstdint>
1111#include < fcntl.h>
12- #include < unistd.h>
12+ #include < iomanip>
13+ #include < map>
14+ #include < sstream>
15+ #include < string>
1316#include < sys/socket.h>
1417#include < sys/types.h>
15- #include < stdio.h>
16- #include < string.h>
17- #include < stdlib.h>
18- #include < sstream>
19- #include < map>
20- #include < chrono>
18+ #include < unistd.h>
2119
2220// Enable/Disable implementation optimisations:
2321// #define TELEPLOT_DISABLE // Would prevent teleplot from doing anything, useful for production builds
@@ -48,7 +46,7 @@ class ShapeTeleplot {
4846 std::string roundValue (const double value, const unsigned short precision) const
4947 {
5048 std::string value_str = std::to_string (value);
51- int res_length = value_str.length ();
49+ int res_length = static_cast < int >( value_str.length () );
5250
5351 int i = 0 ;
5452 bool stop = false ;
@@ -58,7 +56,7 @@ class ShapeTeleplot {
5856 if (value_str[i] == ' .' )
5957 {
6058 int u = i + precision;
61- if (u+1 < value_str.length ())
59+ if (u+1 < static_cast < int >( value_str.length () ))
6260 {
6361 while (value_str[u] == ' 0' ) u--;
6462
@@ -202,7 +200,7 @@ class Teleplot {
202200public:
203201 Teleplot (std::string address, unsigned int port=47269 , unsigned int bufferingFrequencyHz = 30 )
204202 : sockfd_(-1 )
205- , address_(address)
203+ , address_(std::move( address) )
206204 , bufferingFrequencyHz_(bufferingFrequencyHz)
207205 {
208206 #ifdef TELEPLOT_DISABLE
@@ -211,7 +209,7 @@ class Teleplot {
211209 // Create UDP socket
212210 sockfd_ = socket (AF_INET , SOCK_DGRAM , 0 );
213211 serv_.sin_family = AF_INET ;
214- serv_.sin_port = htons (port);
212+ serv_.sin_port = htons (static_cast <std:: uint16_t >( port) );
215213 serv_.sin_addr .s_addr = inet_addr (address_.c_str ());
216214 if (sockfd_ >= 0 ) {
217215 int fl = fcntl (sockfd_, F_GETFL , 0 );
@@ -234,7 +232,7 @@ class Teleplot {
234232 return ;
235233 #endif
236234 int64_t nowUs = std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::system_clock::now ()).time_since_epoch ().count ();
237- double nowMs = static_cast <double >(nowUs)/1000 .d ;
235+ double nowMs = static_cast <double >(nowUs)/1000.0 ;
238236 updateData (key, nowMs, value, 0 , flags, maxFrequencyHz, unit);
239237 }
240238
@@ -244,7 +242,7 @@ class Teleplot {
244242 return ;
245243 #endif
246244 int64_t nowUs = std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::system_clock::now ()).time_since_epoch ().count ();
247- double nowMs = static_cast <double >(nowUs)/1000 .d ;
245+ double nowMs = static_cast <double >(nowUs)/1000.0 ;
248246 updateData (key, valueX, valueY, nowMs, flags, maxFrequencyHz);
249247 }
250248
@@ -254,7 +252,7 @@ class Teleplot {
254252 #endif
255253 int64_t nowUs = std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::system_clock::now ()).time_since_epoch ().count ();
256254 double nowMs = static_cast <double >(nowUs)/1000.0 ;
257- updateData (mshape.getName (), nowMs, NULL , NULL , flags, maxFrequencyHz, " " , mshape);
255+ updateData (mshape.getName (), nowMs, nullptr , nullptr , flags, maxFrequencyHz, " " , mshape);
258256 }
259257
260258 void log (std::string const & log){
@@ -276,6 +274,8 @@ class Teleplot {
276274 }
277275 return false ;
278276#else
277+ (void )key;
278+ (void )frequency;
279279 return true ;
280280#endif
281281 }
@@ -297,6 +297,8 @@ class Teleplot {
297297 #ifdef TELEPLOT_USE_FREQUENCY
298298 if (not shouldUpdateData (key ,maxFrequencyHz)) return ; // may be used to reduce the update frequency by ignoring some values
299299 saveUpdateDataTime (key);
300+ #else
301+ (void )maxFrequencyHz;
300302 #endif
301303
302304 // Format
0 commit comments