merge error fixed

This commit is contained in:
Dhanya Maliakal 2017-09-08 09:31:26 +02:00
parent 1ba325e902
commit aef462da32
7 changed files with 148 additions and 156 deletions

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/moenchDetectorServer"
#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git"
//#define SVNREPPATH ""
#define SVNREPUUID "046a469b1e6582c4c55bd6eaeb4818b618d0a9a9"
//#define SVNREV 0x14
#define SVNREPUUID "a45cc31a576153e251cfe904b3b459c7a2a9abdb"
//#define SVNREV 0x1553
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Maliakal_Dhanya"
#define SVNREV 0x14
#define SVNDATE 0x20140603
#define SVNAUTH "Dhanya_Maliakal"
#define SVNREV 0x1553
#define SVNDATE 0x20170907
//

View File

@ -154,19 +154,100 @@ int decode_function(int file_des) {
else
printf("size of data received %d\n",n);
#endif
printf("calling function=%d (%s)\n", fnum, getFunctionName((enum detFuncs)fnum));
#ifdef VERBOSE
printf( "calling function fnum = %d %x %x %x\n",fnum,(unsigned int)(flist[fnum]), (unsigned int)(flist[F_READ_REGISTER]),(unsigned int)(&read_register));
#endif
if (fnum<0 || fnum>255)
fnum=255;
retval=(*flist[fnum])(file_des);
printf(" function=%d (%s) returned: %d\n", fnum, getFunctionName((enum detFuncs)fnum), retval);
if (retval==FAIL)
printf( "Error executing the function = %d \n",fnum);
return retval;
}
const char* getFunctionName(enum detFuncs func) {
switch (func) {
case F_EXEC_COMMAND: return "F_EXEC_COMMAND";
case F_GET_ERROR: return "F_GET_ERROR";
case F_GET_DETECTOR_TYPE: return "F_GET_DETECTOR_TYPE";
case F_SET_NUMBER_OF_MODULES: return "F_SET_NUMBER_OF_MODULES";
case F_GET_MAX_NUMBER_OF_MODULES: return "F_GET_MAX_NUMBER_OF_MODULES";
case F_SET_EXTERNAL_SIGNAL_FLAG: return "F_SET_EXTERNAL_SIGNAL_FLAG";
case F_SET_EXTERNAL_COMMUNICATION_MODE: return "F_SET_EXTERNAL_COMMUNICATION_MODE";
case F_GET_ID: return "F_GET_ID";
case F_DIGITAL_TEST: return "F_DIGITAL_TEST";
case F_ANALOG_TEST: return "F_ANALOG_TEST";
case F_ENABLE_ANALOG_OUT: return "F_ENABLE_ANALOG_OUT";
case F_CALIBRATION_PULSE: return "F_CALIBRATION_PULSE";
case F_SET_DAC: return "F_SET_DAC";
case F_GET_ADC: return "F_GET_ADC";
case F_WRITE_REGISTER: return "F_WRITE_REGISTER";
case F_READ_REGISTER: return "F_READ_REGISTER";
case F_WRITE_MEMORY: return "F_WRITE_MEMORY";
case F_READ_MEMORY: return "F_READ_MEMORY";
case F_SET_CHANNEL: return "F_SET_CHANNEL";
case F_GET_CHANNEL: return "F_GET_CHANNEL";
case F_SET_ALL_CHANNELS: return "F_SET_ALL_CHANNELS";
case F_SET_CHIP: return "F_SET_CHIP";
case F_GET_CHIP: return "F_GET_CHIP";
case F_SET_ALL_CHIPS: return "F_SET_ALL_CHIPS";
case F_SET_MODULE: return "F_SET_MODULE";
case F_GET_MODULE: return "F_GET_MODULE";
case F_SET_ALL_MODULES: return "F_SET_ALL_MODULES";
case F_SET_SETTINGS: return "F_SET_SETTINGS";
case F_GET_THRESHOLD_ENERGY: return "F_GET_THRESHOLD_ENERGY";
case F_SET_THRESHOLD_ENERGY: return "F_SET_THRESHOLD_ENERGY";
case F_START_ACQUISITION: return "F_START_ACQUISITION";
case F_STOP_ACQUISITION: return "F_STOP_ACQUISITION";
case F_START_READOUT: return "F_START_READOUT";
case F_GET_RUN_STATUS: return "F_GET_RUN_STATUS";
case F_START_AND_READ_ALL: return "F_START_AND_READ_ALL";
case F_READ_FRAME: return "F_READ_FRAME";
case F_READ_ALL: return "F_READ_ALL";
case F_SET_TIMER: return "F_SET_TIMER";
case F_GET_TIME_LEFT: return "F_GET_TIME_LEFT";
case F_SET_DYNAMIC_RANGE: return "F_SET_DYNAMIC_RANGE";
case F_SET_READOUT_FLAGS: return "F_SET_READOUT_FLAGS";
case F_SET_ROI: return "F_SET_ROI";
case F_SET_SPEED: return "F_SET_SPEED";
case F_EXECUTE_TRIMMING: return "F_EXECUTE_TRIMMING";
case F_EXIT_SERVER: return "F_EXIT_SERVER";
case F_LOCK_SERVER: return "F_LOCK_SERVER";
case F_GET_LAST_CLIENT_IP: return "F_GET_LAST_CLIENT_IP";
case F_SET_PORT: return "F_SET_PORT";
case F_UPDATE_CLIENT: return "F_UPDATE_CLIENT";
case F_CONFIGURE_MAC: return "F_CONFIGURE_MAC";
case F_LOAD_IMAGE: return "F_LOAD_IMAGE";
case F_SET_MASTER: return "F_SET_MASTER";
case F_SET_SYNCHRONIZATION_MODE: return "F_SET_SYNCHRONIZATION_MODE";
case F_READ_COUNTER_BLOCK: return "F_READ_COUNTER_BLOCK";
case F_RESET_COUNTER_BLOCK: return "F_RESET_COUNTER_BLOCK";
case F_CALIBRATE_PEDESTAL: return "F_CALIBRATE_PEDESTAL";
case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA";
case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS";
case F_SET_CTB_PATTERN: return "F_SET_CTB_PATTERN";
case F_WRITE_ADC_REG: return "F_WRITE_ADC_REG";
case F_SET_COUNTER_BIT: return "F_SET_COUNTER_BIT";
case F_PULSE_PIXEL: return "F_PULSE_PIXEL";
case F_PULSE_PIXEL_AND_MOVE: return "F_PULSE_PIXEL_AND_MOVE";
case F_PULSE_CHIP: return "F_PULSE_CHIP";
case F_SET_RATE_CORRECT: return "F_SET_RATE_CORRECT";
case F_GET_RATE_CORRECT: return "F_GET_RATE_CORRECT";
case F_SET_NETWORK_PARAMETER: return "F_SET_NETWORK_PARAMETER";
case F_PROGRAM_FPGA: return "F_PROGRAM_FPGA";
case F_RESET_FPGA: return "F_RESET_FPGA";
case F_POWER_CHIP: return "F_POWER_CHIP";
case F_ACTIVATE: return "F_ACTIVATE";
case F_PREPARE_ACQUISITION: return "F_PREPARE_ACQUISITION";
case F_CLEANUP_ACQUISITION: return "F_CLEANUP_ACQUISITION";
default: return "Unknown Function";
}
}
int function_table() {
int i;
for (i=0;i<256;i++){
@ -218,8 +299,6 @@ int function_table() {
flist[F_SET_SYNCHRONIZATION_MODE]=&set_synchronization;
flist[F_READ_COUNTER_BLOCK]=&read_counter_block;
flist[F_RESET_COUNTER_BLOCK]=&reset_counter_block;
flist[F_START_RECEIVER]=&start_receiver;
flist[F_STOP_RECEIVER]=&stop_receiver;
flist[F_CALIBRATE_PEDESTAL]=&calibrate_pedestal;
flist[F_SET_CTB_PATTERN]=&set_ctb_pattern;
flist[F_WRITE_ADC_REG]=&write_adc_register;
@ -3078,80 +3157,6 @@ int reset_counter_block(int file_des) {
int start_receiver(int file_des) {
int ret=OK;
int n=0;
strcpy(mess,"Could not start receiver\n");
/* execute action if the arguments correctly arrived*/
//#ifdef MCB_FUNCS
if (lockStatus==1 && differentClients==1){//necessary???
sprintf(mess,"Detector locked by %s\n", lastClientIP);
ret=FAIL;
}
else
ret = startReceiver(1);
//#endif
if(ret==OK && differentClients){
printf("Force update\n");
ret=FORCE_UPDATE;
}
/* send answer */
n = sendDataOnly(file_des,&ret,sizeof(ret));
if(ret==FAIL)
n = sendDataOnly(file_des,mess,sizeof(mess));
/*return ok/fail*/
return ret;
}
int stop_receiver(int file_des) {
int ret=OK;
int n=0;
strcpy(mess,"Could not stop receiver\n");
/* execute action if the arguments correctly arrived*/
//#ifdef MCB_FUNCS
if (lockStatus==1 && differentClients==1){//necessary???
sprintf(mess,"Detector locked by %s\n", lastClientIP);
ret=FAIL;
}
else
ret=startReceiver(0);
//#endif
if(ret==OK && differentClients){
printf("Force update\n");
ret=FORCE_UPDATE;
}
/* send answer */
n = sendDataOnly(file_des,&ret,sizeof(ret));
if(ret==FAIL)
n = sendDataOnly(file_des,mess,sizeof(mess));
/*return ok/fail*/
return ret;
}
int calibrate_pedestal(int file_des){
int ret=OK;
@ -3653,20 +3658,29 @@ int activate(int file_des) {
}
int prepare_acquisition(int file_des) {
int ret = OK;
int n=0;
strcpy(mess,"prepare acquisition failed\n");
int retval=-1;
int ret=OK;
int arg=-1;
int n;
sprintf(mess,"Can't activate detector\n");
n = receiveDataOnly(file_des,&arg,sizeof(arg));
if (n < 0) {
sprintf(mess,"Error reading from socket\n");
ret = FAIL;
strcpy(mess,"Not implemented for this detector\n");
cprintf(RED, "Warning: %s", mess);
/*
//lock
if (ret==OK && differentClients && lockStatus) {
ret=FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
cprintf(RED, "Warning: %s", mess);
}
if (ret==OK && differentClients==1)
else {
ret = startReceiver(1);
if (ret == FAIL)
cprintf(RED, "Warning: %s", mess);
}
*/
if(ret==OK && differentClients)
ret=FORCE_UPDATE;
/* send answer */
@ -3678,20 +3692,30 @@ int prepare_acquisition(int file_des) {
}
int cleanup_acquisition(int file_des) {
int ret = OK;
int n=0;
int retval=-1;
int ret=OK;
int arg=-1;
int n;
sprintf(mess,"Can't activate detector\n");
n = receiveDataOnly(file_des,&arg,sizeof(arg));
if (n < 0) {
sprintf(mess,"Error reading from socket\n");
//to receive any arguments
while (n > 0)
n = receiveDataOnly(file_des,mess,MAX_STR_LENGTH);
ret = FAIL;
strcpy(mess,"Not implemented for this detector\n");
cprintf(RED, "Warning: %s", mess);
/*
if (lockStatus && differentClients){//necessary???
sprintf(mess,"Detector locked by %s\n", lastClientIP);
cprintf(RED, "Warning: %s", mess);
ret=FAIL;
}
if (ret==OK && differentClients==1)
else {
ret=startReceiver(0);
if (ret == FAIL)
cprintf(RED, "Warning: %s", mess);
}
*/
if(ret==OK && differentClients)
ret=FORCE_UPDATE;
/* send answer */

View File

@ -23,6 +23,7 @@ int sockfd;
int function_table();
int decode_function(int);
const char* getFunctionName(enum detFuncs func);
int init_detector(int,int);
int M_nofunc(int);
@ -85,10 +86,6 @@ int load_image(int);
int read_counter_block(int);
int reset_counter_block(int);
int start_receiver(int);
int stop_receiver(int);
int calibrate_pedestal(int);
int set_roi(int);

View File

@ -1466,7 +1466,6 @@ int multiSlsDetector::cleanupAcquisition(){
/* change these funcs accepting also ok/fail */
int multiSlsDetector::startAcquisition(){
if (getDetectorsType() == EIGER) {
if (prepareAcquisition() == FAIL)
return FAIL;
@ -1780,7 +1779,7 @@ int* multiSlsDetector::startAndReadAll(){
int i=0;
if (thisMultiDetector->onlineFlag==ONLINE_FLAG) {
if(getDetectorsType() == EIGER) {
if (getDetectorsType() == EIGER) {
if (prepareAcquisition() == FAIL)
return NULL;
}
@ -3126,37 +3125,11 @@ dacs_t multiSlsDetector::setDAC(dacs_t val, dacIndex idac, int mV, int imod) {
{
int id=-1, im=-1;
if (decodeNMod(imod, id, im)>=0) {
posmin=id;
posmax=id+1;
}
// cout <<posmin << " " << posmax << endl;
//return storage values
dacs_t* iret[posmax-posmin];
for(int idet=posmin; idet<posmax; ++idet){
//cout << idet << endl;
if(detectors[idet]){
// cout << "*" << endl;
iret[idet]= new dacs_t(-1);
Task* task = new Task(new func4_t <dacs_t,slsDetector,dacs_t,dacIndex,int,int,dacs_t>(&slsDetector::setDAC,detectors[idet],val, idac, mV, im, iret[idet]));
threadpool->add_task(task);
}
}
// cout << "Start" << endl;
threadpool->startExecuting();
threadpool->wait_for_tasks_to_complete();
for(int idet=posmin; idet<posmax; idet++){
if(detectors[idet]){
if(iret[idet] != NULL){
if (ret==-100)
ret=*iret[idet];
else if (ret!=*iret[idet])
ret=-1;
delete iret[idet];
}else ret=-1;
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
if(detectors[id]){
ret = detectors[id]->setDAC(val, idac, mV, im);
if(detectors[id]->getErrorMask())
setErrorMask(getErrorMask()|(1<<id));
return ret;
}
return -1;
}

View File

@ -1343,7 +1343,7 @@ int slsDetector::activate(int const enable){
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL) {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned activate error: " << mess << std::endl;
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(DETECTOR_ACTIVATE));
} else {
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
@ -1736,7 +1736,7 @@ int slsDetector::getTotalNumberOfChannels() {
}
thisDetector->nChans=thisDetector->nChan[X];
thisDetector->dataBytes=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods*2*thisDetector->timerValue[SAMPLES_JCTB];
cout << "Total number of channels is "<< thisDetector->nChans*thisDetector->nChips*thisDetector->nMods << " data bytes is " << thisDetector->dataBytes << endl;
// cout << "Total number of channels is "<< thisDetector->nChans*thisDetector->nChips*thisDetector->nMods << " data bytes is " << thisDetector->dataBytes << endl;
} else {
#ifdef VERBOSE
cout << "det type is "<< thisDetector->myDetectorType << endl;
@ -7922,12 +7922,10 @@ int slsDetector::startReceiver(){
}
//let detector prepare anyway even if receiver didnt work (for those not using the receiver)
if((thisDetector->myDetectorType != JUNGFRAU) ) {
int ret1 = detectorSendToReceiver(true);
if (ret != FAIL)
ret = ret1;
}
// tell detector to send to receiver (if start receiver failed, this is not executed)
if(((thisDetector->myDetectorType == GOTTHARD || thisDetector->myDetectorType == PROPIX) && ret!= FAIL))
return prepareAcquisition(); // send data to receiver for these detectors
return ret;
}
@ -7940,7 +7938,7 @@ int slsDetector::stopReceiver(){
int ret = FAIL;
char mess[MAX_STR_LENGTH] = "";
if(thisDetector->myDetectorType != EIGER && thisDetector->myDetectorType != JUNGFRAU)
if(thisDetector->myDetectorType == GOTTHARD || thisDetector->myDetectorType == PROPIX)
cleanupAcquisition(); // reset (send data to receiver) for these detectors, so back to CPU (dont care about ok/fail at this point)
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {

View File

@ -49,9 +49,9 @@ int ThreadPool::initialize_threadpool(){
m_threads.push_back(tid);
while(!thread_started);
}
#ifdef VERBOSE
#ifdef VERBOSE
cout << m_pool_size << " threads created by the thread pool" << endl;
#endif
#endif
return m_pool_size;
}
@ -87,11 +87,11 @@ int ThreadPool::destroy_threadpool(){
void* ThreadPool::execute_thread(){
//for debugging seting ithread value
//int ithread = current_thread_number;
// int ithread = current_thread_number;
thread_started = true;
Task* task = NULL;
m_tasks_loaded = false;
//cout << "Starting thread " << pthread_self() << endl;
/*cout << "Starting thread " << pthread_self() << endl;*/
while(true) {
// Try to pick a task
/*cout << "Locking: " << pthread_self() << endl;*/
@ -122,7 +122,7 @@ void* ThreadPool::execute_thread(){
//cout<<"***"<<ithread<<" checking out semaphore done address:"<<&semDone<<endl;
// cout << ithread <<" Executing thread " << pthread_self() << endl;
/*cout << ithread <<" Executing thread " << pthread_self() << endl;*/
// execute the task
(*task)(); // could also do task->run(arg);
/*cout << ithread <<" Done executing thread " << pthread_self() << endl;*/