USRP_Server  2.0
A flexible, GPU-accelerated radio-frequency readout software.
USRP_file_writer.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef FILE_WRITER_INCLUDED
3 #define FILE_WRITER_INCLUDED
8 #include <ctime>
9 #include "H5Cpp.h"
10 #include "H5CompType.h"
11 
12 using namespace H5;
14  public:
15 
16  rx_queue* stream_queue;
17 
18  //the initialization needs a rx queue to get packets and a memory to dispose of them
19  //NOTE: the file writer should always be the last element of the chain unless using a very fast storage support
20  H5_file_writer(rx_queue* init_queue, preallocator<float2>* init_memory);
21 
22  H5_file_writer(Sync_server *streaming_server);
23 
24  void start(usrp_param* global_params);
25 
26  bool stop(bool force = false);
27 
28  void close();
29 
30  //in case of pointers update in the TXRX class method set() those functions have to be called
31  //this is because memory size adjustments on rx_output preallocator
32  void update_pointers(rx_queue* init_queue, preallocator<float2>* init_memory);
33 
34  void update_pointers(Sync_server *streaming_server);
35 
36  private:
37 
38  //datatype used by HDF5 api
39  CompType *complex_data_type;//(sizeof(float2));
40 
41  //pointer to the h5 file
42  H5File *file;
43 
44  //pointer to the raw_data group (single USRP writer)
45  Group *group;
46 
47  //pointers to possible groups for representing USRP X300 data
48  Group *A_TXRX;
49  Group *B_TXRX;
50  Group *A_RX2;
51  Group *B_RX2;
52 
53  //dataspace for H5 file writing
54  DataSpace *dataspace;
55 
56  //rank of the raw_data's datasets and dimensions
57  int dspace_rank;
58  hsize_t *dimsf;
59 
60  //pointer to the memory recycler
61  preallocator<float2>* memory;
62 
63  //pointer to the thread
64  boost::thread* binary_writer;
65 
66  std::atomic<bool> writing_in_progress;
67 
68  void write_properties(Group *measure_group, param* parameters_group);
69 
70  std::string get_name();
71 
72  void clean_queue();
73 
74  //force the joining of the thread
75  std::atomic<bool> force_close;
76 
77  void write_files();
78 };
79 #endif
rx_queue * stream_queue
auto start