pulsing client side, and bug fix server side for reset partially

This commit is contained in:
Dhanya Maliakal 2015-11-19 16:15:59 +01:00
parent 291fe8bc22
commit e0464ef782
15 changed files with 372 additions and 14 deletions

View File

@ -53,6 +53,9 @@ using namespace std;
#define COULD_NOT_SET_READOUT_FLAGS 0x0000000000008000ULL
#define COULD_NOT_SET_FIFO_DEPTH 0x0000000000010000ULL
#define COULD_NOT_SET_COUNTER_BIT 0x0000000000020000ULL
#define COULD_NOT_PULSE_PIXEL 0x0000000000040000ULL
#define COULD_NOT_PULSE_PIXEL_NMOVE 0x0000000000080000ULL
// 0x00000000FFFFFFFFULL
/** @short class returning all error messages for error mask */
@ -165,6 +168,13 @@ public:
if(slsErrorMask&COULD_NOT_SET_COUNTER_BIT)
retval.append("Could not set/reset counter bit\n");
if(slsErrorMask&COULD_NOT_PULSE_PIXEL)
retval.append("Could not pulse pixel\n");
if(slsErrorMask&COULD_NOT_PULSE_PIXEL_NMOVE)
retval.append("Could not pulse pixel and move\n");
return retval;
}

View File

@ -95,7 +95,9 @@ enum {
F_SET_CTB_PATTERN, /** < loads a pattern in the CTB */
F_WRITE_ADC_REG, /** < writes an ADC register */
F_SET_COUNTER_BIT /** < set/reset counter bit in detector for eiger */
F_SET_COUNTER_BIT, /** < set/reset counter bit in detector for eiger */
F_PULSE_PIXEL, /** < pulse pixel n number of times in eiger at (x,y) */
F_PULSE_PIXEL_AND_MOVE /** < pulse pixel n number of times and move relatively by x and y */
/* Always append functions hereafter!!! */

View File

@ -1417,7 +1417,7 @@ int Feb_Control_ResetChipCompletely(){
int Feb_Control_ResetChipPartially(){
if(!Feb_Control_SetCommandRegister(DAQ_RESET_PERIPHERY & DAQ_RESET_COLUMN_SELECT) || !Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
if(!Feb_Control_SetCommandRegister(DAQ_RESET_PERIPHERY | DAQ_RESET_COLUMN_SELECT) || !Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
printf("Warning: could not ResetChipPartially().\n");;
return 0;
}

View File

@ -453,6 +453,19 @@ int setCounterBit(int val){
}
int pulsePixel(int n, int x, int y){
printf("not implemented yet\n");
return OK;
}
int pulsePixelNMove(int n, int x, int y){
printf("not implemented yet\n");
return OK;
}
int setModule(sls_detector_module myMod, int* gain, int* offset){
int retval[2];
int i;

View File

@ -5098,9 +5098,6 @@ int multiSlsDetector::setCTBPatWaitAddr(int level, int addr) {
int multiSlsDetector::setCTBPatWaitTime(int level, uint64_t t) {
int ret=-100,ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++)
if (detectors[idet]){
@ -5114,9 +5111,38 @@ int multiSlsDetector::setCTBPatWaitTime(int level, uint64_t t) {
}
return ret;
}
int multiSlsDetector::pulsePixel(int n,int x,int y) {
int ret=-100,ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++)
if (detectors[idet]){
ret1=detectors[idet]->pulsePixel(n,x,y);
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
if(ret==-100)
ret=ret1;
else if (ret!=ret1)
ret=-1;
}
return ret;
}
int multiSlsDetector::pulsePixelNMove(int n,int x,int y) {
int ret=-100,ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++)
if (detectors[idet]){
ret1=detectors[idet]->pulsePixelNMove(n,x,y);
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
if(ret==-100)
ret=ret1;
else if (ret!=ret1)
ret=-1;
}
return ret;
}

View File

@ -1303,7 +1303,23 @@ class multiSlsDetector : public slsDetectorUtils {
*/
int setCTBPatWaitTime(int level, uint64_t t=-1);
/**
Pulse Pixel
\param n is number of times to pulse
\param x is x coordinate
\param y is y coordinate
\returns OK or FAIL
*/
int pulsePixel(int n=0,int x=0,int y=0);
/**
Pulse Pixel and move by a relative value
\param n is number of times to pulse
\param x is relative x value
\param y is relative y value
\returns OK or FAIL
*/
int pulsePixelNMove(int n=0,int x=0,int y=0);

View File

@ -7451,4 +7451,65 @@ int slsDetector::setCTBPatWaitTime(int level, uint64_t t) {
}
int slsDetector::pulsePixel(int n,int x,int y) {
int ret=FAIL;
int fnum=F_PULSE_PIXEL;
char mess[100];
int arg[3];
arg[0] = n; arg[1] = x; arg[2] = y;
#ifdef VERBOSE
std::cout<< std::endl<< "Pulsing Pixel " << n << " number of times at (" << x << "," << "y)" << endl << endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(arg,sizeof(arg));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL){
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(COULD_NOT_PULSE_PIXEL));
}
controlSocket->Disconnect();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
return ret;
}
int slsDetector::pulsePixelNMove(int n,int x,int y) {
int ret=FAIL;
int fnum=F_PULSE_PIXEL_AND_MOVE;
char mess[100];
int arg[3];
arg[0] = n; arg[1] = x; arg[2] = y;
#ifdef VERBOSE
std::cout<< std::endl<< "Pulsing Pixel " << n << " number of times and move by deltax:" << x << " deltay:" << y << endl << endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(arg,sizeof(arg));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL){
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(COULD_NOT_PULSE_PIXEL_NMOVE));
}
controlSocket->Disconnect();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
return ret;
}

View File

@ -1734,6 +1734,24 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/
int setCTBPatWaitTime(int level, uint64_t t=-1);
/**
Pulse Pixel
\param n is number of times to pulse
\param x is x coordinate
\param y is y coordinate
\returns OK or FAIL
*/
int pulsePixel(int n=0,int x=0,int y=0);
/**
Pulse Pixel and move by a relative value
\param n is number of times to pulse
\param x is relative x value
\param y is relative y value
\returns OK or FAIL
*/
int pulsePixelNMove(int n=0,int x=0,int y=0);
protected:

View File

@ -1019,7 +1019,16 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
i++;
/* pulse pixel */
descrToFuncMap[i].m_pFuncName="pulse"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPulse;
i++;
descrToFuncMap[i].m_pFuncName="pulsenmove"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPulse;
i++;
numberOfCommands=i;
@ -4916,3 +4925,73 @@ else return helpPattern(narg, args, action);
return os.str();
}
string slsDetectorCommand::helpPulse(int narg, char *args[], int action) {
ostringstream os;
if (action==PUT_ACTION || action==HELP_ACTION) {
os << "pulse [n] [x] [y] \t pulses pixel at coordinates (x,y) n number of times" << std::endl;
os << "pulsenmove [n] [x] [y]\t pulses pixel n number of times and moves relatively by x value (x axis) and y value(y axis)" << std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION){
os << "pulse \t cannot get" << std::endl;
os << "pulsenmove \t cannot get" << std::endl;
}
return os.str();
}
string slsDetectorCommand::cmdPulse(int narg, char *args[], int action) {
int ival1=1,ival2=-2,ival3=-1;
if (action==HELP_ACTION)
return helpPulse(narg, args, action);
else if (action==GET_ACTION)
return string("cannot get ")+cmd;
myDet->setOnline(ONLINE_FLAG);
if (string(args[0])==string("pulse")){
if(myDet->pulsePixel(ival1,ival2,ival3) == OK)
return string("Pulse pixel successful");
else
return string("Pulse pixel failed");
}
else if (string(args[0])==string("pulsenmove")){
if(myDet->pulsePixelNMove(ival1,ival2,ival3) == OK)
return string("Pulse pixel and move successful");
else
return string("Pulse pixel and move failed");
}
return string("could not decode command")+cmd;
}

View File

@ -85,7 +85,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
static string helpOverwrite(int narg, char *args[], int action);
static string helpReceiver(int narg, char *args[], int action);
static string helpPattern(int narg, char *args[], int action);
static string helpPulse(int narg, char *args[], int action);
@ -157,6 +157,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
string cmdOverwrite(int narg, char *args[], int action);
string cmdReceiver(int narg, char *args[], int action);
string cmdPattern(int narg, char *args[], int action);
string cmdPulse(int narg, char *args[], int action);
int numberOfCommands;

View File

@ -760,9 +760,23 @@ virtual int setReceiverFifoDepth(int i = -1)=0;
*/
virtual int setCTBPatWaitTime(int level, uint64_t t=-1)=0;
/**
Pulse Pixel
\param n is number of times to pulse
\param x is x coordinate
\param y is y coordinate
\returns OK or FAIL
*/
virtual int pulsePixel(int n=0,int x=0,int y=0)=0;
/**
Pulse Pixel and move by a relative value
\param n is number of times to pulse
\param x is relative x value
\param y is relative y value
\returns OK or FAIL
*/
virtual int pulsePixelNMove(int n=0,int x=0,int y=0)=0;

View File

@ -48,6 +48,8 @@ int setHighVolage(int val, int imod);
int setIODelay(int val, int imod);
int enableTenGigabitEthernet(int val);
int setCounterBit(int val);
int pulsePixel(int n, int x, int y);
int pulsePixelNMove(int n, int x, int y);
#endif
#if defined(MYTHEND) || defined(GOTTHARDD)

View File

@ -176,6 +176,9 @@ int function_table() {
flist[F_ENABLE_TEN_GIGA]=&enable_ten_giga;
flist[F_SET_ALL_TRIMBITS]=&set_all_trimbits;
flist[F_SET_COUNTER_BIT]=&set_counter_bit;
flist[F_PULSE_PIXEL]=&pulse_pixel;
flist[F_PULSE_PIXEL_AND_MOVE]=&pulse_pixel_and_move;
#ifdef VERBOSE
@ -3526,19 +3529,25 @@ int enable_ten_giga(int file_des) {
ret=FAIL;
}
/* execute action */
if(ret != FAIL){
#ifndef EIGERD
ret = FAIL;
strcpy(mess,"Not applicable/implemented for this detector\n");
#else
#ifdef VERBOSE
printf("Enabling 10Gbe :%d \n",arg);
#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
if(ret != FAIL){
retval=enableTenGigabitEthernet(arg);
if((arg != -1) && (retval != arg))
ret=FAIL;
else if (differentClients==1) {
ret=FORCE_UPDATE;
}
#endif
}
#endif
#endif
/* send answer */
/* send OK/failed */
//ret could be swapped during sendData
@ -3570,6 +3579,10 @@ int set_all_trimbits(int file_des){
ret=FAIL;
}
#ifndef EIGERD
ret = FAIL;
strcpy(mess,"Not applicable/implemented for this detector\n");
#else
#ifdef VERBOSE
printf("setting all trimbits to %d\n",arg);
#endif
@ -3595,7 +3608,7 @@ int set_all_trimbits(int file_des){
}else if (differentClients)
ret=FORCE_UPDATE;
}
#endif
//ret could be swapped during sendData
ret1 = ret;
@ -3627,19 +3640,24 @@ int set_counter_bit(int file_des) {
ret=FAIL;
}
/* execute action */
if(ret != FAIL){
#ifndef EIGERD
ret = FAIL;
strcpy(mess,"Not applicable/implemented for this detector\n");
#else
#ifdef VERBOSE
printf("Getting/Setting/Resetting counter bit :%d \n",arg);
#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
if(ret != FAIL){
retval=setCounterBit(arg);
if((arg != -1) && (retval != arg))
ret=FAIL;
else if (differentClients==1) {
ret=FORCE_UPDATE;
}
#endif
}
#endif
#endif
/* send answer */
/* send OK/failed */
//ret could be swapped during sendData
@ -3652,3 +3670,99 @@ int set_counter_bit(int file_des) {
/*return ok/fail*/
return ret;
}
int pulse_pixel(int file_des) {
int ret=OK,ret1=OK;
int n;
int arg[3];
arg[0]=-1; arg[1]=-1; arg[2]=-1;
sprintf(mess,"pulse pixel failed\n");
n = receiveData(file_des,arg,sizeof(arg),INT32);
if (n < 0) {
sprintf(mess,"Error reading from socket\n");
ret=FAIL;
}
#ifndef EIGERD
ret = FAIL;
strcpy(mess,"Not applicable/implemented for this detector\n");
#else
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
if (differentClients==1 && lockStatus==1) {
ret=FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
} else
ret=pulsePixel(arg[0],arg[1],arg[2]);
}
#endif
#endif
if(ret==OK){
if (differentClients)
ret=FORCE_UPDATE;
}
/* send answer */
/* send OK/failed */
//ret could be swapped during sendData
ret1 = ret;
n = sendData(file_des,&ret1,sizeof(ret),INT32);
if (ret==FAIL)
n += sendData(file_des,mess,sizeof(mess),OTHER);
/*return ok/fail*/
return ret;
}
int pulse_pixel_and_move(int file_des) {
int ret=OK,ret1=OK;
int n;
int arg[3];
arg[0]=-1; arg[1]=-1; arg[2]=-1;
sprintf(mess,"pulse pixel and move failed\n");
n = receiveData(file_des,arg,sizeof(arg),INT32);
if (n < 0) {
sprintf(mess,"Error reading from socket\n");
ret=FAIL;
}
#ifndef EIGERD
ret = FAIL;
strcpy(mess,"Not applicable/implemented for this detector\n");
#else
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
if (differentClients==1 && lockStatus==1) {
ret=FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
} else
ret=pulsePixelNMove(arg[0],arg[1],arg[2]);
}
#endif
#endif
if(ret==OK){
if (differentClients)
ret=FORCE_UPDATE;
}
/* send answer */
/* send OK/failed */
//ret could be swapped during sendData
ret1 = ret;
n = sendData(file_des,&ret1,sizeof(ret),INT32);
if (ret==FAIL)
n += sendData(file_des,mess,sizeof(mess),OTHER);
/*return ok/fail*/
return ret;
}

View File

@ -84,5 +84,7 @@ int calibrate_pedestal(int);
int enable_ten_giga(int);
int set_all_trimbits(int);
int set_counter_bit(int);
int pulse_pixel(int);
int pulse_pixel_and_move(int);
#endif