reshuffling by Anna

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@179 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
bergamaschi
2012-05-14 13:39:18 +00:00
parent b484ad7f20
commit b5e966bb58
19 changed files with 528 additions and 631 deletions

View File

@ -6,11 +6,11 @@ INCLUDES= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsD
CC=g++
SRC_CLNT= slsDetectorAnalysis/fileIO.cpp slsDetector/slsDetector.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp multiSlsDetector/multiSlsDetector.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp
SRC_CLNT= slsDetectorAnalysis/fileIO.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp
OBJS = $(SRC_CLNT:.cpp=.o)
HEADERS = $(SRC_CLNT:.cpp=.h) commonFiles/sls_detector_defs.h slsDetectorAnalysis/detectorData.h
HEADERS = $(SRC_CLNT:.cpp=.h) commonFiles/sls_detector_defs.h slsDetectorAnalysis/detectorData.h slsDetector/slsDetectorBase.h slsDetector/slsDetectorUsers.h

View File

@ -311,6 +311,10 @@ void exitServer(int socketDescriptor) {
if (total_received>0)
strcpy(thisClientIP,dummyClientIP);
if (strcmp(lastClientIP,"none")==0)
strcpy(lastClientIP,thisClientIP);
if (strcmp(lastClientIP,thisClientIP))
differentClients=1;
else
@ -347,7 +351,9 @@ int sendChip(int file_des, sls_detector_chip *myChip) {
int sendModule(int file_des, sls_detector_module *myMod) {
int ts=0;
//int idac;
#ifdef VERBOSE
int idac;
#endif
int nChips=myMod->nchip;
int nChans=myMod->nchan;
int nAdcs=myMod->nadc;

View File

@ -6,6 +6,7 @@
*/
enum {
// General purpose functions

View File

@ -1872,30 +1872,30 @@ int getModuleNumber(int modnum) {
int testShiftIn(int imod) {
int val,i,j, k, result=OK;
setCSregister(ALLMOD);
setCSregister(imod);
printf("testing shift in for module %d\n", imod);
//for (j=0; j<10; j++) {
//selChip(j);
for (i=0; i<34; i++) {
if (i%2) {
putout("0100000000000000",ALLMOD);
putout("0100000000000000",ALLMOD);
putout("0110000000000000",ALLMOD);
putout("0110000000000000",ALLMOD);
putout("0100000000000000",ALLMOD);
putout("0100000000000000",ALLMOD);
putout("0100000000000000",imod);
putout("0100000000000000",imod);
putout("0110000000000000",imod);
putout("0110000000000000",imod);
putout("0100000000000000",imod);
putout("0100000000000000",imod);
} else {
putout("0000000000000000",ALLMOD);
putout("0000000000000000",ALLMOD);
putout("0010000000000000",ALLMOD);
putout("0010000000000000",ALLMOD);
putout("0000000000000000",ALLMOD);
putout("0000000000000000",ALLMOD);
putout("0000000000000000",imod);
putout("0000000000000000",imod);
putout("0010000000000000",imod);
putout("0010000000000000",imod);
putout("0000000000000000",imod);
putout("0000000000000000",imod);
}
}
putout("0000000000000000",ALLMOD);
putout("0000000000000000",imod);
for (i=0; i<34; i++) {
putout("0000000000000000",ALLMOD);
putout("0000000000000000",imod);
k=imod;
//for (k=0; k<nModX; k++) {
@ -1912,12 +1912,12 @@ int testShiftIn(int imod) {
}
}
//}
putout("0010000000000000",ALLMOD);
putout("0010000000000000",ALLMOD);
putout("0000000000000000",ALLMOD);
putout("0010000000000000",imod);
putout("0010000000000000",imod);
putout("0000000000000000",imod);
}
putout("0000000000000000", ALLMOD);
putout("0000000000000000", imod);
printf("Shift in module %d : %d errors\n", imod,result);
if (result)
return 1;
@ -1932,25 +1932,25 @@ int testShiftOut(int imod) {
printf("testing shift out for module %d\n", imod);
setCSregister(ALLMOD);
setCSregister(imod);
for (i=0; i<24; i++) {
if (dum & 1<<i) {
putout("0100010000000000",ALLMOD);
putout("0110010000000000",ALLMOD);
putout("0110010000000000",ALLMOD);
putout("0100010000000000",ALLMOD);
putout("0100010000000000",imod);
putout("0110010000000000",imod);
putout("0110010000000000",imod);
putout("0100010000000000",imod);
} else {
putout("0000010000000000",ALLMOD);
putout("0010010000000000",ALLMOD);
putout("0010010000000000",ALLMOD);
putout("0000010000000000",ALLMOD);
putout("0000010000000000",imod);
putout("0010010000000000",imod);
putout("0010010000000000",imod);
putout("0000010000000000",imod);
}
}
putout("0000000100000000",ALLMOD);
putout("0000000100000000",imod);
for (i=0; i<24; i++) {
putout("0000010000000000",ALLMOD);
putout("0000010000000000",ALLMOD);
putout("0000010000000000",imod);
putout("0000010000000000",imod);
k=imod;
@ -1969,9 +1969,9 @@ int testShiftOut(int imod) {
}
}
//}
putout("0010010000000000",ALLMOD);
putout("0010010000000000",imod);
}
putout("0000000000000000", ALLMOD);
putout("0000000000000000", imod);
printf("Shift out module %d : %d errors\n", imod,result);
if (result)
return 1;
@ -1983,21 +1983,21 @@ int testShiftStSel(int imod) {
int result=OK;
int val,i,j,k;
printf("testing shift stsel for module %d\n", imod);
setCSregister(ALLMOD);
setCSregister(imod);
for (i=0; i<NCHAN; i++) {
if (i%2) {
putout("0100011000000000",ALLMOD);
putout("0110011000000000",ALLMOD);
putout("0100011000000000",ALLMOD);
putout("0100011000000000",imod);
putout("0110011000000000",imod);
putout("0100011000000000",imod);
} else {
putout("0000011000000000",ALLMOD);
putout("0010011000000000",ALLMOD);
putout("0000011000000000",ALLMOD);
putout("0000011000000000",imod);
putout("0010011000000000",imod);
putout("0000011000000000",imod);
}
}
putout("0010011000000000",ALLMOD);
putout("0010011000000000",imod);
for (i=0; i<NCHAN; i++) {
putout("0000011000000000",ALLMOD);
putout("0000011000000000",imod);
k=imod;
@ -2019,9 +2019,9 @@ int testShiftStSel(int imod) {
putout("0010011000000000",ALLMOD);
putout("0010011000000000",imod);
}
putout("0000011000000000",ALLMOD);
putout("0000011000000000",imod);
printf("Shift stsel module %d : %d errors\n", imod,result);
if (result)
return 1;
@ -2035,16 +2035,16 @@ int testShiftStSel(int imod) {
int testDataInOut(int num, int imod) {
int val[NCHIP*nModX], result=OK;
int ich, ichip;
setCSregister(ALLMOD);
setCSregister(imod);
printf("Testing data in out for module %d pattern 0x%x\n", imod, num);
setSSregister(ALLMOD);
initChannel(0,0,0,0,0,num,ALLMOD);
putout("0000000000000000",ALLMOD);
setCSregister(ALLMOD);
initChip(0, 0,ALLMOD);
clearSSregister(ALLMOD);
setSSregister(imod);
initChannel(0,0,0,0,0,num,imod);
putout("0000000000000000",imod);
setCSregister(imod);
initChip(0, 0,imod);
clearSSregister(imod);
for (ich=0; ich<NCHAN; ich++) {
nextStrip(ALLMOD);
nextStrip(imod);
readOutChan(val);
//imod=0;
//for (imod=0; imod<nModX; imod++) {
@ -2071,20 +2071,20 @@ int testExtPulse(int imod) {
printf("Testing counter for module %d\n", imod);
setCSregister(ALLMOD);
setSSregister(ALLMOD);
counterClear(ALLMOD);
putout("0000000000000000",ALLMOD);
putout("0000100000000000",ALLMOD);
putout("0000000000000000",ALLMOD);
setCSregister(imod);
setSSregister(imod);
counterClear(imod);
putout("0000000000000000",imod);
putout("0000100000000000",imod);
putout("0000000000000000",imod);
for (i=0; i<NCHAN; i++) {
putout("0000000000000000",ALLMOD);
putout("0000000000001000",ALLMOD);
putout("0000000000000000",ALLMOD);
extPulse(1,ALLMOD);
putout("0000000000000000",imod);
putout("0000000000001000",imod);
putout("0000000000000000",imod);
extPulse(1,imod);
}
clearSSregister(ALLMOD);
putout("0000000000000000",ALLMOD);
clearSSregister(imod);
putout("0000000000000000",imod);
// Readout with SM
@ -2141,13 +2141,13 @@ int testExtPulseMux(int imod, int ow) {
setSSregister(ALLMOD);
counterClear(ALLMOD);
initChipWithProbes(0, ow,0,ALLMOD);
// initChip(0, ow,ALLMOD);
// initChip(0, ow,imod);
for (ichip=0; ichip<NCHIP; ichip++) {
setSSregister(ALLMOD);
setSSregister(imod);
for (i=0; i<NCHAN; i++) {
putout("0000000000000000",ALLMOD);
putout("0000000000001000",ALLMOD);
putout("0000000000000000",ALLMOD);
putout("0000000000000000",imod);
putout("0000000000001000",imod);
putout("0000000000000000",imod);
extPulse(1,ALLMOD);
}
nextChip(ALLMOD);
@ -2224,8 +2224,8 @@ int testDataInOutMux(int imod, int ow, int num) {
//printf("Testin data in out\n");
setSSregister(ALLMOD);
counterClear(ALLMOD);
initChannel(0,0,0,0,0,num,ALLMOD);
putout("0000000000000000",ALLMOD);
initChannel(0,0,0,0,0,num,imod);
putout("0000000000000000",imod);
clearSSregister(ALLMOD);
initChipWithProbes(0, ow,0,ALLMOD);
clearSSregister(ALLMOD);
@ -2275,42 +2275,42 @@ int testOutMux(int imod) {
int result=OK;
long pat=0xf0f0f0;
printf("testing outmux for module %d\n", imod);
setCSregister(ALLMOD);
setCSregister(imod);
// Clear outshift reg
putout("0000010000000000",ALLMOD);
putout("0000010000000000",imod);
for (ibit=0; ibit<10;ibit++)
putout("0000110000000000",ALLMOD);
putout("0000010000000000",ALLMOD);
putout("0000110000000000",imod);
putout("0000010000000000",imod);
// Clear inshift reg
putout("0000000000000000",ALLMOD);
putout("0000000000000000",imod);
for (ibit=0; ibit<10;ibit++)
putout("0000100000000000",ALLMOD);
putout("0000000000000000",ALLMOD);
putout("0000100000000000",imod);
putout("0000000000000000",imod);
// input pattern 0f0f0f
for (ibit=0; ibit<24;ibit++) {
if (pat & (1 << ibit)) {
putout("0100010000000000",ALLMOD);
putout("0110010000000000",ALLMOD); //write in the data 1
putout("0100010000000000",ALLMOD);
putout("0100010000000000",imod);
putout("0110010000000000",imod); //write in the data 1
putout("0100010000000000",imod);
} else {
putout("0000010000000000",ALLMOD);
putout("0010010000000000",ALLMOD); //write in the data 0
putout("0000010000000000",ALLMOD);
putout("0000010000000000",imod);
putout("0010010000000000",imod); //write in the data 0
putout("0000010000000000",imod);
}
}
putout("0100000000000000",ALLMOD);
putout("0110000000000000",ALLMOD); //shift in 1
putout("0100000000000000",ALLMOD);
putout("0100000000000000",imod);
putout("0110000000000000",imod); //shift in 1
putout("0100000000000000",imod);
for (ibit=0; ibit<20;ibit++) {
putout("0000000000000000",ALLMOD);
putout("0010000000000000",ALLMOD); //shift in 20 bits
putout("0000000000000000",ALLMOD);
putout("0000000000000000",imod);
putout("0010000000000000",imod); //shift in 20 bits
putout("0000000000000000",imod);
}
// check pattern, with different oumux settings
@ -2326,9 +2326,9 @@ int testOutMux(int imod) {
putout("0000010001000000",ALLMOD);
putout("0000010001000000",ALLMOD); //output is out0
putout("0000010001000000",ALLMOD);
putout("0000010001000000",imod);
putout("0000010001000000",imod); //output is out0
putout("0000010001000000",imod);
i=0;
k=imod;
@ -2354,9 +2354,9 @@ int testOutMux(int imod) {
}
}
//}
putout("0000010001100000",ALLMOD);
putout("0000010001100000",ALLMOD); //output is out1
putout("0000010001100000",ALLMOD);
putout("0000010001100000",imod);
putout("0000010001100000",imod); //output is out1
putout("0000010001100000",imod);
i++;
k=imod;
@ -2386,9 +2386,9 @@ int testOutMux(int imod) {
putout("0000010001010000",ALLMOD);
putout("0000010001010000",ALLMOD); //output is out2
putout("0000010001010000",ALLMOD);
putout("0000010001010000",imod);
putout("0000010001010000",imod); //output is out2
putout("0000010001010000",imod);
i++;
@ -2416,9 +2416,9 @@ int testOutMux(int imod) {
}
//}
putout("0000010001110000",ALLMOD);
putout("0000010001110000",ALLMOD); //output is out3
putout("0000010001110000",ALLMOD);
putout("0000010001110000",imod);
putout("0000010001110000",imod); //output is out3
putout("0000010001110000",imod);
i++;
k=imod;
//for (k=0; k<nModX; k++) {
@ -2444,9 +2444,9 @@ int testOutMux(int imod) {
}
//}
putout("0000000000000000",ALLMOD);
putout("0010000000000000",ALLMOD); //change mux setting
putout("0000000000000000",ALLMOD);
putout("0000000000000000",imod);
putout("0010000000000000",imod); //change mux setting
putout("0000000000000000",imod);
}
printf("Test OutMux module %d : %d errors\n", imod,result);
@ -2468,40 +2468,40 @@ int testFpgaMux(int imod) {
printf("testing fpga mux of module %d\n",imod);
// Clear outshift reg
putout("0000010000000000",ALLMOD);
putout("0000010000000000",imod);
for (ibit=0; ibit<10;ibit++)
putout("0000110000000000",ALLMOD);
putout("0000010000000000",ALLMOD);
putout("0000110000000000",imod);
putout("0000010000000000",imod);
// Clear inshift reg
putout("0000000000000000",ALLMOD);
putout("0000000000000000",imod);
for (ibit=0; ibit<10;ibit++)
putout("0000100000000000",ALLMOD);
putout("0000000000000000",ALLMOD);
putout("0000100000000000",imod);
putout("0000000000000000",imod);
// input pattern 0f0f0f
for (ibit=0; ibit<24;ibit++) {
if (pat & (1 << ibit)) {
putout("0100010000000000",ALLMOD);
putout("0110010000000000",ALLMOD); //write in the data 1
putout("0100010000000000",ALLMOD);
putout("0100010000000000",imod);
putout("0110010000000000",imod); //write in the data 1
putout("0100010000000000",imod);
} else {
putout("0000010000000000",ALLMOD);
putout("0010010000000000",ALLMOD); //write in the data 0
putout("0000010000000000",ALLMOD);
putout("0000010000000000",imod);
putout("0010010000000000",imod); //write in the data 0
putout("0000010000000000",imod);
}
}
putout("0100000000000000",ALLMOD);
putout("0110000000000000",ALLMOD); //shift in 1
putout("0100000000000000",ALLMOD);
putout("0100000000000000",imod);
putout("0110000000000000",imod); //shift in 1
putout("0100000000000000",imod);
for (ibit=0; ibit<20;ibit++) {
putout("0000000000000000",ALLMOD);
putout("0010000000000000",ALLMOD); //shift in 20 bits
putout("0000000000000000",ALLMOD);
putout("0000000000000000",imod);
putout("0010000000000000",imod); //shift in 20 bits
putout("0000000000000000",imod);
}
// check pattern, with different oumux settings
@ -2519,10 +2519,10 @@ int testFpgaMux(int imod) {
//This should test the parallel to serial converter
putout("0000010000000000",ALLMOD) ;
putout("0000010100000000",ALLMOD) ; // reset readout
putout("0000010100000000",ALLMOD) ;
putout("0000010000000000",ALLMOD) ;
putout("0000010000000000",imod) ;
putout("0000010100000000",imod) ; // reset readout
putout("0000010100000000",imod) ;
putout("0000010000000000",imod) ;
#ifdef DEBUGOUT
@ -2555,17 +2555,17 @@ int testFpgaMux(int imod) {
}
}
//}
putout("0000010000000000",ALLMOD);
putout("0010010000000000",ALLMOD); //output
putout("0000010000000000",ALLMOD );
putout("0000010000000000",imod);
putout("0010010000000000",imod); //output
putout("0000010000000000",imod );
}
pat = pat >> 1;
putout("0000000000000000",ALLMOD);
putout("0010000000000000",ALLMOD); //change mux setting
putout("0000000000000000",ALLMOD);
putout("0000000000000000",imod);
putout("0010000000000000",imod); //change mux setting
putout("0000000000000000",imod);
}
printf("Test FpgaMux module %d : %d errors\n", imod,result);
@ -2664,13 +2664,13 @@ int calibration_chip(int num, int *v, int *dacs) {
}
}
//setMSregister();
setCSregister(ALLMOD);
clearSSregister(ALLMOD);
countEnable(ALLMOD);
setCSregister(imod);
clearSSregister(imod);
countEnable(imod);
usleep(20);
calPulse(num,ALLMOD); // give pulses//
calPulse(num,imod); // give pulses//
usleep(20);
selChannel(ich,ALLMOD); // select channel
selChannel(ich,imod); // select channel
readOutChan(val); // readout channel
for (imod=0; imod<nModX; imod++) {
//selMod(imod);

View File

@ -36,21 +36,24 @@ int main(int argc, char *argv[])
b=0;
printf("opening stop server on port %d\n",portno);
}
init_detector(b);
sd=bindSocket(portno);
init_detector(b); //defined in server_funcs
sd=bindSocket(portno); //defined in communication_funcs
sockfd=sd;
if (getServerError(sd)) {
if (getServerError(sd)) { //defined in communication_funcs
printf("server error!\n");
return -1;
}
/* assign function table */
function_table();
function_table(); //defined in server_funcs
#ifdef VERBOSE
printf("function table assigned \n");
#endif
@ -64,23 +67,23 @@ int main(int argc, char *argv[])
#ifdef VERY_VERBOSE
printf("Waiting for client call\n");
#endif
fd=acceptConnection(sockfd);
fd=acceptConnection(sockfd); //defined in communication_funcs
#ifdef VERY_VERBOSE
printf("Conenction accepted\n");
#endif
if (fd>0) {
retval=decode_function(fd);
//#ifdef VERY_VERBOSE
retval=decode_function(fd); //defined in server_funcs
#ifdef VERY_VERBOSE
printf("function executed\n");
//#endif
closeConnection(fd);
#endif
closeConnection(fd); //defined in communication_funcs
#ifdef VERY_VERBOSE
printf("connection closed\n");
#endif
}
}
exitServer(sockfd);
exitServer(sockfd); //defined in communication_funcs
printf("Goodbye!\n");
return 0;

View File

@ -38,5 +38,5 @@
#define CLK_FREQ 100E+6
#define THIS_SOFTWARE_VERSION 0x20111125
#define THIS_SOFTWARE_VERSION 0x20120419
#endif

View File

@ -2426,9 +2426,12 @@ int execute_trimming(int file_des) {
int imod, par1,par2;
enum trimMode mode;
printf("called function execute trimming\n");
sprintf(mess,"can't set execute trimming\n");
n = receiveDataOnly(file_des,&mode,sizeof(mode));
printf("mode received\n");
if (n < 0) {
sprintf(mess,"Error reading from socket\n");
printf("Error reading from socket (mode)\n");
@ -2436,6 +2439,7 @@ int execute_trimming(int file_des) {
}
n = receiveDataOnly(file_des,arg,sizeof(arg));
printf("arg received\n");
if (n < 0) {
sprintf(mess,"Error reading from socket\n");
printf("Error reading from socket (args)\n");
@ -2524,9 +2528,10 @@ int lock_server(int file_des) {
ret=FAIL;
}
if (lock>=0) {
if (lockStatus==0 || strcmp(lastClientIP,thisClientIP)==0 || strcmp(lastClientIP,"none")==0)
if (lockStatus==0 || strcmp(lastClientIP,thisClientIP)==0 || strcmp(lastClientIP,"none")==0) {
lockStatus=lock;
else {
} else {
ret=FAIL;
sprintf(mess,"Server already locked by %s\n", lastClientIP);
}

View File

@ -3880,10 +3880,13 @@ int slsDetector::executeTrimming(trimMode mode, int par1, int par2, int imod){
if (controlSocket) {
if (controlSocket->Connect()>=0) {
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
#ifdef VERBOSE
#ifndef VERBOSE
controlSocket->SendDataOnly(&mode,sizeof(mode));
#else
std::cout<< "sending mode bytes= "<< controlSocket->SendDataOnly(&mode,sizeof(mode)) << std::endl;
#endif
controlSocket->SendDataOnly(arg,sizeof(arg));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL) {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));

View File

@ -7,6 +7,7 @@
#include "slsDetectorUtils.h"
#include "energyConversion.h"
#include "MySocketTCP.h"

View File

@ -429,7 +429,7 @@ int slsDetectorActions::executeScan(int level, int istep) {
break;
default:
//Custom scan script level 1. The arguments are passed as nrun=n fn=filename var=v par=p"
sprintf(cmd,"%s nrun=%d fn=%s var=%f par=%s",getScanScript(level).c_str(),*fileIndex,createFileName().c_str(),currentScanVariable[level],getScanParameter(level).c_str());
sprintf(cmd,"%s nrun=%d fn=%s var=%f par=%s",getScanScript(level).c_str(),getFileIndex(),createFileName().c_str(),currentScanVariable[level],getScanParameter(level).c_str());
#ifdef VERBOSE
cout << "Executing scan script "<< level << " " << cmd << endl;
#endif
@ -448,15 +448,15 @@ int slsDetectorActions::executeAction(int level) {
switch (level) {
case startScript:
case stopScript:
sprintf(cmd,"%s nrun=%d par=%s",getActionScript(level).c_str(),*fileIndex,getActionParameter(level).c_str());
sprintf(cmd,"%s nrun=%d par=%s",getActionScript(level).c_str(),getFileIndex(),getActionParameter(level).c_str());
break;
case scriptBefore:
case scriptAfter:
sprintf(cmd,"%s nrun=%d fn=%s par=%s sv0=%f sv1=%f p0=%s p1=%s",getActionScript(level).c_str(),*fileIndex,currentFileName.c_str(),getActionParameter(level).c_str(),currentScanVariable[0],currentScanVariable[1],getScanParameter(0).c_str(),getScanParameter(1).c_str());
sprintf(cmd,"%s nrun=%d fn=%s par=%s sv0=%f sv1=%f p0=%s p1=%s",getActionScript(level).c_str(),getFileIndex(),getCurrentFileName().c_str(),getActionParameter(level).c_str(),currentScanVariable[0],currentScanVariable[1],getScanParameter(0).c_str(),getScanParameter(1).c_str());
break;
case headerBefore:
fName=currentFileName;
nowIndex=getFileIndexFromFileName(currentFileName);
fName=getCurrentFileName();
nowIndex=getFileIndexFromFileName(getCurrentFileName());
case headerAfter:
// sprintf(cmd,"%s nrun=%d fn=%s acqtime=%f gainmode=%d threshold=%d badfile=%s angfile=%s bloffset=%f fineoffset=%f fffile=%s/%s tau=%f par=%s", \
// getActionScript(level).c_str(), \

View File

@ -3,7 +3,7 @@
#include "postProcessing.h"
#include "slsDetectorBase.h"
#include <string>
#include <fstream>
@ -20,7 +20,9 @@ using namespace std;
*/
class slsDetectorActions : public postProcessing {
class slsDetectorActions : public virtual slsDetectorBase
// : public virtual postProcessing
{
public :
/** default constructor */
slsDetectorActions(){};

View File

@ -47,6 +47,7 @@ Most methods of interest for the user are implemented in the ::slsDetectorBase i
*/
//#include "slsDetectorUsers.h"
#include "sls_detector_defs.h"
#include <string>
@ -55,17 +56,15 @@ Most methods of interest for the user are implemented in the ::slsDetectorBase i
using namespace std;
/**
@libdoc The slsDetectorBase class is a minimal purely virtual interface class which should be instantiated by the users in their acquisition software (EPICS, spec etc.). More advanced configuration functions are not implemented and can be written in a configuration file tha can be read/written.
@libdoc The slsDetectorBase contains also a set of purely virtual functions useful for the implementation of the derived classes
This class contains the functions accessible by the users to control the slsDetectors (both multiSlsDetector and slsDetector)
* @short This is the base class for detector functionalities of interest for the users.
* @short This is the base class for all detector functionalities
*/
class slsDetectorBase : public slsDetectorDefs
//public virtual slsDetectorUsers,
class slsDetectorBase : public virtual slsDetectorDefs
{
public:
@ -77,146 +76,183 @@ class slsDetectorBase : public slsDetectorDefs
/** virtual destructor */
virtual ~slsDetectorBase(){};
/** sets the onlineFlag
\param online can be: <BR> GET_ONLINE_FLAG, returns wether the detector is in online or offline state;<BR> OFFLINE_FLAG, detector in offline state (i.e. no communication to the detector - using only local structure - no data acquisition possible!);<BR> ONLINE_FLAG detector in online state (i.e. communication to the detector updating the local structure)
\returns ONLINE_FLAG or OFFLINE_FLAG
*/
virtual int setOnline(int const online=GET_ONLINE_FLAG)=0;
/** performs a complete acquisition including scansand data processing
moves the detector to next position <br>
starts and reads the detector <br>
reads the IC (if required) <br>
reads the encoder (iof required for angualr conversion) <br>
processes the data (flat field, rate, angular conversion and merging ::processData())
\param delflag 0 leaves the data in the final data queue (default is 1)
\returns nothing
*/
virtual void acquire(int delflag=1)=0;
// protected:
/**
asks and receives a data frame from the detector, writes it to disk and processes the data
\returns pointer to the data or NULL (unused!!!).
set angular conversion
\param fname file with angular conversion constants ("" disable)
\returns 0 if angular conversion disabled, >0 otherwise
*/
virtual int* readFrame()=0;
/* /\** processes the data */
/* \param delflag 0 leaves the data in the final data queue */
/* \returns nothing */
/* *\/ */
/* virtual void* processData(int delflag)=0; */
/**
start detector acquisition
\returns OK/FAIL
*/
virtual int startAcquisition()=0;
/**
stop detector acquisition
\returns OK/FAIL
*/
virtual int stopAcquisition()=0;
/**
get run status
\returns status mask
*/
virtual runStatus getRunStatus()=0;
/* /\** Frees the shared memory - should not be used except for debugging*\/ */
/* virtual int freeSharedMemory()=0; */
/* /\** adds the detector with ID id in postion pos */
/* \param id of the detector to be added (should already exist!) */
/* \param pos position where it should be added (normally at the end of the list (default to -1) */
/* \returns the actual number of detectors or -1 if it failed (always for slsDetector) */
/* *\/ */
/* virtual int addSlsDetector(int id, int pos=-1){return -1;}; */
/* /\** adds the detector name in position pos */
/* \param name of the detector to be added (should already exist in shared memory or at least be online) */
/* \param pos position where it should be added (normally at the end of the list (default to -1) */
/* \return the actual number of detectors or -1 if it failed (always for slsDetector) */
/* *\/ */
/* virtual int addSlsDetector(char* name, int pos=-1){return -1;}; */
/* /\** */
/* removes the detector in position pos from the multidetector */
/* \param pos position of the detector to be removed from the multidetector system (defaults to -1 i.e. last detector) */
/* \returns the actual number of detectors or -1 if it failed (always for slsDetector) */
/* *\/ */
/* virtual int removeSlsDetector(int pos=-1){return -1;}; */
/* /\**removes the detector in position pos from the multidetector */
/* \param name is the name of the detector */
/* \returns the actual number of detectors or -1 if it failed (always for slsDetector) */
/* *\/ */
/* virtual int removeSlsDetector(char* name){return -1;}; */
virtual int setAngularConversionFile(string fname="")=0;
/**
returns the default output files path
pure virtual function
returns the angular conversion file
*/
virtual string getFilePath()=0;
virtual string getAngularConversionFile()=0;
/**
sets the default output files path
\param s file path
\returns file path
set action
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
\param fname for script ("" disable)
\returns 0 if action disabled, >0 otherwise
*/
virtual string setFilePath(string s)=0;
virtual int setActionScript(int iaction, string fname="")=0;
/**
returns the default output files root name
set action
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
\param par for script ("" disable)
\returns 0 if action disabled, >0 otherwise
*/
virtual string getFileName()=0;
virtual int setActionParameter(int iaction, string par="")=0;
/**
sets the default output files path
returns action script
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
\returns action script
*/
virtual string setFileName(string s)=0;
virtual string getActionScript(int iaction)=0;
/**
returns the default output file index
returns action parameter
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
\returns action parameter
*/
virtual string getActionParameter(int iaction)=0;
/**
set scan script
\param index is the scan index (0 or 1)
\param script fname for script ("" disable, "none" disables and overwrites current, "threshold" makes threshold scan, "trimbits" make trimbits scan, "energy" makes energy scan)
\returns 0 if scan disabled, >0 otherwise
*/
virtual int getFileIndex()=0;
virtual int setScanScript(int index, string script="")=0;
/**
set scan script parameter
\param index is the scan index (0 or 1)
\param spar parameter to be passed to the scan script with syntax par=spar
\returns 0 if scan disabled, >0 otherwise
*/
virtual int setScanParameter(int index, string spar="")=0;
/** set scan precision
\param index is the scan index (0 or 1)
\param precision number of decimals to use for the scan variable in the file name
\returns 0 if scan disabled, >0 otherwise */
virtual int setScanPrecision(int index, int precision=-1)=0;
/**
sets the default output file index
set scan steps (passed to the scan script as var=step)
\param index is the scan index (0 or 1)
\param nvalues is the number of steps
\param values array of steps
\returns 0 if scan disabled, >0 otherwise*/
virtual int setScanSteps(int index, int nvalues=-1, float *values=NULL)=0;
/**
get scan script
\param index is the scan index (0 or 1)
\returns "none" if disables, "threshold" threshold scan, "trimbits" trimbits scan, "energy" energy scan or scan script name
*/
virtual int setFileIndex(int i)=0;
virtual string getScanScript(int index)=0;
/**
get scan script
\param index is the scan index (0 or 1)
\returns scan script parameter
*/
virtual string getScanParameter(int index)=0;
/**
get scan precision
\param index is the scan index (0 or 1)
\returns precision i.e. number of decimals to use for the scan variable in the file name
*/
virtual int getScanPrecision(int index)=0;
/**
get scan steps
\param index is the scan index (0 or 1)
\param values pointer to array of values (must be allocated in advance)
\returns number of steps
*/
virtual int getScanSteps(int index, float *values=NULL)=0;
/**
get flat field corrections file directory
\returns flat field correction file directory
Writes the configuration file -- will contain all the informations needed for the configuration (e.g. for a PSI detector caldir, settingsdir, angconv, badchannels etc.)
\param fname file name
\returns OK or FAIL
*/
virtual string getFlatFieldCorrectionDir()=0;
virtual int writeConfigurationFile(string const fname)=0;
/**
Loads dark image or gain image to the detector
\param index can be DARK_IMAGE or GAIN_IMAGE
\param fname file name to load data from
\returns OK or FAIL
*/
virtual int loadImageToDetector(imageType index,string const fname)=0;
/**
set flat field corrections file directory
\param dir flat field correction file directory
\returns flat field correction file directory
*/
virtual string setFlatFieldCorrectionDir(string dir)=0;
\returns number of positions
*/
virtual int getNumberOfPositions()=0;// {return 0;};
/**
get flat field corrections file name
\returns flat field correction file name
*/
virtual string getFlatFieldCorrectionFile()=0;
/**
\returns action mask
*/
virtual int getActionMask()=0;// {return 0;};
/**
\param index scan level index
\returns current scan variable
*/
virtual float getCurrentScanVariable(int index)=0;// {return 0;};
/**
set flat field corrections
\param fname name of the flat field file (or "" if disable)
\returns 0 if disable (or file could not be read), >0 otherwise
*/
virtual int setFlatFieldCorrection(string fname="")=0;
/**
\returns current position index
*/
virtual int getCurrentPositionIndex()=0;// {return 0;};
/**
\returns total number of channels
*/
virtual int getTotalNumberOfChannels()=0;
/** generates file name without extension */
virtual string createFileName()=0;
virtual void incrementProgress()=0;
virtual float getCurrentProgress()=0;
virtual void incrementFileIndex()=0;
virtual int setTotalProgress()=0;
virtual float* decodeData(int *datain, float *fdata=NULL)=0;
virtual string getCurrentFileName()=0;
virtual int getFileIndexFromFileName(string fname)=0;
virtual float *convertAngles()=0;
/**
set rate correction
\param t dead time in ns - if 0 disable correction, if >0 set dead time to t, if <0 set deadtime to default dead time for current settings
@ -237,147 +273,16 @@ class slsDetectorBase : public slsDetectorDefs
*/
virtual int getRateCorrection()=0;
/* /\** */
/* returns the bad channel list file */
/* *\/ */
/* virtual string getBadChannelCorrectionFile()=0; */
virtual int setFlatFieldCorrection(string fname="")=0;
virtual int enableBadChannelCorrection(int i=-1)=0;
virtual int enableAngularConversion(int i=-1)=0;
/* /\** */
/* set angular conversion */
/* \param fname file with angular conversion constants ("" disable) */
/* \returns 0 if angular conversion disabled, >0 otherwise */
/* *\/ */
/* virtual int setAngularConversionFile(string fname="")=0; */
/* /\** */
/* pure virtual function */
/* returns the angular conversion file */
/* *\/ */
/* virtual string getAngularConversionFile()=0; */
/**
set positions for the acquisition
\param nPos number of positions
\param pos array with the encoder positions
\returns number of positions
/**
set/get dynamic range
\param i dynamic range (-1 get)
\returns current dynamic range
*/
virtual int setPositions(int nPos, float *pos)=0;
/**
get positions for the acquisition
\param pos array which will contain the encoder positions
\returns number of positions
*/
virtual int getPositions(float *pos=NULL)=0;
/* /\** */
/* set action */
/* \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS} */
/* \param fname for script ("" disable) */
/* \returns 0 if action disabled, >0 otherwise */
/* *\/ */
/* virtual int setActionScript(int iaction, string fname="")=0; */
/* /\** */
/* set action */
/* \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS} */
/* \param par for script ("" disable) */
/* \returns 0 if action disabled, >0 otherwise */
/* *\/ */
/* virtual int setActionParameter(int iaction, string par="")=0; */
/* /\** */
/* returns action script */
/* \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} */
/* \returns action script */
/* *\/ */
/* virtual string getActionScript(int iaction)=0; */
/* /\** */
/* returns action parameter */
/* \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} */
/* \returns action parameter */
/* *\/ */
/* virtual string getActionParameter(int iaction)=0; */
/* /\** */
/* set scan script */
/* \param index is the scan index (0 or 1) */
/* \param script fname for script ("" disable, "none" disables and overwrites current, "threshold" makes threshold scan, "trimbits" make trimbits scan, "energy" makes energy scan) */
/* \returns 0 if scan disabled, >0 otherwise */
/* *\/ */
/* virtual int setScanScript(int index, string script="")=0; */
/* /\** */
/* set scan script parameter */
/* \param index is the scan index (0 or 1) */
/* \param spar parameter to be passed to the scan script with syntax par=spar */
/* \returns 0 if scan disabled, >0 otherwise */
/* *\/ */
/* virtual int setScanParameter(int index, string spar="")=0; */
/* /\** */
/* set scan precision */
/* \param index is the scan index (0 or 1) */
/* \param precision number of decimals to use for the scan variable in the file name */
/* \returns 0 if scan disabled, >0 otherwise */
/* *\/ */
/* virtual int setScanPrecision(int index, int precision=-1)=0; */
/* /\** */
/* set scan steps (passed to the scan script as var=step) */
/* \param index is the scan index (0 or 1) */
/* \param nvalues is the number of steps */
/* \param values array of steps */
/* \returns 0 if scan disabled, >0 otherwise */
/* *\/ */
/* virtual int setScanSteps(int index, int nvalues=-1, float *values=NULL)=0; */
/* /\** */
/* get scan script */
/* \param index is the scan index (0 or 1) */
/* \returns "none" if disables, "threshold" threshold scan, "trimbits" trimbits scan, "energy" energy scan or scan script name */
/* *\/ */
/* virtual string getScanScript(int index)=0; */
/* /\** */
/* get scan script */
/* \param index is the scan index (0 or 1) */
/* \returns scan script parameter */
/* *\/ */
/* virtual string getScanParameter(int index)=0; */
/* /\** */
/* get scan precision */
/* \param index is the scan index (0 or 1) */
/* \returns precision i.e. number of decimals to use for the scan variable in the file name */
/* *\/ */
/* virtual int getScanPrecision(int index)=0; */
/* /\** */
/* get scan steps */
/* \param index is the scan index (0 or 1) */
/* \param values pointer to array of values (must be allocated in advance) */
/* \returns number of steps */
/* *\/ */
/* virtual int getScanSteps(int index, float *values=NULL)=0; */
/** Locks/Unlocks the connection to the server
/param lock sets (1), usets (0), gets (-1) the lock
/returns lock status of the server
*/
virtual int lockServer(int i=-1)=0;
virtual int setDynamicRange(int i=-1)=0;
/**
@ -390,48 +295,44 @@ class slsDetectorBase : public slsDetectorDefs
/**
set/get dynamic range
\param i dynamic range (-1 get)
\returns current dynamic range
/** Locks/Unlocks the connection to the server
/param lock sets (1), usets (0), gets (-1) the lock
/returns lock status of the server
*/
virtual int setDynamicRange(int i=-1)=0;
virtual int lockServer(int i=-1)=0;
/**
get detector settings
\param imod module number (-1 all)
\returns current settings
/** performs a complete acquisition including scansand data processing
moves the detector to next position <br>
starts and reads the detector <br>
reads the IC (if required) <br>
reads the encoder (iof required for angualr conversion) <br>
processes the data (flat field, rate, angular conversion and merging ::processData())
\param delflag 0 leaves the data in the final data queue (default is 1)
\returns nothing
*/
virtual detectorSettings getSettings(int imod=-1)=0;
/**
set detector settings
\param isettings settings
\param imod module number (-1 all)
\returns current settings
in this function trimbits/settings and calibration files are searched in the settingsDir and calDir directories and the detector is initialized
*/
virtual detectorSettings setSettings(detectorSettings isettings, int imod=-1)=0;
/**
get threshold energy
\param imod module number (-1 all)
\returns current threshold value for imod in ev (-1 failed)
*/
virtual int getThresholdEnergy(int imod=-1)=0;
virtual void acquire(int delflag=1)=0;
/**
set threshold energy
\param e_eV threshold in eV
\param imod module number (-1 all)
\param isettings ev. change settings
\returns current threshold value for imod in ev (-1 failed)
asks and receives a data frame from the detector, writes it to disk and processes the data
\returns pointer to the data or NULL (unused!!!).
*/
virtual int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS)=0;
virtual int* readFrame()=0;
/**
start detector acquisition
\returns OK/FAIL
*/
virtual int startAcquisition()=0;
/**
stop detector acquisition
\returns OK/FAIL
*/
virtual int stopAcquisition()=0;
/**
@ -442,10 +343,40 @@ class slsDetectorBase : public slsDetectorDefs
*/
virtual int64_t setTimer(timerIndex index, int64_t t=-1)=0;
///////////////////////////////////////////////////////////////////////////////////////////
/**
@short get run status
\returns status mask
*/
virtual runStatus getRunStatus()=0;
/**
/** @short sets the onlineFlag
\param online can be: -1 returns wether the detector is in online (1) or offline (0) state; 0 detector in offline state; 1 detector in online state
\returns 0 (offline) or 1 (online)
*/
virtual int setOnline(int const online=-1)=0;
/**
@short set detector settings
\param isettings settings index (-1 gets)
\returns current settings
*/
virtual detectorSettings setSettings(detectorSettings isettings, int imod=-1)=0;
virtual detectorSettings getSettings(int imod=-1)=0;
/**
get threshold energy
\param imod module number (-1 all)
\returns current threshold value for imod in ev (-1 failed)
*/
virtual int getThresholdEnergy(int imod=-1)=0;
/**
set/get the external communication mode
obsolete \sa setExternalSignalFlags
\param pol value to be set \sa externalCommunicationMode
\returns current external communication mode
*/
@ -453,66 +384,25 @@ class slsDetectorBase : public slsDetectorDefs
/**
Reads the configuration file -- will contain all the informations needed for the configuration (e.g. for a PSI detector caldir, settingsdir, angconv, badchannels etc.)
Reads the configuration file fname
\param fname file name
\returns OK or FAIL
*/
virtual int readConfigurationFile(string const fname)=0;
/* /\** */
/* Writes the configuration file -- will contain all the informations needed for the configuration (e.g. for a PSI detector caldir, settingsdir, angconv, badchannels etc.) */
/* \param fname file name */
/* \returns OK or FAIL */
/* *\/ */
/* virtual int writeConfigurationFile(string const fname)=0; */
/**
Reads the parameters from the detector and writes them to file
\param fname file to write to
\param level if 2 reads also trimbits, flat field, angular correction etc. and writes them to files with automatically added extension
\returns OK or FAIL
*/
virtual int dumpDetectorSetup(string const fname, int level=0)=0;
/**
Loads the detector setup from file
\param fname file to read from
\param level if 2 reads also reads trimbits, angular conversion coefficients etc. from files with default extensions as generated by dumpDetectorSetup
\returns OK or FAIL
*/
virtual int retrieveDetectorSetup(string const fname, int level=0)=0;
/* /\** */
/* Loads dark image or gain image to the detector */
/* \param index can be DARK_IMAGE or GAIN_IMAGE */
/* \param fname file name to load data from */
/* \returns OK or FAIL */
/* *\/ */
/* virtual int loadImageToDetector(imageType index,string const fname)=0; */
/************************************************************************
STATIC FUNCTIONS
*********************************************************************/
/** returns string from run status index
\param s can be ERROR, WAITING, RUNNING, TRANSMITTING, RUN_FINISHED
\returns string error, waiting, running, data, finished
/**
@short
\returns the default output file index
*/
static string runStatusType(runStatus s){\
switch (s) { \
case ERROR: return string("error"); \
case WAITING: return string("waiting"); \
case RUNNING: return string("running");\
case TRANSMITTING: return string("data"); \
case RUN_FINISHED: return string("finished"); \
default: return string("idle"); \
}};
virtual int getFileIndex()=0;
/**
@short sets the default output file index
\param i file index
\returns the default output file index
*/
virtual int setFileIndex(int i)=0;
/** returns detector type string from detector type index
\param t string can be Mythen, Pilatus, Eiger, Gotthard, Agipd, Unknown
@ -621,22 +511,6 @@ class slsDetectorBase : public slsDetectorDefs
if (sval=="vcc") return OUTPUT_HIGH;\
return GET_EXTERNAL_SIGNAL_FLAG ;};
/** returns detector settings string from index
\param s can be standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, undefined
\returns STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, GET_SETTINGS
*/
static detectorSettings getDetectorSettings(string s){\
if (s=="standard") return STANDARD;\
if (s=="fast") return FAST;\
if (s=="highgain") return HIGHGAIN; \
if (s=="dynamicgain") return DYNAMICGAIN; \
if (s=="lowgain") return LOWGAIN; \
if (s=="mediumgain") return MEDIUMGAIN; \
if (s=="veryhighgain") return VERYHIGHGAIN; \
return GET_SETTINGS;\
};
/** returns detector settings string from index
\param s can be STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, GET_SETTINGS
\returns standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, undefined
@ -653,6 +527,22 @@ class slsDetectorBase : public slsDetectorDefs
default: return string("undefined"); \
}};
/** returns detector settings string from index
\param s can be standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, undefined
\returns setting index STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, GET_SETTINGS
*/
static detectorSettings getDetectorSettings(string s){ \
if (s=="standard") return STANDARD; \
if (s=="fast") return FAST; \
if (s=="highgain") return HIGHGAIN; \
if (s=="dynamicgain") return DYNAMICGAIN; \
if (s=="lowgain") return LOWGAIN; \
if (s=="mediumgain") return MEDIUMGAIN; \
if (s=="veryhighgain") return VERYHIGHGAIN; \
return GET_SETTINGS; \
};
/**
returns external communication mode string from index
@ -672,7 +562,6 @@ class slsDetectorBase : public slsDetectorDefs
/**
returns external communication mode index from string
\param sval can be auto, trigger, ro_trigger, gating, triggered_gating
@ -685,7 +574,22 @@ class slsDetectorBase : public slsDetectorDefs
if (sval=="ro_trigger") return TRIGGER_READOUT;\
if (sval=="gating") return GATE_FIX_NUMBER;\
if (sval=="triggered_gating") return GATE_WITH_START_TRIGGER;\
return GET_EXTERNAL_COMMUNICATION_MODE;};
return GET_EXTERNAL_COMMUNICATION_MODE; \
};
/** returns string from run status index
\param s can be ERROR, WAITING, RUNNING, TRANSMITTING, RUN_FINISHED
\returns string error, waiting, running, data, finished
*/
static string runStatusType(runStatus s){\
switch (s) { \
case ERROR: return string("error"); \
case WAITING: return string("waiting"); \
case RUNNING: return string("running");\
case TRANSMITTING: return string("data"); \
case RUN_FINISHED: return string("finished"); \
default: return string("idle"); \
}};
};
#endif

View File

@ -32,10 +32,8 @@ extern "C" {
using namespace std;
#include "sls_detector_defs.h"
#include "slsDetectorBase.h"
#include "energyConversion.h"
#include "slsDetectorActions.h"
#include "postProcessing.h"
#define MAX_TIMERS 10
#define MAX_ROIS 100
@ -49,7 +47,7 @@ using namespace std;
(used in the PSi command line interface)
*/
class slsDetectorUtils : public slsDetectorActions, public slsDetectorBase {
class slsDetectorUtils : public slsDetectorActions, public postProcessing {
@ -66,34 +64,35 @@ class slsDetectorUtils : public slsDetectorActions, public slsDetectorBase {
int setPositions(int nPos, float *pos){return angularConversion::setPositions(nPos, pos);};
int getPositions(float *pos=NULL){return angularConversion::getPositions(pos);};
//int setPositions(int nPos, float *pos){return angularConversion::setPositions(nPos, pos);};
// int getPositions(float *pos=NULL){return angularConversion::getPositions(pos);};
using slsDetectorBase::setFlatFieldCorrection;
string getFilePath(){return fileIO::getFilePath();};
string setFilePath(string s){return fileIO::setFilePath(s);};
// string getFilePath(){return fileIO::getFilePath();};
// string setFilePath(string s){return fileIO::setFilePath(s);};
string getFileName(){return fileIO::getFileName();};
string setFileName(string s){return fileIO::setFileName(s);};
// string getFileName(){return fileIO::getFileName();};
// string setFileName(string s){return fileIO::setFileName(s);};
int getFileIndex(){return fileIO::getFileIndex();};
int setFileIndex(int s){return fileIO::setFileIndex(s);};
// int getFileIndex(){return fileIO::getFileIndex();};
// int setFileIndex(int s){return fileIO::setFileIndex(s);};
int getScanPrecision(int i){return slsDetectorActions::getScanPrecision(i);};
// int getScanPrecision(int i){return slsDetectorActions::getScanPrecision(i);};
int getActionMask() {return slsDetectorActions::getActionMask();};
float getCurrentScanVariable(int i) {return slsDetectorActions::getCurrentScanVariable(i);};
int getCurrentPositionIndex(){return angularConversion::getCurrentPositionIndex();};
int getNumberOfPositions(){return angularConversion::getNumberOfPositions();};
// int getActionMask() {return slsDetectorActions::getActionMask();};
// float getCurrentScanVariable(int i) {return slsDetectorActions::getCurrentScanVariable(i);};
// int getCurrentPositionIndex(){return angularConversion::getCurrentPositionIndex();};
// int getNumberOfPositions(){return angularConversion::getNumberOfPositions();};
string getFlatFieldCorrectionDir(){return postProcessing::getFlatFieldCorrectionDir();};
string setFlatFieldCorrectionDir(string s){return postProcessing::setFlatFieldCorrectionDir(s);};
string getFlatFieldCorrectionFile(){return postProcessing::getFlatFieldCorrectionFile();};
int enableBadChannelCorrection(int i){return postProcessing::enableBadChannelCorrection(i);};
int enableAngularConversion(int i){return postProcessing::enableAngularConversion(i);};
// string getFlatFieldCorrectionDir(){return postProcessing::getFlatFieldCorrectionDir();};
// string setFlatFieldCorrectionDir(string s){return postProcessing::setFlatFieldCorrectionDir(s);};
// string getFlatFieldCorrectionFile(){return postProcessing::getFlatFieldCorrectionFile();};
// int enableBadChannelCorrection(int i){return postProcessing::enableBadChannelCorrection(i);};
// int enableAngularConversion(int i){return postProcessing::enableAngularConversion(i);};
/** returns the detector hostname
@ -409,7 +408,6 @@ class slsDetectorUtils : public slsDetectorActions, public slsDetectorBase {
void incrementProgress();
void incrementFileIndex() { (*fileIndex)++;};

View File

@ -3,7 +3,7 @@
#define ANGULARCONVERSION_H
#include "sls_detector_defs.h"
#include "slsDetectorBase.h"
#include <string>
#include <fstream>
@ -38,7 +38,7 @@ class containing the methods to set/unset the angular conversion and merge the d
The angular conversion itself is defined by the angle() function defined in usersFunctions.cpp
*/
class angularConversion : public slsDetectorDefs {
class angularConversion : public virtual slsDetectorBase {
public:
/** default constructor */
@ -281,11 +281,6 @@ class angularConversion : public slsDetectorDefs {
*/
float getAngularConversionParameter(angleConversionParameter c);
/**
pure virtual function
\returns total number of channels of the (multi)detector
*/
virtual int getTotalNumberOfChannels()=0;
@ -385,11 +380,6 @@ class angularConversion : public slsDetectorDefs {
*/
virtual int getMoveFlag(int imod)=0;
/**
returns current position index
*/
int getCurrentPositionIndex() {return currentPositionIndex;};
/**
returns number of positions
*/
@ -428,6 +418,7 @@ class angularConversion : public slsDetectorDefs {
*/
float currentPosition;
/**
current position index of the detector
*/
@ -441,6 +432,11 @@ class angularConversion : public slsDetectorDefs {
*/
virtual int setAngularCorrectionMask(int i=-1)=0;
/**
returns current position index
*/
int getCurrentPositionIndex() {return currentPositionIndex;};
void incrementPositionIndex() {currentPositionIndex++;};
private:
/** merging bins */

View File

@ -10,7 +10,7 @@ using namespace std;
*/
class energyConversion: public slsDetectorDefs {
class energyConversion: private virtual slsDetectorDefs {
public:
/** default constrauctor */

View File

@ -1,7 +1,7 @@
#ifndef FILEIO_H
#define FILEIO_H
#include "sls_detector_defs.h"
#include "slsDetectorBase.h"
#include <iostream>
#include <fstream>
#include <iomanip>
@ -15,7 +15,8 @@ using namespace std;
/**
@short class handling the data file I/O flags
*/
class fileIO : public slsDetectorDefs {
class fileIO : public virtual slsDetectorBase {
@ -47,6 +48,8 @@ class fileIO : public slsDetectorDefs {
*/
int setFileIndex(int i) {*fileIndex=i; return *fileIndex;};
/**
\returns the output files path
@ -91,15 +94,14 @@ class fileIO : public slsDetectorDefs {
static string createFileName(char *filepath, char *filename, int aMask, float sv0, int prec0, float sv1, int prec1, int pindex, int npos, int findex);
/** generates file name without extension */
virtual string createFileName();
string createFileName();
/** static function that returns the file index from the file name
\param fname file name
\returns file index
*/
static int getFileIndexFromFileName(string fname);
int getFileIndexFromFileName(string fname);
/** static function that returns the variables from the file name
\param fname file name
@ -372,36 +374,13 @@ class fileIO : public slsDetectorDefs {
static int readDataFile(ifstream &infile, short int *data, int nch, int offset);
/**
\returns action mask
*/
virtual int getActionMask()=0;// {return 0;};
/**
\param index scan level index
\returns current scan variable
*/
virtual float getCurrentScanVariable(int index)=0;// {return 0;};
/**
\param index scan level index
\returns current scan variable precision (for file name)
*/
virtual int getScanPrecision(int index)=0;// {return 0;};
/**
\returns current position index
*/
virtual int getCurrentPositionIndex()=0;// {return 0;};
/**
\returns number of positions
*/
virtual int getNumberOfPositions()=0;// {return 0;};
/**
\returns total number of channels
*/
virtual int getTotalNumberOfChannels()=0;
protected:
void incrementFileIndex() { (*fileIndex)++;};
string getCurrentFileName(){return currentFileName;};
string currentFileName;

View File

@ -219,16 +219,16 @@ void postProcessing::doProcessing(float *fdata, int delflag, string fname) {
if (*correctionMask!=0) {
if (*correctionMask&(1<< ANGULAR_CONVERSION))
ang=convertAngles(currentPosition);
ang=convertAngles();
writeDataFile (fname+ext, ffcdata, ffcerr,ang);
}
if (*correctionMask&(1<< ANGULAR_CONVERSION) && (*numberOfPositions)>0) {
if (*correctionMask&(1<< ANGULAR_CONVERSION) && getNumberOfPositions()>0) {
#ifdef VERBOSE
cout << "**************Current position index is " << currentPositionIndex << endl;
cout << "**************Current position index is " << getCurrentPositionIndex() << endl;
#endif
// if (*numberOfPositions>0) {
if (currentPositionIndex<=1) {
if (getCurrentPositionIndex()<=1) {
#ifdef VERBOSE
cout << "reset merging " << endl;
@ -237,7 +237,7 @@ void postProcessing::doProcessing(float *fdata, int delflag, string fname) {
}
#ifdef VERBOSE
cout << "add to merging "<< currentPositionIndex << endl;
cout << "add to merging "<< getCurrentPositionIndex() << endl;
#endif
if (*correctionMask&(1<< ANGULAR_CONVERSION))
@ -245,20 +245,20 @@ void postProcessing::doProcessing(float *fdata, int delflag, string fname) {
#ifdef VERBOSE
cout << currentPositionIndex << " " << (*numberOfPositions) << endl;
cout << getCurrentPositionIndex() << " " << getNumberOfPositions() << endl;
#endif
pthread_mutex_lock(&mp);
if ((currentPositionIndex>=(*numberOfPositions) && posfinished==1 && queuesize==1)) {
if ((getCurrentPositionIndex()>=getNumberOfPositions() && posfinished==1 && queuesize==1)) {
#ifdef VERBOSE
cout << "finalize merging " << currentPositionIndex<< endl;
cout << "finalize merging " << getCurrentPositionIndex()<< endl;
#endif
np=finalizeMerging();
/** file writing */
currentPositionIndex++;
incrementPositionIndex();
pthread_mutex_unlock(&mp);
@ -329,8 +329,6 @@ int postProcessing::fillBadChannelMask() {
int nbad=0;
if (*correctionMask&(1<< DISCARD_BAD_CHANNELS)) {
nbad=getBadChannelCorrection();
#ifdef VERBOSE

View File

@ -2,8 +2,8 @@
#define POSTPROCESSING_H
#include "sls_detector_defs.h"
#include "detectorData.h"
#include "slsDetectorBase.h"
#include "angularConversion.h"
#include "fileIO.h"
#include <string>
@ -31,7 +31,9 @@ using namespace std;
(including thread for writing data files and plotting in parallel with the acquisition)
*/
class postProcessing : public angularConversion, public fileIO {
class postProcessing : public angularConversion, public fileIO
//: public virtual angularConversion, public virtual fileIO
{
@ -232,18 +234,6 @@ s
virtual void incrementProgress()=0;
virtual float getCurrentProgress()=0;
virtual void incrementFileIndex()=0;
virtual int setTotalProgress()=0;
virtual float* decodeData(int *datain, float *fdata=NULL)=0;
virtual int getTotalNumberOfChannels()=0;
virtual int rateCorrect(float*, float*, float*, float*)=0;
virtual int flatFieldCorrect(float*, float*, float*, float*)=0;
@ -361,6 +351,19 @@ s
float *fdata;
// private:
/* virtual void incrementProgress()=0; */
/* virtual float getCurrentProgress()=0; */
/* virtual void incrementFileIndex()=0; */
/* virtual int setTotalProgress()=0; */
/* virtual float* decodeData(int *datain, float *fdata=NULL)=0; */
/* virtual int getTotalNumberOfChannels()=0; */
};

View File

@ -34,8 +34,6 @@ extern int differentClients;
char *dataretval=NULL;
int dataret;
char mess[1000];
int dataBytes;