slsDetectorSoftware & eiger server: fixed coordinates in 2 d, but switch to row (x), col(y); numdetx and numdety sent to all receivers now, likely bug fix virtual file linked in master for 1 mod jungfrau; xccoord and y coord calculated at setdetector pos and given to listener

This commit is contained in:
maliakal_d 2018-08-15 19:02:16 +02:00
parent b3ccd5e1a1
commit 87e8333dfd
13 changed files with 156 additions and 98 deletions

View File

@ -1,5 +1,5 @@
/** API versions */
#define APIRECEIVER 0x180517
#define APIEIGER 0x180810
#define APIEIGER 0x180815
#define APIJUNGFRAU 0x180628
#define APIGOTTHARD 0x180529

View File

@ -1215,8 +1215,10 @@ void Beb_SetDetectorNumber(uint32_t detid) {
int Beb_SetDetectorPosition(int pos[]) {
if(!Beb_activated)
return OK;
cprintf(BLUE,"Got Position values %d %d %d...\n", pos[0],pos[1], pos[2]);
pos[1] = Beb_swap_uint16(pos[1]);
pos[0] = Beb_swap_uint16(pos[0]);
//pos[1] = Beb_swap_uint16(pos[1]);
pos[2] = Beb_swap_uint16(pos[2]);
int ret = FAIL;
@ -1231,37 +1233,37 @@ int Beb_SetDetectorPosition(int pos[]) {
uint32_t value = 0;
ret = OK;
// x left
int posval = Beb_swap_uint16((Beb_top ? pos[0] : (pos[0]+1)));
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
value &= UDP_HEADER_ID_MSK; // to keep previous id value
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
if((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK))
value &= UDP_HEADER_ID_MSK; // to keep previous id value
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
if((value & UDP_HEADER_X_MSK) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK))
ret = FAIL;
// x right
posval = Beb_swap_uint16((Beb_top ? (pos[0]+1) : pos[0]));
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
value &= UDP_HEADER_ID_MSK; // to keep previous id value
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
if((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK))
value &= UDP_HEADER_ID_MSK; // to keep previous id value
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
if((value & UDP_HEADER_X_MSK) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK))
ret = FAIL;
// y left
// y left (column)
// overwriting z anyway, so no need to look at previous z value
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
int posval = Beb_swap_uint16(Beb_top ? pos[1] : (pos[1]+1));
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST);
if(value != ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
if(value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
ret = FAIL;
// y right
// overwriting z anyway, so no need to look at previous z value
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
posval = Beb_swap_uint16(Beb_top ? (pos[1]+1) : pos[1]);
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
if(value != ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
if(value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
ret = FAIL;
@ -1290,8 +1292,8 @@ int Beb_SetDetectorPosition(int pos[]) {
cprintf(BLUE, "Position set to...\n"
"Left: [%d, %d, %d]\n"
"Right:[%d, %d, %d]\n",
(Beb_top ? pos[0] : (pos[0]+1)), Beb_swap_uint16(pos[1]), Beb_swap_uint16(pos[2]),
(Beb_top ? (pos[0]+1) : pos[0]), Beb_swap_uint16(pos[1]), Beb_swap_uint16(pos[2]));
Beb_swap_uint16(pos[0]), Beb_top ? pos[1] : (pos[1]+1), Beb_swap_uint16(pos[2]),
Beb_swap_uint16(pos[0]), Beb_top ? (pos[1]+1) : pos[1], Beb_swap_uint16(pos[2]));
}
return ret;

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: c934e92a41da49db07f8d3fed98d88dc39325401
Revision: 344
Branch: eigerfeature
Repsitory UUID: b3ccd5e1a137ddb5f11bc88d51a80e9dd777bc09
Revision: 346
Branch: developer
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3976
Last Changed Date: 2018-08-10 17:34:43.000000002 +0200 ./FebRegisterDefs.h
Last Changed Rev: 3980
Last Changed Date: 2018-08-15 18:03:20.000000002 +0200 ./Beb.c

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "c934e92a41da49db07f8d3fed98d88dc39325401"
#define GITREPUUID "b3ccd5e1a137ddb5f11bc88d51a80e9dd777bc09"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3976
#define GITDATE 0x20180810
#define GITBRANCH "eigerfeature"
#define GITREV 0x3980
#define GITDATE 0x20180815
#define GITBRANCH "developer"

View File

@ -3976,14 +3976,10 @@ int slsDetector::configureMAC() {
if (thisDetector->myDetectorType == JUNGFRAU ||
thisDetector->myDetectorType == EIGER) {
sendpos = true;
int max = multiDet->getNumberOfDetectors(X);
if(!detId) {
pos[0] = 0;
pos[1] = 0;
} else {
pos[1] = detId / max;
pos[0] = (detId % max) * ((thisDetector->myDetectorType == EIGER) ? 2 : 1); // for horiz. udp ports
}
int max = multiDet->getNumberOfDetectors(Y);
pos[0] = (detId % max); // row
pos[1] = (detId / max) * ((thisDetector->myDetectorType == EIGER) ? 2 : 1);// col for horiz. udp ports
}
#ifdef VERBOSE
cout << "SLS [" << detId << "] - (" << pos[0] << "," << pos[1] << "," <<
@ -5288,8 +5284,7 @@ string slsDetector::setReceiver(string receiverIP) {
#endif
if(setDetectorType()!= GENERIC){
if(!detId)
sendMultiDetectorSize();
sendMultiDetectorSize();
setDetectorId();
setDetectorHostname();
setUDPConnection();

View File

@ -209,6 +209,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
void SetSilentMode(bool mode);
private:
/**
@ -335,9 +336,6 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
/** temporary buffer for processing */
char* tempBuffer;
/** x coord hardcoded ad 1D, if detector does not send them yet **/
uint16_t xcoordin1D;
/** Activated/Deactivated */
bool* activated;
@ -345,7 +343,6 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
bool* deactivatedPaddingEnable;
//acquisition start
/** Aquisition Started flag */
bool acquisitionStartedFlag;

View File

@ -114,6 +114,9 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
*/
void EndofAcquisition(bool anyPacketsCaught, uint64_t numf);
private:
/**
* Create Virtual File
* @param numf number of images caught
@ -121,8 +124,12 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
*/
int CreateVirtualFile(uint64_t numf);
private:
/**
* Link virtual file in master file
* Only for Jungfrau at the moment for 1 module and 1 data file
* @returns OK or FAIL
*/
int LinkVirtualFileinMasterFile();
/**
* Get Type

View File

@ -145,6 +145,15 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
*/
int CreateDummySocketForUDPSocketBufferSize(uint32_t s);
/**
* Set xcoord and y coord
* xcoord is in 1d if detector has not send them yet in firmware,
* xcoord is in 2d for jungfrau and eiger (for missing packets/deactivated eiger)
* ycoord when used is in 2d
*/
void SetHardCodedCoords(uint16_t x, uint16_t y);
private:
@ -244,6 +253,15 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
/** Deactivated padding enable */
bool* deactivatedPaddingEnable;
/** x coord hardcoded as 1D or 2d,
* if detector does not send them yet or
* missing packets/deactivated (eiger/jungfrau sends 2d pos) **/
uint16_t xcoord;
/** y coord hardcoded as 2D,
* deactivated eiger/missing packets (eiger/jungfrau sends 2d pos) **/
uint16_t ycoord;
// acquisition start
/** Aquisition Started flag */

View File

@ -47,7 +47,6 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f,
streamingTimerInMs(timer),
currentFreqCount(0),
tempBuffer(0),
xcoordin1D(0),
activated(act),
deactivatedPaddingEnable(depaden),
acquisitionStartedFlag(false),
@ -224,8 +223,6 @@ void DataProcessor::SetupFileWriter(bool fwe, int* nd, uint32_t* maxf,
fileWriteEnable = fwe;
if (g)
generalData = g;
// fix xcoord as detector is not providing it right now
xcoordin1D = ((*dindex) * (*nunits)) + index;
if (file) {
@ -366,15 +363,6 @@ void DataProcessor::ProcessAnImage(char* buf) {
InsertGapPixels(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
*dynamicRange);
// x coord is 0 for detector in pos [0,0,0]
if (xcoordin1D) {
// do nothing as detector has correctly send them
if (header.xCoord || header.yCoord || header.zCoord)
;
// detector has send all 0's when there should have been a value greater than 0 in some dimension
else
header.xCoord = xcoordin1D;
}
// deactivated and padding enabled
if ((!(*activated) && *deactivatedPaddingEnable) ||
@ -402,10 +390,11 @@ void DataProcessor::ProcessAnImage(char* buf) {
(*((uint32_t*)buf)) = revsize;
}
// write to file
if (file)
file->WriteToFile(buf + FIFO_HEADER_NUMBYTES,
sizeof(sls_receiver_header) + (uint32_t)(*((uint32_t*)buf)),
sizeof(sls_receiver_header) + (uint32_t)(*((uint32_t*)buf)), //+ size of data (resizable from previous call back
fnum-firstMeasurementIndex, nump);

View File

@ -170,7 +170,7 @@ void HDF5File::CloseCurrentFile() {
pthread_mutex_lock(&Mutex);
HDF5FileStatic::CloseDataFile(index, filefd);
pthread_mutex_unlock(&Mutex);
for (int i = 0; i < dataset_para.size(); ++i)
for (unsigned int i = 0; i < dataset_para.size(); ++i)
delete dataset_para[i];
dataset_para.clear();
if(dataspace_para) {delete dataspace_para;dataspace_para=0;}
@ -190,7 +190,7 @@ void HDF5File::CloseAllFiles() {
}
pthread_mutex_unlock(&Mutex);
for (int i = 0; i < dataset_para.size(); ++i)
for (unsigned int i = 0; i < dataset_para.size(); ++i)
delete dataset_para[i];
dataset_para.clear();
if(dataspace_para) delete dataspace_para;
@ -201,6 +201,7 @@ void HDF5File::CloseAllFiles() {
int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) {
// check if maxframesperfile = 0 for infinite
if ((*maxFramesPerFile) && (numFramesInFile >= (*maxFramesPerFile))) {
CloseCurrentFile();
@ -228,12 +229,12 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t
((*maxFramesPerFile == 0) ? fnum : fnum%(*maxFramesPerFile)),
nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
dataspace, dataset, datatype) == OK) {
sls_receiver_header* header = (sls_receiver_header*) (buffer);
/*header->xCoord = ((*detIndex) * (*numUnitsPerDetector) + index); */
if (HDF5FileStatic::WriteParameterDatasets(index, dataspace_para,
// infinite then no need for %maxframesperfile
((*maxFramesPerFile == 0) ? fnum : fnum%(*maxFramesPerFile)),
dataset_para, header, parameterDataTypes) == OK) {
dataset_para, (sls_receiver_header*) (buffer),
parameterDataTypes) == OK) {
pthread_mutex_unlock(&Mutex);
return OK;
}
@ -277,43 +278,51 @@ void HDF5File::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) {
//not created before
if (!virtualfd && anyPacketsCaught) {
//only one file and one sub image (link current file in master)
if (((numFilesinAcquisition == 1) && (numDetY*numDetX) == 1)) {
//dataset name
ostringstream osfn;
osfn << "/data";
if ((*numImages > 1)) osfn << "_f" << setfill('0') << setw(12) << 0;
string dsetname = osfn.str();
pthread_mutex_lock(&Mutex);
HDF5FileStatic::LinkVirtualInMaster(masterFileName, currentFileName,
dsetname, parameterNames);
pthread_mutex_unlock(&Mutex);
}
// called only by the one maser receiver
if (master && (*detIndex==0)) {
//create virutal file
else
CreateVirtualFile(numf);
//only one file and one sub image (link current file in master)
if (((numFilesinAcquisition == 1) && (numDetY*numDetX) == 1)) {
LinkVirtualFileinMasterFile();
}
//create virutal file
else{
CreateVirtualFile(numf);}
}
}
numFilesinAcquisition = 0;
}
// called only by the one maser receiver
int HDF5File::CreateVirtualFile(uint64_t numf) {
if (master && (*detIndex==0)) {
pthread_mutex_lock(&Mutex);
int ret = HDF5FileStatic::CreateVirtualDataFile(
virtualfd, masterFileName,
filePath, fileNamePrefix, *fileIndex, (*numImages > 1),
*detIndex, *numUnitsPerDetector,
// infinite images in 1 file, then maxfrperfile = numf
((*maxFramesPerFile == 0) ? numf+1 : *maxFramesPerFile),
numf+1,
"data", datatype,
numDetY, numDetX, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
HDF5_WRITER_VERSION,
parameterNames, parameterDataTypes);
pthread_mutex_unlock(&Mutex);
return ret;
}
return OK;
pthread_mutex_lock(&Mutex);
int ret = HDF5FileStatic::CreateVirtualDataFile(
virtualfd, masterFileName,
filePath, fileNamePrefix, *fileIndex, (*numImages > 1),
*detIndex, *numUnitsPerDetector,
// infinite images in 1 file, then maxfrperfile = numf
((*maxFramesPerFile == 0) ? numf+1 : *maxFramesPerFile),
numf+1,
"data", datatype,
numDetY, numDetX, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
HDF5_WRITER_VERSION,
parameterNames, parameterDataTypes);
pthread_mutex_unlock(&Mutex);
return ret;
}
// called only by the one maser receiver
int HDF5File::LinkVirtualFileinMasterFile() {
//dataset name
ostringstream osfn;
osfn << "/data";
if ((*numImages > 1)) osfn << "_f" << setfill('0') << setw(12) << 0;
string dsetname = osfn.str();
pthread_mutex_lock(&Mutex);
int ret = HDF5FileStatic::LinkVirtualInMaster(masterFileName, currentFileName,
dsetname, parameterNames);
pthread_mutex_unlock(&Mutex);
return ret;
}

View File

@ -40,6 +40,8 @@ Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
frameDiscardMode(fdp),
activated(act),
deactivatedPaddingEnable(depaden),
xcoord(0),
ycoord(0),
acquisitionStartedFlag(false),
measurementStartedFlag(false),
firstAcquisitionIndex(0),
@ -292,6 +294,10 @@ int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) {
return OK;
}
void Listener::SetHardCodedCoords(uint16_t x, uint16_t y) {
xcoord = x;
ycoord = y;
}
void Listener::ThreadExecution() {
char* buffer;
@ -392,14 +398,21 @@ uint32_t Listener::ListenToAnImage(char* buf) {
new_header = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES);
// deactivated (eiger)
if (!(*activated)) {cprintf(RED,"deactivated receiver\n");
if (!(*activated)) {
// no padding
if (!(*deactivatedPaddingEnable)) {
return 0;}
if (!(*deactivatedPaddingEnable))
return 0;
// padding without setting bitmask (all missing packets padded in dataProcessor)
if (currentFrameIndex >= *numImages)
return 0;
new_header->detHeader.frameNumber = currentFrameIndex+1; //(eiger)
//(eiger) first fnum starts at 1
if (!currentFrameIndex) {
++currentFrameIndex;
}
new_header->detHeader.frameNumber = currentFrameIndex;
new_header->detHeader.xCoord = xcoord;
new_header->detHeader.yCoord = ycoord;
new_header->detHeader.detType = (uint8_t) generalData->myDetectorType;
new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION;
return generalData->imageSize;
@ -439,6 +452,10 @@ uint32_t Listener::ListenToAnImage(char* buf) {
break;
}
new_header->detHeader.packetNumber = numpackets;
if(isHeaderEmpty) {
new_header->detHeader.xCoord = xcoord;
new_header->detHeader.yCoord = ycoord;
}
return generalData->imageSize;
}
@ -476,6 +493,8 @@ uint32_t Listener::ListenToAnImage(char* buf) {
// -------------------old header ------------------------------------------------------------------------------
else {
new_header->detHeader.frameNumber = fnum;
new_header->detHeader.xCoord = xcoord;
new_header->detHeader.yCoord = ycoord;
new_header->detHeader.detType = (uint8_t) generalData->myDetectorType;
new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION;
}
@ -510,6 +529,10 @@ uint32_t Listener::ListenToAnImage(char* buf) {
break;
}
new_header->detHeader.packetNumber = numpackets; //number of packets caught
if(isHeaderEmpty) {
new_header->detHeader.xCoord = xcoord;
new_header->detHeader.yCoord = ycoord;
}
return generalData->imageSize; //empty packet now, but not empty image
}
@ -565,6 +588,10 @@ uint32_t Listener::ListenToAnImage(char* buf) {
break;
}
new_header->detHeader.packetNumber = numpackets; //number of packets caught
if(isHeaderEmpty) {
new_header->detHeader.xCoord = xcoord;
new_header->detHeader.yCoord = ycoord;
}
return generalData->imageSize;
}
@ -599,6 +626,8 @@ uint32_t Listener::ListenToAnImage(char* buf) {
// -------------------old header ------------------------------------------------------------------------------
else {
new_header->detHeader.frameNumber = fnum;
new_header->detHeader.xCoord = xcoord;
new_header->detHeader.yCoord = ycoord;
new_header->detHeader.detType = (uint8_t) generalData->myDetectorType;
new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION;
}

View File

@ -424,6 +424,18 @@ void UDPStandardImplementation::setDetectorPositionId(const int i){
&detID, &numThreads, &numberOfFrames, &dynamicRange, &udpPortNum[i],
generalData);
}
for (unsigned int i = 0; i < listener.size(); ++i) {
uint16_t x = 0, y = 0;
if (myDetectorType == EIGER || myDetectorType == JUNGFRAU) {
x = detID % numDet[1]; // row
y = (detID / numDet[1]) * ((myDetectorType == EIGER) ? 2 : 1) + i; // col for horiz. udp ports
}
// calculate x in 1d
else
x = detID * numThreads + i;
listener[i]->SetHardCodedCoords(x,y);
}
}