mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 16:20:03 +02:00
project wide nullptr fix
This commit is contained in:
parent
80a1a3d796
commit
49f71ffca7
@ -187,7 +187,7 @@ int main(int argc, char *argv[]) {
|
|||||||
sa.sa_flags=0; // no flags
|
sa.sa_flags=0; // no flags
|
||||||
sa.sa_handler=sigInterruptHandler; // handler function
|
sa.sa_handler=sigInterruptHandler; // handler function
|
||||||
sigemptyset(&sa.sa_mask); // dont block additional signals during invocation of handler
|
sigemptyset(&sa.sa_mask); // dont block additional signals during invocation of handler
|
||||||
if (sigaction(SIGINT, &sa, NULL) == -1) {
|
if (sigaction(SIGINT, &sa, nullptr) == -1) {
|
||||||
cprintf(RED, "Could not set handler function for SIGINT\n");
|
cprintf(RED, "Could not set handler function for SIGINT\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ int main(int argc, char *argv[]) {
|
|||||||
asa.sa_flags=0; // no flags
|
asa.sa_flags=0; // no flags
|
||||||
asa.sa_handler=SIG_IGN; // handler function
|
asa.sa_handler=SIG_IGN; // handler function
|
||||||
sigemptyset(&asa.sa_mask); // dont block additional signals during invocation of handler
|
sigemptyset(&asa.sa_mask); // dont block additional signals during invocation of handler
|
||||||
if (sigaction(SIGPIPE, &asa, NULL) == -1) {
|
if (sigaction(SIGPIPE, &asa, nullptr) == -1) {
|
||||||
cprintf(RED, "Could not set handler function for SIGPIPE\n");
|
cprintf(RED, "Could not set handler function for SIGPIPE\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,16 +236,16 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
/** - Call back for start acquisition */
|
/** - Call back for start acquisition */
|
||||||
cprintf(BLUE, "Registering StartAcq()\n");
|
cprintf(BLUE, "Registering StartAcq()\n");
|
||||||
receiver->registerCallBackStartAcquisition(StartAcq, NULL);
|
receiver->registerCallBackStartAcquisition(StartAcq, nullptr);
|
||||||
|
|
||||||
/** - Call back for acquisition finished */
|
/** - Call back for acquisition finished */
|
||||||
cprintf(BLUE, "Registering AcquisitionFinished()\n");
|
cprintf(BLUE, "Registering AcquisitionFinished()\n");
|
||||||
receiver->registerCallBackAcquisitionFinished(AcquisitionFinished, NULL);
|
receiver->registerCallBackAcquisitionFinished(AcquisitionFinished, nullptr);
|
||||||
|
|
||||||
/* - Call back for raw data */
|
/* - Call back for raw data */
|
||||||
cprintf(BLUE, "Registering GetData() \n");
|
cprintf(BLUE, "Registering GetData() \n");
|
||||||
if (withCallback == 1) receiver->registerCallBackRawDataReady(GetData,NULL);
|
if (withCallback == 1) receiver->registerCallBackRawDataReady(GetData,nullptr);
|
||||||
else if (withCallback == 2) receiver->registerCallBackRawDataModifyReady(GetData,NULL);
|
else if (withCallback == 2) receiver->registerCallBackRawDataModifyReady(GetData,nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ int main(int argc, char *argv[]) {
|
|||||||
sa.sa_flags=0; // no flags
|
sa.sa_flags=0; // no flags
|
||||||
sa.sa_handler=SIG_IGN; // handler function
|
sa.sa_handler=SIG_IGN; // handler function
|
||||||
sigemptyset(&sa.sa_mask); // dont block additional signals during invocation of handler
|
sigemptyset(&sa.sa_mask); // dont block additional signals during invocation of handler
|
||||||
if (sigaction(SIGINT, &sa, NULL) == -1) {
|
if (sigaction(SIGINT, &sa, nullptr) == -1) {
|
||||||
cprintf(RED, "Could not set handler function for SIGINT\n");
|
cprintf(RED, "Could not set handler function for SIGINT\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
/** - Parent process waits for all child processes to exit */
|
/** - Parent process waits for all child processes to exit */
|
||||||
for(;;) {
|
for(;;) {
|
||||||
pid_t childPid = waitpid (-1, NULL, 0);
|
pid_t childPid = waitpid (-1, nullptr, 0);
|
||||||
|
|
||||||
// no child closed
|
// no child closed
|
||||||
if (childPid == -1) {
|
if (childPid == -1) {
|
||||||
|
@ -103,7 +103,7 @@ void SharedMemory::RemoveSharedMemory() {
|
|||||||
|
|
||||||
|
|
||||||
void* SharedMemory::MapSharedMemory(size_t sz) {
|
void* SharedMemory::MapSharedMemory(size_t sz) {
|
||||||
void* addr = mmap(NULL, sz, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
void* addr = mmap(nullptr, sz, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
if (addr == MAP_FAILED) {
|
if (addr == MAP_FAILED) {
|
||||||
FILE_LOG(logERROR) << "Mapping shared memory " << name << " failed: " << strerror(errno);
|
FILE_LOG(logERROR) << "Mapping shared memory " << name << " failed: " << strerror(errno);
|
||||||
close(fd);
|
close(fd);
|
||||||
@ -120,7 +120,7 @@ std::string SharedMemory::ConstructSharedMemoryName(int multiId, int slsId) {
|
|||||||
// using environment path
|
// using environment path
|
||||||
std::string sEnvPath = "";
|
std::string sEnvPath = "";
|
||||||
char* envpath = getenv(SHM_ENV_NAME);
|
char* envpath = getenv(SHM_ENV_NAME);
|
||||||
if (envpath != NULL) {
|
if (envpath != nullptr) {
|
||||||
sEnvPath.assign(envpath);
|
sEnvPath.assign(envpath);
|
||||||
sEnvPath.insert(0,"_");
|
sEnvPath.insert(0,"_");
|
||||||
}
|
}
|
||||||
|
@ -2389,7 +2389,7 @@ std::string slsDetectorCommand::cmdTrimEn(int narg, char *args[], int action, in
|
|||||||
myDet->setTrimEn(ip, pos, detPos);
|
myDet->setTrimEn(ip, pos, detPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int npos = myDet->getTrimEn(NULL, detPos);
|
int npos = myDet->getTrimEn(nullptr, detPos);
|
||||||
if (npos != -1) {
|
if (npos != -1) {
|
||||||
sprintf(answer, "%d", npos);
|
sprintf(answer, "%d", npos);
|
||||||
int opos[npos];
|
int opos[npos];
|
||||||
@ -4601,7 +4601,7 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action,
|
|||||||
} else if (cmd == "programfpga") {
|
} else if (cmd == "programfpga") {
|
||||||
if (action == GET_ACTION)
|
if (action == GET_ACTION)
|
||||||
return std::string("cannot get");
|
return std::string("cannot get");
|
||||||
if (strstr(args[1], ".pof") == NULL)
|
if (strstr(args[1], ".pof") == nullptr)
|
||||||
return std::string("wrong usage: programming file should have .pof extension");
|
return std::string("wrong usage: programming file should have .pof extension");
|
||||||
std::string sval = std::string(args[1]);
|
std::string sval = std::string(args[1]);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
slsDetectorUsers::slsDetectorUsers(int& ret, int id) : myDetector(0), myCmd(0){
|
slsDetectorUsers::slsDetectorUsers(int& ret, int id) : myDetector(nullptr), myCmd(nullptr){
|
||||||
try {
|
try {
|
||||||
myDetector=new multiSlsDetector(id);
|
myDetector=new multiSlsDetector(id);
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
@ -11,14 +11,14 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
FILE* BinaryFile::masterfd = 0;
|
FILE* BinaryFile::masterfd = nullptr;
|
||||||
|
|
||||||
BinaryFile::BinaryFile(int ind, uint32_t* maxf,
|
BinaryFile::BinaryFile(int ind, uint32_t* maxf,
|
||||||
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable,
|
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable,
|
||||||
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
|
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
|
||||||
bool* smode):
|
bool* smode):
|
||||||
File(ind, maxf, nd, fname, fpath, findex, owenable, dindex, nunits, nf, dr, portno, smode),
|
File(ind, maxf, nd, fname, fpath, findex, owenable, dindex, nunits, nf, dr, portno, smode),
|
||||||
filefd(0),
|
filefd(nullptr),
|
||||||
numFramesInFile(0),
|
numFramesInFile(0),
|
||||||
numActualPacketsInFile(0)
|
numActualPacketsInFile(0)
|
||||||
{
|
{
|
||||||
|
@ -33,10 +33,10 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
|
|||||||
|
|
||||||
ThreadObject(ind),
|
ThreadObject(ind),
|
||||||
runningFlag(0),
|
runningFlag(0),
|
||||||
generalData(0),
|
generalData(nullptr),
|
||||||
fifo(f),
|
fifo(f),
|
||||||
myDetectorType(dtype),
|
myDetectorType(dtype),
|
||||||
file(0),
|
file(nullptr),
|
||||||
dataStreamEnable(dsEnable),
|
dataStreamEnable(dsEnable),
|
||||||
fileFormatType(ftype),
|
fileFormatType(ftype),
|
||||||
fileWriteEnable(fwenable),
|
fileWriteEnable(fwenable),
|
||||||
@ -45,7 +45,7 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
|
|||||||
streamingFrequency(freq),
|
streamingFrequency(freq),
|
||||||
streamingTimerInMs(timer),
|
streamingTimerInMs(timer),
|
||||||
currentFreqCount(0),
|
currentFreqCount(0),
|
||||||
tempBuffer(0),
|
tempBuffer(nullptr),
|
||||||
activated(act),
|
activated(act),
|
||||||
deactivatedPaddingEnable(depaden),
|
deactivatedPaddingEnable(depaden),
|
||||||
silentMode(sm),
|
silentMode(sm),
|
||||||
@ -144,7 +144,7 @@ void DataProcessor::ResetParametersforNewMeasurement(){
|
|||||||
|
|
||||||
if (tempBuffer) {
|
if (tempBuffer) {
|
||||||
delete [] tempBuffer;
|
delete [] tempBuffer;
|
||||||
tempBuffer = 0;
|
tempBuffer = nullptr;
|
||||||
}
|
}
|
||||||
if (*gapPixelsEnable) {
|
if (*gapPixelsEnable) {
|
||||||
tempBuffer = new char[generalData->imageSize];
|
tempBuffer = new char[generalData->imageSize];
|
||||||
@ -196,10 +196,10 @@ void DataProcessor::SetFileFormat(const fileFormat f) {
|
|||||||
if (file && file->GetFileType() != f) {
|
if (file && file->GetFileType() != f) {
|
||||||
//remember the pointer values before they are destroyed
|
//remember the pointer values before they are destroyed
|
||||||
int nd[MAX_DIMENSIONS];nd[0] = 0; nd[1] = 0;
|
int nd[MAX_DIMENSIONS];nd[0] = 0; nd[1] = 0;
|
||||||
uint32_t* maxf = 0;
|
uint32_t* maxf = nullptr;
|
||||||
char* fname=0; char* fpath=0; uint64_t* findex=0;
|
char* fname=nullptr; char* fpath=nullptr; uint64_t* findex=nullptr;
|
||||||
bool* owenable=0; int* dindex=0; int* nunits=0; uint64_t* nf = 0;
|
bool* owenable=nullptr; int* dindex=nullptr; int* nunits=nullptr; uint64_t* nf = nullptr;
|
||||||
uint32_t* dr = 0; uint32_t* port = 0;
|
uint32_t* dr = nullptr; uint32_t* port = nullptr;
|
||||||
file->GetMemberPointerValues(nd, maxf, fname, fpath, findex,
|
file->GetMemberPointerValues(nd, maxf, fname, fpath, findex,
|
||||||
owenable, dindex, nunits, nf, dr, port);
|
owenable, dindex, nunits, nf, dr, port);
|
||||||
//create file writer with same pointers
|
//create file writer with same pointers
|
||||||
@ -221,7 +221,7 @@ void DataProcessor::SetupFileWriter(bool fwe, int* nd, uint32_t* maxf,
|
|||||||
|
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
delete file; file = 0;
|
delete file; file = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileWriteEnable) {
|
if (fileWriteEnable) {
|
||||||
@ -246,7 +246,7 @@ void DataProcessor::SetupFileWriter(bool fwe, int* nd, uint32_t* maxf,
|
|||||||
// only the first file
|
// only the first file
|
||||||
int DataProcessor::CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t st,
|
int DataProcessor::CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t st,
|
||||||
uint64_t sp, uint64_t ap) {
|
uint64_t sp, uint64_t ap) {
|
||||||
if (file == NULL)
|
if (file == nullptr)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
file->CloseAllFiles();
|
file->CloseAllFiles();
|
||||||
if (file->CreateMasterFile(en, generalData->imageSize,
|
if (file->CreateMasterFile(en, generalData->imageSize,
|
||||||
@ -272,7 +272,7 @@ void DataProcessor::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) {
|
|||||||
|
|
||||||
|
|
||||||
void DataProcessor::ThreadExecution() {
|
void DataProcessor::ThreadExecution() {
|
||||||
char* buffer=0;
|
char* buffer=nullptr;
|
||||||
fifo->PopAddress(buffer);
|
fifo->PopAddress(buffer);
|
||||||
FILE_LOG(logDEBUG5) << "DataProcessor " << index << ", "
|
FILE_LOG(logDEBUG5) << "DataProcessor " << index << ", "
|
||||||
"pop 0x" << std::hex << (void*)(buffer) << std::dec << ":" << buffer;
|
"pop 0x" << std::hex << (void*)(buffer) << std::dec << ":" << buffer;
|
||||||
@ -492,8 +492,8 @@ void DataProcessor::InsertGapPixels(char* buf, uint32_t dr) {
|
|||||||
const uint32_t ny = generalData->nPixelsY;
|
const uint32_t ny = generalData->nPixelsY;
|
||||||
const uint32_t npx = nx * ny;
|
const uint32_t npx = nx * ny;
|
||||||
|
|
||||||
char* srcptr = 0;
|
char* srcptr = nullptr;
|
||||||
char* dstptr = 0;
|
char* dstptr = nullptr;
|
||||||
|
|
||||||
const uint32_t b1px = generalData->imageSize / (npx); // not double as not dealing with 4 bit mode
|
const uint32_t b1px = generalData->imageSize / (npx); // not double as not dealing with 4 bit mode
|
||||||
const uint32_t b2px = 2 * b1px;
|
const uint32_t b2px = 2 * b1px;
|
||||||
@ -515,8 +515,8 @@ void DataProcessor::InsertGapPixels(char* buf, uint32_t dr) {
|
|||||||
|
|
||||||
// vertical filling of values
|
// vertical filling of values
|
||||||
{
|
{
|
||||||
char* srcgp1 = 0; char* srcgp2 = 0; char* srcgp3 = 0;
|
char* srcgp1 = nullptr; char* srcgp2 = nullptr; char* srcgp3 = nullptr;
|
||||||
char* dstgp1 = 0; char* dstgp2 = 0; char* dstgp3 = 0;
|
char* dstgp1 = nullptr; char* dstgp2 = nullptr; char* dstgp3 = nullptr;
|
||||||
const uint32_t b3px = 3 * b1px;
|
const uint32_t b3px = 3 * b1px;
|
||||||
|
|
||||||
srcptr = tempBuffer + b1line;
|
srcptr = tempBuffer + b1line;
|
||||||
|
@ -19,9 +19,9 @@ DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, std::vector<ROI>* r,
|
|||||||
uint64_t* fi, int* fd, char* ajh) :
|
uint64_t* fi, int* fd, char* ajh) :
|
||||||
ThreadObject(ind),
|
ThreadObject(ind),
|
||||||
runningFlag(0),
|
runningFlag(0),
|
||||||
generalData(0),
|
generalData(nullptr),
|
||||||
fifo(f),
|
fifo(f),
|
||||||
zmqSocket(0),
|
zmqSocket(nullptr),
|
||||||
dynamicRange(dr),
|
dynamicRange(dr),
|
||||||
roi(r),
|
roi(r),
|
||||||
adcConfigured(-1),
|
adcConfigured(-1),
|
||||||
@ -32,7 +32,7 @@ DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, std::vector<ROI>* r,
|
|||||||
measurementStartedFlag(false),
|
measurementStartedFlag(false),
|
||||||
firstAcquisitionIndex(0),
|
firstAcquisitionIndex(0),
|
||||||
firstMeasurementIndex(0),
|
firstMeasurementIndex(0),
|
||||||
completeBuffer(0)
|
completeBuffer(nullptr)
|
||||||
{
|
{
|
||||||
if(ThreadObject::CreateThread() == FAIL)
|
if(ThreadObject::CreateThread() == FAIL)
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
@ -85,7 +85,7 @@ void DataStreamer::ResetParametersforNewMeasurement(char* fname){
|
|||||||
strcpy(fileNametoStream, fname);
|
strcpy(fileNametoStream, fname);
|
||||||
if (completeBuffer) {
|
if (completeBuffer) {
|
||||||
delete [] completeBuffer;
|
delete [] completeBuffer;
|
||||||
completeBuffer = 0;
|
completeBuffer = nullptr;
|
||||||
}
|
}
|
||||||
if (roi->size()) {
|
if (roi->size()) {
|
||||||
if (generalData->myDetectorType == GOTTHARD) {
|
if (generalData->myDetectorType == GOTTHARD) {
|
||||||
@ -131,7 +131,7 @@ void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srci
|
|||||||
uint32_t portnum = port + index;
|
uint32_t portnum = port + index;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
zmqSocket = new ZmqSocket(portnum, (strlen(srcip)?srcip:NULL));
|
zmqSocket = new ZmqSocket(portnum, (strlen(srcip)?srcip:nullptr));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
FILE_LOG(logERROR) << "Could not create Zmq socket on port " << portnum << " for Streamer " << index;
|
FILE_LOG(logERROR) << "Could not create Zmq socket on port " << portnum << " for Streamer " << index;
|
||||||
throw;
|
throw;
|
||||||
@ -143,13 +143,13 @@ void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srci
|
|||||||
void DataStreamer::CloseZmqSocket() {
|
void DataStreamer::CloseZmqSocket() {
|
||||||
if (zmqSocket) {
|
if (zmqSocket) {
|
||||||
delete zmqSocket;
|
delete zmqSocket;
|
||||||
zmqSocket = 0;
|
zmqSocket = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DataStreamer::ThreadExecution() {
|
void DataStreamer::ThreadExecution() {
|
||||||
char* buffer=0;
|
char* buffer=nullptr;
|
||||||
fifo->PopAddressToStream(buffer);
|
fifo->PopAddressToStream(buffer);
|
||||||
FILE_LOG(logDEBUG5) << "DataStreamer " << index << ", "
|
FILE_LOG(logDEBUG5) << "DataStreamer " << index << ", "
|
||||||
"pop 0x" << std::hex << (void*)(buffer) << std::dec << ":" << buffer;
|
"pop 0x" << std::hex << (void*)(buffer) << std::dec << ":" << buffer;
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
|
|
||||||
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth):
|
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth):
|
||||||
index(ind),
|
index(ind),
|
||||||
memory(0),
|
memory(nullptr),
|
||||||
fifoBound(0),
|
fifoBound(nullptr),
|
||||||
fifoFree(0),
|
fifoFree(nullptr),
|
||||||
fifoStream(0),
|
fifoStream(nullptr),
|
||||||
fifoDepth(depth),
|
fifoDepth(depth),
|
||||||
status_fifoBound(0),
|
status_fifoBound(0),
|
||||||
status_fifoFree(depth){
|
status_fifoFree(depth){
|
||||||
@ -47,7 +47,7 @@ int Fifo::CreateFifos(uint32_t fifoItemSize) {
|
|||||||
//allocate memory
|
//allocate memory
|
||||||
size_t mem_len = fifoItemSize * fifoDepth * sizeof(char);
|
size_t mem_len = fifoItemSize * fifoDepth * sizeof(char);
|
||||||
memory = (char*) malloc (mem_len);
|
memory = (char*) malloc (mem_len);
|
||||||
if (memory == NULL){
|
if (memory == nullptr){
|
||||||
FILE_LOG(logERROR) << "Could not allocate memory for fifos";
|
FILE_LOG(logERROR) << "Could not allocate memory for fifos";
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -72,19 +72,19 @@ void Fifo::DestroyFifos(){
|
|||||||
|
|
||||||
if(memory) {
|
if(memory) {
|
||||||
free(memory);
|
free(memory);
|
||||||
memory = 0;
|
memory = nullptr;
|
||||||
}
|
}
|
||||||
if (fifoBound) {
|
if (fifoBound) {
|
||||||
delete fifoBound;
|
delete fifoBound;
|
||||||
fifoBound = 0;
|
fifoBound = nullptr;
|
||||||
}
|
}
|
||||||
if (fifoFree) {
|
if (fifoFree) {
|
||||||
delete fifoFree;
|
delete fifoFree;
|
||||||
fifoFree = 0;
|
fifoFree = nullptr;
|
||||||
}
|
}
|
||||||
if (fifoStream) {
|
if (fifoStream) {
|
||||||
delete fifoStream;
|
delete fifoStream;
|
||||||
fifoStream = 0;
|
fifoStream = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,11 +24,11 @@ Listener::Listener(int ind, detectorType dtype, Fifo* f, runStatus* s,
|
|||||||
frameDiscardPolicy* fdp, bool* act, bool* depaden, bool* sm) :
|
frameDiscardPolicy* fdp, bool* act, bool* depaden, bool* sm) :
|
||||||
ThreadObject(ind),
|
ThreadObject(ind),
|
||||||
runningFlag(0),
|
runningFlag(0),
|
||||||
generalData(0),
|
generalData(nullptr),
|
||||||
fifo(f),
|
fifo(f),
|
||||||
myDetectorType(dtype),
|
myDetectorType(dtype),
|
||||||
status(s),
|
status(s),
|
||||||
udpSocket(0),
|
udpSocket(nullptr),
|
||||||
udpPortNumber(portno),
|
udpPortNumber(portno),
|
||||||
eth(e),
|
eth(e),
|
||||||
numImages(nf),
|
numImages(nf),
|
||||||
@ -50,8 +50,8 @@ Listener::Listener(int ind, detectorType dtype, Fifo* f, runStatus* s,
|
|||||||
lastCaughtFrameIndex(0),
|
lastCaughtFrameIndex(0),
|
||||||
currentFrameIndex(0),
|
currentFrameIndex(0),
|
||||||
carryOverFlag(0),
|
carryOverFlag(0),
|
||||||
carryOverPacket(0),
|
carryOverPacket(nullptr),
|
||||||
listeningPacket(0),
|
listeningPacket(nullptr),
|
||||||
udpSocketAlive(0),
|
udpSocketAlive(0),
|
||||||
numPacketsStatistic(0),
|
numPacketsStatistic(0),
|
||||||
numFramesStatistic(0)
|
numFramesStatistic(0)
|
||||||
@ -193,7 +193,7 @@ int Listener::CreateUDPSockets() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//if eth is mistaken with ip address
|
//if eth is mistaken with ip address
|
||||||
if (strchr(eth,'.') != NULL){
|
if (strchr(eth,'.') != nullptr){
|
||||||
memset(eth, 0, MAX_STR_LENGTH);
|
memset(eth, 0, MAX_STR_LENGTH);
|
||||||
}
|
}
|
||||||
if(!strlen(eth)){
|
if(!strlen(eth)){
|
||||||
@ -204,7 +204,7 @@ int Listener::CreateUDPSockets() {
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
genericSocket* g = new genericSocket(*udpPortNumber, genericSocket::UDP,
|
genericSocket* g = new genericSocket(*udpPortNumber, genericSocket::UDP,
|
||||||
generalData->packetSize, (strlen(eth)?eth:NULL), generalData->headerPacketSize,
|
generalData->packetSize, (strlen(eth)?eth:nullptr), generalData->headerPacketSize,
|
||||||
*udpSocketBufferSize);
|
*udpSocketBufferSize);
|
||||||
udpSocket = g;
|
udpSocket = g;
|
||||||
FILE_LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber;
|
FILE_LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber;
|
||||||
@ -235,7 +235,7 @@ void Listener::ShutDownUDPSocket() {
|
|||||||
if (runningFlag)
|
if (runningFlag)
|
||||||
sem_wait(&semaphore_socket);
|
sem_wait(&semaphore_socket);
|
||||||
delete udpSocket;
|
delete udpSocket;
|
||||||
udpSocket = 0;
|
udpSocket = nullptr;
|
||||||
sem_destroy(&semaphore_socket);
|
sem_destroy(&semaphore_socket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -253,7 +253,7 @@ int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) {
|
|||||||
*udpSocketBufferSize = s;
|
*udpSocketBufferSize = s;
|
||||||
|
|
||||||
//if eth is mistaken with ip address
|
//if eth is mistaken with ip address
|
||||||
if (strchr(eth,'.') != NULL){
|
if (strchr(eth,'.') != nullptr){
|
||||||
memset(eth, 0, MAX_STR_LENGTH);
|
memset(eth, 0, MAX_STR_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,13 +261,13 @@ int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) {
|
|||||||
if(udpSocket){
|
if(udpSocket){
|
||||||
udpSocket->ShutDownSocket();
|
udpSocket->ShutDownSocket();
|
||||||
delete udpSocket;
|
delete udpSocket;
|
||||||
udpSocket = 0;
|
udpSocket = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//create dummy socket
|
//create dummy socket
|
||||||
try {
|
try {
|
||||||
udpSocket = new genericSocket(*udpPortNumber, genericSocket::UDP,
|
udpSocket = new genericSocket(*udpPortNumber, genericSocket::UDP,
|
||||||
generalData->packetSize, (strlen(eth)?eth:NULL), generalData->headerPacketSize,
|
generalData->packetSize, (strlen(eth)?eth:nullptr), generalData->headerPacketSize,
|
||||||
*udpSocketBufferSize);
|
*udpSocketBufferSize);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
FILE_LOG(logERROR) << "Could not create a test UDP socket on port " << *udpPortNumber;
|
FILE_LOG(logERROR) << "Could not create a test UDP socket on port " << *udpPortNumber;
|
||||||
@ -287,7 +287,7 @@ int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) {
|
|||||||
udpSocketAlive = false;
|
udpSocketAlive = false;
|
||||||
udpSocket->ShutDownSocket();
|
udpSocket->ShutDownSocket();
|
||||||
delete udpSocket;
|
delete udpSocket;
|
||||||
udpSocket = 0;
|
udpSocket = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@ -381,8 +381,8 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
|||||||
uint32_t fifohsize = generalData->fifoBufferHeaderSize;
|
uint32_t fifohsize = generalData->fifoBufferHeaderSize;
|
||||||
uint32_t pperFrame = generalData->packetsPerFrame;
|
uint32_t pperFrame = generalData->packetsPerFrame;
|
||||||
bool isHeaderEmpty = true;
|
bool isHeaderEmpty = true;
|
||||||
sls_detector_header* old_header = 0;
|
sls_detector_header* old_header = nullptr;
|
||||||
sls_receiver_header* new_header = 0;
|
sls_receiver_header* new_header = nullptr;
|
||||||
bool standardheader = generalData->standardheader;
|
bool standardheader = generalData->standardheader;
|
||||||
uint32_t corrected_dsize = dsize - ((pperFrame * dsize) - generalData->imageSize);
|
uint32_t corrected_dsize = dsize - ((pperFrame * dsize) - generalData->imageSize);
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ void ThreadObject::DestroyThread() {
|
|||||||
if(alive){
|
if(alive){
|
||||||
killThread = true;
|
killThread = true;
|
||||||
sem_post(&semaphore);
|
sem_post(&semaphore);
|
||||||
pthread_join(thread,NULL);
|
pthread_join(thread,nullptr);
|
||||||
sem_destroy(&semaphore);
|
sem_destroy(&semaphore);
|
||||||
killThread = false;
|
killThread = false;
|
||||||
alive = false;
|
alive = false;
|
||||||
@ -56,7 +56,7 @@ int ThreadObject::CreateThread() {
|
|||||||
sem_init(&semaphore,1,0);
|
sem_init(&semaphore,1,0);
|
||||||
killThread = false;
|
killThread = false;
|
||||||
|
|
||||||
if(pthread_create(&thread, NULL,StartThread, (void*) this)){
|
if(pthread_create(&thread, nullptr,StartThread, (void*) this)){
|
||||||
FILE_LOG(logERROR) << "Could not create " << GetType() << " thread with index " << index;
|
FILE_LOG(logERROR) << "Could not create " << GetType() << " thread with index " << index;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ void ThreadObject::RunningThread() {
|
|||||||
if(killThread) {
|
if(killThread) {
|
||||||
FILE_LOG(logINFOBLUE) << "Exiting [ " << GetType() <<
|
FILE_LOG(logINFOBLUE) << "Exiting [ " << GetType() <<
|
||||||
" Thread " << index << ", Tid: " << syscall(SYS_gettid) << "]";
|
" Thread " << index << ", Tid: " << syscall(SYS_gettid) << "]";
|
||||||
pthread_exit(NULL);
|
pthread_exit(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}//end of outer loop
|
}//end of outer loop
|
||||||
|
@ -76,7 +76,7 @@ int main(int argc, char *argv[]) {
|
|||||||
sa.sa_flags=0; // no flags
|
sa.sa_flags=0; // no flags
|
||||||
sa.sa_handler=sigInterruptHandler; // handler function
|
sa.sa_handler=sigInterruptHandler; // handler function
|
||||||
sigemptyset(&sa.sa_mask); // dont block additional signals during invocation of handler
|
sigemptyset(&sa.sa_mask); // dont block additional signals during invocation of handler
|
||||||
if (sigaction(SIGINT, &sa, NULL) == -1) {
|
if (sigaction(SIGINT, &sa, nullptr) == -1) {
|
||||||
FILE_LOG(logERROR) << "Could not set handler function for SIGINT";
|
FILE_LOG(logERROR) << "Could not set handler function for SIGINT";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ int main(int argc, char *argv[]) {
|
|||||||
asa.sa_flags=0; // no flags
|
asa.sa_flags=0; // no flags
|
||||||
asa.sa_handler=SIG_IGN; // handler function
|
asa.sa_handler=SIG_IGN; // handler function
|
||||||
sigemptyset(&asa.sa_mask); // dont block additional signals during invocation of handler
|
sigemptyset(&asa.sa_mask); // dont block additional signals during invocation of handler
|
||||||
if (sigaction(SIGPIPE, &asa, NULL) == -1) {
|
if (sigaction(SIGPIPE, &asa, nullptr) == -1) {
|
||||||
FILE_LOG(logERROR) << "Could not set handler function for SIGPIPE";
|
FILE_LOG(logERROR) << "Could not set handler function for SIGPIPE";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
|
|
||||||
slsReceiver::slsReceiver(int argc, char *argv[]):
|
slsReceiver::slsReceiver(int argc, char *argv[]):
|
||||||
tcpipInterface (0) {
|
tcpipInterface (nullptr) {
|
||||||
|
|
||||||
// options
|
// options
|
||||||
std::map<std::string, std::string> configuration_map;
|
std::map<std::string, std::string> configuration_map;
|
||||||
@ -32,11 +32,11 @@ slsReceiver::slsReceiver(int argc, char *argv[]):
|
|||||||
// These options set a flag.
|
// These options set a flag.
|
||||||
//{"verbose", no_argument, &verbose_flag, 1},
|
//{"verbose", no_argument, &verbose_flag, 1},
|
||||||
// These options don’t set a flag. We distinguish them by their indices.
|
// These options don’t set a flag. We distinguish them by their indices.
|
||||||
{"config", required_argument, 0, 'f'},
|
{"config", required_argument, nullptr, 'f'},
|
||||||
{"rx_tcpport", required_argument, 0, 't'},
|
{"rx_tcpport", required_argument, nullptr, 't'},
|
||||||
{"version", no_argument, 0, 'v'},
|
{"version", no_argument, nullptr, 'v'},
|
||||||
{"help", no_argument, 0, 'h'},
|
{"help", no_argument, nullptr, 'h'},
|
||||||
{0, 0, 0, 0}
|
{nullptr, 0, nullptr, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
//initialize global optind variable (required when instantiating multiple receivers in the same process)
|
//initialize global optind variable (required when instantiating multiple receivers in the same process)
|
||||||
|
@ -39,7 +39,7 @@ void slsReceiverImplementation::DeleteMembers() {
|
|||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
if (generalData) {
|
if (generalData) {
|
||||||
delete generalData;
|
delete generalData;
|
||||||
generalData=0;
|
generalData=nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
listener.clear();
|
listener.clear();
|
||||||
@ -107,16 +107,16 @@ void slsReceiverImplementation::InitializeMembers() {
|
|||||||
memset(additionalJsonHeader, 0, sizeof(additionalJsonHeader));
|
memset(additionalJsonHeader, 0, sizeof(additionalJsonHeader));
|
||||||
|
|
||||||
//** class objects ***
|
//** class objects ***
|
||||||
generalData = 0;
|
generalData = nullptr;
|
||||||
|
|
||||||
//***callback parameters***
|
//***callback parameters***
|
||||||
startAcquisitionCallBack = NULL;
|
startAcquisitionCallBack = nullptr;
|
||||||
pStartAcquisition = NULL;
|
pStartAcquisition = nullptr;
|
||||||
acquisitionFinishedCallBack = NULL;
|
acquisitionFinishedCallBack = nullptr;
|
||||||
pAcquisitionFinished = NULL;
|
pAcquisitionFinished = nullptr;
|
||||||
rawDataReadyCallBack = NULL;
|
rawDataReadyCallBack = nullptr;
|
||||||
rawDataModifyReadyCallBack = NULL;
|
rawDataModifyReadyCallBack = nullptr;
|
||||||
pRawDataReady = NULL;
|
pRawDataReady = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@ -953,7 +953,7 @@ int slsReceiverImplementation::startReceiver(char *c) {
|
|||||||
if (startAcquisitionCallBack) {
|
if (startAcquisitionCallBack) {
|
||||||
startAcquisitionCallBack(filePath, fileName, fileIndex,
|
startAcquisitionCallBack(filePath, fileName, fileIndex,
|
||||||
(generalData->imageSize) + (generalData->fifoBufferHeaderSize), pStartAcquisition);
|
(generalData->imageSize) + (generalData->fifoBufferHeaderSize), pStartAcquisition);
|
||||||
if (rawDataReadyCallBack != NULL) {
|
if (rawDataReadyCallBack != nullptr) {
|
||||||
FILE_LOG(logINFO) << "Data Write has been defined externally";
|
FILE_LOG(logINFO) << "Data Write has been defined externally";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
|
|||||||
stop();
|
stop();
|
||||||
if(mySock) {
|
if(mySock) {
|
||||||
delete mySock;
|
delete mySock;
|
||||||
mySock=NULL;
|
mySock=nullptr;
|
||||||
}
|
}
|
||||||
if (interface)
|
if (interface)
|
||||||
delete interface;
|
delete interface;
|
||||||
@ -37,24 +37,24 @@ slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
|
|||||||
|
|
||||||
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn):
|
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn):
|
||||||
myDetectorType(GOTTHARD),
|
myDetectorType(GOTTHARD),
|
||||||
receiver(0),
|
receiver(nullptr),
|
||||||
ret(OK),
|
ret(OK),
|
||||||
fnum(-1),
|
fnum(-1),
|
||||||
lockStatus(0),
|
lockStatus(0),
|
||||||
killTCPServerThread(0),
|
killTCPServerThread(0),
|
||||||
tcpThreadCreated(false),
|
tcpThreadCreated(false),
|
||||||
portNumber(DEFAULT_PORTNO+2),
|
portNumber(DEFAULT_PORTNO+2),
|
||||||
mySock(0),
|
mySock(nullptr),
|
||||||
interface(0)
|
interface(nullptr)
|
||||||
{
|
{
|
||||||
//***callback parameters***
|
//***callback parameters***
|
||||||
startAcquisitionCallBack = NULL;
|
startAcquisitionCallBack = nullptr;
|
||||||
pStartAcquisition = NULL;
|
pStartAcquisition = nullptr;
|
||||||
acquisitionFinishedCallBack = NULL;
|
acquisitionFinishedCallBack = nullptr;
|
||||||
pAcquisitionFinished = NULL;
|
pAcquisitionFinished = nullptr;
|
||||||
rawDataReadyCallBack = NULL;
|
rawDataReadyCallBack = nullptr;
|
||||||
rawDataModifyReadyCallBack = NULL;
|
rawDataModifyReadyCallBack = nullptr;
|
||||||
pRawDataReady = NULL;
|
pRawDataReady = nullptr;
|
||||||
|
|
||||||
// create socket
|
// create socket
|
||||||
portNumber = (pn > 0 ? pn : DEFAULT_PORTNO + 2);
|
portNumber = (pn > 0 ? pn : DEFAULT_PORTNO + 2);
|
||||||
@ -75,7 +75,7 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn):
|
|||||||
int slsReceiverTCPIPInterface::start(){
|
int slsReceiverTCPIPInterface::start(){
|
||||||
FILE_LOG(logDEBUG) << "Creating TCP Server Thread";
|
FILE_LOG(logDEBUG) << "Creating TCP Server Thread";
|
||||||
killTCPServerThread = 0;
|
killTCPServerThread = 0;
|
||||||
if(pthread_create(&TCPServer_thread, NULL,startTCPServerThread, (void*) this)){
|
if(pthread_create(&TCPServer_thread, nullptr,startTCPServerThread, (void*) this)){
|
||||||
FILE_LOG(logERROR) << "Could not create TCP Server thread";
|
FILE_LOG(logERROR) << "Could not create TCP Server thread";
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ void slsReceiverTCPIPInterface::stop(){
|
|||||||
killTCPServerThread = 1;
|
killTCPServerThread = 1;
|
||||||
if(mySock) mySock->ShutDownSocket();
|
if(mySock) mySock->ShutDownSocket();
|
||||||
FILE_LOG(logDEBUG) << "TCP Socket closed on port " << portNumber;
|
FILE_LOG(logDEBUG) << "TCP Socket closed on port " << portNumber;
|
||||||
pthread_join(TCPServer_thread, NULL);
|
pthread_join(TCPServer_thread, nullptr);
|
||||||
tcpThreadCreated = false;
|
tcpThreadCreated = false;
|
||||||
killTCPServerThread = 0;
|
killTCPServerThread = 0;
|
||||||
FILE_LOG(logDEBUG) << "Exiting TCP Server Thread on port " << portNumber;
|
FILE_LOG(logDEBUG) << "Exiting TCP Server Thread on port " << portNumber;
|
||||||
@ -160,7 +160,7 @@ void slsReceiverTCPIPInterface::startTCPServer(){
|
|||||||
|
|
||||||
mySock->exitServer();
|
mySock->exitServer();
|
||||||
FILE_LOG(logINFOBLUE) << "Exiting [ TCP server Tid: " << syscall(SYS_gettid) <<"]";
|
FILE_LOG(logINFOBLUE) << "Exiting [ TCP server Tid: " << syscall(SYS_gettid) <<"]";
|
||||||
pthread_exit(NULL);
|
pthread_exit(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if user entered exit
|
//if user entered exit
|
||||||
@ -171,7 +171,7 @@ void slsReceiverTCPIPInterface::startTCPServer(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
FILE_LOG(logINFOBLUE) << "Exiting [ TCP server Tid: " << syscall(SYS_gettid) <<"]";
|
FILE_LOG(logINFOBLUE) << "Exiting [ TCP server Tid: " << syscall(SYS_gettid) <<"]";
|
||||||
pthread_exit(NULL);
|
pthread_exit(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,7 +309,7 @@ int slsReceiverTCPIPInterface::M_nofunc(){
|
|||||||
|
|
||||||
sprintf(mess,"Unrecognized Function enum %d. Please do not proceed.\n", fnum);
|
sprintf(mess,"Unrecognized Function enum %d. Please do not proceed.\n", fnum);
|
||||||
FILE_LOG(logERROR) << mess;
|
FILE_LOG(logERROR) << mess;
|
||||||
return interface->Server_SendResult(false, ret, NULL, 0, mess);
|
return interface->Server_SendResult(false, ret, nullptr, 0, mess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ int slsReceiverTCPIPInterface::exec_command() {
|
|||||||
FILE_LOG(logERROR) << mess;
|
FILE_LOG(logERROR) << mess;
|
||||||
} else {
|
} else {
|
||||||
while (!feof(pipe.get())) {
|
while (!feof(pipe.get())) {
|
||||||
if (fgets(temp.data(), tempsize, pipe.get()) != NULL)
|
if (fgets(temp.data(), tempsize, pipe.get()) != nullptr)
|
||||||
sresult += temp.data();
|
sresult += temp.data();
|
||||||
}
|
}
|
||||||
strncpy(retval, sresult.c_str(), MAX_STR_LENGTH);
|
strncpy(retval, sresult.c_str(), MAX_STR_LENGTH);
|
||||||
@ -356,7 +356,7 @@ int slsReceiverTCPIPInterface::exit_server() {
|
|||||||
FILE_LOG(logINFO) << "Closing server";
|
FILE_LOG(logINFO) << "Closing server";
|
||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
interface->Server_SendResult(false, ret, NULL, 0);
|
interface->Server_SendResult(false, ret, nullptr, 0);
|
||||||
return GOODBYE;
|
return GOODBYE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,7 +400,7 @@ int slsReceiverTCPIPInterface::set_port() {
|
|||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
int p_number = -1;
|
int p_number = -1;
|
||||||
MySocketTCP* mySocket = 0;
|
MySocketTCP* mySocket = nullptr;
|
||||||
char oldLastClientIP[INET_ADDRSTRLEN] = {0};
|
char oldLastClientIP[INET_ADDRSTRLEN] = {0};
|
||||||
|
|
||||||
// get args, return if socket crashed
|
// get args, return if socket crashed
|
||||||
@ -451,9 +451,9 @@ int slsReceiverTCPIPInterface::update_client() {
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
|
|
||||||
// no arg, check receiver is null
|
// no arg, check receiver is null
|
||||||
interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver);
|
interface->Server_ReceiveArg(ret, mess, nullptr, 0, true, receiver);
|
||||||
|
|
||||||
interface->Server_SendResult(false, ret, NULL, 0, mess);
|
interface->Server_SendResult(false, ret, nullptr, 0, mess);
|
||||||
|
|
||||||
if (ret == FAIL)
|
if (ret == FAIL)
|
||||||
return ret;
|
return ret;
|
||||||
@ -574,7 +574,7 @@ int slsReceiverTCPIPInterface::set_detector_type(){
|
|||||||
// set
|
// set
|
||||||
if (arg >= 0) {
|
if (arg >= 0) {
|
||||||
// if object exists, verify unlocked and idle, else only verify lock (connecting first time)
|
// if object exists, verify unlocked and idle, else only verify lock (connecting first time)
|
||||||
if (receiver == NULL)
|
if (receiver == nullptr)
|
||||||
interface->Server_VerifyLock(ret, mess, lockStatus);
|
interface->Server_VerifyLock(ret, mess, lockStatus);
|
||||||
else
|
else
|
||||||
interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum);
|
interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum);
|
||||||
@ -592,7 +592,7 @@ int slsReceiverTCPIPInterface::set_detector_type(){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(ret == OK) {
|
if(ret == OK) {
|
||||||
if(receiver == NULL){
|
if(receiver == nullptr){
|
||||||
receiver = new slsReceiverImplementation();
|
receiver = new slsReceiverImplementation();
|
||||||
if(startAcquisitionCallBack)
|
if(startAcquisitionCallBack)
|
||||||
receiver->registerCallBackStartAcquisition(startAcquisitionCallBack,pStartAcquisition);
|
receiver->registerCallBackStartAcquisition(startAcquisitionCallBack,pStartAcquisition);
|
||||||
@ -688,7 +688,7 @@ int slsReceiverTCPIPInterface::set_roi() {
|
|||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
|
|
||||||
// base object not null
|
// base object not null
|
||||||
else if (receiver == NULL)
|
else if (receiver == nullptr)
|
||||||
interface->Server_NullObjectError(ret, mess);
|
interface->Server_NullObjectError(ret, mess);
|
||||||
else {
|
else {
|
||||||
// only set
|
// only set
|
||||||
@ -697,7 +697,7 @@ int slsReceiverTCPIPInterface::set_roi() {
|
|||||||
ret = receiver->setROI(arg);
|
ret = receiver->setROI(arg);
|
||||||
}
|
}
|
||||||
arg.clear();
|
arg.clear();
|
||||||
return interface->Server_SendResult(true, ret, NULL, 0, mess);
|
return interface->Server_SendResult(true, ret, nullptr, 0, mess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -738,7 +738,7 @@ int slsReceiverTCPIPInterface::setup_udp(){
|
|||||||
char eth[MAX_STR_LENGTH];
|
char eth[MAX_STR_LENGTH];
|
||||||
memset(eth,0,sizeof(eth));
|
memset(eth,0,sizeof(eth));
|
||||||
strcpy(eth,temp.c_str());
|
strcpy(eth,temp.c_str());
|
||||||
if (strchr(eth,'.') != NULL) {
|
if (strchr(eth,'.') != nullptr) {
|
||||||
strcpy(eth,"");
|
strcpy(eth,"");
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
strcpy(mess, "Failed to get ethernet interface\n");
|
strcpy(mess, "Failed to get ethernet interface\n");
|
||||||
@ -950,7 +950,7 @@ int slsReceiverTCPIPInterface::get_status(){
|
|||||||
enum runStatus retval = ERROR;
|
enum runStatus retval = ERROR;
|
||||||
|
|
||||||
// no arg, check receiver is null
|
// no arg, check receiver is null
|
||||||
interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver);
|
interface->Server_ReceiveArg(ret, mess, nullptr, 0, true, receiver);
|
||||||
|
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
FILE_LOG(logDEBUG1) << "Getting Status";
|
FILE_LOG(logDEBUG1) << "Getting Status";
|
||||||
@ -967,7 +967,7 @@ int slsReceiverTCPIPInterface::start_receiver(){
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
|
|
||||||
// no arg, and check receiver is null
|
// no arg, and check receiver is null
|
||||||
interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver);
|
interface->Server_ReceiveArg(ret, mess, nullptr, 0, true, receiver);
|
||||||
|
|
||||||
// receiver is not null
|
// receiver is not null
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
@ -989,7 +989,7 @@ int slsReceiverTCPIPInterface::start_receiver(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return interface->Server_SendResult(true, ret, NULL, 0, mess);
|
return interface->Server_SendResult(true, ret, nullptr, 0, mess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -999,7 +999,7 @@ int slsReceiverTCPIPInterface::stop_receiver(){
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
|
|
||||||
// no arg, and check receiver is null
|
// no arg, and check receiver is null
|
||||||
interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver);
|
interface->Server_ReceiveArg(ret, mess, nullptr, 0, true, receiver);
|
||||||
|
|
||||||
// receiver is not null
|
// receiver is not null
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
@ -1020,7 +1020,7 @@ int slsReceiverTCPIPInterface::stop_receiver(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return interface->Server_SendResult(true, ret, NULL, 0, mess);
|
return interface->Server_SendResult(true, ret, nullptr, 0, mess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1125,7 +1125,7 @@ int slsReceiverTCPIPInterface::get_frame_index(){
|
|||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
||||||
// no arg, check receiver is null
|
// no arg, check receiver is null
|
||||||
interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver);
|
interface->Server_ReceiveArg(ret, mess, nullptr, 0, true, receiver);
|
||||||
|
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
FILE_LOG(logDEBUG1) << "Getting frame index";
|
FILE_LOG(logDEBUG1) << "Getting frame index";
|
||||||
@ -1143,7 +1143,7 @@ int slsReceiverTCPIPInterface::get_frames_caught(){
|
|||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
||||||
// no arg, check receiver is null
|
// no arg, check receiver is null
|
||||||
interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver);
|
interface->Server_ReceiveArg(ret, mess, nullptr, 0, true, receiver);
|
||||||
|
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
FILE_LOG(logDEBUG1) << "Getting frames caught";
|
FILE_LOG(logDEBUG1) << "Getting frames caught";
|
||||||
@ -1160,7 +1160,7 @@ int slsReceiverTCPIPInterface::reset_frames_caught(){
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
|
|
||||||
// no arg, and check receiver is null
|
// no arg, and check receiver is null
|
||||||
interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver);
|
interface->Server_ReceiveArg(ret, mess, nullptr, 0, true, receiver);
|
||||||
|
|
||||||
// receiver is not null
|
// receiver is not null
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
@ -1171,7 +1171,7 @@ int slsReceiverTCPIPInterface::reset_frames_caught(){
|
|||||||
receiver->resetAcquisitionCount();
|
receiver->resetAcquisitionCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return interface->Server_SendResult(true, ret, NULL, 0, mess);
|
return interface->Server_SendResult(true, ret, nullptr, 0, mess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1649,7 +1649,7 @@ int slsReceiverTCPIPInterface::restream_stop(){
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
|
|
||||||
// no arg, and check receiver is null
|
// no arg, and check receiver is null
|
||||||
interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver);
|
interface->Server_ReceiveArg(ret, mess, nullptr, 0, true, receiver);
|
||||||
|
|
||||||
// receiver is not null
|
// receiver is not null
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
@ -1670,7 +1670,7 @@ int slsReceiverTCPIPInterface::restream_stop(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return interface->Server_SendResult(true, ret, NULL, 0, mess);
|
return interface->Server_SendResult(true, ret, nullptr, 0, mess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1742,7 +1742,7 @@ int slsReceiverTCPIPInterface::get_real_udp_socket_buffer_size(){
|
|||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
||||||
// no arg, check receiver is null
|
// no arg, check receiver is null
|
||||||
interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver);
|
interface->Server_ReceiveArg(ret, mess, nullptr, 0, true, receiver);
|
||||||
|
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
FILE_LOG(logDEBUG1) << "Getting actual UDP buffer size";
|
FILE_LOG(logDEBUG1) << "Getting actual UDP buffer size";
|
||||||
@ -1818,7 +1818,7 @@ int slsReceiverTCPIPInterface::check_version_compatibility() {
|
|||||||
FILE_LOG(logERROR) << mess;
|
FILE_LOG(logERROR) << mess;
|
||||||
}
|
}
|
||||||
else FILE_LOG(logINFO) << "Compatibility with Client: Successful";
|
else FILE_LOG(logINFO) << "Compatibility with Client: Successful";
|
||||||
return interface->Server_SendResult(true, ret, NULL, 0, mess);
|
return interface->Server_SendResult(true, ret, nullptr, 0, mess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
144
slsSupportLib/src/ClientInterface.cpp
Normal file
144
slsSupportLib/src/ClientInterface.cpp
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
#include "ClientInterface.h"
|
||||||
|
|
||||||
|
ClientInterface::ClientInterface(MySocketTCP *socket, int n, std::string t):
|
||||||
|
mySocket(socket),
|
||||||
|
index(n),
|
||||||
|
type(t){}
|
||||||
|
|
||||||
|
void ClientInterface::SetSocket(MySocketTCP *socket) {
|
||||||
|
mySocket = socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ClientInterface::Client_Receive(int& ret, char* mess, void* retval, int sizeOfRetval) {
|
||||||
|
// get result of operation
|
||||||
|
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
|
|
||||||
|
bool unrecognizedFunction = false;
|
||||||
|
if (ret == FAIL) {
|
||||||
|
bool created = false;
|
||||||
|
// allocate mess if null
|
||||||
|
if (!mess){
|
||||||
|
created = true;
|
||||||
|
mess = new char[MAX_STR_LENGTH];
|
||||||
|
memset(mess, 0, MAX_STR_LENGTH);
|
||||||
|
}
|
||||||
|
// get error message
|
||||||
|
mySocket->ReceiveDataOnly(mess,MAX_STR_LENGTH);
|
||||||
|
cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
|
||||||
|
|
||||||
|
// unrecognized function, do not ask for retval
|
||||||
|
if(strstr(mess,"Unrecognized Function") != nullptr)
|
||||||
|
unrecognizedFunction = true;
|
||||||
|
// delete allocated mess
|
||||||
|
if (created)
|
||||||
|
delete [] mess;
|
||||||
|
}
|
||||||
|
// get retval
|
||||||
|
if (!unrecognizedFunction)
|
||||||
|
mySocket->ReceiveDataOnly(retval, sizeOfRetval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ClientInterface::Client_Send(int fnum,
|
||||||
|
void* args, int sizeOfArgs,
|
||||||
|
void* retval, int sizeOfRetval,
|
||||||
|
char* mess) {
|
||||||
|
int ret = FAIL;
|
||||||
|
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
|
mySocket->SendDataOnly(args, sizeOfArgs);
|
||||||
|
Client_Receive(ret, mess, retval, sizeOfRetval);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ClientInterface::Server_SendResult(bool update, int ret,
|
||||||
|
void* retval, int retvalSize, char* mess) {
|
||||||
|
|
||||||
|
// update if different clients
|
||||||
|
if (update && ret == OK && mySocket->differentClients)
|
||||||
|
ret = FORCE_UPDATE;
|
||||||
|
|
||||||
|
// send success of operation
|
||||||
|
mySocket->SendDataOnly(&ret,sizeof(ret));
|
||||||
|
if(ret == FAIL) {
|
||||||
|
// send error message
|
||||||
|
if (mess)
|
||||||
|
mySocket->SendDataOnly(mess, MAX_STR_LENGTH);
|
||||||
|
// debugging feature. should not happen.
|
||||||
|
else
|
||||||
|
FILE_LOG(logERROR) << "No error message provided for this failure. Will mess up TCP\n";
|
||||||
|
}
|
||||||
|
// send return value
|
||||||
|
mySocket->SendDataOnly(retval, retvalSize);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ClientInterface::Server_ReceiveArg(int& ret, char* mess, void* arg, int sizeofArg, bool checkbase, void* base) {
|
||||||
|
// client socket crash, cannot receive arguments
|
||||||
|
if (sizeofArg && mySocket->ReceiveDataOnly(arg, sizeofArg) < 0)
|
||||||
|
return Server_SocketCrash();
|
||||||
|
|
||||||
|
// check if server object created
|
||||||
|
if (checkbase && base == nullptr)
|
||||||
|
Server_NullObjectError(ret, mess);
|
||||||
|
|
||||||
|
// no crash
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ClientInterface::Server_VerifyLock(int& ret, char* mess, int lockstatus) {
|
||||||
|
// server locked
|
||||||
|
if (mySocket->differentClients && lockstatus)
|
||||||
|
return Server_LockedError(ret, mess);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ClientInterface::Server_VerifyLockAndIdle(int& ret, char* mess, int lockstatus, slsDetectorDefs::runStatus status, int fnum) {
|
||||||
|
// server locked
|
||||||
|
if (mySocket->differentClients && lockstatus)
|
||||||
|
return Server_LockedError(ret, mess);
|
||||||
|
|
||||||
|
// server not idle for this command
|
||||||
|
if (status != slsDetectorDefs::IDLE)
|
||||||
|
return Server_NotIdleError(ret, mess, fnum);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ClientInterface::Server_NullObjectError(int& ret, char* mess) {
|
||||||
|
ret=FAIL;
|
||||||
|
strcpy(mess,"Receiver not set up. Please use rx_hostname first.\n");
|
||||||
|
FILE_LOG(logERROR) << mess;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ClientInterface::Server_SocketCrash() {
|
||||||
|
FILE_LOG(logERROR) << "Reading from socket failed. Possible socket crash";
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ClientInterface::Server_LockedError(int& ret, char* mess) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess,"Receiver locked by %s\n", mySocket->lastClientIP);
|
||||||
|
FILE_LOG(logERROR) << mess;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ClientInterface::Server_NotIdleError(int& ret, char* mess, int fnum) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess,"Can not execute %s when receiver is not idle\n",
|
||||||
|
getFunctionNameFromEnum((enum detFuncs)fnum));
|
||||||
|
FILE_LOG(logERROR) << mess;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
148
slsSupportLib/src/utilities.cpp
Normal file
148
slsSupportLib/src/utilities.cpp
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
#include "utilities.h"
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int read_config_file(std::string fname, int *tcpip_port_no,
|
||||||
|
std::map<std::string, std::string> * configuration_map) {
|
||||||
|
|
||||||
|
std::ifstream infile;
|
||||||
|
std::string sLine,sargname, sargvalue;
|
||||||
|
int iline = 0;
|
||||||
|
int success = slsDetectorDefs::OK;
|
||||||
|
|
||||||
|
|
||||||
|
FILE_LOG(logINFO) << "config file name " << fname;
|
||||||
|
try {
|
||||||
|
infile.open(fname.c_str(), std::ios_base::in);
|
||||||
|
} catch(...) {
|
||||||
|
FILE_LOG(logERROR) << "Could not open configuration file " << fname ;
|
||||||
|
success = slsDetectorDefs::FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (success == slsDetectorDefs::OK && infile.is_open()) {
|
||||||
|
while(infile.good()){
|
||||||
|
getline(infile,sLine);
|
||||||
|
iline++;
|
||||||
|
|
||||||
|
//VERBOSE_PRINT(sLine);
|
||||||
|
|
||||||
|
if(sLine.find('#') != std::string::npos)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
else if(sLine.length()<2)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
else{
|
||||||
|
std::istringstream sstr(sLine);
|
||||||
|
|
||||||
|
//parameter name
|
||||||
|
if(sstr.good()){
|
||||||
|
sstr >> sargname;
|
||||||
|
|
||||||
|
if (! sstr.good())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sstr >> sargvalue;
|
||||||
|
(*configuration_map)[sargname] = sargvalue;
|
||||||
|
}
|
||||||
|
//tcp port
|
||||||
|
if(sargname=="rx_tcpport"){
|
||||||
|
if(sstr.good()) {
|
||||||
|
sstr >> sargname;
|
||||||
|
if(sscanf(sargname.c_str(),"%d",tcpip_port_no))
|
||||||
|
cprintf(RESET, "dataport: %d\n" , *tcpip_port_no);
|
||||||
|
else{
|
||||||
|
cprintf(RED, "could not decode port in config file. Exiting.\n");
|
||||||
|
success = slsDetectorDefs::FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
infile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int readDataFile(std::ifstream &infile, short int *data, int nch, int offset) {
|
||||||
|
int ichan, iline=0;
|
||||||
|
short int idata;
|
||||||
|
int interrupt=0;
|
||||||
|
std::string str;
|
||||||
|
while (infile.good() and interrupt==0) {
|
||||||
|
getline(infile,str);
|
||||||
|
std::istringstream ssstr(str);
|
||||||
|
ssstr >> ichan >> idata;
|
||||||
|
if (ssstr.fail() || ssstr.bad()) {
|
||||||
|
interrupt=1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (iline<nch) {
|
||||||
|
if (ichan>=offset) {
|
||||||
|
data[iline]=idata;
|
||||||
|
iline++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
interrupt=1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return iline;
|
||||||
|
};
|
||||||
|
return iline;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int readDataFile(std::string fname, short int *data, int nch) {
|
||||||
|
std::ifstream infile;
|
||||||
|
int iline=0;
|
||||||
|
std::string str;
|
||||||
|
infile.open(fname.c_str(), std::ios_base::in);
|
||||||
|
if (infile.is_open()) {
|
||||||
|
iline=readDataFile(infile, data, nch, 0);
|
||||||
|
infile.close();
|
||||||
|
} else {
|
||||||
|
FILE_LOG(logERROR) << "Could not read file " << fname;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return iline;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int writeDataFile(std::ofstream &outfile,int nch, short int *data, int offset) {
|
||||||
|
if (data==nullptr)
|
||||||
|
return slsDetectorDefs::FAIL;
|
||||||
|
for (int ichan=0; ichan<nch; ichan++)
|
||||||
|
outfile << ichan+offset << " " << *(data+ichan) << std::endl;
|
||||||
|
return slsDetectorDefs::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int writeDataFile(std::string fname,int nch, short int *data) {
|
||||||
|
std::ofstream outfile;
|
||||||
|
if (data==nullptr)
|
||||||
|
return slsDetectorDefs::FAIL;
|
||||||
|
outfile.open (fname.c_str(),std::ios_base::out);
|
||||||
|
if (outfile.is_open()) {
|
||||||
|
writeDataFile(outfile, nch, data, 0);
|
||||||
|
outfile.close();
|
||||||
|
return slsDetectorDefs::OK;
|
||||||
|
} else {
|
||||||
|
FILE_LOG(logERROR) << "Could not open file " << fname << "for writing";
|
||||||
|
return slsDetectorDefs::FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user