YARP
Yet Another Robot Platform
Ping.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef YARP_OS_PING_H
8#define YARP_OS_PING_H
9
10#include <yarp/os/api.h>
11
12#include <cmath>
13#include <string>
14
15
16namespace yarp::os {
17
18class Stat
19{
20public:
21 Stat();
22
23 void clear();
24
25 void add(double val);
26 void add(const Stat& alt);
27 double mean();
28 double deviation();
29 double count();
30
31 operator double();
32
33private:
34 void compute();
35
36 int ct;
37 int at;
38 double tot;
39 double tot2;
40 double mu;
41 double sigma;
42};
43
45{
46public:
47 Stat totalTime; // total includes name server lookups
48 Stat targetTime; // all time involving the target port
49
50 void clear();
51 void add(const ConnectResult& alt);
52};
53
55{
56public:
58
59 void clear();
60 void add(const RateResult& alt);
61};
62
63
69{
70public:
71 Ping(const char* target = nullptr);
72
73 bool setTarget(const char* target);
74
75 void connect();
76
77 void sample();
78
79 void clear();
80 ConnectResult getLastConnect();
81 ConnectResult getAverageConnect();
82
83 void report();
84
85 static std::string renderTime(double t, int space, int decimal);
86
87private:
88 std::string target;
89 ConnectResult lastConnect, accumConnect;
90};
91
92} // namespace yarp::os
93
94#endif // YARP_OS_PING_H
float t
void add(const ConnectResult &alt)
Definition: Ping.cpp:98
Measure performance of a YARP port.
Definition: Ping.h:69
void add(const RateResult &alt)
Definition: Ping.cpp:110
void add(double val)
Definition: Ping.cpp:41
void clear()
Definition: Ping.cpp:31
double mean()
Definition: Ping.cpp:55
double count()
Definition: Ping.cpp:67
double deviation()
Definition: Ping.cpp:61
An interface to the operating system, including Port based communication.
#define YARP_os_API
Definition: api.h:18