slsDetector/slsDetectorCommand.cpp

This commit is contained in:
Dhanya Maliakal 2016-10-20 07:31:53 +02:00
commit 81d96a047d
12 changed files with 132 additions and 29 deletions

View File

@ -10,6 +10,7 @@
#include <string> #include <string>
#include <cstring>
using namespace std; using namespace std;
@ -18,8 +19,12 @@ using namespace std;
/** Error flags */ /** Error flags */
/*Assumption: Only upto 63 detectors */
#define CRITICAL_ERROR_MASK 0xFFFFFFFF #define CRITICAL_ERROR_MASK 0xFFFFFFFF
#define MULTI_DETECTORS_NOT_ADDED 0x8000000000000000ULL
#define CANNOT_CONNECT_TO_DETECTOR 0x8000000000000000ULL #define CANNOT_CONNECT_TO_DETECTOR 0x8000000000000000ULL
#define CANNOT_CONNECT_TO_RECEIVER 0x4000000000000000ULL #define CANNOT_CONNECT_TO_RECEIVER 0x4000000000000000ULL
#define COULDNOT_SET_CONTROL_PORT 0x2000000000000000ULL #define COULDNOT_SET_CONTROL_PORT 0x2000000000000000ULL
@ -72,7 +77,9 @@ class errorDefs {
public: public:
/** Constructor */ /** Constructor */
errorDefs():errorMask(0){}; errorDefs():errorMask(0){
strcpy(notAddedList,"");
};
/** Gets the error message /** Gets the error message
* param errorMask error mask * param errorMask error mask
@ -229,12 +236,29 @@ public:
*/ */
int64_t clearErrorMask(){errorMask=0;return errorMask;}; int64_t clearErrorMask(){errorMask=0;return errorMask;};
/** Gets the not added detector list
/returns list
*/
char* getNotAddedList(){return notAddedList;};
/** Append the detector to not added detector list
* @param name append to the list
/returns list
*/
void appendNotAddedList(const char* name){strcat(notAddedList,name);strcat(notAddedList,"+");};
/** Clears not added detector list
/returns error mask
*/
void clearNotAddedList(){strcpy(notAddedList,"");};
protected: protected:
/** Error Mask */ /** Error Mask */
int64_t errorMask; int64_t errorMask;
/** Detectors Not added List */
char notAddedList[MAX_STR_LENGTH];
}; };
#endif /* ERROR_DEFS_H_ */ #endif /* ERROR_DEFS_H_ */

View File

@ -362,6 +362,8 @@ enum dacIndex {
TEMPERATURE_DCDC, /**< temperature sensor (close to DCDC) */ TEMPERATURE_DCDC, /**< temperature sensor (close to DCDC) */
TEMPERATURE_SODL, /**< temperature sensor (close to SODL) */ TEMPERATURE_SODL, /**< temperature sensor (close to SODL) */
TEMPERATURE_SODR, /**< temperature sensor (close to SODR) */ TEMPERATURE_SODR, /**< temperature sensor (close to SODR) */
TEMPERATURE_FPGA2, /**< temperature sensor (fpga2 (eiger:febl) */
TEMPERATURE_FPGA3, /**< temperature sensor (fpga3 (eiger:febr) */
V_POWER_A = 100, /**new chiptest board */ V_POWER_A = 100, /**new chiptest board */
V_POWER_B = 101, /**new chiptest board */ V_POWER_B = 101, /**new chiptest board */
V_POWER_C = 102, /**new chiptest board */ V_POWER_C = 102, /**new chiptest board */

View File

@ -1676,3 +1676,22 @@ int Feb_Control_PrintCorrectedValues(){
return 1; return 1;
} }
int Feb_Control_GetLeftFPGATemp(){
unsigned int temperature=0;
Feb_Interface_ReadRegister(Module_GetTopLeftAddress (&modules[1]),FEB_REG_STATUS, &temperature);
temperature = temperature >> 16;
//division done in client to send int over network
return (int)temperature;
}
int Feb_Control_GetRightFPGATemp(){
unsigned int temperature=0;
Feb_Interface_ReadRegister(Module_GetTopRightAddress (&modules[1]),FEB_REG_STATUS, &temperature);
temperature = temperature >> 16;
//division done in client to send int over network
return (int)temperature;
}

View File

@ -192,4 +192,7 @@ int Feb_Control_GetModuleNumber();
void Feb_Control_SetRateCorrectionVariable(int activate_rate_correction); void Feb_Control_SetRateCorrectionVariable(int activate_rate_correction);
int Feb_Control_PrintCorrectedValues(); int Feb_Control_PrintCorrectedValues();
int Feb_Control_GetLeftFPGATemp();
int Feb_Control_GetRightFPGATemp();
#endif #endif

View File

@ -95,6 +95,7 @@
#define DAQ_STATUS_DAQ_RUNNING 0x01 #define DAQ_STATUS_DAQ_RUNNING 0x01
#define DAQ_DATA_COLLISION_ERROR 0x02 #define DAQ_DATA_COLLISION_ERROR 0x02
#define DAQ_STATUS_CURRENT_M4 0x04 #define DAQ_STATUS_CURRENT_M4 0x04
#define DAQ_STATUS_CURRENT_M8 0x08 #define DAQ_STATUS_CURRENT_M8 0x08
#define DAQ_STATUS_CURRENT_M12 0x00 //in 12 bit mode both are cleared #define DAQ_STATUS_CURRENT_M12 0x00 //in 12 bit mode both are cleared
@ -149,3 +150,6 @@
#define FRAME_NUM_RESET_OFFSET 0xA0 #define FRAME_NUM_RESET_OFFSET 0xA0
//temp so far
#define FEB_REG_STATUS 0xa

View File

@ -449,6 +449,12 @@ int getADC(enum detAdcIndex ind, int imod){
case TEMP_FPGA: case TEMP_FPGA:
retval=getBebFPGATemp()*1000; retval=getBebFPGATemp()*1000;
break; break;
case TEMP_FPGAFEBL:
retval=Feb_Control_GetLeftFPGATemp();
break;
case TEMP_FPGAFEBR:
retval=Feb_Control_GetRightFPGATemp();
break;
case TEMP_FPGAEXT: case TEMP_FPGAEXT:
case TEMP_10GE: case TEMP_10GE:
case TEMP_DCDC: case TEMP_DCDC:

View File

@ -40,7 +40,7 @@
enum detDacIndex{SVP,VTR,VRF,VRS,SVN,VTGSTV,VCMP_LL,VCMP_LR,CAL,VCMP_RL,RXB_RB,RXB_LB,VCMP_RR,VCP,VCN,VIS,VTHRESHOLD}; enum detDacIndex{SVP,VTR,VRF,VRS,SVN,VTGSTV,VCMP_LL,VCMP_LR,CAL,VCMP_RL,RXB_RB,RXB_LB,VCMP_RR,VCP,VCN,VIS,VTHRESHOLD};
enum detAdcIndex{TEMP_FPGAEXT, TEMP_10GE, TEMP_DCDC, TEMP_SODL, TEMP_SODR, TEMP_FPGA}; enum detAdcIndex{TEMP_FPGAEXT, TEMP_10GE, TEMP_DCDC, TEMP_SODL, TEMP_SODR, TEMP_FPGA, TEMP_FPGAFEBL, TEMP_FPGAFEBR};
enum detNetworkParameter{TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G}; enum detNetworkParameter{TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G};

View File

@ -694,6 +694,8 @@ int multiSlsDetector::addSlsDetector(const char *name, int pos) {
t=slsDetector::getDetectorType(name, DEFAULT_PORTNO); t=slsDetector::getDetectorType(name, DEFAULT_PORTNO);
if (t==GENERIC) { if (t==GENERIC) {
cout << "Detector " << name << "does not exist in shared memory and could not connect to it to determine the type (which is not specified)!" << endl; cout << "Detector " << name << "does not exist in shared memory and could not connect to it to determine the type (which is not specified)!" << endl;
setErrorMask(getErrorMask()|MULTI_DETECTORS_NOT_ADDED);
appendNotAddedList(name);
return -1; return -1;
} }
#ifdef VERBOSE #ifdef VERBOSE
@ -4358,8 +4360,12 @@ int multiSlsDetector::readConfigurationFile(string const fname){
setNumberOfModules(-1); setNumberOfModules(-1);
getMaxNumberOfModules(); getMaxNumberOfModules();
if (getErrorMask()) if (getErrorMask()){
int c;
cprintf(RED,"\n----------------\n Error Messages\n----------------\n%s\n",
getErrorMessage(c).c_str());
return FAIL; return FAIL;
}
return OK; return OK;
@ -4689,7 +4695,8 @@ string multiSlsDetector::checkReceiverOnline() {
string multiSlsDetector::setFilePath(string s) { string multiSlsDetector::setFilePath(string s) {
string ret="errorerror", ret1; string ret="errorerror", ret1;
if(!s.empty()){ //if the sls file paths are different, it should be realized by always using setfilepath even if string empty
//if(!s.empty()){
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) { for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
if (detectors[idet]) { if (detectors[idet]) {
@ -4703,7 +4710,7 @@ string multiSlsDetector::setFilePath(string s) {
} }
} }
fileIO::setFilePath(ret); fileIO::setFilePath(ret);
} //}
return fileIO::getFilePath(); return fileIO::getFilePath();
} }
@ -4911,6 +4918,17 @@ slsDetectorDefs::runStatus multiSlsDetector::getReceiverStatus(){
int multiSlsDetector::getFramesCaughtByReceiver() { int multiSlsDetector::getFramesCaughtByReceiver() {
int ret=0,ret1=0; int ret=0,ret1=0;
if(thisMultiDetector->numberOfDetectors>10) {
if (detectors[0]){
ret =detectors[0]->getFramesCaughtByReceiver();
if(detectors[0]->getErrorMask())
setErrorMask(getErrorMask()|(1<<0));
}
return ret;
}
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) for (int i=0; i<thisMultiDetector->numberOfDetectors; i++)
if (detectors[i]){ if (detectors[i]){
ret1+=detectors[i]->getFramesCaughtByReceiver(); ret1+=detectors[i]->getFramesCaughtByReceiver();
@ -4946,6 +4964,7 @@ int multiSlsDetector::getReceiverCurrentFrameIndex() {
int multiSlsDetector::resetFramesCaught() { int multiSlsDetector::resetFramesCaught() {
int ret=-100, ret1; int ret=-100, ret1;
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++){ for (int i=0; i<thisMultiDetector->numberOfDetectors; i++){
if (detectors[i]){ if (detectors[i]){
ret1=detectors[i]->resetFramesCaught(); ret1=detectors[i]->resetFramesCaught();
@ -5196,6 +5215,9 @@ string multiSlsDetector::getErrorMessage(int &critical){
multiMask = getErrorMask(); multiMask = getErrorMask();
if(multiMask){ if(multiMask){
if(multiMask & MULTI_DETECTORS_NOT_ADDED)
retval.append("Detectors not added:\n"+string(getNotAddedList())+string("\n"));
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) { for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
if (detectors[idet]) { if (detectors[idet]) {
//if the detector has error //if the detector has error
@ -5226,6 +5248,7 @@ string multiSlsDetector::getErrorMessage(int &critical){
int64_t multiSlsDetector::clearAllErrorMask(){ int64_t multiSlsDetector::clearAllErrorMask(){
clearErrorMask(); clearErrorMask();
clearNotAddedList();
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++)
if (detectors[idet]) if (detectors[idet])
detectors[idet]->clearErrorMask(); detectors[idet]->clearErrorMask();

View File

@ -795,10 +795,19 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC; descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
i++; i++;
descrToFuncMap[i].m_pFuncName="adc"; // descrToFuncMap[i].m_pFuncName="adc"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC; descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
i++; i++;
descrToFuncMap[i].m_pFuncName="temp_fpgafl"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
i++;
descrToFuncMap[i].m_pFuncName="temp_fpgafr"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
i++;
/* r/w timers */ /* r/w timers */
@ -3894,6 +3903,10 @@ string slsDetectorCommand::cmdADC(int narg, char *args[], int action) {
adc=TEMPERATURE_SODL; adc=TEMPERATURE_SODL;
else if (cmd=="temp_sodr") else if (cmd=="temp_sodr")
adc=TEMPERATURE_SODR; adc=TEMPERATURE_SODR;
else if (cmd=="temp_fpgafl")
adc=TEMPERATURE_FPGA2;
else if (cmd=="temp_fpgafr")
adc=TEMPERATURE_FPGA3;
else else
return string("cannot decode adc ")+cmd; return string("cannot decode adc ")+cmd;
@ -3926,6 +3939,8 @@ string slsDetectorCommand::helpADC(int narg, char *args[], int action) {
os << "temp_dcdc " << "Cannot be set" << std::endl; os << "temp_dcdc " << "Cannot be set" << std::endl;
os << "temp_sodl " << "Cannot be set" << std::endl; os << "temp_sodl " << "Cannot be set" << std::endl;
os << "temp_sodr " << "Cannot be set" << std::endl; os << "temp_sodr " << "Cannot be set" << std::endl;
os << "temp_fpgafl " << "Cannot be set" << std::endl;
os << "temp_fpgafr " << "Cannot be set" << std::endl;
} }
if (action==GET_ACTION || action==HELP_ACTION) { if (action==GET_ACTION || action==HELP_ACTION) {
os << "temp_adc " << "\t gets the temperature of the adc" << std::endl; os << "temp_adc " << "\t gets the temperature of the adc" << std::endl;
@ -3935,6 +3950,8 @@ string slsDetectorCommand::helpADC(int narg, char *args[], int action) {
os << "temp_dcdc " << "\t gets the temperature close to the dc dc converter" << std::endl; os << "temp_dcdc " << "\t gets the temperature close to the dc dc converter" << std::endl;
os << "temp_sodl " << "\t gets the temperature close to the left so-dimm memory" << std::endl; os << "temp_sodl " << "\t gets the temperature close to the left so-dimm memory" << std::endl;
os << "temp_sodr " << "\t gets the temperature close to the right so-dimm memory" << std::endl; os << "temp_sodr " << "\t gets the temperature close to the right so-dimm memory" << std::endl;
os << "temp_fpgafl " << "\t gets the temperature of the left front end board fpga" << std::endl;
os << "temp_fpgafr " << "\t gets the temperature of the left front end board fpga" << std::endl;
} }
return os.str(); return os.str();
} }

View File

@ -171,7 +171,9 @@ int slsDetectorUtils::acquire(int delflag){
//resets frames caught in receiver //resets frames caught in receiver
if(receiver){ if(receiver){
pthread_mutex_lock(&mg);
resetFramesCaught(); resetFramesCaught();
pthread_mutex_unlock(&mg);
} }
for(int im=0;im<nm;im++) { for(int im=0;im<nm;im++) {
@ -340,9 +342,9 @@ int slsDetectorUtils::acquire(int delflag){
//offline //offline
pthread_mutex_lock(&mg);
if(setReceiverOnline()==OFFLINE_FLAG){ if(setReceiverOnline()==OFFLINE_FLAG){
// wait until data processing thread has finished the data // wait until data processing thread has finished the data
pthread_mutex_lock(&mg);
acquiringDone = 1; acquiringDone = 1;
pthread_mutex_unlock(&mg); pthread_mutex_unlock(&mg);
if (*threadedProcessing) { if (*threadedProcessing) {
@ -372,7 +374,6 @@ int slsDetectorUtils::acquire(int delflag){
//online //online
else{ else{
pthread_mutex_lock(&mg);
acquiringDone = 1; acquiringDone = 1;
pthread_mutex_unlock(&mg); pthread_mutex_unlock(&mg);

View File

@ -512,12 +512,10 @@ void* postProcessing::processData(int delflag) {
usleep(20000); //20ms need this else connecting error to receiver (too fast) usleep(20000); //20ms need this else connecting error to receiver (too fast)
//get progress //get progress
if(setReceiverOnline() == ONLINE_FLAG){
pthread_mutex_lock(&mg); pthread_mutex_lock(&mg);
if(setReceiverOnline() == ONLINE_FLAG)
caught = getFramesCaughtByReceiver(); caught = getFramesCaughtByReceiver();
pthread_mutex_unlock(&mg); pthread_mutex_unlock(&mg);
}
//updating progress //updating progress
if(caught!= -1){ if(caught!= -1){
setCurrentProgress(caught); setCurrentProgress(caught);
@ -609,13 +607,12 @@ void* postProcessing::processData(int delflag) {
} }
//gui //gui
else{ else{
pthread_mutex_lock(&mg);
if(setReceiverOnline()==ONLINE_FLAG){ if(setReceiverOnline()==ONLINE_FLAG){
//get data //get data
strcpy(currentfName,""); strcpy(currentfName,"");
pthread_mutex_lock(&mg);
//int* receiverData = new int [getTotalNumberOfChannels()]; //int* receiverData = new int [getTotalNumberOfChannels()];
int* receiverData = readFrameFromReceiver(currentfName,currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex); int* receiverData = readFrameFromReceiver(currentfName,currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex);
pthread_mutex_unlock(&mg);
//if detector returned null //if detector returned null
if(setReceiverOnline()==OFFLINE_FLAG) if(setReceiverOnline()==OFFLINE_FLAG)
@ -659,6 +656,7 @@ void* postProcessing::processData(int delflag) {
} }
} }
} }
pthread_mutex_unlock(&mg);
} }
} }

View File

@ -1325,9 +1325,6 @@ int get_adc(int file_des) {
#endif #endif
switch (ind) { switch (ind) {
#ifdef EIGERD #ifdef EIGERD
case TEMPERATURE_FPGA:
iadc = TEMP_FPGA;
break;
case TEMPERATURE_FPGAEXT: case TEMPERATURE_FPGAEXT:
iadc = TEMP_FPGAEXT; iadc = TEMP_FPGAEXT;
break; break;
@ -1343,6 +1340,15 @@ int get_adc(int file_des) {
case TEMPERATURE_SODR: case TEMPERATURE_SODR:
iadc = TEMP_SODR; iadc = TEMP_SODR;
break; break;
case TEMPERATURE_FPGA:
iadc = TEMP_FPGA;
break;
case TEMPERATURE_FPGA2:
iadc = TEMP_FPGAFEBL;
break;
case TEMPERATURE_FPGA3:
iadc = TEMP_FPGAFEBR;
break;
#endif #endif
#ifdef GOTTHARDD #ifdef GOTTHARDD
case TEMPERATURE_FPGA: case TEMPERATURE_FPGA: