mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-09 18:02:04 +02:00
Refactoring the WritingManager
This commit is contained in:
+22
-11
@@ -8,7 +8,7 @@
|
||||
#include <boost/any.hpp>
|
||||
#include <chrono>
|
||||
#include "date.h"
|
||||
|
||||
#include <deque>
|
||||
#include "H5Format.hpp"
|
||||
|
||||
namespace writer_utils {
|
||||
@@ -16,38 +16,49 @@ namespace writer_utils {
|
||||
void create_destination_folder(const std::string& output_file);
|
||||
}
|
||||
|
||||
struct WriterManagerLog
|
||||
{
|
||||
std::string filename;
|
||||
|
||||
uint64_t n_requested_frames;
|
||||
uint64_t n_received_frames;
|
||||
uint64_t n_written_frames;
|
||||
};
|
||||
|
||||
|
||||
class WriterManager
|
||||
{
|
||||
|
||||
std::unordered_map<std::string, boost::any> parameters = {};
|
||||
|
||||
// Initialize in constructor.
|
||||
const std::unordered_map<std::string, DATA_TYPE>& parameters_type;
|
||||
std::atomic_bool running_flag;
|
||||
std::atomic_bool killed_flag;
|
||||
const std::deque<WriterManagerLog> logs;
|
||||
|
||||
std::atomic<bool> receiving_flag;
|
||||
std::atomic<bool> writing_flag;
|
||||
std::atomic<bool> killed_flag;
|
||||
|
||||
std::atomic<uint64_t> n_received_frames;
|
||||
std::atomic<uint64_t> n_written_frames;
|
||||
std::atomic<uint64_t> n_lost_frames;
|
||||
std::atomic<int64_t> n_expected_frames;
|
||||
|
||||
public:
|
||||
WriterManager(const std::unordered_map<std::string, DATA_TYPE>& parameters_type);
|
||||
virtual ~WriterManager();
|
||||
|
||||
void start(const std::unordered_map<std::string, boost:any>& parameters);
|
||||
const std::unordered_map<std::string, DATA_TYPE>& get_parameters_type() const;
|
||||
void start(const std::unordered_map<std::string, boost::any>& new_parameters);
|
||||
void stop();
|
||||
void kill();
|
||||
std::string get_status();
|
||||
std::unordered_map<std::string, uint64_t> get_statistics() const;
|
||||
|
||||
std::unordered_map<std::string, boost::any> get_parameters();
|
||||
const std::unordered_map<std::string, DATA_TYPE>& get_parameters_type() const;
|
||||
|
||||
bool is_running();
|
||||
bool is_killed() const;
|
||||
bool are_all_parameters_set();
|
||||
std::string get_output_file() const;
|
||||
|
||||
std::unordered_map<std::string, boost::any> get_parameters();
|
||||
|
||||
|
||||
void received_frame(size_t frame_index);
|
||||
void written_frame(size_t frame_index);
|
||||
void lost_frame(size_t frame_index);
|
||||
|
||||
Reference in New Issue
Block a user