mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-06 10:24:13 +02:00
Remove all DEBUG_OUTPUT references
It turnes out it is not as useful as in the writer project.
This commit is contained in:
@@ -20,17 +20,6 @@ BinaryWriter::BinaryWriter(
|
||||
current_output_filename_(""),
|
||||
output_file_fd_(-1)
|
||||
{
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[BinaryWriter::BinaryWriter]";
|
||||
cout << " Starting with";
|
||||
cout << " device_name " << device_name_;
|
||||
cout << " root_folder_ " << root_folder_;
|
||||
cout << " latest_filename_ " << latest_filename_;
|
||||
cout << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
BinaryWriter::~BinaryWriter()
|
||||
|
||||
@@ -19,14 +19,6 @@ LiveRecvModule::LiveRecvModule(
|
||||
ipc_prefix_(ipc_prefix),
|
||||
is_receiving_(true)
|
||||
{
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[LiveRecvModule::LiveRecvModule]";
|
||||
cout << endl;
|
||||
#endif
|
||||
|
||||
receiving_thread_ = thread(&LiveRecvModule::receive_thread, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,14 +11,6 @@ RingBuffer<T>::RingBuffer(size_t n_slots) :
|
||||
n_slots_(n_slots),
|
||||
ringbuffer_slots_(n_slots, 0)
|
||||
{
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[RingBuffer::RingBuffer]";
|
||||
cout << " Creating ring buffer";
|
||||
cout << " with n_slots " << n_slots << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -65,17 +57,6 @@ void RingBuffer<T>::initialize(const size_t requested_slot_size)
|
||||
buffer_used_slots_ = 0;
|
||||
|
||||
initialized_ = true;
|
||||
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[RingBuffer::initialize]";
|
||||
cout << " Ringbuffer initialized";
|
||||
cout << " with slot_size " << slot_size_;
|
||||
cout << " and n_slots " << n_slots_;
|
||||
cout << " and buffer_size " << buffer_size_ << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -117,17 +98,6 @@ char* RingBuffer<T>::reserve(shared_ptr<T> frame_metadata)
|
||||
|
||||
frame_metadata->buffer_slot_index = write_index_;
|
||||
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[RingBuafer::reserve]";
|
||||
cout << " Ring buffer slot ";
|
||||
cout << frame_metadata->buffer_slot_index;
|
||||
cout << " reserved for frame_index ";
|
||||
cout << frame_metadata->frame_index << endl;
|
||||
#endif
|
||||
|
||||
write_index_ = (write_index_ + 1) % n_slots_;
|
||||
buffer_used_slots_++;
|
||||
|
||||
@@ -145,15 +115,6 @@ void RingBuffer<T>::commit(shared_ptr<T> frame_metadata)
|
||||
lock_guard<mutex> lock(frame_metadata_queue_mutex_);
|
||||
|
||||
frame_metadata_queue_.push_back(frame_metadata);
|
||||
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[RingBuffer::commit]";
|
||||
cout << " Metadata for frame_index " << frame_metadata->frame_index;
|
||||
cout << " added to metadata queue." << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -195,15 +156,6 @@ pair<shared_ptr<T>, char*> RingBuffer<T>::read()
|
||||
frame_metadata_queue_.pop_front();
|
||||
}
|
||||
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[RingBuffer::read]";
|
||||
cout << " Received metadata for frame_index ";
|
||||
cout << frame_metadata->frame_index << endl;
|
||||
#endif
|
||||
|
||||
// Check if the references ring buffer slot is valid.
|
||||
{
|
||||
lock_guard<mutex> lock(ringbuffer_slots_mutex_);
|
||||
|
||||
@@ -28,15 +28,6 @@ void UdpReceiver::bind(const uint16_t port, const size_t usec_timeout)
|
||||
throw runtime_error("Cannot open socket.");
|
||||
}
|
||||
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[UdpReceiver::bind]";
|
||||
cout << " port " << port;
|
||||
cout << " usec_timeout " << usec_timeout << endl;
|
||||
#endif
|
||||
|
||||
sockaddr_in server_address = {0};
|
||||
server_address.sin_family = AF_INET;
|
||||
server_address.sin_addr.s_addr = INADDR_ANY;
|
||||
@@ -78,14 +69,6 @@ bool UdpReceiver::receive(void* buffer, size_t buffer_n_bytes)
|
||||
}
|
||||
|
||||
if (data_len != buffer_n_bytes) {
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[UdpReceiver::receive]";
|
||||
cout << " Expected buffer_n_bytes " << buffer_n_bytes;
|
||||
cout << " but got data_len " << data_len << endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,15 +11,6 @@ UdpRecvModule::UdpRecvModule(
|
||||
queue_(queue),
|
||||
is_receiving_(true)
|
||||
{
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[UdpRecvModule::UdpRecvModule]";
|
||||
cout << " Starting with ";
|
||||
cout << "udp_port " << udp_port << endl;
|
||||
#endif
|
||||
|
||||
receiving_thread_ = thread(
|
||||
&UdpRecvModule::receive_thread, this,
|
||||
udp_port);
|
||||
|
||||
@@ -9,14 +9,6 @@ using namespace std;
|
||||
void WriterUtils::set_process_effective_id(int user_id)
|
||||
{
|
||||
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[WriterUtils::set_process_effective_id]";
|
||||
cout << " Setting process user to " << user_id << endl;
|
||||
#endif
|
||||
|
||||
// TODO: use setfsuid and setfsgid
|
||||
|
||||
if (setegid(user_id)) {
|
||||
@@ -51,14 +43,6 @@ void WriterUtils::create_destination_folder(const string& output_file)
|
||||
if (file_separator_index != string::npos) {
|
||||
string output_folder(output_file.substr(0, file_separator_index));
|
||||
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[WriterUtils::create_destination_folder]";
|
||||
cout << " Creating folder " << output_folder << endl;
|
||||
#endif
|
||||
|
||||
string create_folder_command("mkdir -p " + output_folder);
|
||||
system(create_folder_command.c_str());
|
||||
}
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "MetadataBuffer.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
TEST(MetadataBuffer, basic_operations)
|
||||
{
|
||||
int n_frames = 10;
|
||||
int n_modules = 3;
|
||||
|
||||
unordered_map<string, HeaderDataType> header_values {
|
||||
{"frame", HeaderDataType("uint64")},
|
||||
{"module_number", HeaderDataType("uint64", n_modules)}
|
||||
};
|
||||
|
||||
MetadataBuffer metadata_buffer(
|
||||
static_cast<const uint64_t>(n_frames),
|
||||
header_values);
|
||||
|
||||
uint64_t base_frame_data = 12345678;
|
||||
uint64_t base_module_number = 0;
|
||||
|
||||
for (int i = 0; i<n_frames; i++) {
|
||||
uint64_t frame_index = base_frame_data + i;
|
||||
metadata_buffer.add_metadata_to_buffer("frame", i, (char*)&frame_index);
|
||||
|
||||
uint64_t module_number = base_module_number + i;
|
||||
uint64_t module_number_data[n_modules];
|
||||
|
||||
for (int module_index=0; module_index<n_modules; module_index++) {
|
||||
module_number_data[module_index] = module_number;
|
||||
}
|
||||
|
||||
metadata_buffer.add_metadata_to_buffer("module_number", i, (char*)&module_number_data);
|
||||
}
|
||||
|
||||
uint64_t* frame_data = (uint64_t*) metadata_buffer.get_metadata_values("frame").get();
|
||||
uint64_t* module_number_data = (uint64_t*) metadata_buffer.get_metadata_values("module_number").get();
|
||||
|
||||
for (int i = 0; i<n_frames; i++) {
|
||||
EXPECT_EQ(frame_data[i], base_frame_data+i);
|
||||
|
||||
for (int module_index=0; module_index<n_modules; module_index++) {
|
||||
EXPECT_EQ(module_number_data[n_modules*i + module_index], base_module_number + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(MetadataBuffer, missing_keys)
|
||||
{
|
||||
int n_frames = 10;
|
||||
int n_modules = 3;
|
||||
|
||||
unordered_map<string, HeaderDataType> header_values = {
|
||||
{"frame", HeaderDataType("uint64")},
|
||||
{"module_number", HeaderDataType("uint64", n_modules)}
|
||||
};
|
||||
|
||||
MetadataBuffer metadata_buffer(n_frames, header_values);
|
||||
|
||||
uint64_t data = 0;
|
||||
|
||||
metadata_buffer.add_metadata_to_buffer("frame", 0, (char*)&data);
|
||||
metadata_buffer.get_metadata_values("frame");
|
||||
|
||||
EXPECT_THROW(
|
||||
metadata_buffer.get_metadata_values("non_existant"),
|
||||
runtime_error);
|
||||
EXPECT_THROW(
|
||||
metadata_buffer.add_metadata_to_buffer("non_existant", 0, nullptr),
|
||||
runtime_error);
|
||||
EXPECT_THROW(
|
||||
metadata_buffer.add_metadata_to_buffer("frame", n_frames, nullptr),
|
||||
runtime_error);
|
||||
}
|
||||
@@ -36,16 +36,6 @@ void sf_live (
|
||||
MODULE_N_BYTES,
|
||||
0);
|
||||
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[sf_live::sf_live]";
|
||||
cout << " Sent pulse_id ";
|
||||
cout << current_pulse_id << endl;
|
||||
#endif
|
||||
|
||||
current_pulse_id++;
|
||||
}
|
||||
|
||||
@@ -74,21 +64,6 @@ int main (int argc, char *argv[]) {
|
||||
ipc_stream << BUFFER_LIVE_IPC_URL << (int)source_id;
|
||||
const auto ipc_address = ipc_stream.str();
|
||||
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[sf_live::main]";
|
||||
|
||||
cout << " device " << device;
|
||||
cout << " channel_name " << channel_name;
|
||||
cout << " source_id " << source_id;
|
||||
cout << " start_pulse_id " << start_pulse_id;
|
||||
cout << " ipc_address " << ipc_address;
|
||||
cout << endl;
|
||||
#endif
|
||||
|
||||
auto ctx = zmq_ctx_new();
|
||||
auto socket = zmq_socket(ctx, ZMQ_PUSH);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user