gotthard fixed roi only xmin and xmax.remove updateoffsets

This commit is contained in:
2019-08-14 09:20:50 +02:00
parent 2fe06c7163
commit d4d8cbe9bc
28 changed files with 573 additions and 1419 deletions

View File

@ -32,7 +32,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
* @param nd pointer to number of detectors in each dimension
* @param gpEnable pointer to gap pixels enable
*/
DataStreamer(int ind, Fifo* f, uint32_t* dr, std::vector<ROI>* r,
DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
uint64_t* fi, int fd, char* ajh, int* nd, bool* gpEnable);
/**
@ -188,7 +188,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
uint32_t* dynamicRange;
/** ROI */
std::vector<ROI>* roi;
ROI* roi;
/** adc Configured */
int adcConfigured;

View File

@ -142,17 +142,17 @@ public:
* Set ROI
* @param i ROI
*/
virtual void SetROI(std::vector<slsDetectorDefs::ROI> i) {
virtual void SetROI(slsDetectorDefs::ROI i) {
FILE_LOG(logERROR) << "SetROI is a generic function that should be overloaded by a derived class";
};
/**
* Get Adc configured
* @param index thread index for debugging purposes
* @param i pointer to a vector of ROI pointers
* @param ROI
* @returns adc configured
*/
virtual int GetAdcConfigured(int index, std::vector<slsDetectorDefs::ROI>* i) const{
virtual int GetAdcConfigured(int index, slsDetectorDefs::ROI i) const{
FILE_LOG(logERROR) << "GetAdcConfigured is a generic function that should be overloaded by a derived class";
return 0;
};
@ -311,9 +311,9 @@ private:
* Set ROI
* @param i ROI
*/
void SetROI(std::vector<slsDetectorDefs::ROI> i) {
void SetROI(slsDetectorDefs::ROI i) {
// all adcs
if(!i.size()) {
if(i.xmin == -1) {
nPixelsX = 1280;
dataSize = 1280;
packetSize = GOTTHARD_PACKET_SIZE;
@ -352,28 +352,21 @@ private:
/**
* Get Adc configured
* @param index thread index for debugging purposes
* @param i pointer to a vector of ROI
* @param i ROI
* @returns adc configured
*/
int GetAdcConfigured(int index, std::vector<slsDetectorDefs::ROI>* i) const{
int GetAdcConfigured(int index, slsDetectorDefs::ROI i) const{
int adc = -1;
// single adc
if(i->size()) {
if(i.xmin != -1) {
// gotthard can have only one adc per detector enabled (or all)
// so just looking at the first roi is enough (more not possible at the moment)
//if its for 1 adc or general
if ((i->at(0).xmin == 0) && (i->at(0).xmax == nChip * nChan))
//adc = mid value/numchans also for only 1 roi
adc = ((((i.xmax) + (i.xmin))/2)/
(nChan * nChipsPerAdc));
if((adc < 0) || (adc > 4)) {
FILE_LOG(logWARNING) << index << ": Deleting ROI. "
"Adc value should be between 0 and 4";
adc = -1;
else {
//adc = mid value/numchans also for only 1 roi
adc = ((((i->at(0).xmax) + (i->at(0).xmin))/2)/
(nChan * nChipsPerAdc));
if((adc < 0) || (adc > 4)) {
FILE_LOG(logWARNING) << index << ": Deleting ROI. "
"Adc value should be between 0 and 4";
adc = -1;
}
}
}
FILE_LOG(logINFO) << "Adc Configured: " << adc;

View File

@ -207,9 +207,9 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
//***acquisition parameters***
/**
* Get ROI
* @return index of adc enabled, else -1 if all enabled
* @return roi
*/
std::vector<ROI> getROI() const;
ROI getROI() const;
/**
* Get ADC Enable Mask
@ -529,10 +529,10 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
//***acquisition parameters***
/**
* Set ROI
* @param i ROI
* @param arg ROI
* @return OK or FAIL
*/
int setROI(const std::vector<ROI> new_roi);
int setROI(ROI arg);
/**
* Set ADC Enable Mask
@ -961,7 +961,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
//***acquisition parameters***
/* ROI */
std::vector<ROI> roi;
ROI roi;
/** ADC Enable Mask */
uint32_t adcEnableMask;
/** streaming frequency */

View File

@ -16,7 +16,7 @@
const std::string DataStreamer::TypeName = "DataStreamer";
DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, std::vector<ROI>* r,
DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
uint64_t* fi, int fd, char* ajh, int* nd, bool* gpEnable) :
ThreadObject(ind),
runningFlag(0),
@ -93,9 +93,9 @@ void DataStreamer::ResetParametersforNewMeasurement(const std::string& fname){
delete[] completeBuffer;
completeBuffer = nullptr;
}
if (roi->size()) {
if (roi->xmin != -1) {
if (generalData->myDetectorType == GOTTHARD) {
adcConfigured = generalData->GetAdcConfigured(index, roi);
adcConfigured = generalData->GetAdcConfigured(index, *roi);
}
completeBuffer = new char[generalData->imageSizeComplete];
memset(completeBuffer, 0, generalData->imageSizeComplete);

View File

@ -104,7 +104,8 @@ void slsReceiverImplementation::InitializeMembers() {
overwriteEnable = true;
//***acquisition parameters***
roi.clear();
roi.xmin = -1;
roi.xmax = -1;
adcEnableMask = BIT32_MASK;
streamingFrequency = 0;
streamingTimerInMs = DEFAULT_STREAMING_TIMER_IN_MS;
@ -305,7 +306,7 @@ int slsReceiverImplementation::getNumberofUDPInterfaces() const {
}
/***acquisition parameters***/
std::vector<slsDetectorDefs::ROI> slsReceiverImplementation::getROI() const {
slsDetectorDefs::ROI slsReceiverImplementation::getROI() const {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
return roi;
}
@ -858,51 +859,21 @@ int slsReceiverImplementation::setUDPSocketBufferSize(const int64_t s) {
}
/***acquisition parameters***/
int slsReceiverImplementation::setROI(
const std::vector<slsDetectorDefs::ROI> new_roi) {
bool change = false;
if (roi.size() != new_roi.size())
change = true;
else {
for (size_t i = 0; i != new_roi.size(); ++i) {
if ((roi[i].xmin != new_roi[i].xmin) ||
(roi[i].xmax != new_roi[i].xmax) ||
(roi[i].ymin != new_roi[i].ymin) ||
(roi[i].xmax != new_roi[i].xmax)) {
change = true;
break;
}
}
}
int slsReceiverImplementation::setROI(slsDetectorDefs::ROI arg) {
if (roi.xmin != arg.xmin || roi.xmax != arg.xmax) {
roi.xmin = arg.xmin;
roi.xmax = arg.xmax;
if (change) {
roi = new_roi;
switch (myDetectorType) {
case GOTTHARD:
generalData->SetROI(new_roi);
framesPerFile = generalData->maxFramesPerFile;
break;
default:
break;
}
// only for gotthard
generalData->SetROI(arg);
framesPerFile = generalData->maxFramesPerFile;
for (const auto &it : dataProcessor)
it->SetPixelDimension();
if (SetupFifoStructure() == FAIL)
return FAIL;
}
std::stringstream sstm;
sstm << "ROI: ";
if (!roi.size())
sstm << "0";
else {
for (size_t i = 0; i < roi.size(); ++i) {
sstm << "( " << roi[i].xmin << ", " << roi[i].xmax << ", "
<< roi[i].ymin << ", " << roi[i].ymax << " )";
}
}
std::string message = sstm.str();
FILE_LOG(logINFO) << message;
FILE_LOG(logINFO) << "ROI: [" << roi.xmin << ", " << roi.xmax << "]";;
FILE_LOG(logINFO) << "Packets per Frame: "
<< (generalData->packetsPerFrame);
return OK;

View File

@ -510,22 +510,12 @@ int slsReceiverTCPIPInterface::set_detector_hostname(Interface &socket) {
}
int slsReceiverTCPIPInterface::set_roi(Interface &socket) {
static_assert(sizeof(ROI) == 4 * sizeof(int), "ROI not packed");
auto narg = socket.Receive<int>();
std::vector<ROI> arg;
for (int iloop = 0; iloop < narg; ++iloop) {
ROI temp{};
socket.Receive(temp);
arg.push_back(temp);
}
FILE_LOG(logDEBUG1) << "Set ROI narg: " << narg;
for (int iloop = 0; iloop < narg; ++iloop) {
FILE_LOG(logDEBUG1)
<< "(" << arg[iloop].xmin << ", " << arg[iloop].xmax << ", "
<< arg[iloop].ymin << ", " << arg[iloop].ymax << ")";
}
static_assert(sizeof(ROI) == 2 * sizeof(int), "ROI not packed");
ROI arg;
socket.Receive(arg);
FILE_LOG(logDEBUG1) << "Set ROI: [" << arg.xmin << ", " << arg.xmax << "]";
if (myDetectorType == EIGER || myDetectorType == JUNGFRAU)
if (myDetectorType != GOTTHARD)
functionNotImplemented();
VerifyIdle(socket);