gui: crashing when using roi fixed

This commit is contained in:
maliakal_d 2018-09-20 18:10:10 +02:00
parent 235002cdd4
commit 9f84bf7175
10 changed files with 70 additions and 50 deletions

15
cmk.sh
View File

@ -6,6 +6,7 @@ COMPILERTHREADS=0
TEXTCLIENT=0 TEXTCLIENT=0
RECEIVER=0 RECEIVER=0
GUI=0 GUI=0
DEBUG=0
CLEAN=0 CLEAN=0
@ -24,6 +25,7 @@ Usage: $0 [-c] [-b] [-h] [-d <HDF5 directory>] [-j]
-r: Build/Rebuilds only receiver -r: Build/Rebuilds only receiver
-g: Build/Rebuilds only gui -g: Build/Rebuilds only gui
-j: Number of threads to compile through -j: Number of threads to compile through
-e: Debug mode
For only make: For only make:
./cmk.sh ./cmk.sh
@ -53,7 +55,7 @@ For rebuilding only certain sections
" ; exit 1; } " ; exit 1; }
while getopts ":bchd:j:trg" opt ; do while getopts ":bchd:j:trge" opt ; do
case $opt in case $opt in
b) b)
echo "Building of CMake files Required" echo "Building of CMake files Required"
@ -91,6 +93,10 @@ while getopts ":bchd:j:trg" opt ; do
GUI=1 GUI=1
REBUILD=1 REBUILD=1
;; ;;
e)
echo "Compiling Options: Debug"
DEBUG=1
;;
\?) \?)
echo "Invalid option: -$OPTARG" echo "Invalid option: -$OPTARG"
usage usage
@ -145,7 +151,12 @@ else
fi fi
fi fi
#CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug " #Debug
if [ $DEBUG -eq 1 ]; then
CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug "
echo "Debug Option enabled"
fi
#hdf5 rebuild #hdf5 rebuild
if [ $HDF5 -eq 1 ]; then if [ $HDF5 -eq 1 ]; then

View File

@ -31,7 +31,7 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
* @param ajh additional json header * @param ajh additional json header
* @param sm pointer to silent mode * @param sm pointer to silent mode
*/ */
DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI*>* r, DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI>* r,
uint64_t* fi, int* fd, char* ajh, bool* sm); uint64_t* fi, int* fd, char* ajh, bool* sm);
/** /**
@ -175,7 +175,7 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
uint32_t* dynamicRange; uint32_t* dynamicRange;
/** ROI */ /** ROI */
std::vector<ROI*>* roi; std::vector<ROI>* roi;
/** adc Configured */ /** adc Configured */
int adcConfigured; int adcConfigured;

View File

@ -160,17 +160,17 @@ public:
* Set ROI * Set ROI
* @param i ROI * @param i ROI
*/ */
virtual void SetROI(std::vector<slsReceiverDefs::ROI*> i) { virtual void SetROI(std::vector<slsReceiverDefs::ROI> i) {
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
}; };
/** /**
* Get Adc configured * Get Adc configured
* @param index thread index for debugging purposes * @param index thread index for debugging purposes
* @param i ROI * @param i pointer to a vector of ROI pointers
* @returns adc configured * @returns adc configured
*/ */
virtual const int GetAdcConfigured(int index, std::vector<slsReceiverDefs::ROI*> i) const{ virtual const int GetAdcConfigured(int index, std::vector<slsReceiverDefs::ROI>* i) const{
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
return 0; return 0;
}; };
@ -323,7 +323,7 @@ private:
* Set ROI * Set ROI
* @param i ROI * @param i ROI
*/ */
virtual void SetROI(std::vector<slsReceiverDefs::ROI*> i) { virtual void SetROI(std::vector<slsReceiverDefs::ROI> i) {
// all adcs // all adcs
if(!i.size()) { if(!i.size()) {
nPixelsX = 1280; nPixelsX = 1280;
@ -364,23 +364,22 @@ private:
/** /**
* Get Adc configured * Get Adc configured
* @param index thread index for debugging purposes * @param index thread index for debugging purposes
* @param i ROI * @param i pointer to a vector of ROI
* @returns adc configured * @returns adc configured
*/ */
virtual const int GetAdcConfigured(int index, std::vector<slsReceiverDefs::ROI*> i) const{ virtual const int GetAdcConfigured(int index, std::vector<slsReceiverDefs::ROI>* i) const{
int adc = -1; int adc = -1;
// single adc // single adc
if(i.size()) { if(i->size()) {
// gotthard can have only one adc per detector enabled (or all) // 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) // so just looking at the first roi is enough (more not possible at the moment)
//if its for 1 adc or general //if its for 1 adc or general
if ((i[0]->xmin == 0) && (i[0]->xmax == nChip * nChan)) if ((i->at(0).xmin == 0) && (i->at(0).xmax == nChip * nChan))
adc = -1; adc = -1;
else { else {
//adc = mid value/numchans also for only 1 roi //adc = mid value/numchans also for only 1 roi
adc = ((((i[0]->xmax) + (i[0]->xmin))/2)/ adc = ((((i->at(0).xmax) + (i->at(0).xmin))/2)/
(nChan * nChipsPerAdc)); (nChan * nChipsPerAdc));
if((adc < 0) || (adc > 4)) { if((adc < 0) || (adc > 4)) {
FILE_LOG(logWARNING) << index << ": Deleting ROI. " FILE_LOG(logWARNING) << index << ": Deleting ROI. "
@ -389,6 +388,7 @@ private:
} }
} }
} }
FILE_LOG(logINFO) << "Adc Configured: " << adc;
return adc; return adc;
}; };

View File

@ -185,7 +185,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
* Get ROI * Get ROI
* @return index of adc enabled, else -1 if all enabled * @return index of adc enabled, else -1 if all enabled
*/ */
std::vector<ROI*> getROI() const; std::vector<ROI> getROI() const;
/** /**
* Get the Frequency of Frames Sent to GUI * Get the Frequency of Frames Sent to GUI
@ -452,7 +452,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
* @param i ROI * @param i ROI
* @return OK or FAIL * @return OK or FAIL
*/ */
int setROI(const std::vector<ROI*> i); int setROI(const std::vector<ROI> i);
/** /**
* Set the Frequency of Frames Sent to GUI * Set the Frequency of Frames Sent to GUI
@ -786,7 +786,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
//***acquisition parameters*** //***acquisition parameters***
/* ROI */ /* ROI */
std::vector<ROI*> roi; std::vector<ROI> roi;
/** Frequency of Frames sent to GUI */ /** Frequency of Frames sent to GUI */
uint32_t frameToGuiFrequency; uint32_t frameToGuiFrequency;
/** Timer of Frames sent to GUI when frequency is 0 */ /** Timer of Frames sent to GUI when frequency is 0 */

View File

@ -276,7 +276,7 @@ class UDPInterface {
* Get ROI * Get ROI
* @return index of adc enabled, else -1 if all enabled * @return index of adc enabled, else -1 if all enabled
*/ */
virtual std::vector<slsReceiverDefs::ROI*> getROI() const = 0; virtual std::vector<slsReceiverDefs::ROI> getROI() const = 0;
/** /**
* Get the Frequency of Frames Sent to GUI * Get the Frequency of Frames Sent to GUI
@ -541,7 +541,7 @@ class UDPInterface {
* @param i ROI * @param i ROI
* @return OK or FAIL * @return OK or FAIL
*/ */
virtual int setROI(const std::vector<slsReceiverDefs::ROI*> i) = 0; virtual int setROI(const std::vector<slsReceiverDefs::ROI> i) = 0;
/** /**
* Set the Frequency of Frames Sent to GUI * Set the Frequency of Frames Sent to GUI

View File

@ -77,7 +77,7 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
* @param i ROI * @param i ROI
* @return OK or FAIL * @return OK or FAIL
*/ */
int setROI(const std::vector<ROI*> i); int setROI(const std::vector<ROI> i);
/** /**
* Set the Frequency of Frames Sent to GUI * Set the Frequency of Frames Sent to GUI

View File

@ -15,7 +15,7 @@
const std::string DataStreamer::TypeName = "DataStreamer"; 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, std::vector<ROI>* r,
uint64_t* fi, int* fd, char* ajh, bool* sm) : uint64_t* fi, int* fd, char* ajh, bool* sm) :
ThreadObject(ind), ThreadObject(ind),
runningFlag(0), runningFlag(0),
@ -89,8 +89,9 @@ void DataStreamer::ResetParametersforNewMeasurement(char* fname){
completeBuffer = 0; completeBuffer = 0;
} }
if (roi->size()) { if (roi->size()) {
if (generalData->myDetectorType == GOTTHARD) if (generalData->myDetectorType == GOTTHARD) {
adcConfigured = generalData->GetAdcConfigured(index, *roi); adcConfigured = generalData->GetAdcConfigured(index, roi);
}
completeBuffer = new char[generalData->imageSizeComplete]; completeBuffer = new char[generalData->imageSizeComplete];
memset(completeBuffer, 0, generalData->imageSizeComplete); memset(completeBuffer, 0, generalData->imageSizeComplete);
} }
@ -214,11 +215,19 @@ void DataStreamer::ProcessAnImage(char* buf) {
//shortframe gotthard //shortframe gotthard
if (completeBuffer) { if (completeBuffer) {
if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)), generalData->nPixelsXComplete, generalData->nPixelsYComplete, false)) //disregarding the size modified from callback (always using imageSizeComplete
// instead of buf (32 bit) because gui needs imagesizecomplete and listener
//write imagesize
if (!SendHeader(header, generalData->imageSizeComplete,
generalData->nPixelsXComplete, generalData->nPixelsYComplete, false))
cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n", cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n",
(long long int) fnum, index); (long long int) fnum, index);
memcpy(completeBuffer + ((generalData->imageSize) * adcConfigured), buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), (uint32_t)(*((uint32_t*)buf)) ); // new size possibly from callback memcpy(completeBuffer + ((generalData->imageSize) * adcConfigured),
buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
(uint32_t)(*((uint32_t*)buf)) );
if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete)) if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete))
cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n", cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
(long long int) fnum, index); (long long int) fnum, index);
@ -228,11 +237,13 @@ void DataStreamer::ProcessAnImage(char* buf) {
//normal //normal
else { else {
if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)), generalData->nPixelsX, generalData->nPixelsY, false)) // new size possibly from callback if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)),
generalData->nPixelsX, generalData->nPixelsY, false)) // new size possibly from callback
cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n", cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n",
(long long int) fnum, index); (long long int) fnum, index);
if (!zmqSocket->SendData(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), (uint32_t)(*((uint32_t*)buf)) )) // new size possibly from callback if (!zmqSocket->SendData(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
(uint32_t)(*((uint32_t*)buf)) )) // new size possibly from callback
cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n", cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
(long long int) fnum, index); (long long int) fnum, index);
} }

View File

@ -81,8 +81,6 @@ void UDPBaseImplementation::initializeMembers(){
dataCompressionEnable = false; dataCompressionEnable = false;
//***acquisition parameters*** //***acquisition parameters***
for (std::vector<slsReceiverDefs::ROI*>::const_iterator it = roi.begin(); it != roi.end(); ++it)
delete(*it);
roi.clear(); roi.clear();
frameToGuiFrequency = 0; frameToGuiFrequency = 0;
frameToGuiTimerinMS = DEFAULT_STREAMING_TIMER_IN_MS; frameToGuiTimerinMS = DEFAULT_STREAMING_TIMER_IN_MS;
@ -251,7 +249,7 @@ char *UDPBaseImplementation::getEthernetInterface() const{
/***acquisition parameters***/ /***acquisition parameters***/
std::vector<slsReceiverDefs::ROI*> UDPBaseImplementation::getROI() const{ std::vector<slsReceiverDefs::ROI> UDPBaseImplementation::getROI() const{
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
return roi; return roi;
} }
@ -542,7 +540,7 @@ void UDPBaseImplementation::setEthernetInterface(const char* c){
/***acquisition parameters***/ /***acquisition parameters***/
int UDPBaseImplementation::setROI(const std::vector<slsReceiverDefs::ROI*> i){ int UDPBaseImplementation::setROI(const std::vector<slsReceiverDefs::ROI> i){
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
roi = i; roi = i;
@ -554,10 +552,10 @@ int UDPBaseImplementation::setROI(const std::vector<slsReceiverDefs::ROI*> i){
else { else {
for (unsigned int i = 0; i < roi.size(); ++i) { for (unsigned int i = 0; i < roi.size(); ++i) {
sstm << "( " << sstm << "( " <<
roi[i]->xmin << ", " << roi[i].xmin << ", " <<
roi[i]->xmax << ", " << roi[i].xmax << ", " <<
roi[i]->ymin << ", " << roi[i].ymin << ", " <<
roi[i]->ymax << " )"; roi[i].ymax << " )";
} }
} }
std::string message = sstm.str(); std::string message = sstm.str();

View File

@ -167,7 +167,7 @@ void UDPStandardImplementation::setFileWriteEnable(const bool b){
int UDPStandardImplementation::setROI(const std::vector<slsReceiverDefs::ROI*> i) { int UDPStandardImplementation::setROI(const std::vector<slsReceiverDefs::ROI> i) {
if (myDetectorType != GOTTHARD) { if (myDetectorType != GOTTHARD) {
cprintf(RED, "Error: Can not set ROI for this detector\n"); cprintf(RED, "Error: Can not set ROI for this detector\n");
return FAIL; return FAIL;
@ -180,10 +180,10 @@ int UDPStandardImplementation::setROI(const std::vector<slsReceiverDefs::ROI*> i
else { else {
for (unsigned int iloop = 0; iloop < i.size(); ++iloop) { for (unsigned int iloop = 0; iloop < i.size(); ++iloop) {
if ( if (
(roi[iloop]->xmin != i[iloop]->xmin) || (roi[iloop].xmin != i[iloop].xmin) ||
(roi[iloop]->xmax != i[iloop]->xmax) || (roi[iloop].xmax != i[iloop].xmax) ||
(roi[iloop]->ymin != i[iloop]->ymin) || (roi[iloop].ymin != i[iloop].ymin) ||
(roi[iloop]->xmax != i[iloop]->xmax)) { (roi[iloop].xmax != i[iloop].xmax)) {
change = true; change = true;
break; break;
} }
@ -217,10 +217,10 @@ int UDPStandardImplementation::setROI(const std::vector<slsReceiverDefs::ROI*> i
else { else {
for (unsigned int i = 0; i < roi.size(); ++i) { for (unsigned int i = 0; i < roi.size(); ++i) {
sstm << "( " << sstm << "( " <<
roi[i]->xmin << ", " << roi[i].xmin << ", " <<
roi[i]->xmax << ", " << roi[i].xmax << ", " <<
roi[i]->ymin << ", " << roi[i].ymin << ", " <<
roi[i]->ymax << " )"; roi[i].ymax << " )";
} }
} }
std::string message = sstm.str(); std::string message = sstm.str();
@ -251,7 +251,6 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
if (enable) { if (enable) {
for ( int i = 0; i < numThreads; ++i ) { for ( int i = 0; i < numThreads; ++i ) {
try { try {
DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange, DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange,
&roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode); &roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode);
dataStreamer.push_back(s); dataStreamer.push_back(s);
@ -473,7 +472,6 @@ void UDPStandardImplementation::resetAcquisitionCount() {
int UDPStandardImplementation::startReceiver(char *c) { int UDPStandardImplementation::startReceiver(char *c) {
cprintf(RESET,"\n"); cprintf(RESET,"\n");
FILE_LOG(logINFO) << "Starting Receiver"; FILE_LOG(logINFO) << "Starting Receiver";
ResetParametersforNewMeasurement(); ResetParametersforNewMeasurement();
//listener //listener
@ -733,7 +731,7 @@ int UDPStandardImplementation::SetupFifoStructure() {
for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it) for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
delete(*it); delete(*it);
fifo.clear(); fifo.clear();
for ( int i = 0; i < numThreads; i++ ) { for ( int i = 0; i < numThreads; ++i ) {
//create fifo structure //create fifo structure
try { try {

View File

@ -888,13 +888,13 @@ int slsReceiverTCPIPInterface::set_roi() {
if (mySock->ReceiveDataOnly(&nroi,sizeof(nroi)) < 0 ) if (mySock->ReceiveDataOnly(&nroi,sizeof(nroi)) < 0 )
return printSocketReadError(); return printSocketReadError();
std::vector <ROI*> roiLimits; std::vector <ROI> roiLimits;
int iloop = 0; int iloop = 0;
for (iloop = 0; iloop < nroi; iloop++) { for (iloop = 0; iloop < nroi; iloop++) {
ROI temp; ROI temp;
if ( mySock->ReceiveDataOnly(&temp,sizeof(ROI)) < 0 ) if ( mySock->ReceiveDataOnly(&temp,sizeof(ROI)) < 0 )
return printSocketReadError(); return printSocketReadError();
roiLimits.push_back(&temp); roiLimits.push_back(temp);
} }
//does not exist //does not exist
@ -925,6 +925,8 @@ int slsReceiverTCPIPInterface::set_roi() {
if (ret == FAIL) if (ret == FAIL)
mySock->SendDataOnly(mess,sizeof(mess)); mySock->SendDataOnly(mess,sizeof(mess));
roiLimits.clear();
// return ok/fail // return ok/fail
return ret; return ret;
} }