mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
added black background for reciever to see gray font better
This commit is contained in:
@ -117,12 +117,12 @@ class BinaryFileStatic {
|
||||
{
|
||||
if(!owenable){
|
||||
if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){
|
||||
cprintf(RED,"Error in creating binary master file %s\n",fname.c_str());
|
||||
bprintf(RED,"Error in creating binary master file %s\n",fname.c_str());
|
||||
fd = 0;
|
||||
return 1;
|
||||
}
|
||||
}else if (NULL == (fd = fopen((const char *) fname.c_str(), "w"))){
|
||||
cprintf(RED,"Error in creating binary master file %s\n",fname.c_str());
|
||||
bprintf(RED,"Error in creating binary master file %s\n",fname.c_str());
|
||||
fd = 0;
|
||||
return 1;
|
||||
}
|
||||
@ -166,7 +166,7 @@ class BinaryFileStatic {
|
||||
(long long int)acquisitionPeriod,
|
||||
ctime(&t));
|
||||
if (strlen(message) > MAX_STR_LENGTH) {
|
||||
cprintf(BG_RED,"Master File Size %d is greater than max str size %d\n",
|
||||
bprintf(BG_RED,"Master File Size %d is greater than max str size %d\n",
|
||||
(int)strlen(message), MAX_STR_LENGTH);
|
||||
return 1;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class File : private virtual slsReceiverDefs {
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
virtual int CreateFile(uint64_t fnum){
|
||||
cprintf(RED,"This is a generic function CreateFile that should be overloaded by a derived class\n");
|
||||
bprintf(RED,"This is a generic function CreateFile that should be overloaded by a derived class\n");
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -115,14 +115,14 @@ class File : private virtual slsReceiverDefs {
|
||||
* Close Current File
|
||||
*/
|
||||
virtual void CloseCurrentFile() {
|
||||
cprintf(RED,"This is a generic function CloseCurrentFile that should be overloaded by a derived class\n");
|
||||
bprintf(RED,"This is a generic function CloseCurrentFile that should be overloaded by a derived class\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Close Files
|
||||
*/
|
||||
virtual void CloseAllFiles() {
|
||||
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
|
||||
bprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,7 +133,7 @@ class File : private virtual slsReceiverDefs {
|
||||
* @param OK or FAIL
|
||||
*/
|
||||
virtual int WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) {
|
||||
cprintf(RED,"This is a generic function WriteToFile that should be overloaded by a derived class\n");
|
||||
bprintf(RED,"This is a generic function WriteToFile that should be overloaded by a derived class\n");
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ class File : private virtual slsReceiverDefs {
|
||||
*/
|
||||
virtual int CreateMasterFile(bool en, uint32_t size,
|
||||
uint32_t nx, uint32_t ny, uint64_t at, uint64_t ap) {
|
||||
cprintf(RED,"This is a generic function CreateMasterFile that should be overloaded by a derived class\n");
|
||||
bprintf(RED,"This is a generic function CreateMasterFile that should be overloaded by a derived class\n");
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ class File : private virtual slsReceiverDefs {
|
||||
* @param ny number of pixels in y direction
|
||||
*/
|
||||
virtual void SetNumberofPixels(uint32_t nx, uint32_t ny) {
|
||||
cprintf(RED,"This is a generic function SetNumberofPixels that should be overloaded by a derived class\n");
|
||||
bprintf(RED,"This is a generic function SetNumberofPixels that should be overloaded by a derived class\n");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,7 +168,7 @@ class File : private virtual slsReceiverDefs {
|
||||
* @param numf number of images caught
|
||||
*/
|
||||
virtual void EndofAcquisition(uint64_t numf) {
|
||||
cprintf(RED,"This is a generic function EndofAcquisition that should be overloaded by a derived class\n");
|
||||
bprintf(RED,"This is a generic function EndofAcquisition that should be overloaded by a derived class\n");
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -151,7 +151,7 @@ public:
|
||||
* @param tgEnable true if 10GbE is enabled, else false
|
||||
*/
|
||||
virtual void SetDynamicRange(int dr, bool tgEnable) {
|
||||
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
|
||||
bprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
|
||||
};
|
||||
|
||||
/**
|
||||
@ -160,58 +160,35 @@ public:
|
||||
* @param dr dynamic range
|
||||
*/
|
||||
virtual void SetTenGigaEnable(bool tgEnable, int dr) {
|
||||
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
|
||||
bprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
|
||||
};
|
||||
|
||||
/**
|
||||
* Print all variables
|
||||
*/
|
||||
virtual void Print() const {
|
||||
std::string temp = slsReceiverDefs::getDetectorType(myDetectorType);
|
||||
printf("\n\nDetector Data Variables:\n");
|
||||
printf( "myDetectorType:%s\n"
|
||||
"Pixels X: %u\n"
|
||||
"Pixels Y: %u\n"
|
||||
"Empty Header: %u\n"
|
||||
"Header Size in Packet: %u\n"
|
||||
"Data Size: %u\n"
|
||||
"Packet Size: %u\n"
|
||||
"Packets per Frame: %u\n"
|
||||
"Image Size: %u\n"
|
||||
"Frame Index Mask: 0x%llx\n"
|
||||
"Frame Index Offset: %u\n"
|
||||
"Packet Index Mask: 0x%x\n"
|
||||
"Packet Index Offset: %u\n"
|
||||
"Max Frames Per File: %u\n"
|
||||
"Fifo Buffer Header Size: %u\n"
|
||||
"Default Fifo Depth: %u\n"
|
||||
"Threads Per Receiver: %u\n"
|
||||
"Header Packet Size: %u\n"
|
||||
"Streamer Pixels X: %u\n"
|
||||
"Streamer Pixels Y: %u\n"
|
||||
"Streamer Image Size: %u\n"
|
||||
|
||||
,temp.c_str(),//.c_str() modifies, using temp string for thread safety
|
||||
nPixelsX,
|
||||
nPixelsY,
|
||||
emptyHeader,
|
||||
headerSizeinPacket,
|
||||
dataSize,
|
||||
packetSize,
|
||||
packetsPerFrame,
|
||||
imageSize,
|
||||
(long long int)frameIndexMask,
|
||||
frameIndexOffset,
|
||||
packetIndexMask,
|
||||
packetIndexOffset,
|
||||
maxFramesPerFile,
|
||||
fifoBufferHeaderSize,
|
||||
defaultFifoDepth,
|
||||
threadsPerReceiver,
|
||||
headerPacketSize,
|
||||
nPixelsX_Streamer,
|
||||
nPixelsY_Streamer,
|
||||
imageSize_Streamer);
|
||||
FILE_LOG(logDEBUG) << "\n\nDetector Data Variables:";
|
||||
FILE_LOG(logDEBUG) << "myDetectorType: " << slsReceiverDefs::getDetectorType(myDetectorType);
|
||||
FILE_LOG(logDEBUG) << "Pixels X: " << nPixelsX;
|
||||
FILE_LOG(logDEBUG) << "Pixels Y: " << nPixelsY;
|
||||
FILE_LOG(logDEBUG) << "Empty Header: " << emptyHeader;
|
||||
FILE_LOG(logDEBUG) << "Header Size in Packet: " << headerSizeinPacket;
|
||||
FILE_LOG(logDEBUG) << "Data Size: " << dataSize;
|
||||
FILE_LOG(logDEBUG) << "Packet Size: " << packetSize;
|
||||
FILE_LOG(logDEBUG) << "Packets per Frame: " << packetsPerFrame;
|
||||
FILE_LOG(logDEBUG) << "Image Size: " << imageSize;
|
||||
FILE_LOG(logDEBUG) << "Frame Index Mask: " << frameIndexMask;
|
||||
FILE_LOG(logDEBUG) << "Frame Index Offset: " << frameIndexOffset;
|
||||
FILE_LOG(logDEBUG) << "Packet Index Mask: " << packetIndexMask;
|
||||
FILE_LOG(logDEBUG) << "Packet Index Offset: " << packetIndexOffset;
|
||||
FILE_LOG(logDEBUG) << "Max Frames Per File: " << maxFramesPerFile;
|
||||
FILE_LOG(logDEBUG) << "Fifo Buffer Header Size: " << fifoBufferHeaderSize;
|
||||
FILE_LOG(logDEBUG) << "Default Fifo Depth: " << defaultFifoDepth;
|
||||
FILE_LOG(logDEBUG) << "Threads Per Receiver: " << threadsPerReceiver;
|
||||
FILE_LOG(logDEBUG) << "Header Packet Size: " << headerPacketSize;
|
||||
FILE_LOG(logDEBUG) << "Streamer Pixels X: " << nPixelsX_Streamer;
|
||||
FILE_LOG(logDEBUG) << "Streamer Pixels Y: " << nPixelsY_Streamer;
|
||||
FILE_LOG(logDEBUG) << "Streamer Image Size: " << imageSize_Streamer;
|
||||
};
|
||||
};
|
||||
|
||||
@ -365,7 +342,7 @@ class Moench02Data : public GeneralData {
|
||||
*/
|
||||
void Print() const {
|
||||
GeneralData::Print();
|
||||
printf("Bytes Per Adc: %d\n",bytesPerAdc);
|
||||
FILE_LOG(logINFO) << "Bytes Per Adc: " << bytesPerAdc;
|
||||
}
|
||||
};
|
||||
|
||||
@ -427,7 +404,7 @@ class JCTBData : public GeneralData {
|
||||
*/
|
||||
void Print() const {
|
||||
GeneralData::Print();
|
||||
printf("Bytes Per Adc: %d\n",bytesPerAdc);
|
||||
FILE_LOG(logINFO) << "Bytes Per Adc: " << bytesPerAdc;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -110,7 +110,7 @@ public:
|
||||
fd = 0;
|
||||
}
|
||||
} catch(Exception error) {
|
||||
cprintf(RED,"Error in closing HDF5 handles of index %d\n", ind);
|
||||
bprintf(RED,"Error in closing HDF5 handles of index %d\n", ind);
|
||||
error.printError();
|
||||
}
|
||||
}
|
||||
@ -128,7 +128,7 @@ public:
|
||||
fd = 0;
|
||||
}
|
||||
} catch(Exception error) {
|
||||
cprintf(RED,"Error in closing master HDF5 handles\n");
|
||||
bprintf(RED,"Error in closing master HDF5 handles\n");
|
||||
error.printError();
|
||||
}
|
||||
}
|
||||
@ -142,7 +142,7 @@ public:
|
||||
{
|
||||
if(fd) {
|
||||
if (H5Fclose(fd) < 0 )
|
||||
cprintf(RED,"Error in closing virtual HDF5 handles\n");
|
||||
bprintf(RED,"Error in closing virtual HDF5 handles\n");
|
||||
fd = 0;
|
||||
}
|
||||
}
|
||||
@ -175,7 +175,7 @@ public:
|
||||
memspace.close();
|
||||
}
|
||||
catch(Exception error){
|
||||
cprintf(RED,"Error in writing to file in object %d\n",ind);
|
||||
bprintf(RED,"Error in writing to file in object %d\n",ind);
|
||||
error.printError();
|
||||
return 1;
|
||||
}
|
||||
@ -211,7 +211,7 @@ public:
|
||||
dset_para[12]->write(&header->version, ParameterDataTypes[12], memspace, *dspace_para);
|
||||
}
|
||||
catch(Exception error){
|
||||
cprintf(RED,"Error in writing parameters to file in object %d\n",ind);
|
||||
bprintf(RED,"Error in writing parameters to file in object %d\n",ind);
|
||||
error.printError();
|
||||
return 1;
|
||||
}
|
||||
@ -319,7 +319,7 @@ public:
|
||||
fd->close();
|
||||
|
||||
} catch(Exception error) {
|
||||
cprintf(RED,"Error in creating master HDF5 handles\n");
|
||||
bprintf(RED,"Error in creating master HDF5 handles\n");
|
||||
error.printError();
|
||||
return 1;
|
||||
}
|
||||
@ -403,7 +403,7 @@ public:
|
||||
dset_para[i] = new DataSet(fd->createDataSet(ParameterNames[i], ParameterDataTypes[i], *dspace_para));
|
||||
}
|
||||
catch(Exception error){
|
||||
cprintf(RED,"Error in creating HDF5 handles in object %d\n",ind);
|
||||
bprintf(RED,"Error in creating HDF5 handles in object %d\n",ind);
|
||||
error.printError();
|
||||
fd->close();
|
||||
return 1;
|
||||
@ -449,7 +449,7 @@ public:
|
||||
{
|
||||
//virtual names
|
||||
string virtualFileName = CreateVirtualFileName(fpath, fnameprefix, findex);
|
||||
printf("Virtual File: %s\n", virtualFileName.c_str());
|
||||
FILE_LOG(logINFO) << "Virtual File: " << virtualFileName;
|
||||
|
||||
//file
|
||||
hid_t dfal = H5Pcreate (H5P_FILE_ACCESS);
|
||||
@ -519,12 +519,12 @@ public:
|
||||
|
||||
//setect hyperslabs
|
||||
if (H5Sselect_hyperslab (vdsDataspace, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) {
|
||||
cprintf(RED,"could not select hyperslab\n");
|
||||
bprintf(RED,"could not select hyperslab\n");
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
if (H5Sselect_hyperslab (vdsDataspace_para, H5S_SELECT_SET, offset_para, NULL, count_para, NULL) < 0) {
|
||||
cprintf(RED,"could not select hyperslab for parameters\n");
|
||||
bprintf(RED,"could not select hyperslab for parameters\n");
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
@ -551,14 +551,14 @@ public:
|
||||
|
||||
//mapping
|
||||
if (H5Pset_virtual(dcpl, vdsDataspace, srcFileName.c_str(), srcDatasetName.c_str(), srcDataspace) < 0) {
|
||||
cprintf(RED,"could not set mapping for paramter 1\n");
|
||||
bprintf(RED,"could not set mapping for paramter 1\n");
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int k = 0; k < NumberofParameters; ++k) {
|
||||
if (H5Pset_virtual(dcpl_para[k], vdsDataspace_para, srcFileName.c_str(), ParameterNames[k], srcDataspace_para) < 0) {
|
||||
cprintf(RED,"could not set mapping for paramter %d\n", k);
|
||||
bprintf(RED,"could not set mapping for paramter %d\n", k);
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
@ -631,39 +631,30 @@ public:
|
||||
data_out = (T*)malloc(sizeof(T)*(nDimx*nDimy*nDimz));
|
||||
break;
|
||||
default:
|
||||
cprintf(RED,"invalid rank. Options: 2 or 3\n");
|
||||
bprintf(RED,"invalid rank. Options: 2 or 3\n");
|
||||
return 0;
|
||||
}
|
||||
if (datatype == PredType::STD_U16LE) {
|
||||
printf("datatype:16\n");
|
||||
FILE_LOG(logINFO) << "datatype:16";
|
||||
} else if (datatype == PredType::STD_U32LE) {
|
||||
printf("datatype:32\n");
|
||||
FILE_LOG(logINFO) << "datatype:32";
|
||||
} else if (datatype == PredType::STD_U64LE) {
|
||||
printf("datatype:64\n");
|
||||
FILE_LOG(logINFO) << "datatype:64";
|
||||
} else if (datatype == PredType::STD_U8LE) {
|
||||
printf("datatype:8\n");
|
||||
FILE_LOG(logINFO) << "datatype:8";
|
||||
} else {
|
||||
cprintf(RED, "unknown datatype\n");
|
||||
FILE_LOG(logERROR) << "unknown datatype";
|
||||
return 1;
|
||||
}
|
||||
printf("owenable:%d\n"
|
||||
"oldFileName:%s\n"
|
||||
"oldDatasetName:%s\n"
|
||||
"newFileName:%s\n"
|
||||
"newDatasetName:%s\n"
|
||||
"rank:%d\n"
|
||||
"nDimx:%llu\n"
|
||||
"nDimy:%u\n"
|
||||
"nDimz:%u\n",
|
||||
owenable?1:0,
|
||||
oldFileName.c_str(),
|
||||
oldDatasetName.c_str(),
|
||||
newFileName.c_str(),
|
||||
newDatasetName.c_str(),
|
||||
rank,
|
||||
(long long unsigned int)nDimx,
|
||||
nDimy,
|
||||
nDimz);
|
||||
FILE_LOG(logINFO) << "owenable:" << owenable?1:0 << endl
|
||||
<< "oldFileName:" << oldFileName << endl
|
||||
<< "oldDatasetName:" << oldDatasetName << endl
|
||||
<< "newFileName:" << newFileName << endl
|
||||
<< "newDatasetName:" << newDatasetName << endl
|
||||
<< "rank:" << rank << endl
|
||||
<< "nDimx:" << nDimx << endl
|
||||
<< "nDimy:" << nDimy << endl
|
||||
<< "nDimz:" << nDimz;
|
||||
|
||||
H5File* oldfd;
|
||||
H5File* newfd;
|
||||
@ -697,7 +688,7 @@ public:
|
||||
newfd->close();
|
||||
oldfd->close();
|
||||
} catch(Exception error){
|
||||
cprintf(RED,"Error in copying virtual files\n");
|
||||
bprintf(RED,"Error in copying virtual files\n");
|
||||
error.printError();
|
||||
free(data_out);
|
||||
oldfd->close();
|
||||
@ -781,7 +772,7 @@ public:
|
||||
* @returns 1 for fail
|
||||
*/
|
||||
static int CloseFileOnError(hid_t& fd, const string msg) {
|
||||
cprintf(RED, "%s", msg.c_str());
|
||||
bprintf(RED, "%s", msg.c_str());
|
||||
if(fd > 0)
|
||||
H5Fclose(fd);
|
||||
fd = 0;
|
||||
@ -804,7 +795,7 @@ public:
|
||||
else if (dtype == PredType::STD_U64LE)
|
||||
return H5T_STD_U64LE;
|
||||
else {
|
||||
cprintf(RED, "Invalid Data type\n");
|
||||
bprintf(RED, "Invalid Data type\n");
|
||||
return H5T_STD_U64LE;
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ public:
|
||||
detType, version);
|
||||
#ifdef VERBOSE
|
||||
//if(!index)
|
||||
printf("%d Streamer: buf:%s\n", index, buf);
|
||||
FILE_LOG(logINFO) << index << ": Streamer: buf:" << buf;
|
||||
#endif
|
||||
|
||||
if(zmq_send (socketDescriptor, buf, length, dummy?0:ZMQ_SNDMORE) < 0) {
|
||||
|
@ -6,6 +6,8 @@
|
||||
#define CYAN "\x1b[36m"
|
||||
#define GRAY "\x1b[37m"
|
||||
#define DARKGRAY "\x1b[30m"
|
||||
|
||||
#define BG_BLACK "\x1b[48;5;232m"
|
||||
#define BG_RED "\x1b[41m"
|
||||
#define BG_GREEN "\x1b[42m"
|
||||
#define BG_YELLOW "\x1b[43m"
|
||||
@ -15,8 +17,10 @@
|
||||
#define RESET "\x1b[0m"
|
||||
#define BOLD "\x1b[1m"
|
||||
|
||||
//on background black
|
||||
#define bprintf(code, format, ...) printf(code BG_BLACK format RESET, ##__VA_ARGS__)
|
||||
//normal printout
|
||||
#define cprintf(code, format, ...) printf(code format RESET, ##__VA_ARGS__)
|
||||
|
||||
/*
|
||||
|
||||
Code examples
|
||||
|
@ -70,11 +70,8 @@ int CircularFifo<Element>::getSemValue()
|
||||
template<typename Element>
|
||||
bool CircularFifo<Element>::push(Element*& item_)
|
||||
{
|
||||
|
||||
//cout<<"*head:"<<head<<endl;
|
||||
//cout<<"*tail before"<<tail<<endl;
|
||||
unsigned int nextTail = increment(tail);
|
||||
//cout<<"*next tail"<<nextTail<<endl;
|
||||
|
||||
if(nextTail != head)
|
||||
{
|
||||
array[tail] = item_;
|
||||
@ -95,15 +92,11 @@ bool CircularFifo<Element>::push(Element*& item_)
|
||||
template<typename Element>
|
||||
bool CircularFifo<Element>::pop(Element*& item_)
|
||||
{
|
||||
//cout<<"-tail:"<<tail<<endl;
|
||||
//cout<<"-head before:"<<head<<endl;
|
||||
//if(head == tail)
|
||||
// return false; // empty queue
|
||||
sem_wait(&free_mutex);
|
||||
|
||||
item_ = array[head];
|
||||
head = increment(head);
|
||||
//cout<<"-head after:"<<head<<endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,434 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/***********************************************
|
||||
* @file UDPInterface.h
|
||||
* @short Base class with all the functions for the UDP inteface of the receiver
|
||||
***********************************************/
|
||||
/**
|
||||
* \mainpage Base class with all the functions for the UDP inteface of the receiver
|
||||
*/
|
||||
|
||||
/**
|
||||
* @short Base class with all the functions for the UDP inteface of the receiver
|
||||
*/
|
||||
|
||||
#include "UDPInterface.h"
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "genericSocket.h"
|
||||
|
||||
|
||||
class dummyUDPInterface : public UDPInterface {
|
||||
|
||||
|
||||
/* abstract class that defines the UDP interface of an sls detector data receiver.
|
||||
*
|
||||
* Use the factory method UDPInterface::create() to get an instance:
|
||||
*
|
||||
* UDPInterface *udp_interface = UDPInterface::create()
|
||||
*
|
||||
* supported sequence of method-calls:
|
||||
*
|
||||
* initialize() : once and only once after create()
|
||||
*
|
||||
* get*() : anytime after initialize(), multiples times
|
||||
* set*() : anytime after initialize(), multiple times
|
||||
*
|
||||
* startReceiver(): anytime after initialize(). Will fail if state already is 'running'
|
||||
*
|
||||
* abort(),
|
||||
* stopReceiver() : anytime after initialize(). Will do nothing if state already is idle.
|
||||
*
|
||||
* getStatus() returns the actual state of the data receiver - running or idle. All other
|
||||
* get*() and set*() methods access the local cache of configuration values only and *do not* modify the data receiver settings.
|
||||
*
|
||||
* Only startReceiver() does change the data receiver configuration, it does pass the whole configuration cache to the data receiver.
|
||||
*
|
||||
* get- and set-methods that return a char array (char *) allocate a new array at each call. The caller is responsible to free the allocated space:
|
||||
*
|
||||
* char *c = receiver->getFileName();
|
||||
* ....
|
||||
* delete[] c;
|
||||
*
|
||||
* always: 1:YES 0:NO for int as bool-like arguments
|
||||
*
|
||||
*/
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
dummyUDPInterface() : UDPInterface(), dynamicRange(16), scanTag(1000), nFrames(100), fWrite(1), fOverwrite(1), fIndex(0), fCaught(0), totfCaught(0), startAcqIndex(0), startFrameIndex(0), acqIndex(0), dataCompression(false), period(0), type(slsReceiverDefs::GENERIC), framesNeeded(100), udpPort1(1900), udpPort2(1901), shortFrame(0), nFramesToGui(0), e10G(0) {strcpy(detHostname,"none"); strcpy(fName,"run"); strcpy(fPath,"/scratch/"); strcpy(eth,"eth0"); cout << "New dummy UDP Interface" << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
~dummyUDPInterface() {cout << "Destroying dummy UDP Interface" << endl;};
|
||||
|
||||
|
||||
void del(){cout << "Destroying dummy UDP Interface" << endl;};
|
||||
|
||||
virtual void configure(map<string, string> config_map) {};
|
||||
/**
|
||||
* Initialize the Receiver
|
||||
@param detectorHostName detector hostname
|
||||
* you can call this function only once. You must call it before you call startReceiver() for the first time.
|
||||
*/
|
||||
virtual void initialize(const char *detectorHostName){ cout << "set detector hostname to" << detHostname << endl; strcpy(detHostname,detectorHostName);};
|
||||
|
||||
|
||||
/* Returns detector hostname
|
||||
/returns hostname
|
||||
* caller needs to deallocate the returned char array.
|
||||
* if uninitialized, it must return NULL
|
||||
*/
|
||||
virtual char *getDetectorHostname() const { cout << "get detector hostname " << detHostname << endl; return (char*) detHostname;};
|
||||
|
||||
/**
|
||||
* Returns status of receiver: idle, running or error
|
||||
*/
|
||||
virtual slsReceiverDefs::runStatus getStatus() const { cout << "get dsummy status IDLE " << endl; return slsReceiverDefs::IDLE;};;
|
||||
|
||||
/**
|
||||
* Returns File Name
|
||||
* caller is responsible to deallocate the returned char array.
|
||||
*/
|
||||
virtual char *getFileName() const { cout << "get file name " << fName << endl; return (char*) fName;};
|
||||
|
||||
|
||||
/**
|
||||
* Returns File Path
|
||||
* caller is responsible to deallocate the returned char array
|
||||
*/
|
||||
virtual char *getFilePath() const { cout << "get file path " << fPath << endl; return (char*) fPath;};;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of bits per pixel
|
||||
*/
|
||||
virtual int getDynamicRange() const { cout << "get dynamic range " << dynamicRange << endl; return dynamicRange;};;
|
||||
|
||||
/**
|
||||
* Returns scan tag
|
||||
*/
|
||||
virtual int getScanTag() const { cout << "get scan tag " << scanTag << endl; return scanTag;};
|
||||
|
||||
/*
|
||||
* Returns number of frames to receive
|
||||
* This is the number of frames to expect to receiver from the detector.
|
||||
* The data receiver will change from running to idle when it got this number of frames
|
||||
*/
|
||||
virtual int getNumberOfFrames() const { cout << "get number of frames " << nFrames << endl; return nFrames;};
|
||||
|
||||
/**
|
||||
* Returns file write enable
|
||||
* 1: YES 0: NO
|
||||
*/
|
||||
virtual int getEnableFileWrite() const { cout << "get enable file write " << fWrite << endl; return fWrite;};
|
||||
|
||||
/**
|
||||
* Returns file over write enable
|
||||
* 1: YES 0: NO
|
||||
*/
|
||||
virtual int getEnableOverwrite() const { cout << "get enable file overwrite " << fOverwrite << endl; return fOverwrite;};
|
||||
|
||||
/**
|
||||
* Set File Name (without frame index, file index and extension)
|
||||
@param c file name
|
||||
/returns file name
|
||||
* returns NULL on failure (like bad file name)
|
||||
* does not check the existence of the file - we don't know which path we'll finally use, so no point to check.
|
||||
* caller is responsible to deallocate the returned char array.
|
||||
*/
|
||||
virtual char* setFileName(const char c[]) { strcpy(fName,c); cout << "set file name " << fName << endl; return fName; };
|
||||
|
||||
/**
|
||||
* Set File Path
|
||||
@param c file path
|
||||
/returns file path
|
||||
* checks the existence of the directory. returns NULL if directory does not exist or is not readable.
|
||||
* caller is responsible to deallocate the returned char array.
|
||||
*/
|
||||
virtual char* setFilePath(const char c[]) { strcpy(fPath,c); cout << "set file path " << fPath << endl; return fPath; };
|
||||
|
||||
/**
|
||||
* Returns the number of bits per pixel
|
||||
@param dr sets dynamic range
|
||||
/returns dynamic range
|
||||
* returns -1 on failure
|
||||
* FIXME: what are the allowd values - should we use an enum as argument?
|
||||
*/
|
||||
virtual int setDynamicRange(const int dr) {dynamicRange=dr; cout << "set dynamic range " << dynamicRange << endl; return dynamicRange; };
|
||||
|
||||
|
||||
/**
|
||||
* Set scan tag
|
||||
@param tag scan tag
|
||||
/returns scan tag (always non-negative)
|
||||
* FIXME: valid range - only positive? 16bit ore 32bit?
|
||||
* returns -1 on failure
|
||||
*/
|
||||
virtual int setScanTag(const int tag) {scanTag=tag; cout << "set scan tag " << scanTag << endl; return scanTag; };
|
||||
|
||||
|
||||
/**
|
||||
* Sets number of frames
|
||||
@param fnum number of frames
|
||||
/returns number of frames
|
||||
*/
|
||||
virtual int setNumberOfFrames(const int fnum) {nFrames=fnum; cout << "set number of frames " << nFrames << endl; return nFrames; };
|
||||
|
||||
|
||||
/**
|
||||
* Set enable file write
|
||||
* @param i file write enable
|
||||
/returns file write enable
|
||||
*/
|
||||
virtual int setEnableFileWrite(const int i) {fWrite=i; cout << "set enable file write " << fWrite << endl; return fWrite; };
|
||||
|
||||
|
||||
/**
|
||||
* Set enable file overwrite
|
||||
* @param i file overwrite enable
|
||||
/returns file overwrite enable
|
||||
*/
|
||||
virtual int setEnableOverwrite(const int i) {fOverwrite=i; cout << "set enable file overwrite " << fOverwrite << endl; return fOverwrite; };
|
||||
|
||||
|
||||
/**
|
||||
* Starts Receiver - activate all configuration settings to the eiger receiver and start to listen for packets
|
||||
@param message is the error message if there is an error
|
||||
/returns 0 on success or -1 on failure
|
||||
*/
|
||||
//FIXME: success == 0 or success == 1?
|
||||
virtual int startReceiver(char *message=NULL) {cout << "dummy start receiver" << endl;
|
||||
char buff[8225];
|
||||
buff[8224]='\0';
|
||||
int ip=0;
|
||||
int ib;
|
||||
genericSocket *udpSocket= new genericSocket(50004,genericSocket::UDP,8224);
|
||||
while((ib=udpSocket->ReceiveDataOnly(buff,8224))>0) {
|
||||
cout << "*** "<< ib <<" ************************** " << ip++ << endl;
|
||||
cout << buff << endl;
|
||||
cout << "*****************************" << endl << endl<< endl ;
|
||||
}
|
||||
return 0;};
|
||||
|
||||
/**
|
||||
* Stops Receiver - stops listening for packets
|
||||
/returns success
|
||||
* same as abort(). Always returns 0.
|
||||
*/
|
||||
virtual int stopReceiver() {cout << "dummy stop receiver" << endl; return 0;};
|
||||
|
||||
/**
|
||||
* abort acquisition with minimum damage: close open files, cleanup.
|
||||
* does nothing if state already is 'idle'
|
||||
*/
|
||||
virtual void abort() {cout << "Aborting receiver" << endl; };
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************************************************
|
||||
**************************************** Added by Dhanya *********************************************************
|
||||
*******************************************************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns File Index
|
||||
*/
|
||||
virtual int getFileIndex() {cout << "get file index " << fIndex << endl; return fIndex;};
|
||||
|
||||
/**
|
||||
* Returns Total Frames Caught for an entire acquisition (including all scans)
|
||||
*/
|
||||
virtual int getTotalFramesCaught() {cout << "get total frames caught " << totfCaught << endl ; return totfCaught;};
|
||||
|
||||
/**
|
||||
* Returns Frames Caught for each real time acquisition (eg. for each scan)
|
||||
*/
|
||||
virtual int getFramesCaught() {cout << "get frames caught " << fCaught << endl; return fCaught;};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the frame index at start of entire acquisition (including all scans)
|
||||
*/
|
||||
virtual uint32_t getStartAcquisitionIndex(){ cout << "get start acquisition index " << startAcqIndex << endl; return startAcqIndex; };
|
||||
|
||||
/**
|
||||
* Returns current Frame Index Caught for an entire acquisition (including all scans)
|
||||
*/
|
||||
virtual uint32_t getAcquisitionIndex(){ cout << "get acquisition index " << acqIndex << endl; return acqIndex; };
|
||||
|
||||
|
||||
/**
|
||||
* Returns the frame index at start of each real time acquisition (eg. for each scan)
|
||||
*/
|
||||
virtual uint32_t getStartFrameIndex() { cout << "get start frame index " << startFrameIndex << endl; return startFrameIndex; };
|
||||
|
||||
|
||||
/** get data compression, by saving only hits
|
||||
*/
|
||||
virtual bool getDataCompression() { cout << "get data compression " << dataCompression << endl; return dataCompression;};
|
||||
|
||||
/**
|
||||
* Set receiver type
|
||||
* @param det detector type
|
||||
* Returns success or FAIL
|
||||
*/
|
||||
virtual int setDetectorType(slsReceiverDefs::detectorType det) {type=det; cout << "set detector type " << det << endl; return slsReceiverDefs::OK;};
|
||||
|
||||
/**
|
||||
* Set File Index
|
||||
* @param i file index
|
||||
*/
|
||||
virtual int setFileIndex(int i) {fIndex=i; cout << "get file index " << fIndex << endl; return fIndex;};
|
||||
|
||||
/** set acquisition period if a positive number
|
||||
*/
|
||||
virtual int64_t setAcquisitionPeriod(int64_t index) {if (index>=0) {period=index; cout << "set period " << period << endl;} else { cout << "get period " << period << endl;} return period;};
|
||||
|
||||
/**
|
||||
* Set Frame Index Needed
|
||||
* @param i frame index needed
|
||||
*/
|
||||
virtual int setFrameIndexNeeded(int i) {framesNeeded=i; cout << "set frame index needed " << period << endl; return framesNeeded;};
|
||||
|
||||
/**
|
||||
* Set UDP Port Number
|
||||
*/
|
||||
virtual void setUDPPortNo(int p){udpPort1=p; cout << "set UDP port 1 " << udpPort1 << endl; };
|
||||
|
||||
|
||||
/**
|
||||
* Set UDP Port Number
|
||||
*/
|
||||
virtual void setUDPPortNo2(int p) {udpPort2=p; cout << "set UDP port 2 " << udpPort2 << endl; };
|
||||
|
||||
/**
|
||||
* Set Ethernet Interface or IP to listen to
|
||||
*/
|
||||
virtual void setEthernetInterface(char* c){strcpy(eth,c); cout << "set eth " << c;};
|
||||
|
||||
/**
|
||||
* Set short frame
|
||||
* @param i if shortframe i=1
|
||||
*/
|
||||
virtual int setShortFrame(int i){shortFrame=i; cout << " set short frame" << shortFrame << endl; return shortFrame;};
|
||||
|
||||
/**
|
||||
* Set the variable to send every nth frame to gui
|
||||
* or if 0,send frame only upon gui request
|
||||
*/
|
||||
virtual int setNFrameToGui(int i) {nFramesToGui=i; cout << "set nframes to gui " << nFramesToGui << endl; return nFramesToGui;};
|
||||
|
||||
/**
|
||||
* Resets the Total Frames Caught
|
||||
* This is how the receiver differentiates between entire acquisitions
|
||||
* Returns 0
|
||||
*/
|
||||
virtual void resetTotalFramesCaught() {totfCaught=0; cout << "total frames caugh reset " << totfCaught << endl;};
|
||||
|
||||
/** enabl data compression, by saving only hits
|
||||
/returns if failed
|
||||
*/
|
||||
virtual int enableDataCompression(bool enable) {dataCompression=enable; cout << "set data compression " << dataCompression<< endl; return dataCompression;};
|
||||
|
||||
/**
|
||||
* enable 10Gbe
|
||||
@param enable 1 for 10Gbe or 0 for 1 Gbe, -1 to read out
|
||||
\returns enable for 10Gbe
|
||||
*/
|
||||
virtual int enableTenGiga(int enable = -1) {if (enable>=0) {e10G=enable; cout << "set 10Gb "<< e10G << endl;} else cout << "get 10Gb "<< e10G << endl; return e10G;};
|
||||
|
||||
/**
|
||||
* Returns the buffer-current frame read by receiver
|
||||
* @param c pointer to current file name
|
||||
* @param raw address of pointer, pointing to current frame to send to gui
|
||||
* @param fnum frame number for eiger as it is not in the packet
|
||||
* @param startAcquisitionIndex is the start index of the acquisition
|
||||
* @param startFrameIndex is the start index of the scan
|
||||
*/
|
||||
virtual void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex){cout << "dummy read frame" << endl; };
|
||||
|
||||
/** set status to transmitting and
|
||||
* when fifo is empty later, sets status to run_finished
|
||||
*/
|
||||
virtual void startReadout(){cout << "dummy start readout" << endl; };
|
||||
|
||||
/**
|
||||
* shuts down the udp sockets
|
||||
* \returns if success or fail
|
||||
*/
|
||||
virtual int shutDownUDPSockets(){cout << "dummy shut down udp sockets" << endl; return slsReceiverDefs::OK;};
|
||||
|
||||
/**
|
||||
* Closes all files
|
||||
* @param ithr thread index, -1 for all threads
|
||||
*/
|
||||
virtual void closeFile(int ithr = -1){cout << "dummy close file" << ithr << endl; };
|
||||
|
||||
/**
|
||||
* Call back for start acquisition
|
||||
callback arguments are
|
||||
filepath
|
||||
filename
|
||||
fileindex
|
||||
datasize
|
||||
|
||||
return value is
|
||||
0 callback takes care of open,close,wrie file
|
||||
1 callback writes file, we have to open, close it
|
||||
2 we open, close, write file, callback does not do anything
|
||||
*/
|
||||
virtual void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){cout << "dummy register callback start acquisition" << endl; };
|
||||
|
||||
/**
|
||||
* Call back for acquisition finished
|
||||
callback argument is
|
||||
total frames caught
|
||||
*/
|
||||
virtual void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){cout << "dummy register callback acquisition finished" << endl; };
|
||||
|
||||
/**
|
||||
* Call back for raw data
|
||||
args to raw data ready callback are
|
||||
framenum
|
||||
datapointer
|
||||
datasize in bytes
|
||||
file descriptor
|
||||
guidatapointer (NULL, no data required)
|
||||
*/
|
||||
virtual void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){cout << "dummy register callback get raw data" << endl; };
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
char detHostname[1000];
|
||||
char fName[10000];
|
||||
char fPath[10000];
|
||||
int dynamicRange;
|
||||
int scanTag;
|
||||
int nFrames;
|
||||
int fWrite;
|
||||
int fOverwrite;
|
||||
|
||||
int fIndex;
|
||||
int fCaught;
|
||||
int totfCaught;
|
||||
int startAcqIndex;
|
||||
int startFrameIndex;
|
||||
int acqIndex;
|
||||
bool dataCompression;
|
||||
int64_t period;
|
||||
slsReceiverDefs::detectorType type;
|
||||
int framesNeeded;
|
||||
int udpPort1;
|
||||
int udpPort2;
|
||||
char eth[1000];
|
||||
int shortFrame;
|
||||
int nFramesToGui;
|
||||
int e10G;
|
||||
};
|
||||
|
@ -313,7 +313,7 @@ enum communicationProtocol{
|
||||
/** @short etablishes connection; disconnect should always follow
|
||||
\returns 1 if error
|
||||
*/
|
||||
int Connect(){//cout<<"connect"<<endl;
|
||||
int Connect(){
|
||||
|
||||
if(file_des>0) return file_des;
|
||||
if (protocol==UDP) return -1;
|
||||
@ -458,7 +458,6 @@ enum communicationProtocol{
|
||||
if (ts<=0)
|
||||
return -1;
|
||||
|
||||
//cout << "socketdescriptor "<< socketDescriptor << endl;
|
||||
struct timeval tout;
|
||||
tout.tv_sec = 0;
|
||||
tout.tv_usec = 0;
|
||||
@ -612,7 +611,7 @@ enum communicationProtocol{
|
||||
continue;
|
||||
if(nsent != nsending){
|
||||
if(nsent && (nsent != -1))
|
||||
cprintf(RED,"Incomplete Packet size %d\n",nsent);
|
||||
bprintf(RED,"Incomplete Packet size %d\n",nsent);
|
||||
break;
|
||||
}
|
||||
length-=nsent;
|
||||
@ -625,7 +624,7 @@ enum communicationProtocol{
|
||||
nsending=packet_size;
|
||||
while(1){
|
||||
#ifdef VERYVERBOSE
|
||||
cprintf(BLUE,"%d gonna listen\n", portno); fflush(stdout);
|
||||
bprintf(BLUE,"%d gonna listen\n", portno); fflush(stdout);
|
||||
#endif
|
||||
nsent = recvfrom(socketDescriptor,(char*)buf+total_sent,nsending, 0, (struct sockaddr *) &clientAddress, &clientAddress_length);
|
||||
//break out of loop only if read one packets size or read didnt work (cuz of shutdown)
|
||||
@ -633,7 +632,7 @@ enum communicationProtocol{
|
||||
break;
|
||||
//incomplete packets or header packets ignored and read buffer again
|
||||
if(nsent != packet_size && nsent != header_packet_size)
|
||||
cprintf(RED,"Incomplete Packet size %d\n",nsent);
|
||||
bprintf(RED,"Incomplete Packet size %d\n",nsent);
|
||||
}
|
||||
//nsent = 1040;
|
||||
total_sent+=nsent;
|
||||
|
@ -1,11 +1,11 @@
|
||||
//#define SVNPATH ""
|
||||
#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_receiver_software.git"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUID "7d45ac53d7d92a4817002e7aed7297d5ddfd0f73"
|
||||
//#define SVNREV 0x601
|
||||
#define SVNREPUUID "edef347a62cd0239115c76101154d94814c6916b"
|
||||
//#define SVNREV 0x602
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTH "Dhanya_Maliakal"
|
||||
#define SVNREV 0x601
|
||||
#define SVNDATE 0x20170628
|
||||
#define SVNREV 0x602
|
||||
#define SVNDATE 0x20170629
|
||||
//
|
||||
|
@ -32,13 +32,8 @@
|
||||
)
|
||||
#define __SHORT_AT__ string(__SHORT_FORM_OF_FILE__) + string("::") + string(__func__) + string("(): ")
|
||||
|
||||
//":" TOSTRING(__LINE__)
|
||||
|
||||
/*
|
||||
void error(const char *location, const char *msg){
|
||||
printf("Error at %s: %s\n", location, msg);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
inline std::string NowTime();
|
||||
|
||||
@ -223,10 +218,10 @@ inline void Output2FILE::Output(const std::string& msg, TLogLevel level)
|
||||
return;
|
||||
bool out = true;
|
||||
switch(level){
|
||||
case logERROR: cprintf(RED BOLD,"%s",msg.c_str()); break;
|
||||
case logWARNING: cprintf(YELLOW BOLD,"%s",msg.c_str()); break;
|
||||
case logINFO: cprintf(GRAY,"%s",msg.c_str()); break;
|
||||
// case logINFO: cprintf(DARKGRAY BOLD,"%s",msg.c_str());break;
|
||||
case logERROR: bprintf(RED BOLD,"%s",msg.c_str()); break;
|
||||
case logWARNING: bprintf(YELLOW BOLD,"%s",msg.c_str()); break;
|
||||
case logINFO: bprintf(GRAY,"%s",msg.c_str()); break;
|
||||
// case logINFO: bprintf(DARKGRAY BOLD,"%s",msg.c_str());break;
|
||||
default: fprintf(pStream,"%s",msg.c_str()); out = false; break;
|
||||
}
|
||||
fflush(out ? stdout : pStream);
|
||||
|
Reference in New Issue
Block a user