USRP_Server  2.0
A flexible, GPU-accelerated radio-frequency readout software.
USRP_server_diagnostic.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef USRP_DIAG_INCLUDED
3 #define USRP_DIAG_INCLUDED
4 
6 #include <uhd/types/metadata.hpp>
7 #include <chrono>
8 
10 void set_this_thread_name(std::string thread_name);
11 
12 //print on screen error description
13 void interptet_rx_error(uhd::rx_metadata_t::error_code_t error);
14 
15 int get_rx_errors(uhd::rx_metadata_t *metadata, bool verbose = false);
16 
18 int get_tx_error(uhd::async_metadata_t *async_md, bool verbose = false);
19 
21 void print_params(usrp_param my_parameter);
22 
23 class stop_watch{
24 
25  typedef std::chrono::high_resolution_clock Time;
26  typedef std::chrono::duration<double> dsec;
27 
28  public:
29 
30  stop_watch();
31 
32  void start();
33 
34  void stop();
35 
36  void reset();
37 
38  double get();
39 
40  void store();
41 
42  double get_average();
43 
44  void cycle();
45 
46  private:
47 
48  double get_time();
49 
50  boost::chrono::high_resolution_clock::time_point start_t;
51 
52  double elapsed_time = 0;
53 
54  double total_time = 0;
55 
56  std::vector<double> acc;
57 
58  bool state = false;
59 
60 };
61 
64 void init_logger();
65 
67 typedef boost::log::sinks::synchronous_sink< boost::log::sinks::text_file_backend > file_sink;
68 
70 extern boost::shared_ptr< file_sink > pLogSink;
71 
72 #endif
void set_this_thread_name(std::string thread_name)
Set the htread name reported in the logging.
int get_rx_errors(uhd::rx_metadata_t *metadata, bool verbose=false)
void interptet_rx_error(uhd::rx_metadata_t::error_code_t error)
int get_tx_error(uhd::async_metadata_t *async_md, bool verbose=false)
Interpret tx errors from the async usrp comunication.
void init_logger()
initialize the logger for the server. Creates or access the folder logs. each time the server starts...
boost::log::sinks::synchronous_sink< boost::log::sinks::text_file_backend > file_sink
Define the pointer to the logging file backend.
void print_params(usrp_param my_parameter)
Print parameters on the terminal in a readable way.
boost::shared_ptr< file_sink > pLogSink
Shared pointer to the logfile writer object.