mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 22:40:02 +02:00
slsDetector/slsDetectorCommand.cpp
This commit is contained in:
commit
81d96a047d
@ -10,6 +10,7 @@
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
|
||||
@ -18,8 +19,12 @@ using namespace std;
|
||||
|
||||
|
||||
/** Error flags */
|
||||
/*Assumption: Only upto 63 detectors */
|
||||
#define CRITICAL_ERROR_MASK 0xFFFFFFFF
|
||||
|
||||
#define MULTI_DETECTORS_NOT_ADDED 0x8000000000000000ULL
|
||||
|
||||
|
||||
#define CANNOT_CONNECT_TO_DETECTOR 0x8000000000000000ULL
|
||||
#define CANNOT_CONNECT_TO_RECEIVER 0x4000000000000000ULL
|
||||
#define COULDNOT_SET_CONTROL_PORT 0x2000000000000000ULL
|
||||
@ -72,7 +77,9 @@ class errorDefs {
|
||||
public:
|
||||
|
||||
/** Constructor */
|
||||
errorDefs():errorMask(0){};
|
||||
errorDefs():errorMask(0){
|
||||
strcpy(notAddedList,"");
|
||||
};
|
||||
|
||||
/** Gets the error message
|
||||
* param errorMask error mask
|
||||
@ -229,12 +236,29 @@ public:
|
||||
*/
|
||||
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:
|
||||
|
||||
/** Error Mask */
|
||||
int64_t errorMask;
|
||||
|
||||
/** Detectors Not added List */
|
||||
char notAddedList[MAX_STR_LENGTH];
|
||||
};
|
||||
|
||||
#endif /* ERROR_DEFS_H_ */
|
||||
|
@ -362,6 +362,8 @@ enum dacIndex {
|
||||
TEMPERATURE_DCDC, /**< temperature sensor (close to DCDC) */
|
||||
TEMPERATURE_SODL, /**< temperature sensor (close to SODL) */
|
||||
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_B = 101, /**new chiptest board */
|
||||
V_POWER_C = 102, /**new chiptest board */
|
||||
|
@ -1676,3 +1676,22 @@ int Feb_Control_PrintCorrectedValues(){
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -192,4 +192,7 @@ int Feb_Control_GetModuleNumber();
|
||||
void Feb_Control_SetRateCorrectionVariable(int activate_rate_correction);
|
||||
int Feb_Control_PrintCorrectedValues();
|
||||
|
||||
int Feb_Control_GetLeftFPGATemp();
|
||||
int Feb_Control_GetRightFPGATemp();
|
||||
|
||||
#endif
|
||||
|
@ -95,6 +95,7 @@
|
||||
#define DAQ_STATUS_DAQ_RUNNING 0x01
|
||||
#define DAQ_DATA_COLLISION_ERROR 0x02
|
||||
|
||||
|
||||
#define DAQ_STATUS_CURRENT_M4 0x04
|
||||
#define DAQ_STATUS_CURRENT_M8 0x08
|
||||
#define DAQ_STATUS_CURRENT_M12 0x00 //in 12 bit mode both are cleared
|
||||
@ -149,3 +150,6 @@
|
||||
|
||||
#define FRAME_NUM_RESET_OFFSET 0xA0
|
||||
|
||||
//temp so far
|
||||
#define FEB_REG_STATUS 0xa
|
||||
|
||||
|
@ -449,6 +449,12 @@ int getADC(enum detAdcIndex ind, int imod){
|
||||
case TEMP_FPGA:
|
||||
retval=getBebFPGATemp()*1000;
|
||||
break;
|
||||
case TEMP_FPGAFEBL:
|
||||
retval=Feb_Control_GetLeftFPGATemp();
|
||||
break;
|
||||
case TEMP_FPGAFEBR:
|
||||
retval=Feb_Control_GetRightFPGATemp();
|
||||
break;
|
||||
case TEMP_FPGAEXT:
|
||||
case TEMP_10GE:
|
||||
case TEMP_DCDC:
|
||||
|
@ -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 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};
|
||||
|
||||
|
@ -694,6 +694,8 @@ int multiSlsDetector::addSlsDetector(const char *name, int pos) {
|
||||
t=slsDetector::getDetectorType(name, DEFAULT_PORTNO);
|
||||
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;
|
||||
setErrorMask(getErrorMask()|MULTI_DETECTORS_NOT_ADDED);
|
||||
appendNotAddedList(name);
|
||||
return -1;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
@ -4358,8 +4360,12 @@ int multiSlsDetector::readConfigurationFile(string const fname){
|
||||
setNumberOfModules(-1);
|
||||
getMaxNumberOfModules();
|
||||
|
||||
if (getErrorMask())
|
||||
if (getErrorMask()){
|
||||
int c;
|
||||
cprintf(RED,"\n----------------\n Error Messages\n----------------\n%s\n",
|
||||
getErrorMessage(c).c_str());
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
||||
@ -4689,7 +4695,8 @@ string multiSlsDetector::checkReceiverOnline() {
|
||||
string multiSlsDetector::setFilePath(string s) {
|
||||
|
||||
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++) {
|
||||
if (detectors[idet]) {
|
||||
@ -4703,7 +4710,7 @@ string multiSlsDetector::setFilePath(string s) {
|
||||
}
|
||||
}
|
||||
fileIO::setFilePath(ret);
|
||||
}
|
||||
//}
|
||||
|
||||
return fileIO::getFilePath();
|
||||
}
|
||||
@ -4910,19 +4917,30 @@ slsDetectorDefs::runStatus multiSlsDetector::getReceiverStatus(){
|
||||
|
||||
|
||||
int multiSlsDetector::getFramesCaughtByReceiver() {
|
||||
int ret=0,ret1=0;
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++)
|
||||
if (detectors[i]){
|
||||
ret1+=detectors[i]->getFramesCaughtByReceiver();
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
|
||||
}
|
||||
if(!thisMultiDetector->numberOfDetectors)
|
||||
return ret;
|
||||
ret=(int)(ret1/thisMultiDetector->numberOfDetectors);
|
||||
int ret=0,ret1=0;
|
||||
|
||||
return ret;
|
||||
|
||||
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++)
|
||||
if (detectors[i]){
|
||||
ret1+=detectors[i]->getFramesCaughtByReceiver();
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
|
||||
}
|
||||
if(!thisMultiDetector->numberOfDetectors)
|
||||
return ret;
|
||||
ret=(int)(ret1/thisMultiDetector->numberOfDetectors);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -4946,6 +4964,7 @@ int multiSlsDetector::getReceiverCurrentFrameIndex() {
|
||||
|
||||
int multiSlsDetector::resetFramesCaught() {
|
||||
int ret=-100, ret1;
|
||||
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++){
|
||||
if (detectors[i]){
|
||||
ret1=detectors[i]->resetFramesCaught();
|
||||
@ -5196,6 +5215,9 @@ string multiSlsDetector::getErrorMessage(int &critical){
|
||||
|
||||
multiMask = getErrorMask();
|
||||
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++) {
|
||||
if (detectors[idet]) {
|
||||
//if the detector has error
|
||||
@ -5226,6 +5248,7 @@ string multiSlsDetector::getErrorMessage(int &critical){
|
||||
|
||||
int64_t multiSlsDetector::clearAllErrorMask(){
|
||||
clearErrorMask();
|
||||
clearNotAddedList();
|
||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++)
|
||||
if (detectors[idet])
|
||||
detectors[idet]->clearErrorMask();
|
||||
|
@ -795,10 +795,19 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
|
||||
i++;
|
||||
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="adc"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
|
||||
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 */
|
||||
|
||||
@ -3894,6 +3903,10 @@ string slsDetectorCommand::cmdADC(int narg, char *args[], int action) {
|
||||
adc=TEMPERATURE_SODL;
|
||||
else if (cmd=="temp_sodr")
|
||||
adc=TEMPERATURE_SODR;
|
||||
else if (cmd=="temp_fpgafl")
|
||||
adc=TEMPERATURE_FPGA2;
|
||||
else if (cmd=="temp_fpgafr")
|
||||
adc=TEMPERATURE_FPGA3;
|
||||
else
|
||||
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_sodl " << "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) {
|
||||
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_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_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();
|
||||
}
|
||||
|
@ -171,7 +171,9 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
//resets frames caught in receiver
|
||||
if(receiver){
|
||||
pthread_mutex_lock(&mg);
|
||||
resetFramesCaught();
|
||||
pthread_mutex_unlock(&mg);
|
||||
}
|
||||
|
||||
for(int im=0;im<nm;im++) {
|
||||
@ -340,9 +342,9 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
|
||||
//offline
|
||||
pthread_mutex_lock(&mg);
|
||||
if(setReceiverOnline()==OFFLINE_FLAG){
|
||||
// wait until data processing thread has finished the data
|
||||
pthread_mutex_lock(&mg);
|
||||
acquiringDone = 1;
|
||||
pthread_mutex_unlock(&mg);
|
||||
if (*threadedProcessing) {
|
||||
@ -372,7 +374,6 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
//online
|
||||
else{
|
||||
pthread_mutex_lock(&mg);
|
||||
acquiringDone = 1;
|
||||
pthread_mutex_unlock(&mg);
|
||||
|
||||
|
@ -512,12 +512,10 @@ void* postProcessing::processData(int delflag) {
|
||||
usleep(20000); //20ms need this else connecting error to receiver (too fast)
|
||||
|
||||
//get progress
|
||||
if(setReceiverOnline() == ONLINE_FLAG){
|
||||
pthread_mutex_lock(&mg);
|
||||
pthread_mutex_lock(&mg);
|
||||
if(setReceiverOnline() == ONLINE_FLAG)
|
||||
caught = getFramesCaughtByReceiver();
|
||||
pthread_mutex_unlock(&mg);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&mg);
|
||||
//updating progress
|
||||
if(caught!= -1){
|
||||
setCurrentProgress(caught);
|
||||
@ -609,13 +607,12 @@ void* postProcessing::processData(int delflag) {
|
||||
}
|
||||
//gui
|
||||
else{
|
||||
pthread_mutex_lock(&mg);
|
||||
if(setReceiverOnline()==ONLINE_FLAG){
|
||||
//get data
|
||||
strcpy(currentfName,"");
|
||||
pthread_mutex_lock(&mg);
|
||||
//int* receiverData = new int [getTotalNumberOfChannels()];
|
||||
int* receiverData = readFrameFromReceiver(currentfName,currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex);
|
||||
pthread_mutex_unlock(&mg);
|
||||
|
||||
//if detector returned null
|
||||
if(setReceiverOnline()==OFFLINE_FLAG)
|
||||
@ -659,6 +656,7 @@ void* postProcessing::processData(int delflag) {
|
||||
}
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&mg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1325,9 +1325,6 @@ int get_adc(int file_des) {
|
||||
#endif
|
||||
switch (ind) {
|
||||
#ifdef EIGERD
|
||||
case TEMPERATURE_FPGA:
|
||||
iadc = TEMP_FPGA;
|
||||
break;
|
||||
case TEMPERATURE_FPGAEXT:
|
||||
iadc = TEMP_FPGAEXT;
|
||||
break;
|
||||
@ -1343,6 +1340,15 @@ int get_adc(int file_des) {
|
||||
case TEMPERATURE_SODR:
|
||||
iadc = TEMP_SODR;
|
||||
break;
|
||||
case TEMPERATURE_FPGA:
|
||||
iadc = TEMP_FPGA;
|
||||
break;
|
||||
case TEMPERATURE_FPGA2:
|
||||
iadc = TEMP_FPGAFEBL;
|
||||
break;
|
||||
case TEMPERATURE_FPGA3:
|
||||
iadc = TEMP_FPGAFEBR;
|
||||
break;
|
||||
#endif
|
||||
#ifdef GOTTHARDD
|
||||
case TEMPERATURE_FPGA:
|
||||
|
Loading…
x
Reference in New Issue
Block a user