diff --git a/src/root/storage.cpp b/src/root/storage.cpp index 585cf25..eb255f7 100644 --- a/src/root/storage.cpp +++ b/src/root/storage.cpp @@ -281,8 +281,6 @@ void StorageManager::AddFrame(const vector& frame) { frames.push(frame); frames_count++; - constexpr size_t max_frames = 100000; - if (frames.size() >= max_frames) { throw std::runtime_error("Too many frames in queue"); } @@ -307,6 +305,10 @@ unsigned int StorageManager::GetNumberOfFramesInQueue() { return frames.size(); } +double StorageManager::GetQueueUsage() { + return GetNumberOfFramesInQueue() / (double) max_frames; +} + std::pair> Event::get_signal_id_data_pair(size_t index) const { unsigned short channel = signal_ids[index]; std::array data{}; diff --git a/src/root/storage.h b/src/root/storage.h index e56c1cc..ab522e6 100644 --- a/src/root/storage.h +++ b/src/root/storage.h @@ -114,6 +114,7 @@ class StorageManager { void AddFrame(const std::vector& frame); std::vector PopFrame(); unsigned int GetNumberOfFramesInQueue(); + double GetQueueUsage(); unsigned int GetNumberOfFramesInserted() const; private: @@ -125,6 +126,7 @@ class StorageManager { std::queue> frames; std::atomic frames_count = 0; std::mutex frames_mutex; + const size_t max_frames = 500000; // this should be about 2GB when full (depends on frame size) }; } // namespace feminos_daq_storage