USRP_Server  2.0
A flexible, GPU-accelerated radio-frequency readout software.
USRP_server_link_threads.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef SYNC_CLASS_INCLUDED
3 #define SYNC_CLASS_INCLUDED
9 #include "USRP_demodulator.hpp"
11 #include "USRP_file_writer.hpp"
12 #include "USRP_server_network.hpp"
13 #include "kernels.cuh"
14 
15 class TXRX{
16 
17  public:
18 
20  rx_queue* stream_queue;
21 
24 
26  bool diagnostic;
27 
30 
33 
35  TXRX(server_settings* settings, hardware_manager* init_hardware, bool diagnostic_init = false);
36 
38  void set(usrp_param* global_param);
39 
41  void start(usrp_param* global_param);
42 
46  bool stop(bool force = false);
47 
48  private:
49 
50 
52  std::vector<int> rx_thread_n;
53 
55  std::vector<int> tx_thread_n;
56 
58  int thread_counter;
59 
62  void tx_single_link(
63  preallocator<float2>* memory, //the custom memory allocator to use in case of dynamically denerated buffer
64  TX_buffer_generator* generator, //source of the buffer
65  tx_queue* queue_tx, //holds the pointer to the queue
66  size_t total_samples, //how many sample to produce and push
67  bool dynamic, //true if the preallocation requires dynamic memory
68  int preallocated, // how many samples have been preallocate
69  char front_end
70  );
71 
72  //thread for taking a packet from the receive queue and pushing it into the analysis queue
73  void rx_single_link(
74  preallocator<float2>* input_memory,
75  preallocator<float2>* output_memory,
76  RX_buffer_demodulator* demodulator,
77  hardware_manager* rx_thread,
78  size_t max_samples,
79  rx_queue* stream_q, //pointer to the queue to transport the buffer wrapper structure from the analysis to the streaming thread
80  char front_end
81  );
82 
83  //pointer to current tx parameters.
84  param* A_current_tx_param;
85  param* A_current_rx_param;
86  param* B_current_tx_param;
87  param* B_current_rx_param;
88 
89  //status of the workers
90  std::atomic<bool> RX_status, TX_status;
91 
92  //pointer to the worker threads
93  boost::thread* A_RX_worker;
94  boost::thread* A_TX_worker;
95  boost::thread* B_RX_worker;
96  boost::thread* B_TX_worker;
97 
99  preallocator<float2>* A_rx_memory;
100 
102  preallocator<float2>* B_rx_memory;
103 
105  size_t A_rx_buffer_len;
106 
108  size_t B_rx_buffer_len;
109 
111  preallocator<float2>* A_tx_memory;
112 
114  preallocator<float2>* B_tx_memory;
115 
117  size_t A_preallocated;
118 
120  size_t B_preallocated;
121 
123  size_t A_tx_buffer_len;
124 
126  size_t B_tx_buffer_len;
127 
128  size_t output_memory_size;
129 
130  //pointer to the hardware class
131  hardware_manager* hardware;
132 
133  //pointers to demodulator and signal generators classes
134  TX_buffer_generator* A_tx_gen;
135  RX_buffer_demodulator* A_rx_dem;
136  TX_buffer_generator* B_tx_gen;
137  RX_buffer_demodulator* B_rx_dem;
138 
139  //how to know if the measure is in progress
140  threading_condition *rx_conditional_waiting;
141  threading_condition *tx_conditional_waiting;
142 
143  //internal streaming and writing classes
144  Sync_server* TCP_streamer;
145 
146  H5_file_writer* H5_writer;
147 
148  //temporary storage of memory size multiplier for analysis
149  size_t mem_mult_tmp;
150 };
151 
152 #endif
void start(usrp_param *global_param)
Start the threads.
bool tcp_streaming
Enables server tcp streaming.
This class handles the DSP of the buffer coming from the the SDR. This is the class to implement to a...
rx_queue * stream_queue
Pointer to the TCP streaming queue, initialized with the class. Output of every frontend rx dsp proce...
preallocator< float2 > * rx_output_memory
Pointer to the output memory allocator of all frontends.
bool file_writing
Enables server local file writing.
bool diagnostic
Enables diagnostic info on output.
bool stop(bool force=false)
TXRX(server_settings *settings, hardware_manager *init_hardware, bool diagnostic_init=false)
Initialization method requires an already initialized hardware manager class and an already initializ...
Manages the hardware I/O of one usrp unit.