made it work for gotthard

This commit is contained in:
Dhanya Maliakal
2017-03-09 11:40:48 +01:00
parent 0dccd78567
commit 86018684c9
8 changed files with 59 additions and 36 deletions

View File

@ -124,7 +124,8 @@ public:
subFrameNumber = -1; subFrameNumber = -1;
bunchId = -1; bunchId = -1;
frameNumber = ((uint32_t)(*((uint32_t*)(packetData)))); frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
frameNumber++; if (myDetectorType == slsReceiverDefs::PROPIX ||(myDetectorType == slsReceiverDefs::GOTTHARD && packetSize == GOTTHARD_PACKET_SIZE))
frameNumber++;
packetNumber = frameNumber&packetIndexMask; packetNumber = frameNumber&packetIndexMask;
frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset; frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset;
} }
@ -203,7 +204,7 @@ class GotthardData : public GeneralData {
nPixelsY = 1; nPixelsY = 1;
headerSizeinPacket = 4; headerSizeinPacket = 4;
dataSize = 1280; dataSize = 1280;
packetSize = 1286; packetSize = GOTTHARD_PACKET_SIZE;
packetsPerFrame = 2; packetsPerFrame = 2;
imageSize = dataSize*packetsPerFrame; imageSize = dataSize*packetsPerFrame;
frameIndexMask = 0xFFFFFFFE; frameIndexMask = 0xFFFFFFFE;
@ -211,7 +212,7 @@ class GotthardData : public GeneralData {
packetIndexMask = 1; packetIndexMask = 1;
maxFramesPerFile = MAX_FRAMES_PER_FILE; maxFramesPerFile = MAX_FRAMES_PER_FILE;
fifoBufferSize = imageSize; fifoBufferSize = imageSize;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES; fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
defaultFifoDepth = 25000; defaultFifoDepth = 25000;
}; };
}; };
@ -234,7 +235,7 @@ class ShortGotthardData : public GeneralData {
frameIndexMask = 0xFFFFFFFF; frameIndexMask = 0xFFFFFFFF;
maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE; maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE;
fifoBufferSize = imageSize; fifoBufferSize = imageSize;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES; fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
defaultFifoDepth = 25000; defaultFifoDepth = 25000;
}; };
}; };
@ -264,7 +265,7 @@ class PropixData : public GeneralData {
packetIndexMask = 1; packetIndexMask = 1;
maxFramesPerFile = MAX_FRAMES_PER_FILE; maxFramesPerFile = MAX_FRAMES_PER_FILE;
fifoBufferSize = imageSize; fifoBufferSize = imageSize;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES; fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
defaultFifoDepth = 25000; defaultFifoDepth = 25000;
}; };
}; };

View File

@ -159,6 +159,9 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
/** Number of frames in file */ /** Number of frames in file */
uint32_t numFramesInFile; uint32_t numFramesInFile;
/** Number of files in an acquisition - to verify need of virtual file */
int numFilesinAcquisition;
//parameters //parameters
/** Dataspace of parameters */ /** Dataspace of parameters */
DataSpace* dataspace_para; DataSpace* dataspace_para;
@ -182,6 +185,5 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
DataType datatype_para2; DataType datatype_para2;
}; };
#endif #endif

View File

@ -36,6 +36,10 @@
#define MAX_JOBS_PER_THREAD 1000 #define MAX_JOBS_PER_THREAD 1000
//to differentiate between gotthard and short gotthard
#define GOTTHARD_PACKET_SIZE 1286
#define DUMMY_PACKET_VALUE 0xFFFFFFFF #define DUMMY_PACKET_VALUE 0xFFFFFFFF
#define LISTENER_PRIORITY 99 #define LISTENER_PRIORITY 99

View File

@ -126,8 +126,6 @@ void DataStreamer::ResetParametersforNewMeasurement(char* fname){
firstMeasurementIndex = 0; firstMeasurementIndex = 0;
measurementStartedFlag = false; measurementStartedFlag = false;
strcpy(fileNametoStream, fname); strcpy(fileNametoStream, fname);
cprintf(BLUE,"fname:%s\n",fname);
CreateHeaderPart1(); CreateHeaderPart1();
} }

View File

@ -27,7 +27,7 @@ Fifo::Fifo(uint32_t fifoItemSize, uint32_t fifoDepth, bool &success):
Fifo::~Fifo() { Fifo::~Fifo() {
FILE_LOG (logDEBUG) << __AT__ << " called"; FILE_LOG (logDEBUG) << __AT__ << " called";
cprintf(RED,"destroying fifos\n"); cprintf(BLUE,"Fifo Object %d: Goodbye\n", index);
DestroyFifos(); DestroyFifos();
NumberofFifoClassObjects--; NumberofFifoClassObjects--;
} }
@ -47,6 +47,7 @@ int Fifo::CreateFifos(uint32_t fifoItemSize, uint32_t fifoDepth) {
memory = (char*) calloc (fifoItemSize * fifoDepth, sizeof(char)); memory = (char*) calloc (fifoItemSize * fifoDepth, sizeof(char));
if (memory == NULL){ if (memory == NULL){
FILE_LOG (logERROR) << "Could not allocate memory for fifos"; FILE_LOG (logERROR) << "Could not allocate memory for fifos";
memory = 0;
return FAIL; return FAIL;
} }
@ -69,6 +70,11 @@ int Fifo::CreateFifos(uint32_t fifoItemSize, uint32_t fifoDepth) {
void Fifo::DestroyFifos(){ void Fifo::DestroyFifos(){
FILE_LOG (logDEBUG) << __AT__ << " called"; FILE_LOG (logDEBUG) << __AT__ << " called";
if(memory) {
free(memory);
memory = 0;
}
if (fifoBound) { if (fifoBound) {
delete fifoBound; delete fifoBound;
fifoBound = 0; fifoBound = 0;
@ -81,10 +87,6 @@ void Fifo::DestroyFifos(){
delete fifoStream; delete fifoStream;
fifoStream = 0; fifoStream = 0;
} }
if(memory) {
free(memory);
memory = 0;
}
} }

View File

@ -29,6 +29,7 @@ HDF5File::HDF5File(int ind, int* nd, char* fname, char* fpath, uint64_t* findex,
nPixelsX(nx), nPixelsX(nx),
nPixelsY(ny), nPixelsY(ny),
numFramesInFile(0), numFramesInFile(0),
numFilesinAcquisition(0),
dataspace_para(0), dataspace_para(0),
@ -86,6 +87,7 @@ void HDF5File::UpdateDataType() {
int HDF5File::CreateFile(uint64_t fnum) { int HDF5File::CreateFile(uint64_t fnum) {
numFilesinAcquisition++;
numFramesInFile = 0; numFramesInFile = 0;
currentFileName = HDF5FileStatic::CreateFileName(filePath, fileNamePrefix, *fileIndex, currentFileName = HDF5FileStatic::CreateFileName(filePath, fileNamePrefix, *fileIndex,
*frameIndexEnable, fnum, *detIndex, *numUnitsPerDetector, index); *frameIndexEnable, fnum, *detIndex, *numUnitsPerDetector, index);
@ -119,6 +121,7 @@ void HDF5File::CloseCurrentFile() {
void HDF5File::CloseAllFiles() { void HDF5File::CloseAllFiles() {
numFilesinAcquisition = 0;
pthread_mutex_lock(&Mutex); pthread_mutex_lock(&Mutex);
HDF5FileStatic::CloseDataFile(index, filefd, dataspace, dataset, dataset_para1, dataset_para2); HDF5FileStatic::CloseDataFile(index, filefd, dataspace, dataset, dataset_para1, dataset_para2);
if (master && (*detIndex==0)) { if (master && (*detIndex==0)) {
@ -174,8 +177,21 @@ int HDF5File::CreateMasterFile(bool en, uint32_t size,
void HDF5File::EndofAcquisition(uint64_t numf) { void HDF5File::EndofAcquisition(uint64_t numf) {
//not created before //not created before
if (!virtualfd) if (!virtualfd) {
CreateVirtualFile(numf); //create virtual file only if more than 1 file or more than 1 detector(more than 1 file)
if (((numFilesinAcquisition > 1) ||(numDetY*numDetX) > 1))
CreateVirtualFile(numf);
//link current file in master file
else {
//dataset name
ostringstream osfn;
osfn << "/data";
if (*frameIndexEnable) osfn << "_f" << setfill('0') << setw(12) << 0;
string dsetname = osfn.str();
HDF5FileStatic::LinkVirtualInMaster(masterFileName, currentFileName, dsetname, para1, para2);
}
}
numFilesinAcquisition = 0;
} }

View File

@ -51,6 +51,7 @@ Listener::Listener(Fifo*& f, runStatus* s, uint32_t* portno, char* e, int* act,
carryOverPacket(0), carryOverPacket(0),
listeningPacket(0) listeningPacket(0)
{ {
if(ThreadObject::CreateThread()){ if(ThreadObject::CreateThread()){
pthread_mutex_lock(&Mutex); pthread_mutex_lock(&Mutex);
ErrorMask ^= (1<<index); ErrorMask ^= (1<<index);
@ -309,7 +310,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
//look for carry over //look for carry over
if (carryOverFlag) { if (carryOverFlag) {if(!index) cprintf(RED,"carry flag\n");
//check if its the current image packet //check if its the current image packet
generalData->GetHeaderInfo(index, carryOverPacket, *dynamicRange, fnum, pnum, snum, bid); generalData->GetHeaderInfo(index, carryOverPacket, *dynamicRange, fnum, pnum, snum, bid);
if (fnum != currentFrameIndex) { if (fnum != currentFrameIndex) {

View File

@ -21,7 +21,6 @@ using namespace std;
UDPStandardImplementation::UDPStandardImplementation() { UDPStandardImplementation::UDPStandardImplementation() {
InitializeMembers(); InitializeMembers();
} }
@ -188,7 +187,7 @@ int UDPStandardImplementation::setFrameToGuiFrequency(const uint32_t freq) {
if (frameToGuiFrequency != freq) { if (frameToGuiFrequency != freq) {
frameToGuiFrequency = freq; frameToGuiFrequency = freq;
//only the ones lisening to more than 1 frame at a time needs to change fifo structure /*//only the ones lisening to more than 1 frame at a time needs to change fifo structure
switch (myDetectorType) { switch (myDetectorType) {
case GOTTHARD: case GOTTHARD:
case PROPIX: case PROPIX:
@ -197,7 +196,7 @@ int UDPStandardImplementation::setFrameToGuiFrequency(const uint32_t freq) {
break; break;
default: default:
break; break;
} }*/
} }
FILE_LOG (logINFO) << "Frame to Gui Frequency: " << frameToGuiFrequency; FILE_LOG (logINFO) << "Frame to Gui Frequency: " << frameToGuiFrequency;
return OK; return OK;
@ -246,7 +245,7 @@ int UDPStandardImplementation::setAcquisitionPeriod(const uint64_t i) {
if (acquisitionPeriod != i) { if (acquisitionPeriod != i) {
acquisitionPeriod = i; acquisitionPeriod = i;
//only the ones lisening to more than 1 frame at a time needs to change fifo structure /*//only the ones lisening to more than 1 frame at a time needs to change fifo structure
switch (myDetectorType) { switch (myDetectorType) {
case GOTTHARD: case GOTTHARD:
case PROPIX: case PROPIX:
@ -255,7 +254,7 @@ int UDPStandardImplementation::setAcquisitionPeriod(const uint64_t i) {
break; break;
default: default:
break; break;
} }*/
} }
FILE_LOG (logINFO) << "Acquisition Period: " << (double)acquisitionPeriod/(1E9) << "s"; FILE_LOG (logINFO) << "Acquisition Period: " << (double)acquisitionPeriod/(1E9) << "s";
return OK; return OK;
@ -266,7 +265,7 @@ int UDPStandardImplementation::setAcquisitionTime(const uint64_t i) {
if (acquisitionTime != i) { if (acquisitionTime != i) {
acquisitionTime = i; acquisitionTime = i;
//only the ones lisening to more than 1 frame at a time needs to change fifo structure /*//only the ones lisening to more than 1 frame at a time needs to change fifo structure
switch (myDetectorType) { switch (myDetectorType) {
case GOTTHARD: case GOTTHARD:
case PROPIX: case PROPIX:
@ -275,7 +274,7 @@ int UDPStandardImplementation::setAcquisitionTime(const uint64_t i) {
break; break;
default: default:
break; break;
} }*/
} }
FILE_LOG (logINFO) << "Acquisition Period: " << (double)acquisitionTime/(1E9) << "s"; FILE_LOG (logINFO) << "Acquisition Period: " << (double)acquisitionTime/(1E9) << "s";
return OK; return OK;
@ -286,7 +285,7 @@ int UDPStandardImplementation::setNumberOfFrames(const uint64_t i) {
if (numberOfFrames != i) { if (numberOfFrames != i) {
numberOfFrames = i; numberOfFrames = i;
//only the ones lisening to more than 1 frame at a time needs to change fifo structure /*//only the ones lisening to more than 1 frame at a time needs to change fifo structure
switch (myDetectorType) { switch (myDetectorType) {
case GOTTHARD: case GOTTHARD:
case PROPIX: case PROPIX:
@ -295,7 +294,7 @@ int UDPStandardImplementation::setNumberOfFrames(const uint64_t i) {
break; break;
default: default:
break; break;
} }*/
} }
FILE_LOG (logINFO) << "Number of Frames:" << numberOfFrames; FILE_LOG (logINFO) << "Number of Frames:" << numberOfFrames;
return OK; return OK;
@ -349,7 +348,6 @@ int UDPStandardImplementation::setFifoDepth(const uint32_t i) {
int UDPStandardImplementation::setDetectorType(const detectorType d) { int UDPStandardImplementation::setDetectorType(const detectorType d) {
FILE_LOG (logDEBUG) << "Setting receiver type"; FILE_LOG (logDEBUG) << "Setting receiver type";
DeleteMembers(); DeleteMembers();
InitializeMembers(); InitializeMembers();
myDetectorType = d; myDetectorType = d;
@ -670,7 +668,7 @@ void UDPStandardImplementation::SetLocalNetworkParameters() {
//to increase Socket Receiver Buffer size //to increase Socket Receiver Buffer size
sprintf(command,"echo $((%d)) > /proc/sys/net/core/rmem_max",RECEIVE_SOCKET_BUFFER_SIZE); sprintf(command,"echo $((%d)) > /proc/sys/net/core/rmem_max",RECEIVE_SOCKET_BUFFER_SIZE);
if (system(command)) { if (system(command)) {
FILE_LOG (logWARNING) << "No root permission to change Socket Receiver Buffer size (/proc/sys/net/core/rmem_max)"; FILE_LOG (logWARNING) << "No root privileges to change Socket Receiver Buffer size (net.core.rmem_max)";
return; return;
} }
FILE_LOG (logINFO) << "Socket Receiver Buffer size (/proc/sys/net/core/rmem_max) modified to " << RECEIVE_SOCKET_BUFFER_SIZE ; FILE_LOG (logINFO) << "Socket Receiver Buffer size (/proc/sys/net/core/rmem_max) modified to " << RECEIVE_SOCKET_BUFFER_SIZE ;
@ -679,7 +677,7 @@ void UDPStandardImplementation::SetLocalNetworkParameters() {
// to increase Max length of input packet queue // to increase Max length of input packet queue
sprintf(command,"echo %d > /proc/sys/net/core/netdev_max_backlog",MAX_SOCKET_INPUT_PACKET_QUEUE); sprintf(command,"echo %d > /proc/sys/net/core/netdev_max_backlog",MAX_SOCKET_INPUT_PACKET_QUEUE);
if (system(command)) { if (system(command)) {
FILE_LOG (logWARNING) << "No root permission to change Max length of input packet queue (/proc/sys/net/core/netdev_max_backlog)"; FILE_LOG (logWARNING) << "No root privileges to change Max length of input packet queue (net.core.rmem_max)";
return; return;
} }
FILE_LOG (logINFO) << "Max length of input packet queue (/proc/sys/net/core/netdev_max_backlog) modified to " << MAX_SOCKET_INPUT_PACKET_QUEUE ; FILE_LOG (logINFO) << "Max length of input packet queue (/proc/sys/net/core/netdev_max_backlog) modified to " << MAX_SOCKET_INPUT_PACKET_QUEUE ;
@ -691,26 +689,26 @@ void UDPStandardImplementation::SetThreadPriorities() {
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){ for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){
if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) { if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) {
FILE_LOG(logWARNING) << "Unable to prioritize threads. Root privileges required for this option."; FILE_LOG(logWARNING) << "No root privileges to prioritize threads";
return; return;
} }
} }
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){ for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
if ((*it)->SetThreadPriority(PROCESSOR_PRIORITY) == FAIL) { if ((*it)->SetThreadPriority(PROCESSOR_PRIORITY) == FAIL) {
FILE_LOG(logWARNING) << "Unable to prioritize threads. Root privileges required for this option."; FILE_LOG(logWARNING) << "No root privileges to prioritize threads";
return; return;
} }
} }
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){ for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
if ((*it)->SetThreadPriority(STREAMER_PRIORITY) == FAIL) { if ((*it)->SetThreadPriority(STREAMER_PRIORITY) == FAIL) {
FILE_LOG(logWARNING) << "Unable to prioritize threads. Root privileges required for this option."; FILE_LOG(logWARNING) << "No root privileges to prioritize threads";
return; return;
} }
} }
struct sched_param tcp_param; struct sched_param tcp_param;
tcp_param.sched_priority = TCP_PRIORITY; tcp_param.sched_priority = TCP_PRIORITY;
if (pthread_setschedparam(pthread_self(),5 , &tcp_param) != EPERM) { if (pthread_setschedparam(pthread_self(),5 , &tcp_param) != EPERM) {
FILE_LOG(logWARNING) << "Unable to prioritize threads. Root privileges required for this option."; FILE_LOG(logWARNING) << "No root privileges to prioritize threads";
return; return;
} }
@ -728,21 +726,22 @@ void UDPStandardImplementation::SetThreadPriorities() {
int UDPStandardImplementation::SetupFifoStructure() { int UDPStandardImplementation::SetupFifoStructure() {
//recalculate number of jobs & fifodepth, return if no change //recalculate number of jobs & fifodepth, return if no change
if ((myDetectorType == GOTTHARD) || (myDetectorType == PROPIX)) { /* if ((myDetectorType == GOTTHARD) || (myDetectorType == PROPIX)) {
int oldnumberofjobs = numberofJobs; int oldnumberofjobs = numberofJobs;
//listen to only n jobs at a time //listen to only n jobs at a time
if (frameToGuiFrequency) if (frameToGuiFrequency)
numberofJobs = frameToGuiFrequency; numberofJobs = frameToGuiFrequency;
/*else { NOT YET else { NOT YET
//random freq depends on acquisition period/time (calculate upto 100ms/period) //random freq depends on acquisition period/time (calculate upto 100ms/period)
int i = ((acquisitionPeriod > 0) ? int i = ((acquisitionPeriod > 0) ?
(SAMPLE_TIME_IN_NS/acquisitionPeriod): (SAMPLE_TIME_IN_NS/acquisitionPeriod):
((acquisitionTime > 0) ? (SAMPLE_TIME_IN_NS/acquisitionTime) : SAMPLE_TIME_IN_NS)); ((acquisitionTime > 0) ? (SAMPLE_TIME_IN_NS/acquisitionTime) : SAMPLE_TIME_IN_NS));
//must be > 0 and < max jobs //must be > 0 and < max jobs
numberofJobs = ((i < 1) ? 1 : ((i > MAX_JOBS_PER_THREAD) ? MAX_JOBS_PER_THREAD : i)); numberofJobs = ((i < 1) ? 1 : ((i > MAX_JOBS_PER_THREAD) ? MAX_JOBS_PER_THREAD : i));
}*/ }
FILE_LOG (logINFO) << "Number of Jobs Per Thread:" << numberofJobs << endl; FILE_LOG (logINFO) << "Number of Jobs Per Thread:" << numberofJobs << endl;
uint32_t oldfifodepth = fifoDepth; uint32_t oldfifodepth = fifoDepth;
@ -757,7 +756,7 @@ int UDPStandardImplementation::SetupFifoStructure() {
//no change, return //no change, return
if ((oldnumberofjobs == numberofJobs) && (oldfifodepth == fifoDepth)) if ((oldnumberofjobs == numberofJobs) && (oldfifodepth == fifoDepth))
return OK; return OK;
}else }else*/
numberofJobs = 1; numberofJobs = 1;