mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
gui: crashing when using roi fixed
This commit is contained in:
parent
235002cdd4
commit
9f84bf7175
17
cmk.sh
17
cmk.sh
@ -6,6 +6,7 @@ COMPILERTHREADS=0
|
||||
TEXTCLIENT=0
|
||||
RECEIVER=0
|
||||
GUI=0
|
||||
DEBUG=0
|
||||
|
||||
|
||||
CLEAN=0
|
||||
@ -24,6 +25,7 @@ Usage: $0 [-c] [-b] [-h] [-d <HDF5 directory>] [-j]
|
||||
-r: Build/Rebuilds only receiver
|
||||
-g: Build/Rebuilds only gui
|
||||
-j: Number of threads to compile through
|
||||
-e: Debug mode
|
||||
|
||||
For only make:
|
||||
./cmk.sh
|
||||
@ -53,7 +55,7 @@ For rebuilding only certain sections
|
||||
|
||||
" ; exit 1; }
|
||||
|
||||
while getopts ":bchd:j:trg" opt ; do
|
||||
while getopts ":bchd:j:trge" opt ; do
|
||||
case $opt in
|
||||
b)
|
||||
echo "Building of CMake files Required"
|
||||
@ -90,7 +92,11 @@ while getopts ":bchd:j:trg" opt ; do
|
||||
echo "Compiling Options: GUI"
|
||||
GUI=1
|
||||
REBUILD=1
|
||||
;;
|
||||
;;
|
||||
e)
|
||||
echo "Compiling Options: Debug"
|
||||
DEBUG=1
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG"
|
||||
usage
|
||||
@ -145,7 +151,12 @@ else
|
||||
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
|
||||
if [ $HDF5 -eq 1 ]; then
|
||||
|
@ -31,7 +31,7 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
* @param ajh additional json header
|
||||
* @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);
|
||||
|
||||
/**
|
||||
@ -175,7 +175,7 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
uint32_t* dynamicRange;
|
||||
|
||||
/** ROI */
|
||||
std::vector<ROI*>* roi;
|
||||
std::vector<ROI>* roi;
|
||||
|
||||
/** adc Configured */
|
||||
int adcConfigured;
|
||||
|
@ -160,17 +160,17 @@ public:
|
||||
* Set 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");
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Adc configured
|
||||
* @param index thread index for debugging purposes
|
||||
* @param i ROI
|
||||
* @param i pointer to a vector of ROI pointers
|
||||
* @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");
|
||||
return 0;
|
||||
};
|
||||
@ -323,7 +323,7 @@ private:
|
||||
* Set ROI
|
||||
* @param i ROI
|
||||
*/
|
||||
virtual void SetROI(std::vector<slsReceiverDefs::ROI*> i) {
|
||||
virtual void SetROI(std::vector<slsReceiverDefs::ROI> i) {
|
||||
// all adcs
|
||||
if(!i.size()) {
|
||||
nPixelsX = 1280;
|
||||
@ -364,23 +364,22 @@ private:
|
||||
/**
|
||||
* Get Adc configured
|
||||
* @param index thread index for debugging purposes
|
||||
* @param i ROI
|
||||
* @param i pointer to a vector of ROI
|
||||
* @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;
|
||||
// single adc
|
||||
if(i.size()) {
|
||||
|
||||
if(i->size()) {
|
||||
// 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[0]->xmin == 0) && (i[0]->xmax == nChip * nChan))
|
||||
if ((i->at(0).xmin == 0) && (i->at(0).xmax == nChip * nChan))
|
||||
adc = -1;
|
||||
else {
|
||||
//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));
|
||||
if((adc < 0) || (adc > 4)) {
|
||||
FILE_LOG(logWARNING) << index << ": Deleting ROI. "
|
||||
@ -389,6 +388,7 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO) << "Adc Configured: " << adc;
|
||||
return adc;
|
||||
};
|
||||
|
||||
|
@ -185,7 +185,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
* Get ROI
|
||||
* @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
|
||||
@ -452,7 +452,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
* @param i ROI
|
||||
* @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
|
||||
@ -786,7 +786,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
|
||||
//***acquisition parameters***
|
||||
/* ROI */
|
||||
std::vector<ROI*> roi;
|
||||
std::vector<ROI> roi;
|
||||
/** Frequency of Frames sent to GUI */
|
||||
uint32_t frameToGuiFrequency;
|
||||
/** Timer of Frames sent to GUI when frequency is 0 */
|
||||
|
@ -276,7 +276,7 @@ class UDPInterface {
|
||||
* Get ROI
|
||||
* @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
|
||||
@ -541,7 +541,7 @@ class UDPInterface {
|
||||
* @param i ROI
|
||||
* @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
|
||||
|
@ -77,7 +77,7 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
* @param i ROI
|
||||
* @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
|
||||
|
@ -15,7 +15,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, std::vector<ROI>* r,
|
||||
uint64_t* fi, int* fd, char* ajh, bool* sm) :
|
||||
ThreadObject(ind),
|
||||
runningFlag(0),
|
||||
@ -89,8 +89,9 @@ void DataStreamer::ResetParametersforNewMeasurement(char* fname){
|
||||
completeBuffer = 0;
|
||||
}
|
||||
if (roi->size()) {
|
||||
if (generalData->myDetectorType == GOTTHARD)
|
||||
adcConfigured = generalData->GetAdcConfigured(index, *roi);
|
||||
if (generalData->myDetectorType == GOTTHARD) {
|
||||
adcConfigured = generalData->GetAdcConfigured(index, roi);
|
||||
}
|
||||
completeBuffer = new char[generalData->imageSizeComplete];
|
||||
memset(completeBuffer, 0, generalData->imageSizeComplete);
|
||||
}
|
||||
@ -214,11 +215,19 @@ void DataStreamer::ProcessAnImage(char* buf) {
|
||||
//shortframe gotthard
|
||||
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",
|
||||
(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))
|
||||
cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
|
||||
(long long int) fnum, index);
|
||||
@ -228,11 +237,13 @@ void DataStreamer::ProcessAnImage(char* buf) {
|
||||
//normal
|
||||
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",
|
||||
(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",
|
||||
(long long int) fnum, index);
|
||||
}
|
||||
|
@ -81,8 +81,6 @@ void UDPBaseImplementation::initializeMembers(){
|
||||
dataCompressionEnable = false;
|
||||
|
||||
//***acquisition parameters***
|
||||
for (std::vector<slsReceiverDefs::ROI*>::const_iterator it = roi.begin(); it != roi.end(); ++it)
|
||||
delete(*it);
|
||||
roi.clear();
|
||||
frameToGuiFrequency = 0;
|
||||
frameToGuiTimerinMS = DEFAULT_STREAMING_TIMER_IN_MS;
|
||||
@ -251,7 +249,7 @@ char *UDPBaseImplementation::getEthernetInterface() const{
|
||||
|
||||
|
||||
/***acquisition parameters***/
|
||||
std::vector<slsReceiverDefs::ROI*> UDPBaseImplementation::getROI() const{
|
||||
std::vector<slsReceiverDefs::ROI> UDPBaseImplementation::getROI() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
return roi;
|
||||
}
|
||||
@ -542,7 +540,7 @@ void UDPBaseImplementation::setEthernetInterface(const char* c){
|
||||
|
||||
|
||||
/***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";
|
||||
|
||||
roi = i;
|
||||
@ -554,10 +552,10 @@ int UDPBaseImplementation::setROI(const std::vector<slsReceiverDefs::ROI*> i){
|
||||
else {
|
||||
for (unsigned int i = 0; i < roi.size(); ++i) {
|
||||
sstm << "( " <<
|
||||
roi[i]->xmin << ", " <<
|
||||
roi[i]->xmax << ", " <<
|
||||
roi[i]->ymin << ", " <<
|
||||
roi[i]->ymax << " )";
|
||||
roi[i].xmin << ", " <<
|
||||
roi[i].xmax << ", " <<
|
||||
roi[i].ymin << ", " <<
|
||||
roi[i].ymax << " )";
|
||||
}
|
||||
}
|
||||
std::string message = sstm.str();
|
||||
|
@ -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) {
|
||||
cprintf(RED, "Error: Can not set ROI for this detector\n");
|
||||
return FAIL;
|
||||
@ -180,10 +180,10 @@ int UDPStandardImplementation::setROI(const std::vector<slsReceiverDefs::ROI*> i
|
||||
else {
|
||||
for (unsigned int iloop = 0; iloop < i.size(); ++iloop) {
|
||||
if (
|
||||
(roi[iloop]->xmin != i[iloop]->xmin) ||
|
||||
(roi[iloop]->xmax != i[iloop]->xmax) ||
|
||||
(roi[iloop]->ymin != i[iloop]->ymin) ||
|
||||
(roi[iloop]->xmax != i[iloop]->xmax)) {
|
||||
(roi[iloop].xmin != i[iloop].xmin) ||
|
||||
(roi[iloop].xmax != i[iloop].xmax) ||
|
||||
(roi[iloop].ymin != i[iloop].ymin) ||
|
||||
(roi[iloop].xmax != i[iloop].xmax)) {
|
||||
change = true;
|
||||
break;
|
||||
}
|
||||
@ -217,10 +217,10 @@ int UDPStandardImplementation::setROI(const std::vector<slsReceiverDefs::ROI*> i
|
||||
else {
|
||||
for (unsigned int i = 0; i < roi.size(); ++i) {
|
||||
sstm << "( " <<
|
||||
roi[i]->xmin << ", " <<
|
||||
roi[i]->xmax << ", " <<
|
||||
roi[i]->ymin << ", " <<
|
||||
roi[i]->ymax << " )";
|
||||
roi[i].xmin << ", " <<
|
||||
roi[i].xmax << ", " <<
|
||||
roi[i].ymin << ", " <<
|
||||
roi[i].ymax << " )";
|
||||
}
|
||||
}
|
||||
std::string message = sstm.str();
|
||||
@ -251,7 +251,6 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
|
||||
if (enable) {
|
||||
for ( int i = 0; i < numThreads; ++i ) {
|
||||
try {
|
||||
|
||||
DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange,
|
||||
&roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode);
|
||||
dataStreamer.push_back(s);
|
||||
@ -473,7 +472,6 @@ void UDPStandardImplementation::resetAcquisitionCount() {
|
||||
int UDPStandardImplementation::startReceiver(char *c) {
|
||||
cprintf(RESET,"\n");
|
||||
FILE_LOG(logINFO) << "Starting Receiver";
|
||||
|
||||
ResetParametersforNewMeasurement();
|
||||
|
||||
//listener
|
||||
@ -733,7 +731,7 @@ int UDPStandardImplementation::SetupFifoStructure() {
|
||||
for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
||||
delete(*it);
|
||||
fifo.clear();
|
||||
for ( int i = 0; i < numThreads; i++ ) {
|
||||
for ( int i = 0; i < numThreads; ++i ) {
|
||||
|
||||
//create fifo structure
|
||||
try {
|
||||
|
@ -888,13 +888,13 @@ int slsReceiverTCPIPInterface::set_roi() {
|
||||
if (mySock->ReceiveDataOnly(&nroi,sizeof(nroi)) < 0 )
|
||||
return printSocketReadError();
|
||||
|
||||
std::vector <ROI*> roiLimits;
|
||||
std::vector <ROI> roiLimits;
|
||||
int iloop = 0;
|
||||
for (iloop = 0; iloop < nroi; iloop++) {
|
||||
ROI temp;
|
||||
if ( mySock->ReceiveDataOnly(&temp,sizeof(ROI)) < 0 )
|
||||
return printSocketReadError();
|
||||
roiLimits.push_back(&temp);
|
||||
roiLimits.push_back(temp);
|
||||
}
|
||||
|
||||
//does not exist
|
||||
@ -925,6 +925,8 @@ int slsReceiverTCPIPInterface::set_roi() {
|
||||
if (ret == FAIL)
|
||||
mySock->SendDataOnly(mess,sizeof(mess));
|
||||
|
||||
roiLimits.clear();
|
||||
|
||||
// return ok/fail
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user