replaced old logger

This commit is contained in:
Erik Frojdh
2020-03-11 12:40:12 +01:00
parent 4aeb8bf62e
commit 0de0d82a1a
79 changed files with 3635 additions and 3814 deletions

View File

@ -33,8 +33,8 @@ BinaryFile::~BinaryFile() {
void BinaryFile::PrintMembers(TLogLevel level) {
File::PrintMembers(level);
FILE_LOG(logINFO) << "Max Frames Per File: " << *maxFramesPerFile;
FILE_LOG(logINFO) << "Number of Frames in File: " << numFramesInFile;
LOG(logINFO) << "Max Frames Per File: " << *maxFramesPerFile;
LOG(logINFO) << "Number of Frames in File: " << numFramesInFile;
}
slsDetectorDefs::fileFormat BinaryFile::GetFileType() {
@ -52,7 +52,7 @@ void BinaryFile::CreateFile() {
BinaryFileStatic::CreateDataFile(filefd, *overWriteEnable, currentFileName);
if(!(*silentMode)) {
FILE_LOG(logINFO) << "[" << *udpPortNumber << "]: Binary File created: " << currentFileName;
LOG(logINFO) << "[" << *udpPortNumber << "]: Binary File created: " << currentFileName;
}
}
@ -119,7 +119,7 @@ void BinaryFile::CreateMasterFile(bool mfwenable, masterAttributes& attr) {
masterFileName = BinaryFileStatic::CreateMasterFileName(*filePath,
*fileNamePrefix, *fileIndex);
if(!(*silentMode)) {
FILE_LOG(logINFO) << "Master File: " << masterFileName;
LOG(logINFO) << "Master File: " << masterFileName;
}
attr.version = BINARY_WRITER_VERSION;
BinaryFileStatic::CreateMasterDataFile(masterfd, masterFileName,

View File

@ -13,8 +13,9 @@
#include <memory>
#include <sstream>
#include <string>
#include <syscall.h>
#include <vector>
#include <sys/syscall.h>
#include <unistd.h>
using sls::RuntimeError;
using sls::SocketError;
@ -24,9 +25,9 @@ ClientInterface::~ClientInterface() {
killTcpThread = true;
// shut down tcp sockets
if (server.get() != nullptr) {
FILE_LOG(logINFO) << "Shutting down TCP Socket on port " << portNumber;
LOG(logINFO) << "Shutting down TCP Socket on port " << portNumber;
server->shutDownSocket();
FILE_LOG(logDEBUG) << "TCP Socket closed on port " << portNumber;
LOG(logDEBUG) << "TCP Socket closed on port " << portNumber;
}
// shut down tcp thread
tcpThread->join();
@ -68,12 +69,12 @@ void ClientInterface::registerCallBackRawDataModifyReady(
}
void ClientInterface::startTCPServer() {
FILE_LOG(logINFOBLUE) << "Created [ TCP server Tid: " << syscall(SYS_gettid) << "]";
FILE_LOG(logINFO) << "SLS Receiver starting TCP Server on port "
LOG(logINFOBLUE) << "Created [ TCP server Tid: " << syscall(SYS_gettid) << "]";
LOG(logINFO) << "SLS Receiver starting TCP Server on port "
<< portNumber << '\n';
server = sls::make_unique<sls::ServerSocket>(portNumber);
while (true) {
FILE_LOG(logDEBUG1) << "Start accept loop";
LOG(logDEBUG1) << "Start accept loop";
try {
auto socket = server->accept();
try {
@ -91,7 +92,7 @@ void ClientInterface::startTCPServer() {
break;
}
} catch (const RuntimeError &e) {
FILE_LOG(logERROR) << "Accept failed";
LOG(logERROR) << "Accept failed";
}
// destructor to kill this thread
if (killTcpThread) {
@ -102,7 +103,7 @@ void ClientInterface::startTCPServer() {
if (receiver) {
receiver->shutDownUDPSockets();
}
FILE_LOG(logINFOBLUE) << "Exiting [ TCP server Tid: " << syscall(SYS_gettid) << "]";
LOG(logINFOBLUE) << "Exiting [ TCP server Tid: " << syscall(SYS_gettid) << "]";
}
// clang-format off
@ -177,7 +178,7 @@ int ClientInterface::functionTable(){
flist[F_RECEIVER_SET_NUM_COUNTERS] = &ClientInterface::set_num_counters;
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
FILE_LOG(logDEBUG1) << "function fnum: " << i << " (" <<
LOG(logDEBUG1) << "function fnum: " << i << " (" <<
getFunctionNameFromEnum((enum detFuncs)i) << ") located at " << flist[i];
}
@ -191,11 +192,11 @@ int ClientInterface::decodeFunction(Interface &socket) {
throw RuntimeError("Unrecognized Function enum " +
std::to_string(fnum) + "\n");
} else {
FILE_LOG(logDEBUG1) << "calling function fnum: " << fnum << " ("
LOG(logDEBUG1) << "calling function fnum: " << fnum << " ("
<< getFunctionNameFromEnum((enum detFuncs)fnum)
<< ")";
ret = (this->*flist[fnum])(socket);
FILE_LOG(logDEBUG1)
LOG(logDEBUG1)
<< "Function " << getFunctionNameFromEnum((enum detFuncs)fnum)
<< " finished";
}
@ -248,7 +249,7 @@ int ClientInterface::exec_command(Interface &socket) {
char cmd[MAX_STR_LENGTH]{};
char retval[MAX_STR_LENGTH]{};
socket.Receive(cmd);
FILE_LOG(logINFO) << "Executing command (" << cmd << ")";
LOG(logINFO) << "Executing command (" << cmd << ")";
const size_t tempsize = 256;
std::array<char, tempsize> temp{};
std::string sresult;
@ -261,20 +262,20 @@ int ClientInterface::exec_command(Interface &socket) {
sresult += temp.data();
}
strncpy(retval, sresult.c_str(), MAX_STR_LENGTH);
FILE_LOG(logINFO) << "Result of cmd (" << cmd << "):\n" << retval;
LOG(logINFO) << "Result of cmd (" << cmd << "):\n" << retval;
}
return socket.sendResult(retval);
}
int ClientInterface::exit_server(Interface &socket) {
FILE_LOG(logINFO) << "Closing server";
LOG(logINFO) << "Closing server";
socket.Send(OK);
return GOODBYE;
}
int ClientInterface::lock_receiver(Interface &socket) {
auto lock = socket.Receive<int>();
FILE_LOG(logDEBUG1) << "Locking Server to " << lock;
LOG(logDEBUG1) << "Locking Server to " << lock;
if (lock >= 0) {
if (!lockedByClient || (server->getLockedBy() == server->getThisClient())) {
lockedByClient = lock;
@ -297,7 +298,7 @@ int ClientInterface::set_port(Interface &socket) {
throw RuntimeError("Port Number: " + std::to_string(p_number) +
" is too low (<1024)");
FILE_LOG(logINFO) << "TCP port set to " << p_number << std::endl;
LOG(logINFO) << "TCP port set to " << p_number << std::endl;
auto new_server = sls::make_unique<sls::ServerSocket>(p_number);
new_server->setLockedBy(server->getLockedBy());
new_server->setLastClient(server->getThisClient());
@ -490,7 +491,7 @@ int ClientInterface::set_roi(Interface &socket) {
static_assert(sizeof(ROI) == 2 * sizeof(int), "ROI not packed");
ROI arg;
socket.Receive(arg);
FILE_LOG(logDEBUG1) << "Set ROI: [" << arg.xmin << ", " << arg.xmax << "]";
LOG(logDEBUG1) << "Set ROI: [" << arg.xmin << ", " << arg.xmax << "]";
if (myDetectorType != GOTTHARD)
functionNotImplemented();
@ -506,14 +507,14 @@ int ClientInterface::set_roi(Interface &socket) {
int ClientInterface::set_num_frames(Interface &socket) {
auto value = socket.Receive<int64_t>();
FILE_LOG(logDEBUG1) << "Setting num frames to " << value;
LOG(logDEBUG1) << "Setting num frames to " << value;
impl()->setNumberOfFrames(value);
return socket.Send(OK);
}
int ClientInterface::set_num_analog_samples(Interface &socket) {
auto value = socket.Receive<int>();
FILE_LOG(logDEBUG1) << "Setting num analog samples to " << value;
LOG(logDEBUG1) << "Setting num analog samples to " << value;
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
functionNotImplemented();
}
@ -528,7 +529,7 @@ int ClientInterface::set_num_analog_samples(Interface &socket) {
int ClientInterface::set_num_digital_samples(Interface &socket) {
auto value = socket.Receive<int>();
FILE_LOG(logDEBUG1) << "Setting num digital samples to " << value;
LOG(logDEBUG1) << "Setting num digital samples to " << value;
if (myDetectorType != CHIPTESTBOARD) {
functionNotImplemented();
}
@ -542,21 +543,21 @@ int ClientInterface::set_num_digital_samples(Interface &socket) {
int ClientInterface::set_exptime(Interface &socket) {
auto value = socket.Receive<int64_t>();
FILE_LOG(logDEBUG1) << "Setting exptime to " << value << "ns";
LOG(logDEBUG1) << "Setting exptime to " << value << "ns";
impl()->setAcquisitionTime(value);
return socket.Send(OK);
}
int ClientInterface::set_period(Interface &socket) {
auto value = socket.Receive<int64_t>();
FILE_LOG(logDEBUG1) << "Setting period to " << value << "ns";
LOG(logDEBUG1) << "Setting period to " << value << "ns";
impl()->setAcquisitionPeriod(value);
return socket.Send(OK);
}
int ClientInterface::set_subexptime(Interface &socket) {
auto value = socket.Receive<int64_t>();
FILE_LOG(logDEBUG1) << "Setting period to " << value << "ns";
LOG(logDEBUG1) << "Setting period to " << value << "ns";
uint64_t subdeadtime = impl()->getSubPeriod() - impl()->getSubExpTime();
impl()->setSubExpTime(value);
impl()->setSubPeriod(impl()->getSubExpTime() + subdeadtime);
@ -565,9 +566,9 @@ int ClientInterface::set_subexptime(Interface &socket) {
int ClientInterface::set_subdeadtime(Interface &socket) {
auto value = socket.Receive<int64_t>();
FILE_LOG(logDEBUG1) << "Setting sub deadtime to " << value << "ns";
LOG(logDEBUG1) << "Setting sub deadtime to " << value << "ns";
impl()->setSubPeriod(value + impl()->getSubExpTime());
FILE_LOG(logDEBUG1) << "Setting sub period to " << impl()->getSubPeriod() << "ns";
LOG(logDEBUG1) << "Setting sub period to " << impl()->getSubPeriod() << "ns";
return socket.Send(OK);
}
@ -575,7 +576,7 @@ int ClientInterface::set_dynamic_range(Interface &socket) {
auto dr = socket.Receive<int>();
if (dr >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting dynamic range: " << dr;
LOG(logDEBUG1) << "Setting dynamic range: " << dr;
bool exists = false;
switch(myDetectorType) {
case EIGER:
@ -607,7 +608,7 @@ int ClientInterface::set_dynamic_range(Interface &socket) {
}
int retval = impl()->getDynamicRange();
validate(dr, retval, "set dynamic range", DEC);
FILE_LOG(logDEBUG1) << "dynamic range: " << retval;
LOG(logDEBUG1) << "dynamic range: " << retval;
return socket.sendResult(retval);
}
@ -615,7 +616,7 @@ int ClientInterface::set_streaming_frequency(Interface &socket) {
auto index = socket.Receive<int>();
if (index >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting streaming frequency: " << index;
LOG(logDEBUG1) << "Setting streaming frequency: " << index;
impl()->setStreamingFrequency(index);
}
int retval = impl()->getStreamingFrequency();
@ -625,13 +626,13 @@ int ClientInterface::set_streaming_frequency(Interface &socket) {
int ClientInterface::get_status(Interface &socket) {
auto retval = impl()->getStatus();
FILE_LOG(logDEBUG1) << "Status:" << sls::ToString(retval);
LOG(logDEBUG1) << "Status:" << sls::ToString(retval);
return socket.sendResult(retval);
}
int ClientInterface::start_receiver(Interface &socket) {
if (impl()->getStatus() == IDLE) {
FILE_LOG(logDEBUG1) << "Starting Receiver";
LOG(logDEBUG1) << "Starting Receiver";
impl()->startReceiver();
}
return socket.Send(OK);
@ -640,7 +641,7 @@ int ClientInterface::start_receiver(Interface &socket) {
int ClientInterface::stop_receiver(Interface &socket) {
auto arg = socket.Receive<int>();
if (impl()->getStatus() == RUNNING) {
FILE_LOG(logDEBUG1) << "Stopping Receiver";
LOG(logDEBUG1) << "Stopping Receiver";
impl()->setStoppedFlag(static_cast<bool>(arg));
impl()->stopReceiver();
}
@ -658,7 +659,7 @@ int ClientInterface::set_file_dir(Interface &socket) {
socket.Receive(fPath);
if (strlen(fPath) != 0) {
FILE_LOG(logDEBUG1) << "Setting file path: " << fPath;
LOG(logDEBUG1) << "Setting file path: " << fPath;
if(fPath[0] != '/')
throw RuntimeError("Receiver path needs to be absolute path");
impl()->setFilePath(fPath);
@ -668,7 +669,7 @@ int ClientInterface::set_file_dir(Interface &socket) {
if ((s.empty()) || (strlen(fPath) && strcasecmp(fPath, retval)))
throw RuntimeError("Receiver file path does not exist");
else
FILE_LOG(logDEBUG1) << "file path:" << retval;
LOG(logDEBUG1) << "file path:" << retval;
return socket.sendResult(retval);
}
@ -678,7 +679,7 @@ int ClientInterface::set_file_name(Interface &socket) {
char retval[MAX_STR_LENGTH]{};
socket.Receive(fName);
if (strlen(fName) != 0) {
FILE_LOG(logDEBUG1) << "Setting file name: " << fName;
LOG(logDEBUG1) << "Setting file name: " << fName;
impl()->setFileName(fName);
}
std::string s = impl()->getFileName();
@ -686,7 +687,7 @@ int ClientInterface::set_file_name(Interface &socket) {
throw RuntimeError("file name is empty");
sls::strcpy_safe(retval, s.c_str());
FILE_LOG(logDEBUG1) << "file name:" << retval;
LOG(logDEBUG1) << "file name:" << retval;
return socket.sendResult(retval);
}
@ -694,24 +695,24 @@ int ClientInterface::set_file_index(Interface &socket) {
auto index = socket.Receive<int64_t>();
if (index >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting file index: " << index;
LOG(logDEBUG1) << "Setting file index: " << index;
impl()->setFileIndex(index);
}
int64_t retval = impl()->getFileIndex();
validate(index, retval, "set file index", DEC);
FILE_LOG(logDEBUG1) << "file index:" << retval;
LOG(logDEBUG1) << "file index:" << retval;
return socket.sendResult(retval);
}
int ClientInterface::get_frame_index(Interface &socket) {
uint64_t retval = impl()->getAcquisitionIndex();
FILE_LOG(logDEBUG1) << "frame index:" << retval;
LOG(logDEBUG1) << "frame index:" << retval;
return socket.sendResult(retval);
}
int ClientInterface::get_missing_packets(Interface &socket) {
std::vector<uint64_t> m = impl()->getNumMissingPackets();
FILE_LOG(logDEBUG1) << "missing packets:" << sls::ToString(m);
LOG(logDEBUG1) << "missing packets:" << sls::ToString(m);
int retvalsize = m.size();
uint64_t retval[retvalsize];
std::copy(std::begin(m), std::end(m), retval);
@ -723,7 +724,7 @@ int ClientInterface::get_missing_packets(Interface &socket) {
int ClientInterface::get_frames_caught(Interface &socket) {
int64_t retval = impl()->getFramesCaught();
FILE_LOG(logDEBUG1) << "frames caught:" << retval;
LOG(logDEBUG1) << "frames caught:" << retval;
return socket.sendResult(retval);
}
@ -731,12 +732,12 @@ int ClientInterface::enable_file_write(Interface &socket) {
auto enable = socket.Receive<int>();
if (enable >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting File write enable:" << enable;
LOG(logDEBUG1) << "Setting File write enable:" << enable;
impl()->setFileWriteEnable(enable);
}
int retval = impl()->getFileWriteEnable();
validate(enable, retval, "set file write enable", DEC);
FILE_LOG(logDEBUG1) << "file write enable:" << retval;
LOG(logDEBUG1) << "file write enable:" << retval;
return socket.sendResult(retval);
}
@ -744,12 +745,12 @@ int ClientInterface::enable_master_file_write(Interface &socket) {
auto enable = socket.Receive<int>();
if (enable >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting Master File write enable:" << enable;
LOG(logDEBUG1) << "Setting Master File write enable:" << enable;
impl()->setMasterFileWriteEnable(enable);
}
int retval = impl()->getMasterFileWriteEnable();
validate(enable, retval, "set master file write enable", DEC);
FILE_LOG(logDEBUG1) << "master file write enable:" << retval;
LOG(logDEBUG1) << "master file write enable:" << retval;
return socket.sendResult(retval);
}
@ -757,12 +758,12 @@ int ClientInterface::enable_overwrite(Interface &socket) {
auto index = socket.Receive<int>();
if (index >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting File overwrite enable:" << index;
LOG(logDEBUG1) << "Setting File overwrite enable:" << index;
impl()->setOverwriteEnable(index);
}
int retval = impl()->getOverwriteEnable();
validate(index, retval, "set file overwrite enable", DEC);
FILE_LOG(logDEBUG1) << "file overwrite enable:" << retval;
LOG(logDEBUG1) << "file overwrite enable:" << retval;
return socket.sendResult(retval);
}
@ -774,7 +775,7 @@ int ClientInterface::enable_tengiga(Interface &socket) {
if (val >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting 10GbE:" << val;
LOG(logDEBUG1) << "Setting 10GbE:" << val;
try {
impl()->setTenGigaEnable(val);
} catch(const RuntimeError &e) {
@ -783,7 +784,7 @@ int ClientInterface::enable_tengiga(Interface &socket) {
}
int retval = impl()->getTenGigaEnable();
validate(val, retval, "set 10GbE", DEC);
FILE_LOG(logDEBUG1) << "10Gbe:" << retval;
LOG(logDEBUG1) << "10Gbe:" << retval;
return socket.sendResult(retval);
}
@ -791,7 +792,7 @@ int ClientInterface::set_fifo_depth(Interface &socket) {
auto value = socket.Receive<int>();
if (value >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting fifo depth:" << value;
LOG(logDEBUG1) << "Setting fifo depth:" << value;
try {
impl()->setFifoDepth(value);
} catch(const RuntimeError &e) {
@ -800,7 +801,7 @@ int ClientInterface::set_fifo_depth(Interface &socket) {
}
int retval = impl()->getFifoDepth();
validate(value, retval, std::string("set fifo depth"), DEC);
FILE_LOG(logDEBUG1) << "fifo depth:" << retval;
LOG(logDEBUG1) << "fifo depth:" << retval;
return socket.sendResult(retval);
}
@ -811,12 +812,12 @@ int ClientInterface::set_activate(Interface &socket) {
if (enable >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting activate:" << enable;
LOG(logDEBUG1) << "Setting activate:" << enable;
impl()->setActivate(static_cast<bool>(enable));
}
auto retval = static_cast<int>(impl()->getActivate());
validate(enable, retval, "set activate", DEC);
FILE_LOG(logDEBUG1) << "Activate: " << retval;
LOG(logDEBUG1) << "Activate: " << retval;
return socket.sendResult(retval);
}
@ -824,7 +825,7 @@ int ClientInterface::set_data_stream_enable(Interface &socket) {
auto index = socket.Receive<int>();
if (index >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting data stream enable:" << index;
LOG(logDEBUG1) << "Setting data stream enable:" << index;
try {
impl()->setDataStreamEnable(index);
} catch(const RuntimeError &e) {
@ -833,7 +834,7 @@ int ClientInterface::set_data_stream_enable(Interface &socket) {
}
auto retval = static_cast<int>(impl()->getDataStreamEnable());
validate(index, retval, "set data stream enable", DEC);
FILE_LOG(logDEBUG1) << "data streaming enable:" << retval;
LOG(logDEBUG1) << "data streaming enable:" << retval;
return socket.sendResult(retval);
}
@ -841,12 +842,12 @@ int ClientInterface::set_streaming_timer(Interface &socket) {
auto index = socket.Receive<int>();
if (index >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting streaming timer:" << index;
LOG(logDEBUG1) << "Setting streaming timer:" << index;
impl()->setStreamingTimer(index);
}
int retval = impl()->getStreamingTimer();
validate(index, retval, "set data stream timer", DEC);
FILE_LOG(logDEBUG1) << "Streaming timer:" << retval;
LOG(logDEBUG1) << "Streaming timer:" << retval;
return socket.sendResult(retval);
}
@ -858,12 +859,12 @@ int ClientInterface::set_flipped_data(Interface &socket) {
if (arg >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting flipped data:" << arg;
LOG(logDEBUG1) << "Setting flipped data:" << arg;
impl()->setFlippedDataX(arg);
}
int retval = impl()->getFlippedDataX();
validate(arg, retval, std::string("set flipped data"), DEC);
FILE_LOG(logDEBUG1) << "Flipped Data:" << retval;
LOG(logDEBUG1) << "Flipped Data:" << retval;
return socket.sendResult(retval);
}
@ -872,12 +873,12 @@ int ClientInterface::set_file_format(Interface &socket) {
socket.Receive(f);
if (f >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting file format:" << f;
LOG(logDEBUG1) << "Setting file format:" << f;
impl()->setFileFormat(f);
}
auto retval = impl()->getFileFormat();
validate(f, retval, "set file format", DEC);
FILE_LOG(logDEBUG1) << "File Format: " << retval;
LOG(logDEBUG1) << "File Format: " << retval;
return socket.sendResult(retval);
}
@ -885,12 +886,12 @@ int ClientInterface::set_detector_posid(Interface &socket) {
auto arg = socket.Receive<int>();
if (arg >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting detector position id:" << arg;
LOG(logDEBUG1) << "Setting detector position id:" << arg;
impl()->setDetectorPositionId(arg);
}
auto retval = impl()->getDetectorPositionId();
validate(arg, retval, "set detector position id", DEC);
FILE_LOG(logDEBUG1) << "Position Id:" << retval;
LOG(logDEBUG1) << "Position Id:" << retval;
return socket.sendResult(retval);
}
@ -899,13 +900,13 @@ int ClientInterface::set_multi_detector_size(Interface &socket) {
socket.Receive(arg);
if ((arg[0] > 0) && (arg[1] > 0)) {
verifyIdle(socket);
FILE_LOG(logDEBUG1)
LOG(logDEBUG1)
<< "Setting multi detector size:" << arg[0] << "," << arg[1];
impl()->setMultiDetectorSize(arg);
}
int *temp = impl()->getMultiDetectorSize(); // TODO! return by value!
int retval = temp[0] * temp[1];
FILE_LOG(logDEBUG1) << "Multi Detector Size:" << retval;
LOG(logDEBUG1) << "Multi Detector Size:" << retval;
return socket.sendResult(retval);
}
@ -913,12 +914,12 @@ int ClientInterface::set_streaming_port(Interface &socket) {
auto port = socket.Receive<int>();
if (port >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting streaming port:" << port;
LOG(logDEBUG1) << "Setting streaming port:" << port;
impl()->setStreamingPort(port);
}
int retval = impl()->getStreamingPort();
validate(port, retval, "set streaming port", DEC);
FILE_LOG(logDEBUG1) << "streaming port:" << retval;
LOG(logDEBUG1) << "streaming port:" << retval;
return socket.sendResult(retval);
}
@ -926,7 +927,7 @@ int ClientInterface::set_streaming_source_ip(Interface &socket) {
sls::IpAddr arg;
socket.Receive(arg);
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting streaming source ip:" << arg;
LOG(logDEBUG1) << "Setting streaming source ip:" << arg;
impl()->setStreamingSourceIP(arg);
sls::IpAddr retval = impl()->getStreamingSourceIP();
if (retval != arg) {
@ -942,12 +943,12 @@ int ClientInterface::set_silent_mode(Interface &socket) {
auto value = socket.Receive<int>();
if (value >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting silent mode:" << value;
LOG(logDEBUG1) << "Setting silent mode:" << value;
impl()->setSilentMode(value);
}
auto retval = static_cast<int>(impl()->getSilentMode());
validate(value, retval, "set silent mode", DEC);
FILE_LOG(logDEBUG1) << "silent mode:" << retval;
LOG(logDEBUG1) << "silent mode:" << retval;
return socket.sendResult(retval);
}
@ -958,7 +959,7 @@ int ClientInterface::enable_gap_pixels(Interface &socket) {
if (enable >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting gap pixels enable:" << enable;
LOG(logDEBUG1) << "Setting gap pixels enable:" << enable;
try {
impl()->setGapPixelsEnable(static_cast<bool>(enable));
} catch(const RuntimeError &e) {
@ -967,7 +968,7 @@ int ClientInterface::enable_gap_pixels(Interface &socket) {
}
auto retval = static_cast<int>(impl()->getGapPixelsEnable());
validate(enable, retval, "set gap pixels enable", DEC);
FILE_LOG(logDEBUG1) << "Gap Pixels Enable: " << retval;
LOG(logDEBUG1) << "Gap Pixels Enable: " << retval;
return socket.sendResult(retval);
}
@ -977,7 +978,7 @@ int ClientInterface::restream_stop(Interface &socket) {
throw RuntimeError(
"Could not restream stop packet as data Streaming is disabled");
} else {
FILE_LOG(logDEBUG1) << "Restreaming stop";
LOG(logDEBUG1) << "Restreaming stop";
impl()->restreamStop();
}
return socket.Send(OK);
@ -988,17 +989,17 @@ int ClientInterface::set_additional_json_header(Interface &socket) {
char retval[MAX_STR_LENGTH]{};
socket.Receive(arg);
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting additional json header: " << arg;
LOG(logDEBUG1) << "Setting additional json header: " << arg;
impl()->setAdditionalJsonHeader(arg);
sls::strcpy_safe(retval, impl()->getAdditionalJsonHeader().c_str());
FILE_LOG(logDEBUG1) << "additional json header:" << retval;
LOG(logDEBUG1) << "additional json header:" << retval;
return socket.sendResult(retval);
}
int ClientInterface::get_additional_json_header(Interface &socket) {
char retval[MAX_STR_LENGTH]{};
sls::strcpy_safe(retval, impl()->getAdditionalJsonHeader().c_str());
FILE_LOG(logDEBUG1) << "additional json header:" << retval;
LOG(logDEBUG1) << "additional json header:" << retval;
return socket.sendResult(retval);
}
@ -1006,7 +1007,7 @@ int ClientInterface::set_udp_socket_buffer_size(Interface &socket) {
auto index = socket.Receive<int64_t>();
if (index >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting UDP Socket Buffer size: " << index;
LOG(logDEBUG1) << "Setting UDP Socket Buffer size: " << index;
impl()->setUDPSocketBufferSize(index);
}
int64_t retval = impl()->getUDPSocketBufferSize();
@ -1014,14 +1015,14 @@ int ClientInterface::set_udp_socket_buffer_size(Interface &socket) {
validate(index, retval,
"set udp socket buffer size (No CAP_NET_ADMIN privileges?)",
DEC);
FILE_LOG(logDEBUG1) << "UDP Socket Buffer Size:" << retval;
LOG(logDEBUG1) << "UDP Socket Buffer Size:" << retval;
return socket.sendResult(retval);
}
int ClientInterface::get_real_udp_socket_buffer_size(
Interface &socket) {
auto size = impl()->getActualUDPSocketBufferSize();
FILE_LOG(logDEBUG1) << "Actual UDP socket size :" << size;
LOG(logDEBUG1) << "Actual UDP socket size :" << size;
return socket.sendResult(size);
}
@ -1029,18 +1030,18 @@ int ClientInterface::set_frames_per_file(Interface &socket) {
auto index = socket.Receive<int>();
if (index >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting frames per file: " << index;
LOG(logDEBUG1) << "Setting frames per file: " << index;
impl()->setFramesPerFile(index);
}
auto retval = static_cast<int>(impl()->getFramesPerFile());
validate(index, retval, "set frames per file", DEC);
FILE_LOG(logDEBUG1) << "frames per file:" << retval;
LOG(logDEBUG1) << "frames per file:" << retval;
return socket.sendResult(retval);
}
int ClientInterface::check_version_compatibility(Interface &socket) {
auto arg = socket.Receive<int64_t>();
FILE_LOG(logDEBUG1) << "Checking versioning compatibility with value "
LOG(logDEBUG1) << "Checking versioning compatibility with value "
<< arg;
int64_t client_requiredVersion = arg;
int64_t rx_apiVersion = APIRECEIVER;
@ -1061,7 +1062,7 @@ int ClientInterface::check_version_compatibility(Interface &socket) {
<< ").\n Please update the receiver";
throw RuntimeError(os.str());
} else {
FILE_LOG(logINFO) << "Compatibility with Client: Successful";
LOG(logINFO) << "Compatibility with Client: Successful";
}
return socket.Send(OK);
}
@ -1070,12 +1071,12 @@ int ClientInterface::set_discard_policy(Interface &socket) {
auto index = socket.Receive<int>();
if (index >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting frames discard policy: " << index;
LOG(logDEBUG1) << "Setting frames discard policy: " << index;
impl()->setFrameDiscardPolicy(static_cast<frameDiscardPolicy>(index));
}
int retval = impl()->getFrameDiscardPolicy();
validate(index, retval, "set discard policy", DEC);
FILE_LOG(logDEBUG1) << "frame discard policy:" << retval;
LOG(logDEBUG1) << "frame discard policy:" << retval;
return socket.sendResult(retval);
}
@ -1083,12 +1084,12 @@ int ClientInterface::set_padding_enable(Interface &socket) {
auto index = socket.Receive<int>();
if (index >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting frames padding enable: " << index;
LOG(logDEBUG1) << "Setting frames padding enable: " << index;
impl()->setFramePaddingEnable(static_cast<bool>(index));
}
auto retval = static_cast<int>(impl()->getFramePaddingEnable());
validate(index, retval, "set frame padding enable", DEC);
FILE_LOG(logDEBUG1) << "Frame Padding Enable:" << retval;
LOG(logDEBUG1) << "Frame Padding Enable:" << retval;
return socket.sendResult(retval);
}
@ -1100,12 +1101,12 @@ int ClientInterface::set_deactivated_padding_enable(
if (enable >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting deactivated padding enable: " << enable;
LOG(logDEBUG1) << "Setting deactivated padding enable: " << enable;
impl()->setDeactivatedPadding(enable > 0);
}
auto retval = static_cast<int>(impl()->getDeactivatedPadding());
validate(enable, retval, "set deactivated padding enable", DEC);
FILE_LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval;
LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval;
return socket.sendResult(retval);
}
@ -1117,7 +1118,7 @@ int ClientInterface::set_readout_mode(Interface &socket) {
if (arg >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting readout mode: " << arg;
LOG(logDEBUG1) << "Setting readout mode: " << arg;
try {
impl()->setReadoutMode(arg);
} catch(const RuntimeError &e) {
@ -1127,14 +1128,14 @@ int ClientInterface::set_readout_mode(Interface &socket) {
auto retval = impl()->getReadoutMode();
validate(static_cast<int>(arg), static_cast<int>(retval),
"set readout mode", DEC);
FILE_LOG(logDEBUG1) << "Readout mode: " << retval;
LOG(logDEBUG1) << "Readout mode: " << retval;
return socket.sendResult(retval);
}
int ClientInterface::set_adc_mask(Interface &socket) {
auto arg = socket.Receive<uint32_t>();
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting 1Gb ADC enable mask: " << arg;
LOG(logDEBUG1) << "Setting 1Gb ADC enable mask: " << arg;
try {
impl()->setADCEnableMask(arg);
} catch(const RuntimeError &e) {
@ -1147,18 +1148,18 @@ int ClientInterface::set_adc_mask(Interface &socket) {
<< " but read 0x" << std::hex << retval;
throw RuntimeError(os.str());
}
FILE_LOG(logDEBUG1) << "1Gb ADC enable mask retval: " << retval;
LOG(logDEBUG1) << "1Gb ADC enable mask retval: " << retval;
return socket.sendResult(retval);
}
int ClientInterface::set_dbit_list(Interface &socket) {
sls::FixedCapacityContainer<int, MAX_RX_DBIT> args;
socket.Receive(args);
FILE_LOG(logDEBUG1) << "Setting DBIT list";
LOG(logDEBUG1) << "Setting DBIT list";
for (auto &it : args) {
FILE_LOG(logDEBUG1) << it << " ";
LOG(logDEBUG1) << it << " ";
}
FILE_LOG(logDEBUG1) << "\n";
LOG(logDEBUG1) << "\n";
verifyIdle(socket);
impl()->setDbitList(args);
return socket.Send(OK);
@ -1167,7 +1168,7 @@ int ClientInterface::set_dbit_list(Interface &socket) {
int ClientInterface::get_dbit_list(Interface &socket) {
sls::FixedCapacityContainer<int, MAX_RX_DBIT> retval;
retval = impl()->getDbitList();
FILE_LOG(logDEBUG1) << "Dbit list size retval:" << retval.size();
LOG(logDEBUG1) << "Dbit list size retval:" << retval.size();
return socket.sendResult(retval);
}
@ -1175,12 +1176,12 @@ int ClientInterface::set_dbit_offset(Interface &socket) {
auto arg = socket.Receive<int>();
if (arg >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting Dbit offset: " << arg;
LOG(logDEBUG1) << "Setting Dbit offset: " << arg;
impl()->setDbitOffset(arg);
}
int retval = impl()->getDbitOffset();
validate(arg, retval, "set dbit offset", DEC);
FILE_LOG(logDEBUG1) << "Dbit offset retval: " << retval;
LOG(logDEBUG1) << "Dbit offset retval: " << retval;
return socket.sendResult(retval);
}
@ -1188,7 +1189,7 @@ int ClientInterface::set_quad_type(Interface &socket) {
auto quadEnable = socket.Receive<int>();
if (quadEnable >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting quad:" << quadEnable;
LOG(logDEBUG1) << "Setting quad:" << quadEnable;
try {
impl()->setQuad(quadEnable == 0 ? false : true);
} catch(const RuntimeError &e) {
@ -1197,7 +1198,7 @@ int ClientInterface::set_quad_type(Interface &socket) {
}
int retval = impl()->getQuad() ? 1 : 0;
validate(quadEnable, retval, "set quad", DEC);
FILE_LOG(logDEBUG1) << "quad retval:" << retval;
LOG(logDEBUG1) << "quad retval:" << retval;
return socket.Send(OK);
}
@ -1205,12 +1206,12 @@ int ClientInterface::set_read_n_lines(Interface &socket) {
auto arg = socket.Receive<int>();
if (arg >= 0) {
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting Read N Lines:" << arg;
LOG(logDEBUG1) << "Setting Read N Lines:" << arg;
impl()->setReadNLines(arg);
}
int retval = impl()->getReadNLines();
validate(arg, retval, "set read n lines", DEC);
FILE_LOG(logDEBUG1) << "read n lines retval:" << retval;
LOG(logDEBUG1) << "read n lines retval:" << retval;
return socket.Send(OK);
}
@ -1218,7 +1219,7 @@ int ClientInterface::set_read_n_lines(Interface &socket) {
int ClientInterface::set_udp_ip(Interface &socket) {
auto arg = socket.Receive<sls::IpAddr>();
verifyIdle(socket);
FILE_LOG(logINFO) << "Received UDP IP: " << arg;
LOG(logINFO) << "Received UDP IP: " << arg;
// getting eth
std::string eth = sls::IpToInterfaceName(arg.str());
if (eth == "none") {
@ -1226,7 +1227,7 @@ int ClientInterface::set_udp_ip(Interface &socket) {
}
if (eth.find('.') != std::string::npos) {
eth = "";
FILE_LOG(logERROR) << "Failed to get udp ethernet interface from IP " << arg << ". Got " << eth;
LOG(logERROR) << "Failed to get udp ethernet interface from IP " << arg << ". Got " << eth;
}
impl()->setEthernetInterface(eth);
if (myDetectorType == EIGER) {
@ -1237,7 +1238,7 @@ int ClientInterface::set_udp_ip(Interface &socket) {
if (retval == 0) {
throw RuntimeError("Failed to get udp mac adddress to listen to\n");
}
FILE_LOG(logINFO) << "Receiver MAC Address: " << retval;
LOG(logINFO) << "Receiver MAC Address: " << retval;
return socket.sendResult(retval);
}
@ -1248,7 +1249,7 @@ int ClientInterface::set_udp_ip2(Interface &socket) {
if (myDetectorType != JUNGFRAU) {
throw RuntimeError("UDP Destination IP2 not implemented for this detector");
}
FILE_LOG(logINFO) << "Received UDP IP2: " << arg;
LOG(logINFO) << "Received UDP IP2: " << arg;
// getting eth
std::string eth = sls::IpToInterfaceName(arg.str());
if (eth == "none") {
@ -1256,7 +1257,7 @@ int ClientInterface::set_udp_ip2(Interface &socket) {
}
if (eth.find('.') != std::string::npos) {
eth = "";
FILE_LOG(logERROR) << "Failed to get udp ethernet interface2 from IP " << arg << ". Got " << eth;
LOG(logERROR) << "Failed to get udp ethernet interface2 from IP " << arg << ". Got " << eth;
}
impl()->setEthernetInterface2(eth);
@ -1265,14 +1266,14 @@ int ClientInterface::set_udp_ip2(Interface &socket) {
if (retval == 0) {
throw RuntimeError("Failed to get udp mac adddress2 to listen to\n");
}
FILE_LOG(logINFO) << "Receiver MAC Address2: " << retval;
LOG(logINFO) << "Receiver MAC Address2: " << retval;
return socket.sendResult(retval);
}
int ClientInterface::set_udp_port(Interface &socket) {
auto arg = socket.Receive<int>();
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting UDP Port:" << arg;
LOG(logDEBUG1) << "Setting UDP Port:" << arg;
impl()->setUDPPortNumber(arg);
return socket.Send(OK);
}
@ -1283,7 +1284,7 @@ int ClientInterface::set_udp_port2(Interface &socket) {
if (myDetectorType != JUNGFRAU && myDetectorType != EIGER) {
throw RuntimeError("UDP Destination Port2 not implemented for this detector");
}
FILE_LOG(logDEBUG1) << "Setting UDP Port:" << arg;
LOG(logDEBUG1) << "Setting UDP Port:" << arg;
impl()->setUDPPortNumber2(arg);
return socket.Send(OK);
}
@ -1295,7 +1296,7 @@ int ClientInterface::set_num_interfaces(Interface &socket) {
if (myDetectorType != JUNGFRAU) {
throw RuntimeError("Number of interfaces not implemented for this detector");
}
FILE_LOG(logDEBUG1) << "Setting Number of UDP Interfaces:" << arg;
LOG(logDEBUG1) << "Setting Number of UDP Interfaces:" << arg;
try {
impl()->setNumberofUDPInterfaces(arg);
} catch(const RuntimeError &e) {
@ -1307,7 +1308,7 @@ int ClientInterface::set_num_interfaces(Interface &socket) {
int ClientInterface::set_adc_mask_10g(Interface &socket) {
auto arg = socket.Receive<uint32_t>();
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting 10Gb ADC enable mask: " << arg;
LOG(logDEBUG1) << "Setting 10Gb ADC enable mask: " << arg;
try {
impl()->setTenGigaADCEnableMask(arg);
} catch(const RuntimeError &e) {
@ -1320,14 +1321,14 @@ int ClientInterface::set_adc_mask_10g(Interface &socket) {
<< " but read 0x" << std::hex << retval;
throw RuntimeError(os.str());
}
FILE_LOG(logDEBUG1) << "10Gb ADC enable mask retval: " << retval;
LOG(logDEBUG1) << "10Gb ADC enable mask retval: " << retval;
return socket.sendResult(retval);
}
int ClientInterface::set_num_counters(Interface &socket) {
auto arg = socket.Receive<int>();
verifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting counters: " << arg;
LOG(logDEBUG1) << "Setting counters: " << arg;
impl()->setNumberofCounters(arg);
return socket.Send(OK);
}

View File

@ -62,7 +62,7 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
rawDataModifyReadyCallBack(nullptr),
pRawDataReady(nullptr)
{
FILE_LOG(logDEBUG) << "DataProcessor " << ind << " created";
LOG(logDEBUG) << "DataProcessor " << ind << " created";
memset((void*)&timerBegin, 0, sizeof(timespec));
}
@ -135,7 +135,7 @@ void DataProcessor::RecordFirstIndex(uint64_t fnum) {
startedFlag = true;
firstIndex = fnum;
FILE_LOG(logDEBUG1) << index << " First Index:" << firstIndex;
LOG(logDEBUG1) << index << " First Index:" << firstIndex;
}
@ -232,12 +232,12 @@ void DataProcessor::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) {
void DataProcessor::ThreadExecution() {
char* buffer=nullptr;
fifo->PopAddress(buffer);
FILE_LOG(logDEBUG5) << "DataProcessor " << index << ", "
LOG(logDEBUG5) << "DataProcessor " << index << ", "
"pop 0x" << std::hex << (void*)(buffer) << std::dec << ":" << buffer;
//check dummy
auto numBytes = (uint32_t)(*((uint32_t*)buffer));
FILE_LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << numBytes;
LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << numBytes;
if (numBytes == DUMMY_PACKET_VALUE) {
StopProcessing(buffer);
return;
@ -254,7 +254,7 @@ void DataProcessor::ThreadExecution() {
void DataProcessor::StopProcessing(char* buf) {
FILE_LOG(logDEBUG1) << "DataProcessing " << index << ": Dummy";
LOG(logDEBUG1) << "DataProcessing " << index << ": Dummy";
//stream or free
if (*dataStreamEnable)
@ -265,7 +265,7 @@ void DataProcessor::StopProcessing(char* buf) {
if (file != nullptr)
file->CloseCurrentFile();
StopRunning();
FILE_LOG(logDEBUG1) << index << ": Processing Completed";
LOG(logDEBUG1) << index << ": Processing Completed";
}
@ -280,7 +280,7 @@ void DataProcessor::ProcessAnImage(char* buf) {
numFramesCaught++;
}
FILE_LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
if (!startedFlag) {
RecordFirstIndex(fnum);
@ -367,7 +367,7 @@ bool DataProcessor::CheckTimer() {
struct timespec end;
clock_gettime(CLOCK_REALTIME, &end);
FILE_LOG(logDEBUG1) << index << " Timer elapsed time:" <<
LOG(logDEBUG1) << index << " Timer elapsed time:" <<
(( end.tv_sec - timerBegin.tv_sec ) + ( end.tv_nsec - timerBegin.tv_nsec ) / 1000000000.0)
<< " seconds";
//still less than streaming timer, keep waiting
@ -412,7 +412,7 @@ void DataProcessor::registerCallBackRawDataModifyReady(void (*func)(char* ,
}
void DataProcessor::PadMissingPackets(char* buf) {
FILE_LOG(logDEBUG) << index << ": Padding Missing Packets";
LOG(logDEBUG) << index << ": Padding Missing Packets";
uint32_t pperFrame = generalData->packetsPerFrame;
auto* header = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES);
@ -422,7 +422,7 @@ void DataProcessor::PadMissingPackets(char* buf) {
uint32_t dsize = generalData->dataSize;
uint32_t fifohsize = generalData->fifoBufferHeaderSize;
uint32_t corrected_dsize = dsize - ((pperFrame * dsize) - generalData->imageSize);
FILE_LOG(logDEBUG1) << "bitmask: " << pmask.to_string();
LOG(logDEBUG1) << "bitmask: " << pmask.to_string();
for (unsigned int pnum = 0; pnum < pperFrame; ++pnum) {
@ -434,7 +434,7 @@ void DataProcessor::PadMissingPackets(char* buf) {
if (nmissing == 0u)
break;
FILE_LOG(logDEBUG) << "padding for " << index << " for pnum: " << pnum << std::endl;
LOG(logDEBUG) << "padding for " << index << " for pnum: " << pnum << std::endl;
// missing packet
switch(myDetectorType) {
@ -468,7 +468,7 @@ void DataProcessor::RearrangeDbitData(char* buf) {
// no digital data
if (ctbDigitalDataBytes == 0) {
FILE_LOG(logWARNING) << "No digital data for call back, yet dbitlist is not empty.";
LOG(logWARNING) << "No digital data for call back, yet dbitlist is not empty.";
return;
}

View File

@ -38,7 +38,7 @@ DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
numDet[0] = nd[0];
numDet[1] = nd[1];
FILE_LOG(logDEBUG) << "DataStreamer " << ind << " created";
LOG(logDEBUG) << "DataStreamer " << ind << " created";
}
@ -91,7 +91,7 @@ void DataStreamer::RecordFirstIndex(uint64_t fnum) {
startedFlag = true;
firstIndex = fnum;
FILE_LOG(logDEBUG1) << index << " First Index: " << firstIndex;
LOG(logDEBUG1) << index << " First Index: " << firstIndex;
}
void DataStreamer::SetGeneralData(GeneralData* g) {
@ -114,10 +114,10 @@ void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const sls::IpAdd
try {
zmqSocket = new ZmqSocket(portnum, (ip != 0? sip.c_str(): nullptr));
} catch (...) {
FILE_LOG(logERROR) << "Could not create Zmq socket on port " << portnum << " for Streamer " << index;
LOG(logERROR) << "Could not create Zmq socket on port " << portnum << " for Streamer " << index;
throw;
}
FILE_LOG(logINFO) << index << " Streamer: Zmq Server started at " << zmqSocket->GetZmqServerAddress();
LOG(logINFO) << index << " Streamer: Zmq Server started at " << zmqSocket->GetZmqServerAddress();
}
@ -132,13 +132,13 @@ void DataStreamer::CloseZmqSocket() {
void DataStreamer::ThreadExecution() {
char* buffer=nullptr;
fifo->PopAddressToStream(buffer);
FILE_LOG(logDEBUG5) << "DataStreamer " << index << ", "
LOG(logDEBUG5) << "DataStreamer " << index << ", "
"pop 0x" << std::hex << (void*)(buffer) << std::dec << ":" << buffer;
//check dummy
uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer));
FILE_LOG(logDEBUG1) << "DataStreamer " << index << ", Numbytes:" << numBytes;
LOG(logDEBUG1) << "DataStreamer " << index << ", Numbytes:" << numBytes;
if (numBytes == DUMMY_PACKET_VALUE) {
StopProcessing(buffer);
return;
@ -154,17 +154,17 @@ void DataStreamer::ThreadExecution() {
void DataStreamer::StopProcessing(char* buf) {
FILE_LOG(logDEBUG1) << "DataStreamer " << index << ": Dummy";
LOG(logDEBUG1) << "DataStreamer " << index << ": Dummy";
sls_receiver_header* header = (sls_receiver_header*) (buf);
//send dummy header and data
if (!SendHeader(header, 0, 0, 0, true)) {
FILE_LOG(logERROR) << "Could not send zmq dummy header for streamer " << index;
LOG(logERROR) << "Could not send zmq dummy header for streamer " << index;
}
fifo->FreeAddress(buf);
StopRunning();
FILE_LOG(logDEBUG1) << index << ": Streaming Completed";
LOG(logDEBUG1) << index << ": Streaming Completed";
}
/** buf includes only the standard header */
@ -172,7 +172,7 @@ void DataStreamer::ProcessAnImage(char* buf) {
sls_receiver_header* header = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES);
uint64_t fnum = header->detHeader.frameNumber;
FILE_LOG(logDEBUG1) << "DataStreamer " << index << ": fnum:" << fnum;
LOG(logDEBUG1) << "DataStreamer " << index << ": fnum:" << fnum;
if (!startedFlag) {
RecordFirstIndex(fnum);
@ -187,14 +187,14 @@ void DataStreamer::ProcessAnImage(char* buf) {
if (!SendHeader(header, generalData->imageSizeComplete,
generalData->nPixelsXComplete, generalData->nPixelsYComplete, false)) {
FILE_LOG(logERROR) << "Could not send zmq header for fnum " << fnum << " and streamer " << index;
LOG(logERROR) << "Could not send zmq header for fnum " << fnum << " and streamer " << index;
}
memcpy(completeBuffer + ((generalData->imageSize) * adcConfigured),
buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
(uint32_t)(*((uint32_t*)buf)) );
if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete)) {
FILE_LOG(logERROR) << "Could not send zmq data for fnum " << fnum << " and streamer " << index;
LOG(logERROR) << "Could not send zmq data for fnum " << fnum << " and streamer " << index;
}
}
@ -204,11 +204,11 @@ void DataStreamer::ProcessAnImage(char* buf) {
if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)),
generalData->nPixelsX, generalData->nPixelsY, false)) {// new size possibly from callback
FILE_LOG(logERROR) << "Could not send zmq header for fnum " << fnum << " and streamer " << index;
LOG(logERROR) << "Could not send zmq header for fnum " << fnum << " and streamer " << index;
}
if (!zmqSocket->SendData(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
(uint32_t)(*((uint32_t*)buf)) )) {// new size possibly from callback
FILE_LOG(logERROR) << "Could not send zmq data for fnum " << fnum << " and streamer " << index;
LOG(logERROR) << "Could not send zmq data for fnum " << fnum << " and streamer " << index;
}
}
}

View File

@ -11,7 +11,7 @@
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <unistd.h>
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth):
index(ind),
@ -22,20 +22,20 @@ Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth):
fifoDepth(depth),
status_fifoBound(0),
status_fifoFree(depth){
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
LOG(logDEBUG3) << __SHORT_AT__ << " called";
CreateFifos(fifoItemSize);
}
Fifo::~Fifo() {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
LOG(logDEBUG3) << __SHORT_AT__ << " called";
DestroyFifos();
}
void Fifo::CreateFifos(uint32_t fifoItemSize) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
LOG(logDEBUG3) << __SHORT_AT__ << " called";
//destroy if not already
DestroyFifos();
@ -55,7 +55,7 @@ void Fifo::CreateFifos(uint32_t fifoItemSize) {
for (size_t i = 0; i < mem_len; i += pagesize) {
strcpy(memory + i, "memory");
}
FILE_LOG(logDEBUG) << "Memory Allocated " << index << ": " << (double)mem_len/(double)(1024 * 1024) << " MB";
LOG(logDEBUG) << "Memory Allocated " << index << ": " << (double)mem_len/(double)(1024 * 1024) << " MB";
{ //push free addresses into fifoFree fifo
char* buffer = memory;
@ -65,12 +65,12 @@ void Fifo::CreateFifos(uint32_t fifoItemSize) {
buffer += fifoItemSize;
}
}
FILE_LOG(logINFO) << "Fifo " << index << " reconstructed Depth (rx_fifodepth): " << fifoFree->getDataValue();
LOG(logINFO) << "Fifo " << index << " reconstructed Depth (rx_fifodepth): " << fifoFree->getDataValue();
}
void Fifo::DestroyFifos(){
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
LOG(logDEBUG3) << __SHORT_AT__ << " called";
if(memory) {
free(memory);

View File

@ -43,7 +43,7 @@ void File::resetSubFileIndex(){
}
void File::PrintMembers(TLogLevel level) {
FILE_LOG(level) << "\nGeneral Writer Variables:" << std::endl
LOG(level) << "\nGeneral Writer Variables:" << std::endl
<< "Index: " << index << std::endl
<< "Max Frames Per File: " << *maxFramesPerFile << std::endl
<< "Number of Detectors in x dir: " << numDetX << std::endl

View File

@ -119,7 +119,7 @@ class File : private virtual slsDetectorDefs {
* @param ny number of pixels in y direction
*/
virtual void SetNumberofPixels(uint32_t nx, uint32_t ny) {
FILE_LOG(logERROR) << "This is a generic function SetNumberofPixels that "
LOG(logERROR) << "This is a generic function SetNumberofPixels that "
"should be overloaded by a derived class";
}
@ -130,7 +130,7 @@ class File : private virtual slsDetectorDefs {
* @param numf number of images caught
*/
virtual void EndofAcquisition(bool anyPacketsCaught, uint64_t numf) {
FILE_LOG(logERROR) << "This is a generic function EndofAcquisition that "
LOG(logERROR) << "This is a generic function EndofAcquisition that "
"should be overloaded by a derived class";
}

View File

@ -139,7 +139,7 @@ public:
* @param i ROI
*/
virtual void SetROI(slsDetectorDefs::ROI i) {
FILE_LOG(logERROR) << "SetROI is a generic function that should be overloaded by a derived class";
LOG(logERROR) << "SetROI is a generic function that should be overloaded by a derived class";
};
/**
@ -149,7 +149,7 @@ public:
* @returns adc configured
*/
virtual int GetAdcConfigured(int index, slsDetectorDefs::ROI i) const{
FILE_LOG(logERROR) << "GetAdcConfigured is a generic function that should be overloaded by a derived class";
LOG(logERROR) << "GetAdcConfigured is a generic function that should be overloaded by a derived class";
return 0;
};
@ -159,7 +159,7 @@ public:
* @param tgEnable true if 10GbE is enabled, else false
*/
virtual void SetDynamicRange(int dr, bool tgEnable) {
FILE_LOG(logERROR) << "SetDynamicRange is a generic function that should be overloaded by a derived class";
LOG(logERROR) << "SetDynamicRange is a generic function that should be overloaded by a derived class";
};
/**
@ -168,7 +168,7 @@ public:
* @param dr dynamic range
*/
virtual void SetTenGigaEnable(bool tgEnable, int dr) {
FILE_LOG(logERROR) << "SetTenGigaEnable is a generic function that should be overloaded by a derived class";
LOG(logERROR) << "SetTenGigaEnable is a generic function that should be overloaded by a derived class";
};
/**
@ -178,7 +178,7 @@ public:
* @param q quad enable
*/
virtual void SetGapPixelsEnable(bool b, int dr, bool q) {
FILE_LOG(logERROR) << "SetGapPixelsEnable is a generic function that should be overloaded by a derived class";
LOG(logERROR) << "SetGapPixelsEnable is a generic function that should be overloaded by a derived class";
};
/**
@ -188,7 +188,7 @@ public:
* @returns true or false for odd starting packet number
*/
virtual bool SetOddStartingPacket(int index, char* packetData) {
FILE_LOG(logERROR) << "SetOddStartingPacket is a generic function that should be overloaded by a derived class";
LOG(logERROR) << "SetOddStartingPacket is a generic function that should be overloaded by a derived class";
return false;
};
@ -202,7 +202,7 @@ public:
* @returns analog data bytes
*/
virtual int setImageSize(uint32_t a, uint32_t as, uint32_t ds, bool t, slsDetectorDefs::readoutMode) {
FILE_LOG(logERROR) << "setImageSize is a generic function that should be overloaded by a derived class";
LOG(logERROR) << "setImageSize is a generic function that should be overloaded by a derived class";
return 0;
};
@ -211,7 +211,7 @@ public:
* @param n number of interfaces
*/
virtual void SetNumberofInterfaces(const int n) {
FILE_LOG(logERROR) << "SetNumberofInterfaces is a generic function that should be overloaded by a derived class";
LOG(logERROR) << "SetNumberofInterfaces is a generic function that should be overloaded by a derived class";
}
/**
@ -220,36 +220,36 @@ public:
* @param dr dynamic range
*/
virtual void SetNumberofCounters(const int n, const int dr) {
FILE_LOG(logERROR) << "SetNumberofCounters is a generic function that should be overloaded by a derived class";
LOG(logERROR) << "SetNumberofCounters is a generic function that should be overloaded by a derived class";
}
/**
* Print all variables
*/
virtual void Print(TLogLevel level = logDEBUG1) const {
FILE_LOG(level) << "\n\nDetector Data Variables:";
FILE_LOG(level) << "myDetectorType: " << sls::ToString(myDetectorType);
FILE_LOG(level) << "Pixels X: " << nPixelsX;
FILE_LOG(level) << "Pixels Y: " << nPixelsY;
FILE_LOG(level) << "Header Size in Packet: " << headerSizeinPacket;
FILE_LOG(level) << "Data Size: " << dataSize;
FILE_LOG(level) << "Packet Size: " << packetSize;
FILE_LOG(level) << "Packets per Frame: " << packetsPerFrame;
FILE_LOG(level) << "Image Size: " << imageSize;
FILE_LOG(level) << "Frame Index Mask: " << frameIndexMask;
FILE_LOG(level) << "Frame Index Offset: " << frameIndexOffset;
FILE_LOG(level) << "Packet Index Mask: " << packetIndexMask;
FILE_LOG(level) << "Packet Index Offset: " << packetIndexOffset;
FILE_LOG(level) << "Max Frames Per File: " << maxFramesPerFile;
FILE_LOG(level) << "Fifo Buffer Header Size: " << fifoBufferHeaderSize;
FILE_LOG(level) << "Default Fifo Depth: " << defaultFifoDepth;
FILE_LOG(level) << "Threads Per Receiver: " << threadsPerReceiver;
FILE_LOG(level) << "Header Packet Size: " << headerPacketSize;
FILE_LOG(level) << "Complete Pixels X: " << nPixelsXComplete;
FILE_LOG(level) << "Complete Pixels Y: " << nPixelsYComplete;
FILE_LOG(level) << "Complete Image Size: " << imageSizeComplete;
FILE_LOG(level) << "Standard Header: " << standardheader;
FILE_LOG(level) << "UDP Socket Buffer Size: " << defaultUdpSocketBufferSize;
LOG(level) << "\n\nDetector Data Variables:";
LOG(level) << "myDetectorType: " << sls::ToString(myDetectorType);
LOG(level) << "Pixels X: " << nPixelsX;
LOG(level) << "Pixels Y: " << nPixelsY;
LOG(level) << "Header Size in Packet: " << headerSizeinPacket;
LOG(level) << "Data Size: " << dataSize;
LOG(level) << "Packet Size: " << packetSize;
LOG(level) << "Packets per Frame: " << packetsPerFrame;
LOG(level) << "Image Size: " << imageSize;
LOG(level) << "Frame Index Mask: " << frameIndexMask;
LOG(level) << "Frame Index Offset: " << frameIndexOffset;
LOG(level) << "Packet Index Mask: " << packetIndexMask;
LOG(level) << "Packet Index Offset: " << packetIndexOffset;
LOG(level) << "Max Frames Per File: " << maxFramesPerFile;
LOG(level) << "Fifo Buffer Header Size: " << fifoBufferHeaderSize;
LOG(level) << "Default Fifo Depth: " << defaultFifoDepth;
LOG(level) << "Threads Per Receiver: " << threadsPerReceiver;
LOG(level) << "Header Packet Size: " << headerPacketSize;
LOG(level) << "Complete Pixels X: " << nPixelsXComplete;
LOG(level) << "Complete Pixels Y: " << nPixelsYComplete;
LOG(level) << "Complete Image Size: " << imageSizeComplete;
LOG(level) << "Standard Header: " << standardheader;
LOG(level) << "UDP Socket Buffer Size: " << defaultUdpSocketBufferSize;
};
};
@ -362,12 +362,12 @@ private:
adc = ((((i.xmax) + (i.xmin))/2)/
(nChan * nChipsPerAdc));
if((adc < 0) || (adc > 4)) {
FILE_LOG(logWARNING) << index << ": Deleting ROI. "
LOG(logWARNING) << index << ": Deleting ROI. "
"Adc value should be between 0 and 4";
adc = -1;
}
}
FILE_LOG(logINFO) << "Adc Configured: " << adc;
LOG(logINFO) << "Adc Configured: " << adc;
return adc;
};
@ -571,14 +571,14 @@ public:
}
ncounters = n;
nPixelsX = NCHAN * ncounters;
FILE_LOG(logINFO) << "nPixelsX: " << nPixelsX;
LOG(logINFO) << "nPixelsX: " << nPixelsX;
imageSize = nPixelsX * nPixelsY * ((dr > 16) ? 4 : // 32 bit
((dr > 8) ? 2 : // 16 bit
((dr > 4) ? 0.5 : // 4 bit
0.125))); // 1 bit
dataSize = imageSize / packetsPerFrame;
packetSize = headerSizeinPacket + dataSize;
FILE_LOG(logINFO) << "PacketSize: " << packetSize;
LOG(logINFO) << "PacketSize: " << packetSize;
}
/**
@ -593,7 +593,7 @@ public:
0.125))); // 1 bit
dataSize = imageSize / packetsPerFrame;
packetSize = headerSizeinPacket + dataSize;
FILE_LOG(logINFO) << "PacketSize: " << packetSize;
LOG(logINFO) << "PacketSize: " << packetSize;
}
};
@ -677,7 +677,7 @@ public:
}
}
adatabytes = nachans * NUM_BYTES_PER_ANALOG_CHANNEL * as;
FILE_LOG(logDEBUG1) << " Number of Analog Channels:" << nachans
LOG(logDEBUG1) << " Number of Analog Channels:" << nachans
<< " Databytes: " << adatabytes;
}
// digital channels
@ -685,10 +685,10 @@ public:
f == slsDetectorDefs::ANALOG_AND_DIGITAL) {
ndchans = NCHAN_DIGITAL;
ddatabytes = (sizeof(uint64_t) * ds);
FILE_LOG(logDEBUG1) << "Number of Digital Channels:" << ndchans
LOG(logDEBUG1) << "Number of Digital Channels:" << ndchans
<< " Databytes: " << ddatabytes;
}
FILE_LOG(logDEBUG1) << "Total Number of Channels:" << nachans + ndchans
LOG(logDEBUG1) << "Total Number of Channels:" << nachans + ndchans
<< " Databytes: " << adatabytes + ddatabytes;
nPixelsX = nachans + ndchans;
@ -761,7 +761,7 @@ public:
nrows = 2;
}
nPixelsY = as / 25 * nrows;
FILE_LOG(logINFO) << "Number of Pixels: [" << nPixelsX << ", " << nPixelsY << "]";
LOG(logINFO) << "Number of Pixels: [" << nPixelsX << ", " << nPixelsY << "]";
// 10G
@ -777,7 +777,7 @@ public:
packetSize = headerSizeinPacket + dataSize;
packetsPerFrame = ceil((double)imageSize / (double)dataSize);
FILE_LOG(logDEBUG) << "Databytes: " << imageSize;
LOG(logDEBUG) << "Databytes: " << imageSize;
return imageSize;
}

View File

@ -96,13 +96,13 @@ void HDF5File::PrintMembers(TLogLevel level) {
File::PrintMembers();
UpdateDataType();
if (datatype == PredType::STD_U8LE) {
FILE_LOG(level) << "Data Type: 4 or 8";
LOG(level) << "Data Type: 4 or 8";
} else if (datatype == PredType::STD_U16LE) {
FILE_LOG(level) << "Data Type: 16";
LOG(level) << "Data Type: 16";
} else if (datatype == PredType::STD_U32LE) {
FILE_LOG(level) << "Data Type: 32";
LOG(level) << "Data Type: 32";
} else {
FILE_LOG(logERROR) << "unknown data type";
LOG(logERROR) << "unknown data type";
}
}
@ -151,7 +151,7 @@ void HDF5File::CreateFile() {
parameterNames, parameterDataTypes);
if(!(*silentMode)) {
FILE_LOG(logINFO) << *udpPortNumber << ": HDF5 File created: " << currentFileName;
LOG(logINFO) << *udpPortNumber << ": HDF5 File created: " << currentFileName;
}
}
@ -209,7 +209,7 @@ void HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t
HDF5FileStatic::ExtendDataset(index, dataspace, dataset,
dataspace_para, dataset_para, *numImages);
if (!(*silentMode)) {
FILE_LOG(logINFO) << index << " Extending HDF5 dataset by " <<
LOG(logINFO) << index << " Extending HDF5 dataset by " <<
extNumImages << ", Total x Dimension: " << (extNumImages + *numImages);
}
extNumImages += *numImages;
@ -241,7 +241,7 @@ void HDF5File::CreateMasterFile(bool mfwenable, masterAttributes& attr) {
masterFileName = HDF5FileStatic::CreateMasterFileName(*filePath,
*fileNamePrefix, *fileIndex);
if(!(*silentMode)) {
FILE_LOG(logINFO) << "Master File: " << masterFileName;
LOG(logINFO) << "Master File: " << masterFileName;
}
std::lock_guard<std::mutex> lock(mutex);
attr.version = HDF5_WRITER_VERSION;
@ -277,7 +277,7 @@ void HDF5File::CreateVirtualFile(uint64_t numf) {
std::string vname = HDF5FileStatic::CreateVirtualFileName(*filePath, *fileNamePrefix, *fileIndex);
if(!(*silentMode)) {
FILE_LOG(logINFO) << "Virtual File: " << vname;
LOG(logINFO) << "Virtual File: " << vname;
}
HDF5FileStatic::CreateVirtualDataFile(vname,
virtualfd, masterFileName,

View File

@ -108,7 +108,7 @@ public:
fd = 0;
}
} catch(const Exception& error) {
FILE_LOG(logERROR) << "Could not close HDF5 handles of index " << ind;
LOG(logERROR) << "Could not close HDF5 handles of index " << ind;
error.printErrorStack();
}
}
@ -126,7 +126,7 @@ public:
fd = 0;
}
} catch(const Exception& error) {
FILE_LOG(logERROR) << "Could not close master HDF5 handles";
LOG(logERROR) << "Could not close master HDF5 handles";
error.printErrorStack();
}
}
@ -140,7 +140,7 @@ public:
{
if(fd) {
if (H5Fclose(fd) < 0 ) {
FILE_LOG(logERROR) << "Could not close virtual HDF5 handles";
LOG(logERROR) << "Could not close virtual HDF5 handles";
}
fd = 0;
}
@ -173,7 +173,7 @@ public:
memspace.close();
}
catch(const Exception& error){
FILE_LOG(logERROR) << "Could not write to file in object " << ind;
LOG(logERROR) << "Could not write to file in object " << ind;
error.printErrorStack();
throw RuntimeError("Could not write to file in object " + std::to_string(ind));
}
@ -659,7 +659,7 @@ public:
std::string srcFileName = HDF5FileStatic::CreateFileName(fpath, fnameprefix, findex,
j, dindex, numunits, i);
FILE_LOG(logERROR) << srcFileName;
LOG(logERROR) << srcFileName;
// find relative path
std::string relative_srcFileName = srcFileName;
{
@ -774,17 +774,17 @@ public:
throw RuntimeError("Invalid rank. Options: 2 or 3");
}
if (datatype == PredType::STD_U16LE) {
FILE_LOG(logINFO) << "datatype:16";
LOG(logINFO) << "datatype:16";
} else if (datatype == PredType::STD_U32LE) {
FILE_LOG(logINFO) << "datatype:32";
LOG(logINFO) << "datatype:32";
} else if (datatype == PredType::STD_U64LE) {
FILE_LOG(logINFO) << "datatype:64";
LOG(logINFO) << "datatype:64";
} else if (datatype == PredType::STD_U8LE) {
FILE_LOG(logINFO) << "datatype:8";
LOG(logINFO) << "datatype:8";
} else {
throw RuntimeError("Unknown datatype:" + std::to_string(datatype));
}
FILE_LOG(logINFO) << "owenable:" << (owenable?1:0) << std::endl
LOG(logINFO) << "owenable:" << (owenable?1:0) << std::endl
<< "oldFileName:" << oldFileName << std::endl
<< "oldDatasetName:" << oldDatasetName << std::endl
<< "newFileName:" << newFileName << std::endl

File diff suppressed because it is too large Load Diff

View File

@ -56,7 +56,7 @@ Listener::Listener(int ind, detectorType dtype, Fifo* f, std::atomic<runStatus>*
numFramesStatistic(0),
oddStartingPacket(true)
{
FILE_LOG(logDEBUG) << "Listener " << ind << " created";
LOG(logDEBUG) << "Listener " << ind << " created";
}
@ -137,7 +137,7 @@ void Listener::RecordFirstIndex(uint64_t fnum) {
if(!(*silentMode)) {
if (!index) {
FILE_LOG(logINFOBLUE) << index <<
LOG(logINFOBLUE) << index <<
" First Index: " << firstIndex;
}
}
@ -160,7 +160,7 @@ void Listener::CreateUDPSockets() {
(*eth) = "";
}
if (!(*eth).length()) {
FILE_LOG(logWARNING) << "eth is empty. Listening to all";
LOG(logWARNING) << "eth is empty. Listening to all";
}
ShutDownUDPSocket();
@ -169,7 +169,7 @@ void Listener::CreateUDPSockets() {
udpSocket = sls::make_unique<SELECTED_SOCKET>(*udpPortNumber, genericSocket::UDP,
generalData->packetSize, ((*eth).length() ? (*eth).c_str() : nullptr), generalData->headerPacketSize,
*udpSocketBufferSize);
FILE_LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber;
LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber;
} catch (...) {
throw sls::RuntimeError("Could not create UDP socket on port "+ std::to_string(*udpPortNumber));
}
@ -187,7 +187,7 @@ void Listener::ShutDownUDPSocket() {
if(udpSocket){
udpSocketAlive = false;
udpSocket->ShutDownSocket();
FILE_LOG(logINFO) << "Shut down of UDP port " << *udpPortNumber;
LOG(logINFO) << "Shut down of UDP port " << *udpPortNumber;
fflush(stdout);
// wait only if the threads have started as it is the threads that
//give a post to semaphore(at stopListening)
@ -199,7 +199,7 @@ void Listener::ShutDownUDPSocket() {
void Listener::CreateDummySocketForUDPSocketBufferSize(int64_t s) {
FILE_LOG(logINFO) << "Testing UDP Socket Buffer size " << s << " with test port " << *udpPortNumber;
LOG(logINFO) << "Testing UDP Socket Buffer size " << s << " with test port " << *udpPortNumber;
if (!(*activated)) {
*actualUDPSocketBufferSize = (s*2);
@ -243,12 +243,12 @@ void Listener::ThreadExecution() {
int rc = 0;
fifo->GetNewAddress(buffer);
FILE_LOG(logDEBUG5) << "Listener " << index << ", "
LOG(logDEBUG5) << "Listener " << index << ", "
"pop 0x" << std::hex << (void*)(buffer) << std::dec << ":" << buffer;
//udpsocket doesnt exist
if (*activated && !udpSocketAlive && !carryOverFlag) {
//FILE_LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier";
//LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier";
(*((uint32_t*)buffer)) = 0;
StopListening(buffer);
return;
@ -272,7 +272,7 @@ void Listener::ThreadExecution() {
// discarding image
else if (rc < 0) {
FILE_LOG(logDEBUG) << index << " discarding fnum:" << currentFrameIndex;
LOG(logDEBUG) << index << " discarding fnum:" << currentFrameIndex;
fifo->FreeAddress(buffer);
currentFrameIndex++;
return;
@ -303,8 +303,8 @@ void Listener::StopListening(char* buf) {
StopRunning();
sem_post(&semaphore_socket);
FILE_LOG(logDEBUG1) << index << ": Listening Packets (" << *udpPortNumber << ") : " << numPacketsCaught;
FILE_LOG(logDEBUG1) << index << ": Listening Completed";
LOG(logDEBUG1) << index << ": Listening Packets (" << *udpPortNumber << ") : " << numPacketsCaught;
LOG(logDEBUG1) << index << ": Listening Completed";
}
@ -356,7 +356,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
//look for carry over
if (carryOverFlag) {
FILE_LOG(logDEBUG3) << index << "carry flag";
LOG(logDEBUG3) << index << "carry flag";
//check if its the current image packet
// -------------------------- new header ----------------------------------------------------------------------
if (standardheader) {
@ -371,7 +371,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
//------------------------------------------------------------------------------------------------------------
if (fnum != currentFrameIndex) {
if (fnum < currentFrameIndex) {
FILE_LOG(logERROR) << "(Weird), With carry flag: Frame number " <<
LOG(logERROR) << "(Weird), With carry flag: Frame number " <<
fnum << " less than current frame number " << currentFrameIndex;
carryOverFlag = false;
return 0;
@ -492,7 +492,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
// Eiger Firmware in a weird state
if (myDetectorType == EIGER && fnum == 0) {
FILE_LOG(logERROR) << "[" << *udpPortNumber << "]: Got Frame Number "
LOG(logERROR) << "[" << *udpPortNumber << "]: Got Frame Number "
"Zero from Firmware. Discarding Packet";
numPacketsCaught--;
return 0;
@ -500,14 +500,14 @@ uint32_t Listener::ListenToAnImage(char* buf) {
lastCaughtFrameIndex = fnum;
FILE_LOG(logDEBUG5) << "Listening " << index << ": currentfindex:" << currentFrameIndex <<
LOG(logDEBUG5) << "Listening " << index << ": currentfindex:" << currentFrameIndex <<
", fnum:" << fnum << ", pnum:" << pnum << ", numpackets:" << numpackets;
if (!startedFlag)
RecordFirstIndex(fnum);
if (pnum >= pperFrame ) {
FILE_LOG(logERROR) << "Bad packet " << pnum <<
LOG(logERROR) << "Bad packet " << pnum <<
"(fnum: " << fnum << "), throwing away. "
"Packets caught so far: " << numpackets;
return 0; // bad packet
@ -587,7 +587,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
void Listener::PrintFifoStatistics() {
FILE_LOG(logDEBUG1) << "numFramesStatistic:" << numFramesStatistic << " numPacketsStatistic:" << numPacketsStatistic;
LOG(logDEBUG1) << "numFramesStatistic:" << numFramesStatistic << " numPacketsStatistic:" << numPacketsStatistic;
//calculate packet loss
int64_t loss = (numFramesStatistic*(generalData->packetsPerFrame)) - numPacketsStatistic;
@ -595,7 +595,7 @@ void Listener::PrintFifoStatistics() {
numFramesStatistic = 0;
const auto color = loss ? logINFORED : logINFOGREEN;
FILE_LOG(color) << "[" << *udpPortNumber << "]: "
LOG(color) << "[" << *udpPortNumber << "]: "
"Packet_Loss:" << loss <<
" Used_Fifo_Max_Level:" << fifo->GetMaxLevelForFifoBound() <<
" \tFree_Slots_Min_Level:" << fifo->GetMinLevelForFifoFree() <<

View File

@ -7,7 +7,8 @@
#include <cstring>
#include <iostream>
#include <sys/wait.h> //wait
#include <syscall.h> //tid
#include <sys/syscall.h>
#include <unistd.h>
#include <semaphore.h>
/** Define Colors to print data call back in different colors for different recievers */
@ -45,7 +46,7 @@ void printHelp() {
* \returns ignored
*/
int StartAcq(std::string filepath, std::string filename, uint64_t fileindex, uint32_t datasize, void*p){
FILE_LOG(logINFOBLUE) << "#### StartAcq: filepath:" << filepath << " filename:" << filename << " fileindex:" << fileindex << " datasize:" << datasize << " ####";
LOG(logINFOBLUE) << "#### StartAcq: filepath:" << filepath << " filename:" << filename << " fileindex:" << fileindex << " datasize:" << datasize << " ####";
return 0;
}
@ -55,7 +56,7 @@ int StartAcq(std::string filepath, std::string filename, uint64_t fileindex, uin
* @param p pointer to object
*/
void AcquisitionFinished(uint64_t frames, void*p){
FILE_LOG(logINFOBLUE) << "#### AcquisitionFinished: frames:" << frames << " ####";
LOG(logINFOBLUE) << "#### AcquisitionFinished: frames:" << frames << " ####";
}
@ -194,7 +195,7 @@ int main(int argc, char *argv[]) {
try {
receiver = sls::make_unique<Receiver>(startTCPPort + i);
} catch (...) {
FILE_LOG(logINFOBLUE) << "Exiting Child Process [ Tid: " << syscall(SYS_gettid) << " ]";
LOG(logINFOBLUE) << "Exiting Child Process [ Tid: " << syscall(SYS_gettid) << " ]";
throw;
}
/** - register callbacks. remember to set file write enable to 0 (using the client)

View File

@ -12,7 +12,8 @@
#include <map>
#include <sstream>
#include <string>
#include <syscall.h>
#include <sys/syscall.h>
#include <unistd.h>
Receiver::~Receiver() = default;
@ -63,7 +64,7 @@ Receiver::Receiver(int argc, char *argv[]):
case 'v':
std::cout << "SLS Receiver Version: " << GITBRANCH << " (0x" << std::hex << APIRECEIVER << ")" << std::endl;
FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
exit(EXIT_SUCCESS);
case 'h':
@ -84,7 +85,7 @@ Receiver::Receiver(int argc, char *argv[]):
// set effective id if provided
if (userid != static_cast<uid_t>(-1)) {
if (geteuid() == userid) {
FILE_LOG(logINFO) << "Process already has the same Effective UID " << userid;
LOG(logINFO) << "Process already has the same Effective UID " << userid;
} else {
if (seteuid(userid) != 0) {
std::ostringstream oss;
@ -96,7 +97,7 @@ Receiver::Receiver(int argc, char *argv[]):
oss << "Could not set Effective UID to " << userid << ". Got " << geteuid();
throw sls::RuntimeError(oss.str());
}
FILE_LOG(logINFO) << "Process Effective UID changed to " << userid;
LOG(logINFO) << "Process Effective UID changed to " << userid;
}
}

View File

@ -5,7 +5,8 @@
#include "container_utils.h"
#include <csignal> //SIGINT
#include <syscall.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <semaphore.h>
sem_t semaphore;
@ -19,7 +20,7 @@ int main(int argc, char *argv[]) {
sem_init(&semaphore,1,0);
FILE_LOG(logINFOBLUE) << "Created [ Tid: " << syscall(SYS_gettid) << " ]";
LOG(logINFOBLUE) << "Created [ Tid: " << syscall(SYS_gettid) << " ]";
// Catch signal SIGINT to close files and call destructors properly
struct sigaction sa;
@ -27,7 +28,7 @@ int main(int argc, char *argv[]) {
sa.sa_handler=sigInterruptHandler; // handler function
sigemptyset(&sa.sa_mask); // dont block additional signals during invocation of handler
if (sigaction(SIGINT, &sa, nullptr) == -1) {
FILE_LOG(logERROR) << "Could not set handler function for SIGINT";
LOG(logERROR) << "Could not set handler function for SIGINT";
}
@ -38,22 +39,22 @@ int main(int argc, char *argv[]) {
asa.sa_handler=SIG_IGN; // handler function
sigemptyset(&asa.sa_mask); // dont block additional signals during invocation of handler
if (sigaction(SIGPIPE, &asa, nullptr) == -1) {
FILE_LOG(logERROR) << "Could not set handler function for SIGPIPE";
LOG(logERROR) << "Could not set handler function for SIGPIPE";
}
std::unique_ptr<Receiver> receiver = nullptr;
try {
receiver = sls::make_unique<Receiver>(argc, argv);
} catch (...) {
FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
throw;
}
FILE_LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]";
LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]";
sem_wait(&semaphore);
sem_destroy(&semaphore);
FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
FILE_LOG(logINFO) << "Exiting Receiver";
LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
LOG(logINFO) << "Exiting Receiver";
return 0;
}

View File

@ -7,15 +7,15 @@
#include "ThreadObject.h"
#include "container_utils.h"
#include <iostream>
#include <syscall.h>
#include <sys/syscall.h>
#include <unistd.h>
ThreadObject::ThreadObject(int threadIndex, std::string threadType)
: index(threadIndex), type(threadType) {
FILE_LOG(logDEBUG) << type << " thread created: " << index;
LOG(logDEBUG) << type << " thread created: " << index;
sem_init(&semaphore,1,0);
@ -38,8 +38,8 @@ ThreadObject::~ThreadObject() {
void ThreadObject::RunningThread() {
FILE_LOG(logINFOBLUE) << "Created [ " << type << "Thread " << index << ", Tid: " << syscall(SYS_gettid) << "]";
FILE_LOG(logDEBUG) << type << " thread " << index << " created successfully.";
LOG(logINFOBLUE) << "Created [ " << type << "Thread " << index << ", Tid: " << syscall(SYS_gettid) << "]";
LOG(logDEBUG) << type << " thread " << index << " created successfully.";
while(true) {
while(IsRunning()) {
@ -52,8 +52,8 @@ void ThreadObject::RunningThread() {
}
}
FILE_LOG(logDEBUG) << type << " thread with index " << index << " destroyed successfully.";
FILE_LOG(logINFOBLUE) << "Exiting [ " << type << " Thread " << index << ", Tid: " << syscall(SYS_gettid) << "]";
LOG(logDEBUG) << type << " thread with index " << index << " destroyed successfully.";
LOG(logINFOBLUE) << "Exiting [ " << type << " Thread " << index << ", Tid: " << syscall(SYS_gettid) << "]";
}
@ -67,10 +67,10 @@ void ThreadObject::SetThreadPriority(int priority) {
param.sched_priority = priority;
if (pthread_setschedparam(threadObject->native_handle(), SCHED_FIFO, &param) == EPERM) {
if (index == 0) {
FILE_LOG(logWARNING) << "Could not prioritize " << type << " thread. "
LOG(logWARNING) << "Could not prioritize " << type << " thread. "
"(No Root Privileges?)";
}
} else {
FILE_LOG(logINFO) << "Priorities set - " << type << ": " << priority;
LOG(logINFO) << "Priorities set - " << type << ": " << priority;
}
}