mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
in between
This commit is contained in:
@ -49,6 +49,7 @@
|
||||
int Beb_activated = 1;
|
||||
|
||||
uint32_t Beb_detid = 0;
|
||||
int Beb_top =0;
|
||||
|
||||
|
||||
|
||||
@ -164,8 +165,10 @@ void Beb_GetModuleConfiguration(int* master, int* top, int* normal){
|
||||
ret = Beb_Read32(csp0base, MODULE_CONFIGURATION_MASK);
|
||||
printf("Module Configuration OK\n");
|
||||
printf("Beb: value =0x%x\n",ret);
|
||||
if(ret&TOP_BIT_MASK)
|
||||
if(ret&TOP_BIT_MASK) {
|
||||
*top = 1;
|
||||
Beb_top = 1;
|
||||
}
|
||||
if(ret&MASTER_BIT_MASK)
|
||||
*master = 1;
|
||||
if(ret&NORMAL_MODULE_BIT_MASK)
|
||||
@ -1161,7 +1164,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
if(!Beb_activated)
|
||||
return OK;
|
||||
|
||||
pos[0] = Beb_swap_uint16(pos[0]);
|
||||
pos[1] = Beb_swap_uint16(pos[1]);
|
||||
pos[2] = Beb_swap_uint16(pos[2]);
|
||||
|
||||
int ret = FAIL;
|
||||
@ -1176,37 +1179,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 | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
|
||||
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) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK))
|
||||
if((value & UDP_HEADER_X_MSK) != ((posval << 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 | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
|
||||
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) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK))
|
||||
if((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK))
|
||||
ret = FAIL;
|
||||
|
||||
|
||||
|
||||
// y left
|
||||
int posval = Beb_swap_uint16(pos[1]);
|
||||
// overwriting z anyway, so no need to look at previous z value
|
||||
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
|
||||
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST);
|
||||
if(value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
|
||||
if(value != ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
|
||||
ret = FAIL;
|
||||
|
||||
// y right
|
||||
posval = Beb_swap_uint16(pos[1]+1);
|
||||
// overwriting z anyway, so no need to look at previous z value
|
||||
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
|
||||
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
|
||||
if(value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
|
||||
if(value != ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
|
||||
ret = FAIL;
|
||||
|
||||
|
||||
@ -1235,8 +1238,8 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
cprintf(BLUE, "Position set to...\n"
|
||||
"Left: [%d, %d, %d]\n"
|
||||
"Right:[%d, %d, %d]\n",
|
||||
Beb_swap_uint16(pos[0]), pos[1], Beb_swap_uint16(pos[2]),
|
||||
Beb_swap_uint16(pos[0]), pos[1]+1, Beb_swap_uint16(pos[2]));
|
||||
(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]));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -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: da010a03d725b6f18020d2142d58771534414274
|
||||
Revision: 328
|
||||
Branch: developer
|
||||
Last Changed Author: Erik_Frojdh
|
||||
Last Changed Rev: 3751
|
||||
Last Changed Date: 2018-04-03 16:29:39.000000002 +0200 ./xparameters.h
|
||||
Repsitory UUID: 753290b2289ec7a3dbb153493896f778a7182aae
|
||||
Revision: 329
|
||||
Branch: zmqhandler
|
||||
Last Changed Author: Dhanya_Thattil
|
||||
Last Changed Rev: 3755
|
||||
Last Changed Date: 2018-04-06 14:04:16.000000002 +0200 ./Beb.c
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "da010a03d725b6f18020d2142d58771534414274"
|
||||
#define GITAUTH "Erik_Frojdh"
|
||||
#define GITREV 0x3751
|
||||
#define GITDATE 0x20180403
|
||||
#define GITBRANCH "developer"
|
||||
#define GITREPUUID "753290b2289ec7a3dbb153493896f778a7182aae"
|
||||
#define GITAUTH "Dhanya_Thattil"
|
||||
#define GITREV 0x3755
|
||||
#define GITDATE 0x20180406
|
||||
#define GITBRANCH "zmqhandler"
|
||||
|
@ -6028,15 +6028,19 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){
|
||||
|
||||
void multiSlsDetector::readFrameFromReceiver(){
|
||||
|
||||
int nX = thisMultiDetector->numberOfDetector[X]; // to copy data in multi module
|
||||
int nY = thisMultiDetector->numberOfDetector[Y]; // for eiger, to reverse the data
|
||||
int numSockets = thisMultiDetector->numberOfDetectors;
|
||||
bool gappixelsenable = false;
|
||||
bool eiger = false;
|
||||
if (getDetectorsType() == EIGER) {
|
||||
eiger = true;
|
||||
nX *= 2;
|
||||
numSockets *= 2;
|
||||
gappixelsenable = detectors[0]->enableGapPixels(-1) >= 1 ? true: false;
|
||||
}
|
||||
|
||||
bool runningList[numSockets];
|
||||
bool connectList[numSockets];
|
||||
bool runningList[numSockets], connectList[numSockets];
|
||||
int numRunning = 0;
|
||||
for(int i = 0; i < numSockets; ++i) {
|
||||
if(!zmqSocket[i]->Connect()) {
|
||||
@ -6054,17 +6058,15 @@ void multiSlsDetector::readFrameFromReceiver(){
|
||||
bool data = false;
|
||||
char* image = NULL;
|
||||
char* multiframe = NULL;
|
||||
char* multigappixels = NULL
|
||||
char* multigappixels = NULL;
|
||||
int multisize = 0;
|
||||
// header info
|
||||
uint32_t size = 0; // only first message header
|
||||
uint32_t nPixelsx = 0, nPixelsY = 0;
|
||||
uint32_t dynamicRange = 0;
|
||||
// only first message header
|
||||
uint32_t size = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0;
|
||||
float bytesPerPixel = 0;
|
||||
// header info every header
|
||||
string currentFileName = "";
|
||||
uint64_t currentAcquisitionIndex = -1;
|
||||
uint64_t currentFrameIndex = -1;
|
||||
uint32_t currentSubFrameIndex = -1;
|
||||
uint64_t currentFileIndex = -1;
|
||||
uint64_t currentAcquisitionIndex = -1, currentFrameIndex = -1, currentFileIndex = -1;
|
||||
uint32_t currentSubFrameIndex = -1, coordX = -1, coordY = -1, flippedDataX = -1;
|
||||
|
||||
//wait for real time acquisition to start
|
||||
bool running = true;
|
||||
@ -6075,64 +6077,109 @@ void multiSlsDetector::readFrameFromReceiver(){
|
||||
//exit when checkJoinThread() (all sockets done)
|
||||
while(running){
|
||||
|
||||
// reset data
|
||||
data = false;
|
||||
if (multiframe != NULL)
|
||||
memset(multiframe, 0xFF, multisize);
|
||||
|
||||
//get each frame
|
||||
for(int isocket=0; isocket<numSockets; ++isocket){
|
||||
|
||||
// reset data
|
||||
data = false;
|
||||
if (multiframe != NULL)
|
||||
memset(multiframe, 0xFF, multisize);
|
||||
|
||||
//if running
|
||||
if (runningList[isocket]) {
|
||||
// sub images - header
|
||||
rapidjson::Document doc;
|
||||
if(!zmqSocket[isocket]->ReceiveHeader(isocket, doc, SLS_DETECTOR_JSON_HEADER_VERSION)){
|
||||
zmqSocket[isocket]->CloseHeaderMessage();
|
||||
// parse error, version error or end of acquisition for socket
|
||||
runningList[isocket] = false;
|
||||
--numRunning;
|
||||
continue;
|
||||
}
|
||||
|
||||
// if first message, allocate (all one time stuff)
|
||||
if (image == NULL) {
|
||||
// allocate
|
||||
size = doc["size"].GetUint();
|
||||
multisize = size * numSockets;
|
||||
image = new char[size];
|
||||
multiframe = new char[multisize];
|
||||
|
||||
// one time values
|
||||
// dynamic range
|
||||
dynamicRange = doc["bitmode"].GetUint();
|
||||
// shape
|
||||
if (dynamicRange == 4) {
|
||||
nPixelsx = thisMultiDetector->numberOfChannelInclGapPixels[X];
|
||||
nPixelsY = thisMultiDetector->numberOfChannelInclGapPixels[Y];
|
||||
} else {
|
||||
const Value& a = doc["shape"];
|
||||
nPixelsx = a[0].GetUint(); /* later try doc["shape"].GetUint();*/
|
||||
nPixelsY = a[1].GetUint();
|
||||
// HEADER
|
||||
{
|
||||
rapidjson::Document doc;
|
||||
if(!zmqSocket[isocket]->ReceiveHeader(isocket, doc, SLS_DETECTOR_JSON_HEADER_VERSION)){
|
||||
zmqSocket[isocket]->CloseHeaderMessage();
|
||||
// parse error, version error or end of acquisition for socket
|
||||
runningList[isocket] = false;
|
||||
--numRunning;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// parse rest of header
|
||||
currentFileName = doc["fname"].GetString();
|
||||
currentAcquisitionIndex = doc["acqIndex"].GetUint64();
|
||||
currentFrameIndex = doc["fIndex"].GetUint64();
|
||||
currentFileIndex = doc["fileIndex"].GetUint64();
|
||||
currentSubFrameIndex = doc["expLength"].GetUint();
|
||||
zmqSocket[isocket]->CloseHeaderMessage();
|
||||
|
||||
// copying data (receiving incorrect size is replaced by 0xFF)
|
||||
// if first message, allocate (all one time stuff)
|
||||
if (image == NULL) {
|
||||
// allocate
|
||||
size = doc["size"].GetUint();
|
||||
multisize = size * numSockets;
|
||||
image = new char[size];
|
||||
multiframe = new char[multisize];
|
||||
memset(multiframe, 0xFF, multisize);
|
||||
// dynamic range
|
||||
dynamicRange = doc["bitmode"].GetUint();
|
||||
bytesPerPixel = (float)dynamicRange / 8;
|
||||
// shape
|
||||
nPixelsX = doc["shape"][0].GetUint();
|
||||
nPixelsY = doc["shape"][1].GetUint();
|
||||
#ifdef VERBOSE
|
||||
cprintf(BLUE,"(Debug) One Time Header Info:\n"
|
||||
"size: %u\n"
|
||||
"multisize: %u\n"
|
||||
"dynamicRange: %u\n"
|
||||
"bytesPerPixel: %f\n"
|
||||
"nPixelsX: %u\n"
|
||||
"nPixelsY: %u\n",
|
||||
size, multisize, dynamicRange, bytesPerPixel, nPixelsX, nPixelsY);
|
||||
#endif
|
||||
}
|
||||
// each time, parse rest of header
|
||||
currentFileName = doc["fname"].GetString();
|
||||
currentAcquisitionIndex = doc["acqIndex"].GetUint64();
|
||||
currentFrameIndex = doc["fIndex"].GetUint64();
|
||||
currentFileIndex = doc["fileIndex"].GetUint64();
|
||||
currentSubFrameIndex = doc["expLength"].GetUint();
|
||||
coordX = doc["xCoord"].GetUint();
|
||||
coordY = doc["yCoord"].GetUint();
|
||||
if (eiger)
|
||||
coordY = (nY - 1) - coordY;
|
||||
//cout << "X:" << doc["xCoord"].GetUint() <<" Y:"<<doc["yCoord"].GetUint();
|
||||
flippedDataX = doc["flippedDataX"].GetUint();
|
||||
#ifdef VERBOSE
|
||||
cprintf(BLUE,"(Debug) Header Info:\n"
|
||||
"currentFileName: %s\n"
|
||||
"currentAcquisitionIndex: %lu\n"
|
||||
"currentFrameIndex: %lu\n"
|
||||
"currentFileIndex: %lu\n"
|
||||
"currentSubFrameIndex: %u\n"
|
||||
"coordX: %u\n"
|
||||
"coordY: %u\n"
|
||||
"flippedDataX: %u\n",
|
||||
currentFileName.c_str(), currentAcquisitionIndex, currentFrameIndex,
|
||||
currentFileIndex, currentSubFrameIndex, coordX, coordY, flippedDataX);
|
||||
#endif
|
||||
zmqSocket[isocket]->CloseHeaderMessage();
|
||||
}
|
||||
|
||||
|
||||
// DATA
|
||||
data = true;
|
||||
zmqSocket[isocket]->ReceiveData(isocket, image, size);
|
||||
|
||||
// creaing multi image
|
||||
|
||||
// creating multi image
|
||||
{
|
||||
uint32_t xoffset = coordX * nPixelsX * bytesPerPixel;
|
||||
uint32_t yoffset = coordY * nPixelsY;
|
||||
uint32_t singledetrowoffset = nPixelsX * bytesPerPixel;
|
||||
uint32_t rowoffset = nX * singledetrowoffset;
|
||||
|
||||
if (eiger && flippedDataX) {
|
||||
for (uint32_t i = 0; i < nPixelsY; ++i) {
|
||||
memcpy( ((char*)multiframe) + ((yoffset + (nPixelsY - 1 - i) ) * rowoffset) + xoffset,
|
||||
(char*)image + (i * singledetrowoffset),
|
||||
singledetrowoffset);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (uint32_t i = 0; i < nPixelsY; ++i) {
|
||||
memcpy( ((char*)multiframe) + ((yoffset + i ) * rowoffset) + xoffset,
|
||||
(char*)image + (i * singledetrowoffset),
|
||||
singledetrowoffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//send data to callback
|
||||
@ -6140,15 +6187,18 @@ void multiSlsDetector::readFrameFromReceiver(){
|
||||
// 4bit gap pixels
|
||||
if (dynamicRange == 4 && gappixelsenable) {
|
||||
int n = processImageWithGapPixels(multiframe, multigappixels);
|
||||
nPixelsX = thisMultiDetector->numberOfChannelInclGapPixels[X];
|
||||
nPixelsY = thisMultiDetector->numberOfChannelInclGapPixels[Y];
|
||||
thisData = new detectorData(NULL,NULL,NULL,getCurrentProgress(),
|
||||
currentFileName.c_str(), nPixelsx, nPixelsY,
|
||||
currentFileName.c_str(), nPixelsX, nPixelsY,
|
||||
multigappixels, n, dynamicRange, currentFileIndex);
|
||||
}
|
||||
// normal pixels
|
||||
else
|
||||
else {
|
||||
thisData = new detectorData(NULL, NULL, NULL, getCurrentProgress(),
|
||||
currentFileName.c_str(), nPixelsx, nPixelsY,
|
||||
currentFileName.c_str(), nPixelsX, nPixelsY,
|
||||
multiframe, multisize, dynamicRange, currentFileIndex);
|
||||
}
|
||||
dataReady(thisData, currentFrameIndex,
|
||||
((dynamicRange == 32) ? currentSubFrameIndex : -1),
|
||||
pCallbackArg);
|
||||
|
@ -6782,10 +6782,13 @@ int slsDetector::configureMAC(){
|
||||
pos[0] = 0;
|
||||
pos[1] = 0;
|
||||
} else {
|
||||
pos[0] = posId / max;
|
||||
pos[1] = (posId % max) * ((thisDetector->myDetectorType == EIGER) ? 2 : 1); // for horiz. udp ports
|
||||
pos[1] = posId / max;
|
||||
pos[0] = (posId % max) * ((thisDetector->myDetectorType == EIGER) ? 2 : 1); // for horiz. udp ports
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
cout << "SLS [" << posId << "] - (" << pos[0] << "," << pos[1] << "," << pos[2] << ")" << endl;
|
||||
#endif
|
||||
|
||||
|
||||
//if udpip wasnt initialized in config file
|
||||
|
Reference in New Issue
Block a user