in between

This commit is contained in:
2018-04-06 17:48:10 +02:00
parent 753290b228
commit 8cf6e0cbd6
10 changed files with 170 additions and 102 deletions

View File

@ -151,9 +151,9 @@
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>35</x>
<x>0</x>
<y>10</y>
<width>326</width>
<width>357</width>
<height>321</height>
</rect>
</property>
@ -965,9 +965,9 @@ Frame period between exposures.
<property name="geometry">
<rect>
<x>30</x>
<y>297</y>
<y>298</y>
<width>318</width>
<height>30</height>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
@ -1049,9 +1049,6 @@ Frame period between exposures.
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/stop.png</normaloff>:/icons/images/stop.png</iconset>
</property>
<property name="shortcut">
<string>Shift+Space</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>

View File

@ -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;

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: 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

View File

@ -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"

View File

@ -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,17 +6077,19 @@ void multiSlsDetector::readFrameFromReceiver(){
//exit when checkJoinThread() (all sockets done)
while(running){
//get each frame
for(int isocket=0; isocket<numSockets; ++isocket){
// reset data
data = false;
if (multiframe != NULL)
memset(multiframe, 0xFF, multisize);
//get each frame
for(int isocket=0; isocket<numSockets; ++isocket){
//if running
if (runningList[isocket]) {
// sub images - header
// HEADER
{
rapidjson::Document doc;
if(!zmqSocket[isocket]->ReceiveHeader(isocket, doc, SLS_DETECTOR_JSON_HEADER_VERSION)){
zmqSocket[isocket]->CloseHeaderMessage();
@ -6102,37 +6106,80 @@ void multiSlsDetector::readFrameFromReceiver(){
multisize = size * numSockets;
image = new char[size];
multiframe = new char[multisize];
// one time values
memset(multiframe, 0xFF, multisize);
// dynamic range
dynamicRange = doc["bitmode"].GetUint();
bytesPerPixel = (float)dynamicRange / 8;
// 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();
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
}
}
// parse rest of header
// 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();
}
// copying data (receiving incorrect size is replaced by 0xFF)
// 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);

View File

@ -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

View File

@ -24,8 +24,9 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
* @param dr pointer to dynamic range
* @param sEnable pointer to short frame enable
* @param fi pointer to file index
* @param fd flipped data enable for x and y dimensions
*/
DataStreamer(Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi);
DataStreamer(Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi, int* fd);
/**
* Destructor
@ -229,5 +230,8 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
/** Complete buffer used for roi, eg. shortGotthard */
char* completeBuffer;
/** flipped data across both dimensions enable */
int* flippedData;
};

View File

@ -276,7 +276,7 @@ public:
uint64_t bunchId = 0, uint64_t timestamp = 0,
uint16_t modId = 0, uint16_t xCoord = 0, uint16_t yCoord = 0, uint16_t zCoord = 0,
uint32_t debug = 0, uint16_t roundRNumber = 0,
uint8_t detType = 0, uint8_t version = 0) {
uint8_t detType = 0, uint8_t version = 0, int* flippedData = 0) {
char buf[MAX_STR_LENGTH] = "";
@ -305,14 +305,23 @@ public:
"\"debug\":%u, "
"\"roundRNumber\":%u, "
"\"detType\":%u, "
"\"version\":%u"
"\"version\":%u, "
//additional stuff
"\"flippedDataX\":%u"
"}\n\0";
int length = sprintf(buf, jsonHeaderFormat,
jsonversion, dynamicrange, fileIndex, npixelsx, npixelsy, imageSize,
acqIndex, fIndex, (fname == NULL)? "":fname, dummy?0:1,
frameNumber, expLength, packetNumber, bunchId, timestamp,
modId, xCoord, yCoord, zCoord, debug, roundRNumber,
detType, version);
detType, version,
//additional stuff
((flippedData == 0 ) ? 0 :flippedData[0])
);
#ifdef VERBOSE
//if(!index)
FILE_LOG(logINFO) << index << ": Streamer: buf:" << buf;

View File

@ -26,7 +26,7 @@ pthread_mutex_t DataStreamer::Mutex = PTHREAD_MUTEX_INITIALIZER;
bool DataStreamer::SilentMode(false);
DataStreamer::DataStreamer(Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi) :
DataStreamer::DataStreamer(Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi, int* fd) :
ThreadObject(NumberofDataStreamers),
generalData(0),
fifo(f),
@ -38,7 +38,8 @@ DataStreamer::DataStreamer(Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi) :
measurementStartedFlag(false),
firstAcquisitionIndex(0),
firstMeasurementIndex(0),
completeBuffer(0)
completeBuffer(0),
flippedData(fd)
{
if(ThreadObject::CreateThread()){
pthread_mutex_lock(&Mutex);
@ -285,7 +286,8 @@ int DataStreamer::SendHeader(sls_detector_header* header, uint32_t size, uint32_
header->frameNumber, header->expLength, header->packetNumber, header->bunchId, header->timestamp,
header->modId, header->xCoord, header->yCoord, header->zCoord,
header->debug, header->roundRNumber,
header->detType, header->version
header->detType, header->version,
flippedData
);
}

View File

@ -218,7 +218,7 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
if (enable) {
bool error = false;
for ( int i = 0; i < numThreads; ++i ) {
dataStreamer.push_back(new DataStreamer(fifo[i], &dynamicRange, &shortFrameEnable, &fileIndex));
dataStreamer.push_back(new DataStreamer(fifo[i], &dynamicRange, &shortFrameEnable, &fileIndex, flippedData));
dataStreamer[i]->SetGeneralData(generalData);
if (dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP) == FAIL) {
error = true;