Commit 1b1cb283 authored by flechsig's avatar flechsig
Browse files

working version without core dump (UF+XW)

parent 7111b68d
// Time-stamp: <18 Feb 19 14:25:29 flechsig>
// Time-stamp: <20 Feb 19 14:52:43 flechsig>
/*
* NDPluginXGI.cpp
*
......@@ -213,33 +213,29 @@ void NDPluginXGI::processCallbacks(NDArray *pArray)
break;
case 2:
#ifdef DEBUG
printf("Algorithm == %d --> call evaluf()\n", algorithm);
printf("Algorithm == %d --> call evaluf()\n", algorithm);
#endif
this->XGIconfig.direction= COLDIR;
evaluf(&image, &this->XGIconfig, &output);
// setDoubleParam(WFIPluginROC, ROC); // radius
break;
break;
case 3:
#ifdef DEBUG
printf("Algorithm == %d --> call evalfft2d()\n", algorithm);
#endif
evalfft2d(&image, &this->XGIconfig, &output);
//autorange((double*)pOutput->pData, arrayInfo.ySize, arrayInfo.xSize, logscale);
break;
evalfft2d(&image, &this->XGIconfig, &output);
break;
case 5:
#ifdef DEBUG
printf("Algorithm == %d --> call evaluf()\n", algorithm);
#endif
this->XGIconfig.direction= ROWDIR;
evaluf(&image, &this->XGIconfig, &output);
// setDoubleParam(WFIPluginROC, ROC); // radius
break;
break;
case 6:
#ifdef DEBUG
printf("Algorithm == %d --> call evalfft_ifft_2d()\n", algorithm);
#endif
evalfft_ifft_2d(&image, &this->XGIconfig, &output);
//autorange((double*)pOutput->pData, arrayInfo.ySize, arrayInfo.xSize, logscale);
break;
case 7:
#ifdef DEBUG
......@@ -247,21 +243,19 @@ void NDPluginXGI::processCallbacks(NDArray *pArray)
#endif
this->XGIconfig.direction= COLDIR;
evaluf_zp(&image, &this->XGIconfig, &output);
// setDoubleParam(WFIPluginROC, ROC); // radius
break;
break;
case 8:
#ifdef DEBUG
printf("Algorithm == %d --> call evaluf()\n", algorithm);
#endif
this->XGIconfig.direction= ROWDIR;
evaluf_zp(&image, &this->XGIconfig, &output);
// setDoubleParam(WFIPluginROC, ROC); // radius
break;
break;
case 9:
#ifdef DEBUG
printf("Algorithm == %d --> just overlay plus callback \n", algorithm);
#endif
myoverlay(&image, &this->XGIconfig, &output);
myoverlay(&image, &this->XGIconfig, &output);
break;
default:
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
......@@ -295,20 +289,16 @@ void NDPluginXGI::processCallbacks(NDArray *pArray)
}
if (this->pArrays[i]) this->pArrays[i]->release();
// UF problem if we start with unallocated arrays
if ( ! m ) // UF avoid a core dump
std::cout << "error: Matrix == NULL- skip matrixToNDArray " << std::endl;
else
{
this->pArrays[i] = matrixToNDArray(m);
/* Copy time stamp and uniqueId from input array */
this->pArrays[i]->uniqueId = pArray->uniqueId;
this->pArrays[i]->timeStamp = pArray->timeStamp;
/* Update attribute list */
this->getAttributes(this->pArrays[i]->pAttributeList);
/* Call the NDArray callback */
doCallbacksGenericPointer(this->pArrays[i], NDArrayData, i);
}
this->pArrays[i] = matrixToNDArray(m);
if (this->pArrays[i] == NULL)
continue;
/* Copy time stamp and uniqueId from input array */
this->pArrays[i]->uniqueId = pArray->uniqueId;
this->pArrays[i]->timeStamp = pArray->timeStamp;
/* Update attribute list */
this->getAttributes(this->pArrays[i]->pAttributeList);
/* Call the NDArray callback */
doCallbacksGenericPointer(this->pArrays[i], NDArrayData, i);
}
}
/* Leave output matrix, they are reused for the next processing */
......@@ -381,12 +371,11 @@ NDArray *NDPluginXGI::matrixToNDArray(const Matrix *matrix)
{
int ndims = 2;
// UF it fails in case the matrix is not filled
if (! matrix)
{
std::cout << "error: matrixToNDArray: matrix== NULL" << std::endl;
if (matrix->data == NULL) // UF it fails in case the matrix is not allocated
{
std::cerr << "error: matrixToNDArray: matrix == NULL" << std::endl;
return NULL;
}
}
size_t dims[2] = {matrix->width, matrix->height};
NDDataType_t dataType = NDFloat64;
......@@ -403,7 +392,7 @@ NDArray *NDPluginXGI::matrixToNDArray(const Matrix *matrix)
}
return pArrayOut;
}
} // end NDPluginXGI::matrixToNDArray
/** Constructor for NDPluginXGI; all parameters are simply passed to NDPluginDriver::NDPluginDriver.
* \param[in] portName The name of the asyn port driver to be created.
......
// File : /afs/psi.ch/user/f/flechsig/git/WFI/src/algorithms.cpp
// Date : <11 Feb 19 10:02:46 flechsig>
// Time-stamp: <13 Feb 19 14:27:30 flechsig>
// Time-stamp: <20 Feb 19 12:32:03 flechsig>
// Author : Flechsig Uwe, uwe.flechsig&#64;psi.&#99;&#104;
#include <iostream>
......@@ -72,15 +72,15 @@ void autorange(double *data, int rows, int cols, int logscale)
// calc a 2d forward i.e. fft(-1) -
// apply fftshift,
// parameter outphase determines output data (amplitude, phase, unwrapped phase)
// output amp, wrapped and unwrapped phase
void evalfft2d(Matrix *put_in, struct ConfigStruct *cstp, struct Xgi_out *put_out)
{
fftw_complex *in, *out;
fftw_plan p1;
int idxc, idxmax;
double amp, pha;
FLOATING *data;
int rows, cols;
fftw_plan p1;
int idxc, idxmax;
double amp, pha;
FLOATING *data;
int rows, cols;
#ifdef DEBUG
cout << "eval evalfft2d called" << endl;
......@@ -111,11 +111,11 @@ void evalfft2d(Matrix *put_in, struct ConfigStruct *cstp, struct Xgi_out *put_ou
{
amp= sqrt(pow(out[idxc][0], 2)+ pow(out[idxc][1], 2));
pha= atan2(out[idxc][1], out[idxc][0]); // the r phase
data[idxc]= amp;
put_out->dphi_wrap.data[idxc]= pha;
data[idxc]= amp; // fill amp
put_out->dphi_wrap.data[idxc]= pha; // fill wrap
}
put_out->dphi_wrap.copy(&put_out->dphi_unwrap);
put_out->dphi_wrap.copy(&put_out->dphi_unwrap); // cp wrap to unwrap
unwrap_phase(put_out->dphi_unwrap.data, rows, cols); // call Herra
fftw_destroy_plan(p1); // clean up
......@@ -130,7 +130,6 @@ void evalfft2d(Matrix *put_in, struct ConfigStruct *cstp, struct Xgi_out *put_ou
// calc a forward i.e. fft(-1) and backward fft(1)- to test speed
// see evalfft2d
void evalfft_ifft_2d(Matrix *put_in, struct ConfigStruct *cstp, struct Xgi_out *put_out)
//double *data, int rows, int cols, int outphase)
{
fftw_complex *in, *out;
fftw_plan p1, p2;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment