mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 14:38:14 +02:00
merge conflict fix
This commit is contained in:
commit
12348ac76c
@ -20,8 +20,12 @@ using namespace std;
|
||||
/** Error flags */
|
||||
/*Assumption: Only upto 63 detectors */
|
||||
|
||||
// multi errors
|
||||
// 0xFFF0000000000000ULL
|
||||
#define MULTI_DETECTORS_NOT_ADDED 0x8000000000000000ULL
|
||||
#define MULTI_HAVE_DIFFERENT_VALUES 0x4000000000000000ULL
|
||||
|
||||
// sls errors
|
||||
#define CRITICAL_ERROR_MASK 0xFFFFFFF
|
||||
|
||||
// 0xFFFFFFF000000000ULL
|
||||
@ -45,6 +49,7 @@ using namespace std;
|
||||
#define RECEIVER_MULTI_DET_SIZE_NOT_SET 0x0000200000000000ULL
|
||||
#define PREPARE_ACQUISITION 0x0000100000000000ULL
|
||||
#define CLEANUP_ACQUISITION 0x0000080000000000ULL
|
||||
#define REGISER_WRITE_READ 0x0000040000000000ULL
|
||||
// 0xFFFFFFF000000000ULL
|
||||
|
||||
// 0x0000000FFFFFFFFFULL
|
||||
@ -156,7 +161,8 @@ public:
|
||||
if(slsErrorMask&CLEANUP_ACQUISITION)
|
||||
retval.append("Could not clean up after acquisition in detector\n");
|
||||
|
||||
|
||||
if(slsErrorMask®ISER_WRITE_READ)
|
||||
retval.append("Could not read/write register in detector\n");
|
||||
|
||||
|
||||
|
||||
|
@ -4714,66 +4714,116 @@ int multiSlsDetector::saveCalibrationFile(string fname, int imod) {
|
||||
|
||||
int multiSlsDetector::writeRegister(int addr, int val){
|
||||
|
||||
int i;//imi, ima,
|
||||
int ret, ret1=-100;
|
||||
int ret, ret1=-100;
|
||||
|
||||
for (i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
|
||||
if (detectors[i]) {
|
||||
ret=detectors[i]->writeRegister(addr,val);
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
if (ret1==-100)
|
||||
ret1=ret;
|
||||
else if (ret!=ret1)
|
||||
ret1=-1;
|
||||
}
|
||||
}
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
|
||||
if (detectors[i]) {
|
||||
ret=detectors[i]->writeRegister(addr,val);
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
if (ret1==-100)
|
||||
ret1=ret;
|
||||
else if (ret!=ret1) {
|
||||
// not setting it to -1 as it is a possible value
|
||||
std::cout << "Error: Different Values for function writeRegister [" << ret << "," << ret1 << "]" << endl;
|
||||
setErrorMask(getErrorMask()|MULTI_HAVE_DIFFERENT_VALUES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret1;
|
||||
};
|
||||
return ret1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::writeAdcRegister(int addr, int val){
|
||||
|
||||
int i;//imi, ima,
|
||||
int ret, ret1=-100;
|
||||
int ret, ret1=-100;
|
||||
|
||||
for (i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
|
||||
if (detectors[i]) {
|
||||
ret=detectors[i]->writeAdcRegister(addr,val);
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
if (ret1==-100)
|
||||
ret1=ret;
|
||||
else if (ret!=ret1)
|
||||
ret1=-1;
|
||||
}
|
||||
}
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
|
||||
if (detectors[i]) {
|
||||
ret=detectors[i]->writeAdcRegister(addr,val);
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
if (ret1==-100)
|
||||
ret1=ret;
|
||||
else if (ret!=ret1) {
|
||||
// not setting it to -1 as it is a possible value
|
||||
std::cout << "Error: Different Values for function writeAdcRegister [" << ret << "," << ret1 << "]" << endl;
|
||||
setErrorMask(getErrorMask()|MULTI_HAVE_DIFFERENT_VALUES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret1;
|
||||
};
|
||||
return ret1;
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::readRegister(int addr){
|
||||
|
||||
int i;//imi, ima,
|
||||
int ret, ret1=-100;
|
||||
int ret, ret1=-100;
|
||||
|
||||
for (i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
|
||||
if (detectors[i]) {
|
||||
ret=detectors[i]->readRegister(addr);
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
if (ret1==-100)
|
||||
ret1=ret;
|
||||
else if (ret!=ret1)
|
||||
ret1=-1;
|
||||
}
|
||||
}
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
|
||||
if (detectors[i]) {
|
||||
ret=detectors[i]->readRegister(addr);
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
if (ret1==-100)
|
||||
ret1=ret;
|
||||
else if (ret!=ret1) {
|
||||
// not setting it to -1 as it is a possible value
|
||||
std::cout << "Error: Different Values for function readRegister [" << ret << "," << ret1 << "]" << endl;
|
||||
setErrorMask(getErrorMask()|MULTI_HAVE_DIFFERENT_VALUES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret1;
|
||||
};
|
||||
return ret1;
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::setBit(int addr, int n) {
|
||||
int ret1, ret=-100;
|
||||
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
|
||||
if (detectors[i]) {
|
||||
ret1=detectors[i]->setBit(addr,n);
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
if (ret==-100)
|
||||
ret=ret1;
|
||||
else if (ret!=ret1) {
|
||||
// not setting it to -1 as it is a possible value
|
||||
std::cout << "Error: Different Values for function setBit [" << ret << "," << ret1 << "]" << endl;
|
||||
setErrorMask(getErrorMask()|MULTI_HAVE_DIFFERENT_VALUES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::clearBit(int addr, int n) {
|
||||
int ret1, ret=-100;
|
||||
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
|
||||
if (detectors[i]) {
|
||||
ret1=detectors[i]->clearBit(addr,n);
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
if (ret==-100)
|
||||
ret=ret1;
|
||||
else if (ret!=ret1) {
|
||||
// not setting it to -1 as it is a possible value
|
||||
std::cout << "Error: Different Values for function clearBit [" << ret << "," << ret1 << "]" << endl;
|
||||
setErrorMask(getErrorMask()|MULTI_HAVE_DIFFERENT_VALUES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6245,8 +6295,15 @@ string multiSlsDetector::getErrorMessage(int &critical){
|
||||
|
||||
multiMask = getErrorMask();
|
||||
if(multiMask){
|
||||
if(multiMask & MULTI_DETECTORS_NOT_ADDED)
|
||||
if(multiMask & MULTI_DETECTORS_NOT_ADDED) {
|
||||
retval.append("Detectors not added:\n"+string(getNotAddedList())+string("\n"));
|
||||
critical = 1;
|
||||
}
|
||||
if(multiMask & MULTI_HAVE_DIFFERENT_VALUES) {
|
||||
retval.append("A previous multi detector command gave different values\n"
|
||||
"Please check the console\n");
|
||||
critical = 0;
|
||||
}
|
||||
|
||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) {
|
||||
if (detectors[idet]) {
|
||||
|
@ -1077,6 +1077,27 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
|
||||
int readRegister(int addr);
|
||||
|
||||
/**
|
||||
sets a bit in a register
|
||||
\param addr address
|
||||
\param n nth bit ranging from 0 to 31
|
||||
\returns current register value
|
||||
|
||||
DO NOT USE!!! ONLY EXPERT USER!!!
|
||||
*/
|
||||
int setBit(int addr, int n);
|
||||
|
||||
|
||||
/**
|
||||
clear a bit in a register
|
||||
\param addr address
|
||||
\param n nth bit ranging from 0 to 31
|
||||
\returns current register value
|
||||
|
||||
DO NOT USE!!! ONLY EXPERT USER!!!
|
||||
*/
|
||||
int clearBit(int addr, int n);
|
||||
|
||||
|
||||
|
||||
int setTrimEn(int nen, int *en=NULL);
|
||||
|
@ -2396,90 +2396,86 @@ int slsDetector::digitalTest( digitalTestMode mode, int imod){
|
||||
|
||||
int slsDetector::writeRegister(int addr, int val){
|
||||
|
||||
|
||||
int retval;
|
||||
int fnum=F_WRITE_REGISTER;
|
||||
int ret=FAIL;
|
||||
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
|
||||
int arg[2];
|
||||
arg[0]=addr;
|
||||
arg[1]=val;
|
||||
|
||||
int retval=-1;
|
||||
int fnum=F_WRITE_REGISTER;
|
||||
int ret=FAIL;
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
int arg[2];
|
||||
arg[0]=addr;
|
||||
arg[1]=val;
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< std::endl;
|
||||
std::cout<< "Writing to register "<< hex<<addr << " data " << hex<<val << std::endl;
|
||||
std::cout<< std::endl;
|
||||
std::cout<< "Writing to register "<< hex<<addr << " data " << hex<<val << std::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(&retval,sizeof(retval));
|
||||
else {
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
}
|
||||
disconnectControl();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
}
|
||||
}
|
||||
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(&retval,sizeof(retval));
|
||||
else {
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
}
|
||||
disconnectControl();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Register returned "<< retval << std::endl;
|
||||
std::cout<< "Register returned "<< retval << std::endl;
|
||||
#endif
|
||||
if (ret==FAIL) {
|
||||
std::cout<< "Write to register failed " << std::endl;
|
||||
}
|
||||
return retval;
|
||||
if (ret==FAIL) {
|
||||
std::cout<< "Write to register failed " << std::endl;
|
||||
setErrorMask((getErrorMask())|(REGISER_WRITE_READ));
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
};
|
||||
/* write or read register */
|
||||
|
||||
int slsDetector::writeAdcRegister(int addr, int val){
|
||||
|
||||
int retval=-1;
|
||||
int fnum=F_WRITE_ADC_REG;
|
||||
int ret=FAIL;
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
|
||||
int retval;
|
||||
int fnum=F_WRITE_ADC_REG;
|
||||
int ret=FAIL;
|
||||
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
|
||||
int arg[2];
|
||||
arg[0]=addr;
|
||||
arg[1]=val;
|
||||
int arg[2];
|
||||
arg[0]=addr;
|
||||
arg[1]=val;
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< std::endl;
|
||||
std::cout<< "Writing to adc register "<< hex<<addr << " data " << hex<<val << std::endl;
|
||||
std::cout<< std::endl;
|
||||
std::cout<< "Writing to adc register "<< hex<<addr << " data " << hex<<val << std::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(&retval,sizeof(retval));
|
||||
else {
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
}
|
||||
disconnectControl();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
}
|
||||
}
|
||||
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(&retval,sizeof(retval));
|
||||
else {
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
}
|
||||
disconnectControl();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "ADC Register returned "<< retval << std::endl;
|
||||
std::cout<< "ADC Register returned "<< retval << std::endl;
|
||||
#endif
|
||||
if (ret==FAIL) {
|
||||
std::cout<< "Write ADC to register failed " << std::endl;
|
||||
}
|
||||
return retval;
|
||||
if (ret==FAIL) {
|
||||
std::cout<< "Write ADC to register failed " << std::endl;
|
||||
setErrorMask((getErrorMask())|(REGISER_WRITE_READ));
|
||||
}
|
||||
return retval;
|
||||
|
||||
};
|
||||
|
||||
@ -2488,49 +2484,81 @@ int slsDetector::writeAdcRegister(int addr, int val){
|
||||
|
||||
int slsDetector::readRegister(int addr){
|
||||
|
||||
|
||||
int retval;
|
||||
int fnum=F_READ_REGISTER;
|
||||
int ret=FAIL;
|
||||
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
|
||||
int arg;
|
||||
arg=addr;
|
||||
int retval=-1;
|
||||
int fnum=F_READ_REGISTER;
|
||||
int ret=FAIL;
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
int arg;
|
||||
arg=addr;
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< std::endl;
|
||||
std::cout<< "Reading register "<< hex<<addr << std::endl;
|
||||
std::cout<< std::endl;
|
||||
std::cout<< "Reading register "<< hex<<addr << std::endl;
|
||||
#endif
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
// if (connectControl() == OK){
|
||||
if (stopSocket) {
|
||||
if (connectStop() == OK) {
|
||||
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
stopSocket->SendDataOnly(&arg,sizeof(arg));
|
||||
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret!=FAIL)
|
||||
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
else {
|
||||
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
}
|
||||
disconnectStop();
|
||||
// if (ret==FORCE_UPDATE)
|
||||
// updateDetector();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
// if (connectControl() == OK){
|
||||
if (stopSocket) {
|
||||
if (connectStop() == OK) {
|
||||
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
stopSocket->SendDataOnly(&arg,sizeof(arg));
|
||||
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret!=FAIL)
|
||||
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
else {
|
||||
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
}
|
||||
disconnectStop();
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Register returned "<< retval << std::endl;
|
||||
std::cout<< "Register returned "<< retval << std::endl;
|
||||
#endif
|
||||
if (ret==FAIL) {
|
||||
std::cout<< "Read register failed " << std::endl;
|
||||
}
|
||||
return retval;
|
||||
if (ret==FAIL) {
|
||||
std::cout<< "Read register failed " << std::endl;
|
||||
setErrorMask((getErrorMask())|(REGISER_WRITE_READ));
|
||||
}
|
||||
return retval;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::setBit(int addr, int n) {
|
||||
if (n<0 || n>31) {
|
||||
std::cout << "Bit number out of Range" << std:: endl;
|
||||
setErrorMask((getErrorMask())|(REGISER_WRITE_READ));
|
||||
}
|
||||
|
||||
// normal bit range
|
||||
else {
|
||||
int val = readRegister(addr);
|
||||
if (val != -1) {
|
||||
writeRegister(addr,val | 1<<n);
|
||||
}
|
||||
}
|
||||
|
||||
return readRegister(addr);
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::clearBit(int addr, int n) {
|
||||
if (n<0 || n>31) {
|
||||
std::cout << "Bit number out of Range" << std:: endl;
|
||||
setErrorMask((getErrorMask())|(REGISER_WRITE_READ));
|
||||
}
|
||||
|
||||
// normal bit range
|
||||
else {
|
||||
int val = readRegister(addr);
|
||||
if (val != -1) {
|
||||
writeRegister(addr,val & ~(1<<n));
|
||||
}
|
||||
}
|
||||
|
||||
return readRegister(addr);
|
||||
}
|
||||
|
||||
|
||||
// Expert initialization functions
|
||||
|
@ -906,6 +906,27 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
int readRegister(int addr);
|
||||
|
||||
/**
|
||||
sets a bit in a register
|
||||
\param addr address
|
||||
\param n nth bit ranging from 0 to 31
|
||||
\returns current register value
|
||||
|
||||
DO NOT USE!!! ONLY EXPERT USER!!!
|
||||
*/
|
||||
int setBit(int addr, int n);
|
||||
|
||||
|
||||
/**
|
||||
clear a bit in a register
|
||||
\param addr address
|
||||
\param n nth bit ranging from 0 to 31
|
||||
\returns current register value
|
||||
|
||||
DO NOT USE!!! ONLY EXPERT USER!!!
|
||||
*/
|
||||
int clearBit(int addr, int n);
|
||||
|
||||
/**
|
||||
set dacs value
|
||||
\param val value (in V)
|
||||
|
@ -4866,9 +4866,9 @@ string slsDetectorCommand::cmdRegister(int narg, char *args[], int action) {
|
||||
return string("Bit number out of range")+string(args[2]);
|
||||
|
||||
if (cmd=="setbit")
|
||||
sprintf(answer,"0x%x",myDet->writeRegister(addr,myDet->readRegister(addr)| 1<<n));
|
||||
sprintf(answer,"0x%x",myDet->setBit(addr,n));
|
||||
if (cmd=="clearbit")
|
||||
sprintf(answer,"0x%x",myDet->writeRegister(addr,myDet->readRegister(addr) & ~(1<<n)));
|
||||
sprintf(answer,"0x%x",myDet->clearBit(addr,n));
|
||||
}
|
||||
|
||||
|
||||
|
@ -559,6 +559,30 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
DO NOT USE!!! ONLY EXPERT USER!!!
|
||||
*/
|
||||
virtual int readRegister(int addr)=0;
|
||||
|
||||
|
||||
/**
|
||||
sets a bit in a register
|
||||
\param addr address
|
||||
\param n nth bit ranging from 0 to 31
|
||||
\returns current register value
|
||||
|
||||
DO NOT USE!!! ONLY EXPERT USER!!!
|
||||
*/
|
||||
virtual int setBit(int addr, int n)=0;
|
||||
|
||||
|
||||
/**
|
||||
clear a bit in a register
|
||||
\param addr address
|
||||
\param n nth bit ranging from 0 to 31
|
||||
\returns current register value
|
||||
|
||||
DO NOT USE!!! ONLY EXPERT USER!!!
|
||||
*/
|
||||
virtual int clearBit(int addr, int n)=0;
|
||||
|
||||
|
||||
/**
|
||||
Returns the IP of the last client connecting to the detector
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user