mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 21:07:13 +02:00
made it work for gotthard
This commit is contained in:
@ -124,7 +124,8 @@ public:
|
||||
subFrameNumber = -1;
|
||||
bunchId = -1;
|
||||
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
|
||||
frameNumber++;
|
||||
if (myDetectorType == slsReceiverDefs::PROPIX ||(myDetectorType == slsReceiverDefs::GOTTHARD && packetSize == GOTTHARD_PACKET_SIZE))
|
||||
frameNumber++;
|
||||
packetNumber = frameNumber&packetIndexMask;
|
||||
frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset;
|
||||
}
|
||||
@ -203,7 +204,7 @@ class GotthardData : public GeneralData {
|
||||
nPixelsY = 1;
|
||||
headerSizeinPacket = 4;
|
||||
dataSize = 1280;
|
||||
packetSize = 1286;
|
||||
packetSize = GOTTHARD_PACKET_SIZE;
|
||||
packetsPerFrame = 2;
|
||||
imageSize = dataSize*packetsPerFrame;
|
||||
frameIndexMask = 0xFFFFFFFE;
|
||||
@ -211,7 +212,7 @@ class GotthardData : public GeneralData {
|
||||
packetIndexMask = 1;
|
||||
maxFramesPerFile = MAX_FRAMES_PER_FILE;
|
||||
fifoBufferSize = imageSize;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||
defaultFifoDepth = 25000;
|
||||
};
|
||||
};
|
||||
@ -234,7 +235,7 @@ class ShortGotthardData : public GeneralData {
|
||||
frameIndexMask = 0xFFFFFFFF;
|
||||
maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE;
|
||||
fifoBufferSize = imageSize;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||
defaultFifoDepth = 25000;
|
||||
};
|
||||
};
|
||||
@ -264,7 +265,7 @@ class PropixData : public GeneralData {
|
||||
packetIndexMask = 1;
|
||||
maxFramesPerFile = MAX_FRAMES_PER_FILE;
|
||||
fifoBufferSize = imageSize;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||
defaultFifoDepth = 25000;
|
||||
};
|
||||
};
|
||||
|
@ -159,6 +159,9 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
|
||||
/** Number of frames in file */
|
||||
uint32_t numFramesInFile;
|
||||
|
||||
/** Number of files in an acquisition - to verify need of virtual file */
|
||||
int numFilesinAcquisition;
|
||||
|
||||
//parameters
|
||||
/** Dataspace of parameters */
|
||||
DataSpace* dataspace_para;
|
||||
@ -182,6 +185,5 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
|
||||
DataType datatype_para2;
|
||||
|
||||
|
||||
|
||||
};
|
||||
#endif
|
||||
|
@ -36,6 +36,10 @@
|
||||
#define MAX_JOBS_PER_THREAD 1000
|
||||
|
||||
|
||||
//to differentiate between gotthard and short gotthard
|
||||
#define GOTTHARD_PACKET_SIZE 1286
|
||||
|
||||
|
||||
#define DUMMY_PACKET_VALUE 0xFFFFFFFF
|
||||
|
||||
#define LISTENER_PRIORITY 99
|
||||
|
@ -126,8 +126,6 @@ void DataStreamer::ResetParametersforNewMeasurement(char* fname){
|
||||
firstMeasurementIndex = 0;
|
||||
measurementStartedFlag = false;
|
||||
strcpy(fileNametoStream, fname);
|
||||
cprintf(BLUE,"fname:%s\n",fname);
|
||||
|
||||
CreateHeaderPart1();
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ Fifo::Fifo(uint32_t fifoItemSize, uint32_t fifoDepth, bool &success):
|
||||
|
||||
Fifo::~Fifo() {
|
||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||
cprintf(RED,"destroying fifos\n");
|
||||
cprintf(BLUE,"Fifo Object %d: Goodbye\n", index);
|
||||
DestroyFifos();
|
||||
NumberofFifoClassObjects--;
|
||||
}
|
||||
@ -47,6 +47,7 @@ int Fifo::CreateFifos(uint32_t fifoItemSize, uint32_t fifoDepth) {
|
||||
memory = (char*) calloc (fifoItemSize * fifoDepth, sizeof(char));
|
||||
if (memory == NULL){
|
||||
FILE_LOG (logERROR) << "Could not allocate memory for fifos";
|
||||
memory = 0;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -69,6 +70,11 @@ int Fifo::CreateFifos(uint32_t fifoItemSize, uint32_t fifoDepth) {
|
||||
void Fifo::DestroyFifos(){
|
||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||
|
||||
|
||||
if(memory) {
|
||||
free(memory);
|
||||
memory = 0;
|
||||
}
|
||||
if (fifoBound) {
|
||||
delete fifoBound;
|
||||
fifoBound = 0;
|
||||
@ -81,10 +87,6 @@ void Fifo::DestroyFifos(){
|
||||
delete fifoStream;
|
||||
fifoStream = 0;
|
||||
}
|
||||
if(memory) {
|
||||
free(memory);
|
||||
memory = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,6 +29,7 @@ HDF5File::HDF5File(int ind, int* nd, char* fname, char* fpath, uint64_t* findex,
|
||||
nPixelsX(nx),
|
||||
nPixelsY(ny),
|
||||
numFramesInFile(0),
|
||||
numFilesinAcquisition(0),
|
||||
|
||||
dataspace_para(0),
|
||||
|
||||
@ -86,6 +87,7 @@ void HDF5File::UpdateDataType() {
|
||||
|
||||
|
||||
int HDF5File::CreateFile(uint64_t fnum) {
|
||||
numFilesinAcquisition++;
|
||||
numFramesInFile = 0;
|
||||
currentFileName = HDF5FileStatic::CreateFileName(filePath, fileNamePrefix, *fileIndex,
|
||||
*frameIndexEnable, fnum, *detIndex, *numUnitsPerDetector, index);
|
||||
@ -119,6 +121,7 @@ void HDF5File::CloseCurrentFile() {
|
||||
|
||||
|
||||
void HDF5File::CloseAllFiles() {
|
||||
numFilesinAcquisition = 0;
|
||||
pthread_mutex_lock(&Mutex);
|
||||
HDF5FileStatic::CloseDataFile(index, filefd, dataspace, dataset, dataset_para1, dataset_para2);
|
||||
if (master && (*detIndex==0)) {
|
||||
@ -174,8 +177,21 @@ int HDF5File::CreateMasterFile(bool en, uint32_t size,
|
||||
|
||||
void HDF5File::EndofAcquisition(uint64_t numf) {
|
||||
//not created before
|
||||
if (!virtualfd)
|
||||
CreateVirtualFile(numf);
|
||||
if (!virtualfd) {
|
||||
//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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,6 +51,7 @@ Listener::Listener(Fifo*& f, runStatus* s, uint32_t* portno, char* e, int* act,
|
||||
carryOverPacket(0),
|
||||
listeningPacket(0)
|
||||
{
|
||||
|
||||
if(ThreadObject::CreateThread()){
|
||||
pthread_mutex_lock(&Mutex);
|
||||
ErrorMask ^= (1<<index);
|
||||
@ -309,7 +310,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
|
||||
|
||||
//look for carry over
|
||||
if (carryOverFlag) {
|
||||
if (carryOverFlag) {if(!index) cprintf(RED,"carry flag\n");
|
||||
//check if its the current image packet
|
||||
generalData->GetHeaderInfo(index, carryOverPacket, *dynamicRange, fnum, pnum, snum, bid);
|
||||
if (fnum != currentFrameIndex) {
|
||||
|
@ -21,7 +21,6 @@ using namespace std;
|
||||
|
||||
UDPStandardImplementation::UDPStandardImplementation() {
|
||||
InitializeMembers();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -188,7 +187,7 @@ int UDPStandardImplementation::setFrameToGuiFrequency(const uint32_t freq) {
|
||||
if (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) {
|
||||
case GOTTHARD:
|
||||
case PROPIX:
|
||||
@ -197,7 +196,7 @@ int UDPStandardImplementation::setFrameToGuiFrequency(const uint32_t freq) {
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
FILE_LOG (logINFO) << "Frame to Gui Frequency: " << frameToGuiFrequency;
|
||||
return OK;
|
||||
@ -246,7 +245,7 @@ int UDPStandardImplementation::setAcquisitionPeriod(const uint64_t i) {
|
||||
if (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) {
|
||||
case GOTTHARD:
|
||||
case PROPIX:
|
||||
@ -255,7 +254,7 @@ int UDPStandardImplementation::setAcquisitionPeriod(const uint64_t i) {
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
FILE_LOG (logINFO) << "Acquisition Period: " << (double)acquisitionPeriod/(1E9) << "s";
|
||||
return OK;
|
||||
@ -266,7 +265,7 @@ int UDPStandardImplementation::setAcquisitionTime(const uint64_t i) {
|
||||
if (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) {
|
||||
case GOTTHARD:
|
||||
case PROPIX:
|
||||
@ -275,7 +274,7 @@ int UDPStandardImplementation::setAcquisitionTime(const uint64_t i) {
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
FILE_LOG (logINFO) << "Acquisition Period: " << (double)acquisitionTime/(1E9) << "s";
|
||||
return OK;
|
||||
@ -286,7 +285,7 @@ int UDPStandardImplementation::setNumberOfFrames(const uint64_t i) {
|
||||
if (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) {
|
||||
case GOTTHARD:
|
||||
case PROPIX:
|
||||
@ -295,7 +294,7 @@ int UDPStandardImplementation::setNumberOfFrames(const uint64_t i) {
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
FILE_LOG (logINFO) << "Number of Frames:" << numberOfFrames;
|
||||
return OK;
|
||||
@ -349,7 +348,6 @@ int UDPStandardImplementation::setFifoDepth(const uint32_t i) {
|
||||
|
||||
int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
||||
FILE_LOG (logDEBUG) << "Setting receiver type";
|
||||
|
||||
DeleteMembers();
|
||||
InitializeMembers();
|
||||
myDetectorType = d;
|
||||
@ -670,7 +668,7 @@ void UDPStandardImplementation::SetLocalNetworkParameters() {
|
||||
//to increase Socket Receiver Buffer size
|
||||
sprintf(command,"echo $((%d)) > /proc/sys/net/core/rmem_max",RECEIVE_SOCKET_BUFFER_SIZE);
|
||||
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;
|
||||
}
|
||||
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
|
||||
sprintf(command,"echo %d > /proc/sys/net/core/netdev_max_backlog",MAX_SOCKET_INPUT_PACKET_QUEUE);
|
||||
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;
|
||||
}
|
||||
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){
|
||||
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;
|
||||
}
|
||||
}
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
|
||||
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;
|
||||
}
|
||||
}
|
||||
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
|
||||
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;
|
||||
}
|
||||
}
|
||||
struct sched_param tcp_param;
|
||||
tcp_param.sched_priority = TCP_PRIORITY;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -728,21 +726,22 @@ void UDPStandardImplementation::SetThreadPriorities() {
|
||||
|
||||
int UDPStandardImplementation::SetupFifoStructure() {
|
||||
//recalculate number of jobs & fifodepth, return if no change
|
||||
if ((myDetectorType == GOTTHARD) || (myDetectorType == PROPIX)) {
|
||||
/* if ((myDetectorType == GOTTHARD) || (myDetectorType == PROPIX)) {
|
||||
|
||||
int oldnumberofjobs = numberofJobs;
|
||||
|
||||
//listen to only n jobs at a time
|
||||
if (frameToGuiFrequency)
|
||||
numberofJobs = frameToGuiFrequency;
|
||||
|
||||
/*else { NOT YET
|
||||
else { NOT YET
|
||||
//random freq depends on acquisition period/time (calculate upto 100ms/period)
|
||||
int i = ((acquisitionPeriod > 0) ?
|
||||
(SAMPLE_TIME_IN_NS/acquisitionPeriod):
|
||||
((acquisitionTime > 0) ? (SAMPLE_TIME_IN_NS/acquisitionTime) : SAMPLE_TIME_IN_NS));
|
||||
//must be > 0 and < max jobs
|
||||
numberofJobs = ((i < 1) ? 1 : ((i > MAX_JOBS_PER_THREAD) ? MAX_JOBS_PER_THREAD : i));
|
||||
}*/
|
||||
}
|
||||
FILE_LOG (logINFO) << "Number of Jobs Per Thread:" << numberofJobs << endl;
|
||||
|
||||
uint32_t oldfifodepth = fifoDepth;
|
||||
@ -757,7 +756,7 @@ int UDPStandardImplementation::SetupFifoStructure() {
|
||||
//no change, return
|
||||
if ((oldnumberofjobs == numberofJobs) && (oldfifodepth == fifoDepth))
|
||||
return OK;
|
||||
}else
|
||||
}else*/
|
||||
numberofJobs = 1;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user