Fix DEBUG build

This commit is contained in:
2019-04-26 15:55:35 +02:00
parent 32a025f0fc
commit 6225d0cf1d
4 changed files with 81 additions and 33 deletions
+57
View File
@@ -0,0 +1,57 @@
void PSIWriter::notify_first_pulse_id(uint64_t pulse_id)
{
string request_address(bsread_rest_address);
async(launch::async, [pulse_id, &request_address]{
try {
cout << "Sending first received pulse_id " << pulse_id <<;
cout << " to bsread_rest_address " << request_address << endl;
stringstream request;
request << "curl -X PUT " << request_address;
request << "/start_pulse_id/" << pulse_id;
string request_call(request.str());
#ifdef DEBUG_OUTPUT
using namespace date;
cout << "[" << chrono::system_clock::now() << "]";
cout << "[ProcessManager::notify_first_pulse_id] Sending request";
cout << "(" << request_call << ")." << endl;
#endif
system(request_call.c_str());
} catch (...){}
});
}
void PSIWriter::notify_last_pulse_id(uint64_t pulse_id)
{
try {
cout << "Sending last received pulse_id " << pulse_id;
cout << " to bsread address " << bsread_rest_address << endl;
stringstream request;
request << "curl -X PUT " << bsread_rest_address;
request << "/stop_pulse_id/" << pulse_id;
cout << "Request: " << request.str() << endl;
string request_call(request.str());
#ifdef DEBUG_OUTPUT
using namespace date;
cout << "[" << chrono::system_clock::now() << "]";
cout << "[ProcessManager::notify_last_pulse_id] Sending request";
cout << "(" << request_call << ")." << endl;
#endif
system(request_call.c_str());
} catch (...){}
}
-5
View File
@@ -12,11 +12,6 @@ void RestApi::start_rest_api(WriterManager& writer_manager, uint16_t port)
#ifdef DEBUG_OUTPUT
cout << "[rest_interface::start_rest_api] Starting rest interface on port ";
cout << port << endl;
cout << "[rest_interface::start_rest_api] Accepting start parameters:" << endl;
for (const auto& item : rest_start_parameters) {
cout << "\t " << item.key() << endl;
}
#endif
crow::SimpleApp app;
+6 -6
View File
@@ -13,7 +13,7 @@ RingBuffer::RingBuffer(size_t n_slots) : n_slots(n_slots), ringbuffer_slots(n_sl
#ifdef DEBUG_OUTPUT
using namespace date;
using namespace chrono;
error_message << "[" << system_clock::now() << "]";
cout << "[" << system_clock::now() << "]";
cout << "[RingBuffer::RingBuffer] Creating ring buffer";
cout << " with n_slots " << n_slots << endl;
#endif
@@ -44,7 +44,7 @@ void RingBuffer::initialize(size_t slot_size)
#ifdef DEBUG_OUTPUT
using namespace date;
using namespace chrono;
error_message << "[" << system_clock::now() << "]";
cout << "[" << system_clock::now() << "]";
cout << "[RingBuffer::initialize] Initializing ring buffer";
cout << " with slot_size " << slot_size << endl;
#endif
@@ -59,7 +59,7 @@ void RingBuffer::initialize(size_t slot_size)
#ifdef DEBUG_OUTPUT
using namespace date;
using namespace chrono;
error_message << "[" << system_clock::now() << "]";
cout << "[" << system_clock::now() << "]";
cout << "[RingBuffer::initialize] Total buffer_size " << buffer_size << endl;
#endif
}
@@ -98,7 +98,7 @@ void RingBuffer::write(shared_ptr<FrameMetadata> frame_metadata, const char* dat
#ifdef DEBUG_OUTPUT
using namespace date;
using namespace chrono;
error_message << "[" << system_clock::now() << "]";
cout << "[" << system_clock::now() << "]";
cout << "[RingBuafer::write] Ring buffer slot ";
cout << frame_metadata->buffer_slot_index;
cout << " reserved for frame_index ";
@@ -128,7 +128,7 @@ void RingBuffer::write(shared_ptr<FrameMetadata> frame_metadata, const char* dat
#ifdef DEBUG_OUTPUT
using namespace date;
using namespace chrono;
error_message << "[" << system_clock::now() << "]";
cout << "[" << system_clock::now() << "]";
cout << "[RingBuffer::write] Copied " << frame_metadata->frame_bytes_size;
cout << " frame bytes to buffer_slot_index ";
cout << frame_metadata->buffer_slot_index << endl;
@@ -189,7 +189,7 @@ pair<shared_ptr<FrameMetadata>, char*> RingBuffer::read()
#ifdef DEBUG_OUTPUT
using namespace date;
using namespace chrono;
error_message << "[" << system_clock::now() << "]";
cout << "[" << system_clock::now() << "]";
cout << "[RingBuffer::read] Received metadata for frame_index ";
cout << frame_metadata->frame_index << endl;
#endif
+18 -22
View File
@@ -15,7 +15,7 @@ void writer_utils::set_process_id(int user_id)
#ifdef DEBUG_OUTPUT
using namespace date;
using namespace chrono;
error_message << "[" << system_clock::now() << "]";
cout << "[" << system_clock::now() << "]";
cout << "[writer_utils::set_process_id] Setting process user to ";
cout << user_id << endl;
#endif
@@ -34,6 +34,7 @@ void writer_utils::set_process_id(int user_id)
if (seteuid(user_id)) {
stringstream error_message;
using namespace date;
using namespace chrono;
error_message << "[" << system_clock::now() << "]";
@@ -83,7 +84,8 @@ WriterManager::WriterManager(
#ifdef DEBUG_OUTPUT
using namespace date;
using namespace chrono;
error_message << "[" << system_clock::now() << "]";
cout << "[" << system_clock::now() << "]";
cout << "[WriterManager::WriterManager] Writer manager initialized." << endl;
#endif
}
@@ -131,19 +133,14 @@ void WriterManager::start(const string output_file,
{
#ifdef DEBUG_OUTPUT
stringstream output_message;
using namespace date;
output_message << "[" << std::chrono::system_clock::now() << "]";
output_message << "[WriterManager::start] Starting with parameters: ";
for (const auto& parameter : new_parameters) {
auto& parameter_name = parameter.first;
auto& parameter_value = parameter.second;
output_message << parameter_name << ": " << parameter_value << ", ";
}
cout << output_message.str() << endl;
using namespace chrono;
cout << "[" << system_clock::now() << "]";
cout << "[WriterManager::start] Starting with parameters: ";
cout << "\toutput_file: " << output_file;
cout << "\tn_frames: " << n_frames;
cout << "\tuser_id: " << user_id;
cout << endl;
#endif
n_frames_to_write = n_frames;
@@ -191,11 +188,10 @@ void WriterManager::writing_completed() {
writing_flag = false;
#ifdef DEBUG_OUTPUT
stringstream output_message;
using namespace date;
output_message << "[" << std::chrono::system_clock::now() << "]";
output_message << "[WriterManager::writing_completed] Writing has finished.";
output_message << endl;
using namespace chrono;
cout << "[" << system_clock::now() << "]";
cout << "[WriterManager::writing_completed] Writing has finished." << endl;
#endif
//TODO: Send this event somewhere somehow?
@@ -219,7 +215,7 @@ void WriterManager::write_h5_format(H5::H5File& file) {
}
}
void WriterManager::write_h5(string output_file, uint64_t n_frames)
void WriterManager::write_h5(const string output_file, const uint64_t n_frames)
{
try {
@@ -274,7 +270,7 @@ void WriterManager::write_h5(string output_file, uint64_t n_frames)
using namespace chrono;
cout << "[" << system_clock::now() << "]";
cout << "[PSIWriter::write_h5] Frame index ";
cout << "[WriterManager::write_h5] Frame index ";
cout << received_data.first->frame_index;
cout << " does not belong to current file. ";
cout << " Write format before switching file." << endl;
@@ -311,7 +307,7 @@ void WriterManager::write_h5(string output_file, uint64_t n_frames)
duration<float, milli>(frame_time_difference).count();
cout << "[" << system_clock::now() << "]";
cout << "[PSIWriter::write_h5] Frame index ";
cout << "[WriterManager::write_h5] Frame index ";
cout << received_data.first->frame_index;
cout << " written in " << frame_diff_ms << " ms." << endl;
#endif
@@ -384,7 +380,7 @@ void WriterManager::write_h5(string output_file, uint64_t n_frames)
using namespace chrono;
cout << "[" << system_clock::now() << "]";
cout << "[ProcessManager::write] Closing file " << get_output_file() << endl;
cout << "[ProcessManager::write] Closing file " << output_file << endl;
#endif
writer->close_file();