Merge branch '3.0.1' into condatest

This commit is contained in:
Erik Frojdh 2018-02-08 10:36:06 +01:00
commit 23c5a73285
37 changed files with 1433 additions and 293 deletions

View File

@ -374,7 +374,7 @@ void qTabAdvanced::SetOutputFile(){
//gets the clean absolute path //gets the clean absolute path
dirPath = dir.absoluteFilePath(dirPath); dirPath = dir.absoluteFilePath(dirPath);
dirPath = dir.cleanPath(dirPath); dirPath = dir.cleanPath(dirPath);
QString trimdir = QString(myDet->getSettingsFile()).section('/',0,-2,QString::SectionIncludeLeadingSep); QString trimdir = QString::fromStdString(myDet->getSettingsFile()).section('/',0,-2,QString::SectionIncludeLeadingSep);
trimdir = dir.absoluteFilePath(trimdir); trimdir = dir.absoluteFilePath(trimdir);
trimdir = dir.cleanPath(trimdir); trimdir = dir.cleanPath(trimdir);
if(!dirPath.compare(trimdir)){ if(!dirPath.compare(trimdir)){

View File

@ -316,6 +316,8 @@ int receiveData(int file_des, void* buf,int length, intType itype){
int sendDataOnly(int file_des, void* buf,int length) { int sendDataOnly(int file_des, void* buf,int length) {
if (!length)
return 0;
int ret = write(file_des, buf, length); //value of -1 is other end socket crash as sigpipe is ignored int ret = write(file_des, buf, length); //value of -1 is other end socket crash as sigpipe is ignored
if (ret < 0) cprintf(BG_RED, "Error writing to socket. Possible socket crash\n"); if (ret < 0) cprintf(BG_RED, "Error writing to socket. Possible socket crash\n");
return ret; return ret;
@ -415,19 +417,14 @@ int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll) {
ts+=sendData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32); ts+=sendData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32);
ts+=sendData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32); ts+=sendData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32);
ts+=sendData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32); ts+=sendData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32);
ts+=sendData(file_des,myMod->dacs,sizeof(myMod->ndac),OTHER);
if(sendAll){
ts+=sendData(file_des,myMod->adcs,sizeof(myMod->nadc),OTHER);
}else{
uint32_t k = 0;
ts+=sendData(file_des,&k,sizeof(k),OTHER);
}
/*some detectors dont require sending all trimbits etc.*/ #ifdef MYTHEND
if(sendAll){ ts+=sendData(file_des,myMod->dacs,sizeof(myMod->ndac),OTHER);
ts+=sendData(file_des,myMod->chipregs,sizeof(myMod->nchip),OTHER); ts+=sendData(file_des,myMod->adcs,sizeof(myMod->nadc),OTHER);
ts+=sendData(file_des,myMod->chanregs,sizeof(myMod->nchan),OTHER); ts+=sendData(file_des,myMod->chipregs,sizeof(myMod->nchip),OTHER);
ts+=sendData(file_des,myMod->chanregs,sizeof(myMod->nchan),OTHER);
} }
#endif
ts+=sendData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER); ts+=sendData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER);
ts+=sendData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER); ts+=sendData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER);
@ -437,16 +434,11 @@ int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll) {
ts+= sendData(file_des,myMod->dacs,sizeof(dacs_t)*nDacs,INT32); ts+= sendData(file_des,myMod->dacs,sizeof(dacs_t)*nDacs,INT32);
#ifdef VERBOSE #ifdef VERBOSE
printf("dacs %d of size %d sent\n",myMod->module, ts); printf("dacs %d of size %d sent\n",myMod->module, ts);
int idac;
for (idac=0; idac< nDacs; idac++) for (idac=0; idac< nDacs; idac++)
printf("dac %d is %d\n",idac,(int)myMod->dacs[idac]); printf("dac %d is %d\n",idac,(int)myMod->dacs[idac]);
#endif #endif
if(sendAll) ts+= sendData(file_des,myMod->adcs,sizeof(dacs_t)*nAdcs,INT32);
ts+= sendData(file_des,myMod->adcs,sizeof(dacs_t)*nAdcs,INT32);
else {
uint32_t k = 0;
ts+= sendData(file_des,&k,sizeof(k),INT32);
}
#ifdef VERBOSE #ifdef VERBOSE
printf("adcs %d of size %d sent\n",myMod->module, ts); printf("adcs %d of size %d sent\n",myMod->module, ts);
#endif #endif
@ -547,18 +539,12 @@ int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveA
ts+=receiveData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32); ts+=receiveData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32);
ts+=receiveData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32); ts+=receiveData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32);
ts+=receiveData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32); ts+=receiveData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32);
#ifdef MYTHEND
ts+=receiveData(file_des,myMod->dacs,sizeof(myMod->ndac),INT32); ts+=receiveData(file_des,myMod->dacs,sizeof(myMod->ndac),INT32);
if(receiveAll){ // temporary fix ts+=receiveData(file_des,myMod->adcs,sizeof(myMod->nadc),INT32);
ts+=receiveData(file_des,myMod->adcs,sizeof(myMod->nadc),INT32); ts+=receiveData(file_des,myMod->chipregs,sizeof(myMod->nchip),INT32);
}else { ts+=receiveData(file_des,myMod->chanregs,sizeof(myMod->nchan),INT32);
uint32_t k;ts+=receiveData(file_des,&k,sizeof(k),INT32);//nadc is 0 #endif
}
/*some detectors dont require sending all trimbits etc.*/
if(receiveAll){
ts+=receiveData(file_des,myMod->chipregs,sizeof(myMod->nchip),INT32);
ts+=receiveData(file_des,myMod->chanregs,sizeof(myMod->nchan),INT32);
}
ts+=receiveData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER); ts+=receiveData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER);
ts+=receiveData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER); ts+=receiveData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER);

View File

@ -50,9 +50,9 @@ using namespace std;
#define PREPARE_ACQUISITION 0x0000100000000000ULL #define PREPARE_ACQUISITION 0x0000100000000000ULL
#define CLEANUP_ACQUISITION 0x0000080000000000ULL #define CLEANUP_ACQUISITION 0x0000080000000000ULL
#define REGISER_WRITE_READ 0x0000040000000000ULL #define REGISER_WRITE_READ 0x0000040000000000ULL
// 0xFFFFFFF000000000ULL // 0xFFFFFF0000000000ULL
// 0x0000000FFFFFFFFFULL // 0x000000FFFFFFFFFFULL
#define COULDNOT_SET_NETWORK_PARAMETER 0x0000000000000001ULL #define COULDNOT_SET_NETWORK_PARAMETER 0x0000000000000001ULL
#define COULDNOT_SET_ROI 0x0000000000000002ULL #define COULDNOT_SET_ROI 0x0000000000000002ULL
#define RECEIVER_READ_FREQUENCY 0x0000000000000004ULL #define RECEIVER_READ_FREQUENCY 0x0000000000000004ULL
@ -88,8 +88,9 @@ using namespace std;
#define RECEIVER_SUBF_TIME_NOT_SET 0x0000000100000000ULL #define RECEIVER_SUBF_TIME_NOT_SET 0x0000000100000000ULL
#define RECEIVER_SILENT_MODE_NOT_SET 0x0000000200000000ULL #define RECEIVER_SILENT_MODE_NOT_SET 0x0000000200000000ULL
#define RESTREAM_STOP_FROM_RECEIVER 0x0000000400000000ULL #define RESTREAM_STOP_FROM_RECEIVER 0x0000000400000000ULL
#define TEMPERATURE_CONTROL 0x0000000800000000ULL
// 0x0000000FFFFFFFFFULL #define AUTO_COMP_DISABLE 0x0000001000000000ULL
// 0x000000FFFFFFFFFFULL
/** @short class returning all error messages for error mask */ /** @short class returning all error messages for error mask */
class errorDefs { class errorDefs {
@ -277,9 +278,11 @@ public:
if(slsErrorMask&RESTREAM_STOP_FROM_RECEIVER) if(slsErrorMask&RESTREAM_STOP_FROM_RECEIVER)
retval.append("Could not restream stop from receiver.\n"); retval.append("Could not restream stop from receiver.\n");
if(slsErrorMask&TEMPERATURE_CONTROL)
retval.append("Could not set/get threshold temperature, temp control or temp event.\n");
if(slsErrorMask&AUTO_COMP_DISABLE)
retval.append("Could not set/get auto comparator disable\n");
//------------------------------------------------------ length of message //------------------------------------------------------ length of message

View File

@ -112,6 +112,12 @@ enum detFuncs{
F_ACTIVATE, /** < activate */ F_ACTIVATE, /** < activate */
F_PREPARE_ACQUISITION, /** < prepare acquisition */ F_PREPARE_ACQUISITION, /** < prepare acquisition */
F_CLEANUP_ACQUISITION, /** < clean up after acquisition */ F_CLEANUP_ACQUISITION, /** < clean up after acquisition */
F_THRESHOLD_TEMP, /** < set threshold temperature */
F_TEMP_CONTROL, /** < set temperature control */
F_TEMP_EVENT, /** < set temperature event */
F_AUTO_COMP_DISABLE, /** < auto comp disable mode */
/* Always append functions hereafter!!! */ /* Always append functions hereafter!!! */
/* Always append functions before!!! */ /* Always append functions before!!! */

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: a161a9aad8ac38a79ba43340344a3c923cea85f7 Repsitory UUID: ecf1e9fac1aaa7034e462638bd01965df892726a
Revision: 307 Revision: 313
Branch: 3.0.1 Branch: 3.0.1
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 1578 Last Changed Rev: 3348
Last Changed Date: 2017-10-11 12:45:54.679255119 +0200 ./Makefile.virtual Last Changed Date: 2018-02-07 11:04:32.000000002 +0100 ./FebRegisterDefs.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "a161a9aad8ac38a79ba43340344a3c923cea85f7" #define GITREPUUID "ecf1e9fac1aaa7034e462638bd01965df892726a"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x1578 #define GITREV 0x3348
#define GITDATE 0x20171011 #define GITDATE 0x20180207
#define GITBRANCH "blabla" #define GITBRANCH "3.0.1"

View File

@ -68,7 +68,7 @@ int normal = 0;
/* basic tests */ /* basic tests */
void checkFirmwareCompatibility(){ void checkFirmwareCompatibility(int flag){
uint32_t ipadd = getDetectorIP(); uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC(); uint64_t macadd = getDetectorMAC();
int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION); int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION);
@ -134,10 +134,7 @@ int64_t getDetectorId(enum idMode arg){
case SOFTWARE_FIRMWARE_API_VERSION: case SOFTWARE_FIRMWARE_API_VERSION:
return (int64_t)Beb_GetFirmwareSoftwareAPIVersion(); return (int64_t)Beb_GetFirmwareSoftwareAPIVersion();
case DETECTOR_SOFTWARE_VERSION: case DETECTOR_SOFTWARE_VERSION:
retval= GITREV; return (GITDATE & 0xFFFFFF);
retval= (retval <<32) | GITDATE;
//cprintf(BLUE,"git date:%x, git rev:%x\n",GITDATE,GITREV);
break;
default: default:
break; break;
} }
@ -831,23 +828,6 @@ enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){
/* configure mac */ /* configure mac */
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival) { int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival) {
if (sourcemac != getDetectorMAC()){
printf("*************************************************\n");
printf("WARNING: actual detector mac address %llx does not match the one from client %llx\n",getDetectorMAC(),sourcemac);
sourcemac = getDetectorMAC();
printf("WARNING: Matched detectormac to the hardware mac now\n");
printf("*************************************************\n");
}
//only for 1Gbe
if(!send_to_ten_gig){
if (sourceip != getDetectorIP()){
printf("*************************************************\n");
printf("WARNING: actual detector ip address %x does not match the one from client %x\n",getDetectorIP(),sourceip);
sourceip = getDetectorIP();
printf("WARNING: Matched detector ip to the hardware ip now\n");
printf("*************************************************\n");
}
}
char src_mac[50], src_ip[50],dst_mac[50], dst_ip[50]; char src_mac[50], src_ip[50],dst_mac[50], dst_ip[50];
int src_port = 0xE185; int src_port = 0xE185;

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/gotthardDetectorServer Path: slsDetectorsPackage/slsDetectorSoftware/gotthardDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 0649626842512b772ab660c36dece505f3244aee Repsitory UUID: e6bd874a88493557fc5127d4a1686832299aaf06
Revision: 212 Revision: 217
Branch: 3.0.1 Branch: 3.0.1
Last Changed Author: Dhanya_Maliakal Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3318 Last Changed Rev: 3346
Last Changed Date: 2017-12-19 17:45:11.000000002 +0100 ./server_funcs.c Last Changed Date: 2018-02-07 09:09:56.000000002 +0100 ./server_funcs.c

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "0649626842512b772ab660c36dece505f3244aee" #define GITREPUUID "e6bd874a88493557fc5127d4a1686832299aaf06"
#define GITAUTH "Dhanya_Maliakal" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3318 #define GITREV 0x3346
#define GITDATE 0x20171219 #define GITDATE 0x20180207
#define GITBRANCH "3.0.1" #define GITBRANCH "3.0.1"

View File

@ -588,13 +588,9 @@ int get_id(int file_des) {
retval=getDetectorNumber(); retval=getDetectorNumber();
break; break;
case DETECTOR_FIRMWARE_VERSION: case DETECTOR_FIRMWARE_VERSION:
retval=getFirmwareSVNVersion(); return (getFirmwareVersion() & 0xFFFFFF);
retval=(retval <<32) | getFirmwareVersion();
break;
case DETECTOR_SOFTWARE_VERSION: case DETECTOR_SOFTWARE_VERSION:
retval= GITREV; return (GITDATE & 0xFFFFFF);
retval= (retval <<32) | GITDATE;
break;
default: default:
printf("Required unknown id %d \n", arg); printf("Required unknown id %d \n", arg);
ret=FAIL; ret=FAIL;

View File

@ -62,6 +62,14 @@
#define HARDWARE_VERSION_NUM_MSK (0x0000003F << HARDWARE_VERSION_NUM_OFST) //Not used in software #define HARDWARE_VERSION_NUM_MSK (0x0000003F << HARDWARE_VERSION_NUM_OFST) //Not used in software
/* API Version Register */
#define API_VERSION_REG (0x0F << 11)
#define API_VERSION_OFST (0)
#define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST)
#define API_VERSION_DETECTOR_TYPE_OFST (24) //Not used in software
#define API_VERSION_DETECTOR_TYPE_MSK (0x000000FF << API_VERSION_DETECTOR_TYPE_OFST) //Not used in software
/* Time from Start 64 bit register */ /* Time from Start 64 bit register */
#define TIME_FROM_START_LSB_REG (0x10 << 11) #define TIME_FROM_START_LSB_REG (0x10 << 11)
#define TIME_FROM_START_MSB_REG (0x11 << 11) #define TIME_FROM_START_MSB_REG (0x11 << 11)
@ -188,7 +196,7 @@
#define CONFIG_TDMA_ENABLE_VAL ((0x1 << CONFIG_TDMA_OFST) & CONFIG_TDMA_MSK) #define CONFIG_TDMA_ENABLE_VAL ((0x1 << CONFIG_TDMA_OFST) & CONFIG_TDMA_MSK)
#define CONFIG_TDMA_TIMESLOT_OFST (25) #define CONFIG_TDMA_TIMESLOT_OFST (25)
#define CONFIG_TDMA_TIMESLOT_MSK (0x0000001F << CONFIG_TDMA_TIMESLOT_OFST) #define CONFIG_TDMA_TIMESLOT_MSK (0x0000001F << CONFIG_TDMA_TIMESLOT_OFST)
#define CONFIG_TDMA_TIMESLOT_0_VAL ((0x0 << CONFIG_TDMA_TIMESLOT_OFST) & CONFIG_TDMA_TIMESLOT_MSK)
/* External Signal Register */ /* External Signal Register */
#define EXT_SIGNAL_REG (0x4E << 11) #define EXT_SIGNAL_REG (0x4E << 11)
@ -211,6 +219,8 @@
#define CONTROL_DDR3_MEM_RST_MSK (0x00000001 << CONTROL_DDR3_MEM_RST_OFST) //only PHY, not DDR3 PLL ,Not used in software #define CONTROL_DDR3_MEM_RST_MSK (0x00000001 << CONTROL_DDR3_MEM_RST_OFST) //only PHY, not DDR3 PLL ,Not used in software
#define CONTROL_ACQ_FIFO_CLR_OFST (14) #define CONTROL_ACQ_FIFO_CLR_OFST (14)
#define CONTROL_ACQ_FIFO_CLR_MSK (0x00000001 << CONTROL_ACQ_FIFO_CLR_OFST) #define CONTROL_ACQ_FIFO_CLR_MSK (0x00000001 << CONTROL_ACQ_FIFO_CLR_OFST)
#define CONTROL_STORAGE_CELL_NUM_OFST (16)
#define CONTROL_STORAGE_CELL_NUM_MSK (0x0000000F << CONTROL_STORAGE_CELL_NUM_OFST)
/* Reconfiguratble PLL Paramater Register */ /* Reconfiguratble PLL Paramater Register */
#define PLL_PARAM_REG (0x50 << 11) #define PLL_PARAM_REG (0x50 << 11)
@ -278,7 +288,13 @@
#define SAMPLE_DECMT_FACTOR_4_VAL ((0x2 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK) #define SAMPLE_DECMT_FACTOR_4_VAL ((0x2 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK)
/** Vref Comp Mod Register */ /** Vref Comp Mod Register */
#define VREF_COMP_MOD_REG (0x5C << 11) //Not used in software, TBD in firmware #define VREF_COMP_MOD_REG (0x5C << 11)
#define VREF_COMP_MOD_OFST (0)
#define VREF_COMP_MOD_MSK (0x00000FFF << VREF_COMP_MOD_OFST)
#define VREF_COMP_MOD_ENABLE_OFST (31)
#define VREF_COMP_MOD_ENABLE_MSK (0x00000FFF << VREF_COMP_MOD_ENABLE_OFST)
/** DAQ Register */ /** DAQ Register */
#define DAQ_REG (0x5D << 11) //TBD in firmware #define DAQ_REG (0x5D << 11) //TBD in firmware
@ -288,6 +304,21 @@
#define CHIP_POWER_ENABLE_OFST (0) #define CHIP_POWER_ENABLE_OFST (0)
#define CHIP_POWER_ENABLE_MSK (0x00000001 << CHIP_POWER_ENABLE_OFST) #define CHIP_POWER_ENABLE_MSK (0x00000001 << CHIP_POWER_ENABLE_OFST)
#define CHIP_POWER_STATUS_OFST (1)
#define CHIP_POWER_STATUS_MSK (0x00000001 << CHIP_POWER_STATUS_OFST)
/** Temperature Control Register */
#define TEMP_CTRL_REG (0x5F << 11)
#define TEMP_CTRL_PROTCT_THRSHLD_OFST (0)
#define TEMP_CTRL_PROTCT_THRSHLD_MSK (0x000007FF << TEMP_CTRL_PROTCT_THRSHLD_OFST)
#define TEMP_CTRL_PROTCT_ENABLE_OFST (16)
#define TEMP_CTRL_PROTCT_ENABLE_MSK (0x00000001 << TEMP_CTRL_PROTCT_ENABLE_OFST)
#define TEMP_CTRL_OVR_TMP_EVNT_OFST (31)
#define TEMP_CTRL_OVR_TMP_EVNT_MSK (0x00000001 << TEMP_CTRL_OVR_TMP_EVNT_OFST)
#define TEMP_CTRL_CLR_OVR_TMP_EVNT_VAL ((0x1 << TEMP_CTRL_OVR_TMP_EVNT_OFST) & TEMP_CTRL_OVR_TMP_EVNT_MSK)
/* Set Delay 64 bit register */ /* Set Delay 64 bit register */
#define SET_DELAY_LSB_REG (0x60 << 11) #define SET_DELAY_LSB_REG (0x60 << 11)
@ -309,6 +340,10 @@
#define SET_EXPTIME_LSB_REG (0x68 << 11) #define SET_EXPTIME_LSB_REG (0x68 << 11)
#define SET_EXPTIME_MSB_REG (0x69 << 11) #define SET_EXPTIME_MSB_REG (0x69 << 11)
/* Trigger Delay 32 bit register */
#define SET_TRIGGER_DELAY_LSB_REG (0x70 << 11)
#define SET_TRIGGER_DELAY_MSB_REG (0x71 << 11)
/* Module Coordinates Register 0 */ /* Module Coordinates Register 0 */
#define COORD_0 (0x7C << 11) #define COORD_0 (0x7C << 11)
@ -323,6 +358,14 @@
#define COORD_0_Z_OFST (0) #define COORD_0_Z_OFST (0)
#define COORD_0_Z_MSK (0x0000FFFF << COORD_0_Z_OFST) #define COORD_0_Z_MSK (0x0000FFFF << COORD_0_Z_OFST)
/* ASIC Control Register */
#define ASIC_CTRL_REG (0x7F)
#define ASIC_CTRL_PRCHRG_TMR_OFST (0)
#define ASIC_CTRL_PRCHRG_TMR_MSK (0x000000FF << ASIC_CTRL_PRCHRG_TMR_OFST)
#define ASIC_CTRL_DS_TMR_OFST (8)
#define ASIC_CTRL_DS_TMR_MSK (0x000000FF << ASIC_CTRL_DS_TMR_OFST)
#endif //REGISTERS_G_H #endif //REGISTERS_G_H

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 3c1eb747d1930d6d38030a5a607f72d3b58a7a21 Repsitory UUID: e6bd874a88493557fc5127d4a1686832299aaf06
Revision: 90 Revision: 108
Branch: 3.0 Branch: 3.0.1
Last Changed Author: Dhanya_Maliakal Last Changed Author: Dhanya_Thattil
Last Changed Rev: 1549 Last Changed Rev: 3346
Last Changed Date: 2017-10-25 16:48:35.000000002 +0200 ./RegisterDefs.h Last Changed Date: 2018-02-05 11:53:33.000000002 +0100 ./RegisterDefs.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "3c1eb747d1930d6d38030a5a607f72d3b58a7a21" #define GITREPUUID "e6bd874a88493557fc5127d4a1686832299aaf06"
#define GITAUTH "Dhanya_Maliakal" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x1549 #define GITREV 0x3346
#define GITDATE 0x20171025 #define GITDATE 0x20180205
#define GITBRANCH "blabla" #define GITBRANCH "3.0.1"

View File

@ -25,11 +25,17 @@ int32_t clkPhase[2] = {0, 0};
/* basic tests */ /* basic tests */
void checkFirmwareCompatibility() { void checkFirmwareCompatibility(int flag) {
defineGPIOpins(); defineGPIOpins();
resetFPGA(); resetFPGA();
if ((mapCSP0() == FAIL) || (checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL)) { if (mapCSP0() == FAIL) {
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
exit(EXIT_FAILURE);
}
// does check only if flag is 0 (by default), set by command line
if ((!flag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) {
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n"); cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -40,7 +46,9 @@ void checkFirmwareCompatibility() {
uint64_t macadd = getDetectorMAC(); uint64_t macadd = getDetectorMAC();
int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION); int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION);
int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION); int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION);
//int64_t sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION); int64_t sw_fw_apiversion = 0;
if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION);
cprintf(BLUE,"\n\n" cprintf(BLUE,"\n\n"
"********************************************************\n" "********************************************************\n"
"****************** Jungfrau Server *********************\n" "****************** Jungfrau Server *********************\n"
@ -49,46 +57,49 @@ void checkFirmwareCompatibility() {
"Hardware Serial Nr:\t\t 0x%x\n" "Hardware Serial Nr:\t\t 0x%x\n"
"Detector IP Addr:\t\t 0x%x\n" "Detector IP Addr:\t\t 0x%x\n"
"Detector MAC Addr:\t\t 0x%llx\n" "Detector MAC Addr:\t\t 0x%llx\n\n"
"Firmware Version:\t\t 0x%llx\n" "Firmware Version:\t\t 0x%llx\n"
"Software Version:\t\t 0x%llx\n" "Software Version:\t\t 0x%llx\n"
//"F/w-S/w API Version:\t\t 0x%llx\n" "F/w-S/w API Version:\t\t 0x%llx\n"
//"Required Firmware Version:\t 0x%x\n" "Required Firmware Version:\t 0x%x\n"
"\n" "\n"
"********************************************************\n", "********************************************************\n",
hversion, hsnumber, hversion, hsnumber,
ipadd, macadd, ipadd, macadd,
fwversion, swversion fwversion, swversion,
//, sw_fw_apiversion, REQUIRED_FIRMWARE_VERSION sw_fw_apiversion, REQRD_FRMWR_VRSN
); );
// return if flag is not zero, debug mode
if (flag)
return;
/*
* printf("Testing firmware capability... ");
//cant read versions //cant read versions
printf("Testing Firmware-software compatibility ...\n");
if(!fwversion || !sw_fw_apiversion){ if(!fwversion || !sw_fw_apiversion){
cprintf(RED,"FATAL ERROR: Cant read versions from FPGA. Please update firmware\n"); cprintf(RED,"FATAL ERROR: Cant read versions from FPGA. Please update firmware\n");
cprintf(RED,"Exiting Server. Goodbye!\n\n"); cprintf(RED,"Exiting Server. Goodbye!\n\n");
exit(-1); exit(EXIT_FAILURE);
} }
//check for API compatibility - old server //check for API compatibility - old server
if(sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION){ if(sw_fw_apiversion > REQRD_FRMWR_VRSN){
cprintf(RED,"FATAL ERROR: This software version is incompatible.\n" cprintf(RED,"FATAL ERROR: This software version is incompatible.\n"
"Please update it to be compatible with this firmware\n\n"); "Please update it to be compatible with this firmware\n\n");
cprintf(RED,"Exiting Server. Goodbye!\n\n"); cprintf(RED,"Exiting Server. Goodbye!\n\n");
exit(-1); exit(EXIT_FAILURE);
} }
//check for firmware compatibility - old firmware //check for firmware compatibility - old firmware
if( REQUIRED_FIRMWARE_VERSION > fwversion){ if( REQRD_FRMWR_VRSN > fwversion){
cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n" cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n"
"Please update it to v%d to be compatible with this server\n\n", REQUIRED_FIRMWARE_VERSION); "Please update it to v%d to be compatible with this server\n\n", REQRD_FRMWR_VRSN);
cprintf(RED,"Exiting Server. Goodbye!\n\n"); cprintf(RED,"Exiting Server. Goodbye!\n\n");
exit(-1); exit(EXIT_FAILURE);
} }
*/ printf("Compatibility - success\n");
} }
@ -170,28 +181,26 @@ int64_t getDetectorId(enum idMode arg){
switch(arg){ switch(arg){
case DETECTOR_SERIAL_NUMBER: case DETECTOR_SERIAL_NUMBER:
retval = getDetectorNumber();// or getDetectorMAC() return getDetectorNumber();// or getDetectorMAC()
break;
case DETECTOR_FIRMWARE_VERSION: case DETECTOR_FIRMWARE_VERSION:
retval = getFirmwareVersion(); return getFirmwareVersion();
break; case SOFTWARE_FIRMWARE_API_VERSION:
//case SOFTWARE_FIRMWARE_API_VERSION: return getFirmwareAPIVersion();
//return GetFirmwareSoftwareAPIVersion();
case DETECTOR_SOFTWARE_VERSION: case DETECTOR_SOFTWARE_VERSION:
retval= GITREV; return (GITDATE & 0xFFFFFF);
retval= (retval <<32) | GITDATE;
break;
default: default:
break; return retval;
} }
return retval;
} }
u_int64_t getFirmwareVersion() { u_int64_t getFirmwareVersion() {
return ((bus_r(FPGA_VERSION_REG) & BOARD_REVISION_MSK) >> BOARD_REVISION_OFST); return ((bus_r(FPGA_VERSION_REG) & BOARD_REVISION_MSK) >> BOARD_REVISION_OFST);
} }
u_int64_t getFirmwareAPIVersion() {
return ((bus_r(API_VERSION_REG) & API_VERSION_MSK) >> API_VERSION_OFST);
}
u_int16_t getHardwareVersionNumber() { u_int16_t getHardwareVersionNumber() {
return ((bus_r(MOD_SERIAL_NUM_REG) & HARDWARE_VERSION_NUM_MSK) >> HARDWARE_VERSION_NUM_OFST); return ((bus_r(MOD_SERIAL_NUM_REG) & HARDWARE_VERSION_NUM_MSK) >> HARDWARE_VERSION_NUM_OFST);
} }
@ -254,7 +263,7 @@ u_int32_t getDetectorIP(){
/* initialization */ /* initialization */
void initControlServer(){ void initControlServer(){
clkPhase[0] = 0; clkPhase[1] = 0;
setupDetector(); setupDetector();
printf("\n"); printf("\n");
} }
@ -353,6 +362,12 @@ void setupDetector() {
/*setSpeed(CLOCK_DIVIDER, HALF_SPEED); depends if all the previous stuff works*/ /*setSpeed(CLOCK_DIVIDER, HALF_SPEED); depends if all the previous stuff works*/
setTiming(DEFAULT_TIMING_MODE); setTiming(DEFAULT_TIMING_MODE);
setHighVoltage(DEFAULT_HIGH_VOLTAGE); setHighVoltage(DEFAULT_HIGH_VOLTAGE);
/* temporary set up until new firmware fixes bug */
// set temperature threshold
setThresholdTemperature(DEFAULT_TMP_THRSHLD);
// reset temp event
setTemperatureEvent(0);
} }
@ -374,9 +389,30 @@ int powerChip (int on){
bus_w(CHIP_POWER_REG, bus_r(CHIP_POWER_REG) & ~CHIP_POWER_ENABLE_MSK); bus_w(CHIP_POWER_REG, bus_r(CHIP_POWER_REG) & ~CHIP_POWER_ENABLE_MSK);
} }
} }
return bus_r(CHIP_POWER_REG);
return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_ENABLE_MSK) >> CHIP_POWER_ENABLE_OFST);
/* temporary setup until new firmware fixes bug */
//return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_STATUS_MSK) >> CHIP_POWER_STATUS_OFST);
} }
int autoCompDisable(int on) {
if(on != -1){
if(on){
cprintf(BLUE, "\n*** Auto comp disable mode: enabling ***\n");
bus_w(VREF_COMP_MOD_REG, bus_r(VREF_COMP_MOD_REG) | VREF_COMP_MOD_ENABLE_MSK);
}
else{
cprintf(BLUE, "\n*** Auto comp disable mode: disabling *** \n");
bus_w(VREF_COMP_MOD_REG, bus_r(VREF_COMP_MOD_REG) & ~VREF_COMP_MOD_ENABLE_MSK);
}
}
return (bus_r(VREF_COMP_MOD_REG) & VREF_COMP_MOD_ENABLE_MSK);
}
void cleanFifos() { void cleanFifos() {
printf("\nClearing Acquisition Fifos\n"); printf("\nClearing Acquisition Fifos\n");
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_ACQ_FIFO_CLR_MSK); bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_ACQ_FIFO_CLR_MSK);
@ -449,33 +485,65 @@ int setSpeed(enum speedVariable arg, int val) {
// setting // setting
if(val >= 0) { if(val >= 0) {
switch(val){ // stop state machine if running
if(runBusy())
stopStateMachine();
// stop state machine if running uint32_t txndelay_msk = 0;
if(runBusy())
stopStateMachine(); switch(val){
// todo in firmware, for now setting half speed // todo in firmware, for now setting half speed
case FULL_SPEED://40 case FULL_SPEED://40
printf("\nSetting Half Speed (20 MHz):\n"); printf("\nSetting Half Speed (20 MHz):\n");
printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_HALF_SPEED); bus_w(SAMPLE_REG, SAMPLE_ADC_HALF_SPEED);
printf("Setting Config Reg to 0x%x\n", CONFIG_HALF_SPEED); bus_w(CONFIG_REG, CONFIG_HALF_SPEED); printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_HALF_SPEED);
printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_HALF_SPEED_VAL); bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL); bus_w(SAMPLE_REG, SAMPLE_ADC_HALF_SPEED);
printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED); adcPhase(ADC_PHASE_HALF_SPEED);
txndelay_msk = (bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK); // read config tdma timeslot value
printf("Setting Config Reg to 0x%x\n", CONFIG_HALF_SPEED | txndelay_msk);
bus_w(CONFIG_REG, CONFIG_HALF_SPEED | txndelay_msk);
printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_HALF_SPEED_VAL);
bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL);
printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED);
adcPhase(ADC_PHASE_HALF_SPEED);
break; break;
case HALF_SPEED: case HALF_SPEED:
printf("\nSetting Half Speed (20 MHz):\n"); printf("\nSetting Half Speed (20 MHz):\n");
printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_HALF_SPEED); bus_w(SAMPLE_REG, SAMPLE_ADC_HALF_SPEED);
printf("Setting Config Reg to 0x%x\n", CONFIG_HALF_SPEED); bus_w(CONFIG_REG, CONFIG_HALF_SPEED); printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_HALF_SPEED);
printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_HALF_SPEED_VAL); bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL); bus_w(SAMPLE_REG, SAMPLE_ADC_HALF_SPEED);
printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED); adcPhase(ADC_PHASE_HALF_SPEED);
txndelay_msk = (bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK); // read config tdma timeslot value
printf("Setting Config Reg to 0x%x\n", CONFIG_HALF_SPEED | txndelay_msk);
bus_w(CONFIG_REG, CONFIG_HALF_SPEED | txndelay_msk);
printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_HALF_SPEED_VAL);
bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL);
printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED);
adcPhase(ADC_PHASE_HALF_SPEED);
break; break;
case QUARTER_SPEED: case QUARTER_SPEED:
printf("\nSetting Half Speed (10 MHz):\n"); printf("\nSetting Half Speed (10 MHz):\n");
printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_QUARTER_SPEED); bus_w(SAMPLE_REG, SAMPLE_ADC_QUARTER_SPEED);
printf("Setting Config Reg to 0x%x\n", CONFIG_QUARTER_SPEED); bus_w(CONFIG_REG, CONFIG_QUARTER_SPEED); printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_QUARTER_SPEED);
printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_QUARTER_SPEED_VAL); bus_w(ADC_OFST_REG, ADC_OFST_QUARTER_SPEED_VAL); bus_w(SAMPLE_REG, SAMPLE_ADC_QUARTER_SPEED);
printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_QUARTER_SPEED); adcPhase(ADC_PHASE_QUARTER_SPEED);
txndelay_msk = (bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK); // read config tdma timeslot value
printf("Setting Config Reg to 0x%x\n", CONFIG_QUARTER_SPEED | txndelay_msk);
bus_w(CONFIG_REG, CONFIG_QUARTER_SPEED | txndelay_msk);
printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_QUARTER_SPEED_VAL);
bus_w(ADC_OFST_REG, ADC_OFST_QUARTER_SPEED_VAL);
printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_QUARTER_SPEED);
adcPhase(ADC_PHASE_QUARTER_SPEED);
break; break;
} }
printf("\n"); printf("\n");
@ -537,7 +605,7 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
printf("\nSetting delay to %lldns\n", (long long int)val); printf("\nSetting delay to %lldns\n", (long long int)val);
val *= (1E-3 * CLK_SYNC); val *= (1E-3 * CLK_SYNC);
} }
retval = set64BitReg(val, SET_DELAY_LSB_REG, SET_DELAY_MSB_REG) / (1E-3 * CLK_SYNC); retval = set64BitReg(val, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG) / (1E-3 * CLK_SYNC);
printf("Getting delay: %lldns\n", (long long int)retval); printf("Getting delay: %lldns\n", (long long int)retval);
break; break;
@ -829,6 +897,11 @@ void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]){
DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST); DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST);
dacValues[ind] = dacval; dacValues[ind] = dacval;
if (ind == VREF_COMP) {
bus_w (VREF_COMP_MOD_REG, (bus_r(VREF_COMP_MOD_REG) &~ (VREF_COMP_MOD_MSK)) // reset
| ((val << VREF_COMP_MOD_OFST) & VREF_COMP_MOD_MSK)); // or it with value
}
} }
printf("Getting DAC %d : ",ind); printf("Getting DAC %d : ",ind);
@ -1105,6 +1178,82 @@ void configurePll() {
int setThresholdTemperature(int val) {
if (val >= 0) {
printf("\nThreshold Temperature: %d\n", val);
val *= (10.0/625.0);
#ifdef VERBOSE
printf("Converted Threshold Temperature: %d\n", val);
#endif
bus_w(TEMP_CTRL_REG, (bus_r(TEMP_CTRL_REG) &~(TEMP_CTRL_PROTCT_THRSHLD_MSK) &~(TEMP_CTRL_OVR_TMP_EVNT_MSK))
| (((val << TEMP_CTRL_PROTCT_THRSHLD_OFST) & TEMP_CTRL_PROTCT_THRSHLD_MSK)));
#ifdef VERBOSE
printf("Converted Threshold Temperature set to %d\n", ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_THRSHLD_MSK) >> TEMP_CTRL_PROTCT_THRSHLD_OFST));
#endif
}
uint32_t temp = ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_THRSHLD_MSK) >> TEMP_CTRL_PROTCT_THRSHLD_OFST);
// conversion
temp *= (625.0/10.0);
printf("Threshold Temperature %f °C\n",(double)temp/1000.00);
return temp;
}
int setTemperatureControl(int val) {
if (val >= 0) {
// binary value
if (val > 0 ) val = 1;
printf("\nTemperature control: %d\n", val);
bus_w(TEMP_CTRL_REG, (bus_r(TEMP_CTRL_REG) &~(TEMP_CTRL_PROTCT_ENABLE_MSK) &~(TEMP_CTRL_OVR_TMP_EVNT_MSK))
| (((val << TEMP_CTRL_PROTCT_ENABLE_OFST) & TEMP_CTRL_PROTCT_ENABLE_MSK)));
#ifdef VERBOSE
printf("Temperature control set to %d\n", ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_ENABLE_MSK) >> TEMP_CTRL_PROTCT_ENABLE_OFST));
#endif
}
return ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_ENABLE_MSK) >> TEMP_CTRL_PROTCT_ENABLE_OFST);
}
int setTemperatureEvent(int val) {
if (val >= 0) {
// set bit to clear it
val = 1;
printf("\nTemperature Event: %d\n", val);
bus_w(TEMP_CTRL_REG, (bus_r(TEMP_CTRL_REG) &~TEMP_CTRL_OVR_TMP_EVNT_MSK)
| (((val << TEMP_CTRL_OVR_TMP_EVNT_OFST) & TEMP_CTRL_OVR_TMP_EVNT_MSK)));
#ifdef VERBOSE
printf("Temperature Event set to %d\n", ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_OVR_TMP_EVNT_MSK) >> TEMP_CTRL_OVR_TMP_EVNT_OFST));
#endif
}
return ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_OVR_TMP_EVNT_MSK) >> TEMP_CTRL_OVR_TMP_EVNT_OFST);
}
int setNetworkParameter(enum NETWORKINDEX mode, int value) {
if (mode != TXN_FRAME)
return -1;
if (value >= 0) {
printf("\nSetting transmission delay: %d\n", value);
bus_w(CONFIG_REG, (bus_r(CONFIG_REG) &~CONFIG_TDMA_TIMESLOT_MSK)
| (((value << CONFIG_TDMA_TIMESLOT_OFST) & CONFIG_TDMA_TIMESLOT_MSK)));
#ifdef VERBOSE
printf("Transmission delay set to %d\n", ((bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK) >> CONFIG_TDMA_TIMESLOT_OFST));
#endif
}
return ((bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK) >> CONFIG_TDMA_TIMESLOT_OFST);
}
/* aquisition */ /* aquisition */

View File

@ -8,7 +8,8 @@
#define GOODBYE (-200) #define GOODBYE (-200)
//#define REQUIRED_FIRMWARE_VERSION 16 #define MIN_REQRD_VRSN_T_RD_API 0x171113
#define REQRD_FRMWR_VRSN 0x171113
/* Struct Definitions */ /* Struct Definitions */
@ -48,13 +49,14 @@ enum DACINDEX {VB_COMP, VDD_PROT, VIN_COM, VREF_PRECH, VB_PIXBUF, VB_DS, VREF
0x1f00, /* FORCESWITCHG1 */ \ 0x1f00, /* FORCESWITCHG1 */ \
0x3f00 /* FORCESWITCHG2 */ \ 0x3f00 /* FORCESWITCHG2 */ \
}; };
#define DEFAULT_SETT_NAMES { "Dynamic Gain", /* DYNAMICGAIN */ \ #define DEFAULT_SETT_NAMES { "Dynamic Gain", /* DYNAMICGAIN */ \
"Dynamic High Gain 0", /* DYNAMICHG0 */ \ "Dynamic High Gain 0", /* DYNAMICHG0 */ \
"Fix Gain 1", /* FIXGAIN1 */ \ "Fix Gain 1", /* FIXGAIN1 */ \
"Fix Gain 2", /* FIXGAIN2 */ \ "Fix Gain 2", /* FIXGAIN2 */ \
"Force Switch Gain 1", /* FORCESWITCHG1*/ \ "Force Switch Gain 1", /* FORCESWITCHG1*/ \
"Force Switch Gain 2" /* FORCESWITCHG2*/ \ "Force Switch Gain 2" /* FORCESWITCHG2*/ \
}; };
enum NETWORKINDEX { TXN_FRAME };
@ -84,16 +86,19 @@ enum DACINDEX {VB_COMP, VDD_PROT, VIN_COM, VREF_PRECH, VB_PIXBUF, VB_DS, VREF
#define DEFAULT_TIMING_MODE (AUTO_TIMING) #define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_SETTINGS (DYNAMICGAIN) #define DEFAULT_SETTINGS (DYNAMICGAIN)
#define DEFAULT_TX_UDP_PORT (0x7e9a) #define DEFAULT_TX_UDP_PORT (0x7e9a)
#define DEFAULT_TMP_THRSHLD (65*1000) //milli degree Celsius
/* Defines in the Firmware */ /* Defines in the Firmware */
#define FIX_PATT_VAL (0xACDC2014) #define FIX_PATT_VAL (0xACDC2014)
#define ADC_PORT_INVERT_VAL (0x453b2a9c) #define ADC_PORT_INVERT_VAL (0x453b2a9c)
#define MAX_TIMESLOT_VAL (0x1F)
#define MAX_THRESHOLD_TEMP_VAL (127999) //millidegrees
#define SAMPLE_ADC_HALF_SPEED (SAMPLE_DECMT_FACTOR_2_VAL + SAMPLE_DGTL_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + SAMPLE_ADC_SAMPLE_0_VAL) /* 0x1000 */ #define SAMPLE_ADC_HALF_SPEED (SAMPLE_DECMT_FACTOR_2_VAL + SAMPLE_DGTL_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + SAMPLE_ADC_SAMPLE_0_VAL) /* 0x1000 */
#define SAMPLE_ADC_QUARTER_SPEED (SAMPLE_DECMT_FACTOR_4_VAL + SAMPLE_DGTL_SAMPLE_8_VAL + SAMPLE_ADC_DECMT_FACTOR_1_VAL + SAMPLE_ADC_SAMPLE_0_VAL) /* 0x2810 */ #define SAMPLE_ADC_QUARTER_SPEED (SAMPLE_DECMT_FACTOR_4_VAL + SAMPLE_DGTL_SAMPLE_8_VAL + SAMPLE_ADC_DECMT_FACTOR_1_VAL + SAMPLE_ADC_SAMPLE_0_VAL) /* 0x2810 */
#define CONFIG_HALF_SPEED (CONFIG_TDMA_TIMESLOT_0_VAL + CONFIG_TDMA_DISABLE_VAL + CONFIG_HALF_SPEED_20MHZ_VAL + CONFIG_MODE_1_X_10GBE_VAL) #define CONFIG_HALF_SPEED (CONFIG_TDMA_DISABLE_VAL + CONFIG_HALF_SPEED_20MHZ_VAL + CONFIG_MODE_1_X_10GBE_VAL)
#define CONFIG_QUARTER_SPEED (CONFIG_TDMA_TIMESLOT_0_VAL + CONFIG_TDMA_DISABLE_VAL + CONFIG_QUARTER_SPEED_10MHZ_VAL + CONFIG_MODE_1_X_10GBE_VAL) #define CONFIG_QUARTER_SPEED (CONFIG_TDMA_DISABLE_VAL + CONFIG_QUARTER_SPEED_10MHZ_VAL + CONFIG_MODE_1_X_10GBE_VAL)
#define ADC_OFST_HALF_SPEED_VAL (0x20) //adc pipeline #define ADC_OFST_HALF_SPEED_VAL (0x20) //adc pipeline
#define ADC_OFST_QUARTER_SPEED_VAL (0x0f) #define ADC_OFST_QUARTER_SPEED_VAL (0x0f)
#define ADC_PHASE_HALF_SPEED (0x41) #define ADC_PHASE_HALF_SPEED (0x41)

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/moenchDetectorServer Path: slsDetectorsPackage/slsDetectorSoftware/moenchDetectorServer
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 9f1b82c18ab0893d65bfadeb646b8ea244614632 Repsitory UUID: e6bd874a88493557fc5127d4a1686832299aaf06
Revision: 83 Revision: 85
Branch: developer Branch: 3.0.1
Last Changed Author: Dhanya_Maliakal Last Changed Author: Dhanya_Thattil
Last Changed Rev: 1443 Last Changed Rev: 3346
Last Changed Date: 2017-07-10 11:03:27.000000002 +0200 ./Makefile Last Changed Date: 2018-02-07 09:14:36.000000002 +0100 ./server_funcs.c

View File

@ -1,6 +1,6 @@
#define GITURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "9f1b82c18ab0893d65bfadeb646b8ea244614632" #define GITREPUUID "e6bd874a88493557fc5127d4a1686832299aaf06"
#define GITAUTH "Dhanya_Maliakal" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x1443 #define GITREV 0x3346
#define GITDATE 0x20170710 #define GITDATE 0x20180207
#define GITBRANCH "blabla" #define GITBRANCH "3.0.1"

View File

@ -593,13 +593,9 @@ int get_id(int file_des) {
retval=getDetectorNumber(); retval=getDetectorNumber();
break; break;
case DETECTOR_FIRMWARE_VERSION: case DETECTOR_FIRMWARE_VERSION:
retval=getFirmwareSVNVersion(); return (getFirmwareVersion() & 0xFFFFFF);
retval=(retval <<32) | getFirmwareVersion();
break;
case DETECTOR_SOFTWARE_VERSION: case DETECTOR_SOFTWARE_VERSION:
retval= GITREV; return (GITDATE & 0xFFFFFF);
retval= (retval <<32) | GITDATE;
break;
default: default:
printf("Required unknown id %d \n", arg); printf("Required unknown id %d \n", arg);
ret=FAIL; ret=FAIL;

View File

@ -3331,6 +3331,173 @@ dacs_t multiSlsDetector::getADC(dacIndex idac, int imod) {
return ret; return ret;
} }
int multiSlsDetector::setThresholdTemperature(int val, int imod) {
int ret = -100;
// single
{
int id=-1, im=-1;
if (decodeNMod(imod, id, im)>=0) {
if(detectors[id]){
ret = detectors[id]->setThresholdTemperature(val, im);
if(detectors[id]->getErrorMask())
setErrorMask(getErrorMask()|(1<<id));
return ret;
}
return -1;
}
}
// multi
if(!threadpool){
cout << "Error in creating threadpool. Exiting" << endl;
return -1;
}
int posmin=0, posmax=thisMultiDetector->numberOfDetectors;
int* iret[posmax-posmin];
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
iret[idet]= new dacs_t(-1);
Task* task = new Task(new func2_t<int,int,int>(&slsDetector::setThresholdTemperature,
detectors[idet], val, imod, iret[idet]));
threadpool->add_task(task);
}
}
threadpool->startExecuting();
threadpool->wait_for_tasks_to_complete();
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
if(iret[idet] != NULL){
if (ret==-100)
ret=*iret[idet];
else if (ret!=*iret[idet])
ret=-1;
delete iret[idet];
}else ret=-1;
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
}
}
return ret;
}
int multiSlsDetector::setTemperatureControl(int val, int imod) {
int ret = -100;
// single
{
int id=-1, im=-1;
if (decodeNMod(imod, id, im)>=0) {
if(detectors[id]){
ret = detectors[id]->setTemperatureControl(val, im);
if(detectors[id]->getErrorMask())
setErrorMask(getErrorMask()|(1<<id));
return ret;
}
return -1;
}
}
// multi
if(!threadpool){
cout << "Error in creating threadpool. Exiting" << endl;
return -1;
}
int posmin=0, posmax=thisMultiDetector->numberOfDetectors;
int* iret[posmax-posmin];
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
iret[idet]= new dacs_t(-1);
Task* task = new Task(new func2_t<int,int,int>(&slsDetector::setTemperatureControl,
detectors[idet], val, imod, iret[idet]));
threadpool->add_task(task);
}
}
threadpool->startExecuting();
threadpool->wait_for_tasks_to_complete();
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
if(iret[idet] != NULL){
if (ret==-100)
ret=*iret[idet];
else if (ret!=*iret[idet])
ret=-1;
delete iret[idet];
}else ret=-1;
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
}
}
return ret;
}
int multiSlsDetector::setTemperatureEvent(int val, int imod) {
int ret = -100;
// single
{
int id=-1, im=-1;
if (decodeNMod(imod, id, im)>=0) {
if(detectors[id]){
ret = detectors[id]->setTemperatureEvent(val, im);
if(detectors[id]->getErrorMask())
setErrorMask(getErrorMask()|(1<<id));
return ret;
}
return -1;
}
}
// multi
if(!threadpool){
cout << "Error in creating threadpool. Exiting" << endl;
return -1;
}
int posmin=0, posmax=thisMultiDetector->numberOfDetectors;
int* iret[posmax-posmin];
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
iret[idet]= new dacs_t(-1);
Task* task = new Task(new func2_t<int,int,int>(&slsDetector::setTemperatureEvent,
detectors[idet], val, imod, iret[idet]));
threadpool->add_task(task);
}
}
threadpool->startExecuting();
threadpool->wait_for_tasks_to_complete();
for(int idet=posmin; idet<posmax; ++idet){
if(detectors[idet]){
if(iret[idet] != NULL){
if (ret==-100)
ret=*iret[idet];
else if (ret!=*iret[idet])
ret=-1;
delete iret[idet];
}else ret=-1;
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
}
}
return ret;
}
int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) { int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) {
int ret, ret1=-100; int ret, ret1=-100;
int id=-1, im=-1; int id=-1, im=-1;
@ -3900,7 +4067,7 @@ slsDetectorDefs::externalSignalFlag multiSlsDetector::setExternalSignalFlags(ext
const char * multiSlsDetector::getSettingsFile() { string multiSlsDetector::getSettingsFile() {
string s0="", s1="",s ; string s0="", s1="",s ;
@ -3921,9 +4088,9 @@ const char * multiSlsDetector::getSettingsFile() {
} }
} }
if (s1=="bad") if (s1=="bad")
return s0.c_str(); return s0;
else else
return s1.c_str(); return s1;
} }
@ -4061,40 +4228,59 @@ int multiSlsDetector::setCounterBit(int i){
int multiSlsDetector::setDynamicRange(int p) { int multiSlsDetector::setDynamicRange(int p) {
int ret=-100, ret1; int ret=-100;
thisMultiDetector->dataBytes=0; thisMultiDetector->dataBytes=0;
thisMultiDetector->numberOfChannels=0; thisMultiDetector->numberOfChannels=0;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) {
if (detectors[idet]) {
ret1=detectors[idet]->setDynamicRange(p);
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
thisMultiDetector->dataBytes+=detectors[idet]->getDataBytes();
// cout << "db " << idet << " " << detectors[idet]->getDataBytes() << endl;
thisMultiDetector->numberOfChannels+=detectors[idet]->getTotalNumberOfChannels();
if (ret==-100)
ret=ret1;
else if (ret!=ret1)
ret=-1;
}
}
//for usability for the user
if (getDetectorsType() == EIGER){
if(p == 32){
std::cout << "Setting Clock to Quarter Speed to cope with Dynamic Range of 32" << std::endl;
setSpeed(CLOCK_DIVIDER,2);
}
else if(p == 16){
std::cout << "Setting Clock to Half Speed for Dynamic Range of 16" << std::endl;
setSpeed(CLOCK_DIVIDER,1);
}
}
return ret;
if(!threadpool){
cout << "Error in creating threadpool. Exiting" << endl;
return -1;
}else{
//return storage values
int* iret[thisMultiDetector->numberOfDetectors];
for(int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet){
if(detectors[idet]){
iret[idet]= new int(-1);
Task* task = new Task(new func1_t<int,int>(&slsDetector::setDynamicRange,
detectors[idet],p,iret[idet]));
threadpool->add_task(task);
}
}
threadpool->startExecuting();
threadpool->wait_for_tasks_to_complete();
for(int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet){
if(detectors[idet]){
if(iret[idet] != NULL){
thisMultiDetector->dataBytes+=detectors[idet]->getDataBytes();
thisMultiDetector->numberOfChannels+=detectors[idet]->getTotalNumberOfChannels();
if (ret==-100)
ret=*iret[idet];
else if (ret!=*iret[idet])
ret=-1;
delete iret[idet];
}else ret=-1;
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
}
}
}
//for usability for the user
if (getDetectorsType() == EIGER){
if(p == 32){
std::cout << "Setting Clock to Quarter Speed to cope with Dynamic Range of 32" << std::endl;
setSpeed(CLOCK_DIVIDER,2);
}
else if(p == 16){
std::cout << "Setting Clock to Half Speed for Dynamic Range of 16" << std::endl;
setSpeed(CLOCK_DIVIDER,1);
}
}
return ret;
} }
int multiSlsDetector::getMaxMods() { int multiSlsDetector::getMaxMods() {
@ -4428,6 +4614,22 @@ int multiSlsDetector::powerChip(int ival){
} }
int multiSlsDetector::setAutoComparatorDisableMode(int ival) {
int ret=OK, ret1=OK;
for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
if (detectors[i]) {
ret=detectors[i]->setAutoComparatorDisableMode(ival);
if(detectors[i]->getErrorMask())
setErrorMask(getErrorMask()|(1<<i));
if (ret==FAIL)
ret1=FAIL;
}
}
return ret1;
}
int multiSlsDetector::loadSettingsFile(string fname, int imod) { int multiSlsDetector::loadSettingsFile(string fname, int imod) {
int ret=OK; int ret=OK;

View File

@ -505,7 +505,7 @@ class multiSlsDetector : public slsDetectorUtils {
int64_t getId(idMode mode, int imod=0); int64_t getId(idMode mode, int imod=0);
int digitalTest(digitalTestMode mode, int imod=0); int digitalTest(digitalTestMode mode, int imod=0);
int executeTrimming(trimMode mode, int par1, int par2, int imod=-1); int executeTrimming(trimMode mode, int par1, int par2, int imod=-1);
const char *getSettingsFile(); string getSettingsFile();
int decodeNMod(int i, int &idet, int &imod); int decodeNMod(int i, int &idet, int &imod);
@ -527,6 +527,12 @@ class multiSlsDetector : public slsDetectorUtils {
*/ */
int powerChip(int ival= -1); int powerChip(int ival= -1);
/** automatic comparator disable for Jungfrau only
\param ival on is 1, off is 0, -1 to get
\returns OK or FAIL
*/
int setAutoComparatorDisableMode(int ival= -1);
/** loads the modules settings/trimbits reading from a file - file name extension is automatically generated! */ /** loads the modules settings/trimbits reading from a file - file name extension is automatically generated! */
int loadSettingsFile(string fname, int nmod=-1); int loadSettingsFile(string fname, int nmod=-1);
@ -948,6 +954,31 @@ class multiSlsDetector : public slsDetectorUtils {
\returns current DAC value (temperature for eiger and jungfrau in millidegrees) \returns current DAC value (temperature for eiger and jungfrau in millidegrees)
*/ */
dacs_t getADC(dacIndex index, int imod=-1); dacs_t getADC(dacIndex index, int imod=-1);
/**
set/gets threshold temperature (Jungfrau only)
\param val value in millidegrees, -1 gets
\param imod module number, -1 is all
\returns threshold temperature in millidegrees
*/
int setThresholdTemperature(int val=-1, int imod=-1);
/**
enables/disables temperature control (Jungfrau only)
\param val value, -1 gets
\param imod module number, -1 is all
\returns temperature control enable
*/
int setTemperatureControl(int val=-1, int imod=-1);
/**
Resets/ gets over-temperature event (Jungfrau only)
\param val value, -1 gets
\param imod module number, -1 is all
\returns over-temperature event
*/
int setTemperatureEvent(int val=-1, int imod=-1);
/** /**
configure channel configure channel
\param reg channel register \param reg channel register

View File

@ -1151,18 +1151,19 @@ int slsDetector::sendModule(sls_detector_module *myMod) {
ts+=controlSocket->SendDataOnly(&(myMod->ndac),sizeof(myMod->ndac)); ts+=controlSocket->SendDataOnly(&(myMod->ndac),sizeof(myMod->ndac));
ts+=controlSocket->SendDataOnly(&(myMod->nadc),sizeof(myMod->nadc)); ts+=controlSocket->SendDataOnly(&(myMod->nadc),sizeof(myMod->nadc));
ts+=controlSocket->SendDataOnly(&(myMod->reg),sizeof(myMod->reg)); ts+=controlSocket->SendDataOnly(&(myMod->reg),sizeof(myMod->reg));
ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(myMod->ndac)); // only for sending structures like in old mythen server
ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(myMod->nadc)); if (thisDetector->myDetectorType == MYTHEN) {
ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(myMod->ndac));
if(thisDetector->myDetectorType != JUNGFRAU){ ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(myMod->nadc));
ts+=controlSocket->SendDataOnly(myMod->chipregs,sizeof(myMod->nchip)); ts+=controlSocket->SendDataOnly(myMod->chipregs,sizeof(myMod->nchip));
ts+=controlSocket->SendDataOnly(myMod->chanregs,sizeof(myMod->nchan)); ts+=controlSocket->SendDataOnly(myMod->chanregs,sizeof(myMod->nchan));
} }
ts+=controlSocket->SendDataOnly(&(myMod->gain),sizeof(myMod->gain)); ts+=controlSocket->SendDataOnly(&(myMod->gain),sizeof(myMod->gain));
ts+=controlSocket->SendDataOnly(&(myMod->offset), sizeof(myMod->offset)); ts+=controlSocket->SendDataOnly(&(myMod->offset), sizeof(myMod->offset));
// actual data to the pointers
ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(dacs_t)*(myMod->ndac)); ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(dacs_t)*(myMod->ndac));
ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(dacs_t)*(myMod->nadc)); ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(dacs_t)*(myMod->nadc));
if(thisDetector->myDetectorType != JUNGFRAU){ if(thisDetector->myDetectorType != JUNGFRAU){
ts+=controlSocket->SendDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip)); ts+=controlSocket->SendDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip));
ts+=controlSocket->SendDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan)); ts+=controlSocket->SendDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan));
@ -1219,13 +1220,14 @@ int slsDetector::receiveModule(sls_detector_module* myMod) {
ts+=controlSocket->ReceiveDataOnly(&(myMod->ndac),sizeof(myMod->ndac)); ts+=controlSocket->ReceiveDataOnly(&(myMod->ndac),sizeof(myMod->ndac));
ts+=controlSocket->ReceiveDataOnly(&(myMod->nadc),sizeof(myMod->nadc)); ts+=controlSocket->ReceiveDataOnly(&(myMod->nadc),sizeof(myMod->nadc));
ts+=controlSocket->ReceiveDataOnly(&(myMod->reg),sizeof(myMod->reg)); ts+=controlSocket->ReceiveDataOnly(&(myMod->reg),sizeof(myMod->reg));
ts+=controlSocket->ReceiveDataOnly(myMod->dacs,sizeof(myMod->ndac)); // only for sending structures like in old mythen server
ts+=controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(myMod->nadc)); if (thisDetector->myDetectorType == MYTHEN) {
ts+=controlSocket->ReceiveDataOnly(myMod->dacs,sizeof(myMod->ndac));
if(thisDetector->myDetectorType != JUNGFRAU){ ts+=controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(myMod->nadc));
ts+=controlSocket->ReceiveDataOnly(myMod->chipregs,sizeof(myMod->nchip)); ts+=controlSocket->ReceiveDataOnly(myMod->chipregs,sizeof(myMod->nchip));
ts+=controlSocket->ReceiveDataOnly(myMod->chanregs,sizeof(myMod->nchan)); ts+=controlSocket->ReceiveDataOnly(myMod->chanregs,sizeof(myMod->nchan));
} }
ts+=controlSocket->ReceiveDataOnly(&(myMod->gain), sizeof(myMod->gain)); ts+=controlSocket->ReceiveDataOnly(&(myMod->gain), sizeof(myMod->gain));
ts+=controlSocket->ReceiveDataOnly(&(myMod->offset), sizeof(myMod->offset)); ts+=controlSocket->ReceiveDataOnly(&(myMod->offset), sizeof(myMod->offset));
@ -2606,6 +2608,129 @@ dacs_t slsDetector::getADC(dacIndex index, int imod){
}; };
int slsDetector::setThresholdTemperature(int val, int imod) {
int retval = -1;
int fnum = F_THRESHOLD_TEMP;
int ret = FAIL;
char mess[MAX_STR_LENGTH] = "";
int arg[2];
arg[0]=val;
arg[1]=imod;
#ifdef VERBOSE
std::cout<< std::endl;
std::cout<< "Setting/Getting Threshold Temperature to "<< val << " of module " << imod << std::endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
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));
#ifdef VERBOSE
std::cout<< "Threshold Temperature returned "<< retval << std::endl;
#endif
} else {
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL));
}
disconnectStop();
}
}
return retval;
}
int slsDetector::setTemperatureControl(int val, int imod) {
int retval = -1;
int fnum = F_TEMP_CONTROL;
int ret = FAIL;
char mess[MAX_STR_LENGTH] = "";
int arg[2];
arg[0]=val;
arg[1]=imod;
#ifdef VERBOSE
std::cout<< std::endl;
std::cout<< "Setting/Getting Threshold Temperature to "<< val << " of module " << imod << std::endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
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));
#ifdef VERBOSE
std::cout<< "Threshold Temperature returned "<< retval << std::endl;
#endif
} else {
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL));
}
disconnectStop();
}
}
return retval;
}
int slsDetector::setTemperatureEvent(int val, int imod) {
int retval = -1;
int fnum = F_TEMP_EVENT;
int ret = FAIL;
char mess[MAX_STR_LENGTH] = "";
int arg[2];
arg[0]=val;
arg[1]=imod;
#ifdef VERBOSE
std::cout<< std::endl;
std::cout<< "Setting/Getting Threshold Temperature to "<< val << " of module " << imod << std::endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
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));
#ifdef VERBOSE
std::cout<< "Threshold Temperature returned "<< retval << std::endl;
#endif
} else {
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL));
}
disconnectStop();
}
}
return retval;
}
/* /*
configure single channel configure single channel
enum channelRegisterBit { enum channelRegisterBit {
@ -3738,11 +3863,11 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
std::cout<< thisDetector->settingsDir<<endl<< thisDetector->calDir <<endl; std::cout<< thisDetector->settingsDir<<endl<< thisDetector->calDir <<endl;
#endif #endif
break; break;
case MOENCH: case MYTHEN:
case GOTTHARD: ostfn << thisDetector->settingsDir << ssettings <<"/noise.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
case PROPIX: oscfn << thisDetector->calDir << ssettings << "/calibration.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
case JUNGFRAU: break;
case JUNGFRAUCTB: default:
//settings is saved in myMod.reg //settings is saved in myMod.reg
myMod->reg=thisDetector->currentSettings; myMod->reg=thisDetector->currentSettings;
ostfn << thisDetector->settingsDir << ssettings <<"/settings.sn";// << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10); ostfn << thisDetector->settingsDir << ssettings <<"/settings.sn";// << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
@ -3751,9 +3876,6 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
std::cout<< thisDetector->settingsDir<<endl<< thisDetector->calDir <<endl; std::cout<< thisDetector->settingsDir<<endl<< thisDetector->calDir <<endl;
#endif #endif
break; break;
default:
ostfn << thisDetector->settingsDir << ssettings <<"/noise.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
oscfn << thisDetector->calDir << ssettings << "/calibration.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
} }
@ -3766,17 +3888,13 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
//if it didnt open, try default settings file //if it didnt open, try default settings file
ostringstream ostfn_default; ostringstream ostfn_default;
switch(thisDetector->myDetectorType){ switch(thisDetector->myDetectorType){
case MOENCH: case EIGER:
case GOTTHARD: case MYTHEN:
case PROPIX: ostfn_default << thisDetector->settingsDir << ssettings << ssettings << ".trim";
case JUNGFRAU: break;
case JUNGFRAUCTB: default:
ostfn_default << thisDetector->settingsDir << ssettings << ssettings << ".settings"; ostfn_default << thisDetector->settingsDir << ssettings << ssettings << ".settings";
break; break;
case EIGER:
default:
ostfn_default << thisDetector->settingsDir << ssettings << ssettings << ".trim";
break;
} }
settingsfname=ostfn_default.str(); settingsfname=ostfn_default.str();
#ifdef VERBOSE #ifdef VERBOSE
@ -6583,8 +6701,41 @@ int slsDetector::configureMAC(){
std::cout<< "Detector returned error: " << mess << std::endl; std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC)); setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
} }
else else {
controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
if (thisDetector->myDetectorType == EIGER) {
//rewrite detectormac, detector ip
char arg[2][50];
memset(arg,0,sizeof(arg));
uint64_t idetectormac = 0;
uint32_t idetectorip = 0;
controlSocket->ReceiveDataOnly(arg,sizeof(arg));
sscanf(arg[0], "%lx", &idetectormac);
sscanf(arg[1], "%x", &idetectorip);
sprintf(arg[0],"%02x:%02x:%02x:%02x:%02x:%02x",
(unsigned int)((idetectormac>>40)&0xFF),
(unsigned int)((idetectormac>>32)&0xFF),
(unsigned int)((idetectormac>>24)&0xFF),
(unsigned int)((idetectormac>>16)&0xFF),
(unsigned int)((idetectormac>>8)&0xFF),
(unsigned int)((idetectormac>>0)&0xFF));
sprintf(arg[1],"%d.%d.%d.%d",
(idetectorip>>24)&0xff,
(idetectorip>>16)&0xff,
(idetectorip>>8)&0xff,
(idetectorip)&0xff);
if (strcasecmp(arg[0],thisDetector->detectorMAC)) {
memset(thisDetector->detectorMAC, 0, MAX_STR_LENGTH);
strcpy(thisDetector->detectorMAC, arg[0]);
cprintf(RESET,"%d: Detector MAC updated to %s\n", detId, thisDetector->detectorMAC);
}
if (strcasecmp(arg[1],thisDetector->detectorIP)) {
memset(thisDetector->detectorIP, 0, MAX_STR_LENGTH);
strcpy(thisDetector->detectorIP, arg[1]);
cprintf(RESET,"%d: Detector IP updated to %s\n", detId, thisDetector->detectorIP);
}
}
}
disconnectControl(); disconnectControl();
if (ret==FORCE_UPDATE) if (ret==FORCE_UPDATE)
updateDetector(); updateDetector();
@ -7390,6 +7541,43 @@ int slsDetector::powerChip(int ival){
return retval; return retval;
} }
int slsDetector::setAutoComparatorDisableMode(int ival){
int ret=FAIL;
int fnum=F_AUTO_COMP_DISABLE;
char mess[MAX_STR_LENGTH]="";
int retval=-1;
if(thisDetector->myDetectorType != JUNGFRAU){
std::cout << "Not implemented for this detector" << std::endl;
return FAIL;
}
#ifdef VERBOSE
std::cout<< "Enabling/disabling Auto comp disable mode " << endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(&ival,sizeof(ival));
//check opening error
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL) {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(AUTO_COMP_DISABLE));
}else
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
disconnectControl();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
return retval;
}
int slsDetector::loadSettingsFile(string fname, int imod) { int slsDetector::loadSettingsFile(string fname, int imod) {
sls_detector_module *myMod=NULL; sls_detector_module *myMod=NULL;
@ -7407,15 +7595,21 @@ int slsDetector::loadSettingsFile(string fname, int imod) {
for (int im=mmin; im<mmax; ++im) { for (int im=mmin; im<mmax; ++im) {
ostringstream ostfn; ostringstream ostfn;
ostfn << fname; ostfn << fname;
if(thisDetector->myDetectorType != EIGER){ switch (thisDetector->myDetectorType) {
if (fname.find(".sn")==string::npos && fname.find(".trim")==string::npos && fname.find(".settings")==string::npos) { case MYTHEN:
ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im); if (fname.find(".sn")==string::npos && fname.find(".trim")==string::npos && fname.find(".settings")==string::npos) {
fn=ostfn.str(); ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im);
} }
}else if (fname.find(".sn")==string::npos && fname.find(".trim")==string::npos && fname.find(".settings")==string::npos) { break;
ostfn << ".sn" << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER, im); case EIGER:
fn=ostfn.str(); if (fname.find(".sn")==string::npos && fname.find(".trim")==string::npos && fname.find(".settings")==string::npos) {
ostfn << ".sn" << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER, im);
}
break;
default:
break;
} }
fn=ostfn.str();
myMod=readSettingsFile(fn, thisDetector->myDetectorType,iodelay, tau, myMod); myMod=readSettingsFile(fn, thisDetector->myDetectorType,iodelay, tau, myMod);
if (myMod) { if (myMod) {
@ -7445,18 +7639,27 @@ int slsDetector::saveSettingsFile(string fname, int imod) {
mmax=imod+1; mmax=imod+1;
} }
for (int im=mmin; im<mmax; ++im) { for (int im=mmin; im<mmax; ++im) {
string fn=fname;
ostringstream ostfn; ostringstream ostfn;
if(thisDetector->myDetectorType == EIGER){ ostfn << fname;
ostfn << fname << ".sn" << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER); switch (thisDetector->myDetectorType) {
} else case MYTHEN:
ostfn << fname << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER,im); ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER,im);
break;
case EIGER:
ostfn << ".sn" << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER);
break;
default:
break;
}
fn=ostfn.str();
if ((myMod=getModule(im))) { if ((myMod=getModule(im))) {
if(thisDetector->myDetectorType == EIGER){ if(thisDetector->myDetectorType == EIGER){
iodelay = (int)setDAC((dacs_t)-1,IO_DELAY,0,-1); iodelay = (int)setDAC((dacs_t)-1,IO_DELAY,0,-1);
tau = (int64_t)getRateCorrectionTau(); tau = (int64_t)getRateCorrectionTau();
} }
ret=writeSettingsFile(ostfn.str(), thisDetector->myDetectorType, *myMod, iodelay, tau); ret=writeSettingsFile(fn, thisDetector->myDetectorType, *myMod, iodelay, tau);
deleteModule(myMod); deleteModule(myMod);
} }
} }
@ -7533,14 +7736,22 @@ int slsDetector::loadCalibrationFile(string fname, int imod) {
mmax=imod+1; mmax=imod+1;
} }
for (int im=mmin; im<mmax; ++im) { for (int im=mmin; im<mmax; ++im) {
string fn=fname;
ostringstream ostfn; ostringstream ostfn;
ostfn << fname ; ostfn << fname ;
if(thisDetector->myDetectorType != EIGER){ switch (thisDetector->myDetectorType) {
if (fname.find(".sn")==string::npos && fname.find(".cal")==string::npos) { case MYTHEN:
ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im); if (fname.find(".sn")==string::npos && fname.find(".cal")==string::npos) {
} ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im);
}else if (fname.find(".sn")==string::npos && fname.find(".cal")==string::npos) { }
ostfn << "." << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER); break;
case EIGER:
if (fname.find(".sn")==string::npos && fname.find(".cal")==string::npos) {
ostfn << "." << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER);
}
break;
default:
break;
} }
fn=ostfn.str(); fn=ostfn.str();
if((myMod=getModule(im))){ if((myMod=getModule(im))){
@ -7577,18 +7788,27 @@ int slsDetector::saveCalibrationFile(string fname, int imod) {
mmax=imod+1; mmax=imod+1;
} }
for (int im=mmin; im<mmax; ++im) { for (int im=mmin; im<mmax; ++im) {
string fn=fname;
ostringstream ostfn; ostringstream ostfn;
if(thisDetector->myDetectorType == EIGER) ostfn << fname;
ostfn << fname << ".sn" << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER); switch (thisDetector->myDetectorType) {
else case MYTHEN:
ostfn << fname << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER,im); ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER,im);
break;
case EIGER:
ostfn << ".sn" << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER);
break;
default:
break;
}
fn=ostfn.str();
if ((myMod=getModule(im))) { if ((myMod=getModule(im))) {
//extra gain and offset //extra gain and offset
if(thisDetector->nGain) if(thisDetector->nGain)
ret=writeCalibrationFile(ostfn.str(),gain, offset); ret=writeCalibrationFile(fn,gain, offset);
//normal gain and offset inside sls_detector_module //normal gain and offset inside sls_detector_module
else else
ret=writeCalibrationFile(ostfn.str(),myMod->gain, myMod->offset); ret=writeCalibrationFile(fn,myMod->gain, myMod->offset);
deleteModule(myMod); deleteModule(myMod);
}else }else

View File

@ -524,13 +524,13 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
/** /**
returns currently the loaded trimfile/settingsfile name returns currently the loaded trimfile/settingsfile name
*/ */
const char *getSettingsFile(){\ string getSettingsFile(){\
string s(thisDetector->settingsFile); \ string s(thisDetector->settingsFile); \
if (s.length()>6) {\ if (s.length()>6) {\
if (s.substr(s.length()-6,3)==string(".sn") && s.substr(s.length()-3)!=string("xxx") ) \ if (s.substr(s.length()-6,3)==string(".sn") && s.substr(s.length()-3)!=string("xxx") ) \
return s.substr(0,s.length()-6).c_str(); \ return s.substr(0,s.length()-6); \
} \ } \
return thisDetector->settingsFile;\ return string(thisDetector->settingsFile);\
}; };
@ -551,6 +551,12 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/ */
int powerChip(int ival= -1); int powerChip(int ival= -1);
/** automatic comparator disable for Jungfrau only
\param ival on is 1, off is 0, -1 to get
\returns OK or FAIL
*/
int setAutoComparatorDisableMode(int ival= -1);
/** loads the modules settings/trimbits reading from a file /** loads the modules settings/trimbits reading from a file
\param fname file name . If not specified, extension is automatically generated! \param fname file name . If not specified, extension is automatically generated!
@ -916,7 +922,31 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
\returns current ADC value (temperature for eiger and jungfrau in millidegrees) \returns current ADC value (temperature for eiger and jungfrau in millidegrees)
*/ */
dacs_t getADC(dacIndex index, int imod=0); dacs_t getADC(dacIndex index, int imod=0);
/**
set/gets threshold temperature (Jungfrau only)
\param val value in millidegrees, -1 gets
\param imod module number, -1 is all
\returns threshold temperature in millidegrees
*/
int setThresholdTemperature(int val=-1, int imod=-1);
/**
enables/disables temperature control (Jungfrau only)
\param val value, -1 gets
\param imod module number, -1 is all
\returns temperature control enable
*/
int setTemperatureControl(int val=-1, int imod=-1);
/**
Resets/ gets over-temperature event (Jungfrau only)
\param val value, -1 gets
\param imod module number, -1 is all
\returns over-temperature event
*/
int setTemperatureEvent(int val=-1, int imod=-1);
/** /**
configure channel configure channel
\param reg channel register \param reg channel register

View File

@ -234,7 +234,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
/*! \page config Configuration commands /*! \page config Configuration commands
Commands to configure the detector. these commands are often left to the configuration file. Commands to configure the detector. these commands are often left to the configuration file.
- \ref configstructure "Data Structure": commands to configure detector data structure - \ref configstructure "Data Structure": commands to configure detector data structure
@ -461,6 +460,13 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced; descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced;
++i; ++i;
/*! \page config
- <b>auto_comp_disable i </b> Currently not implemented. this mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us). 1 enables mode, 0 disables mode. By default, mode is disabled (comparator is enabled throughout). (JUNGFRAU only). \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="auto_comp_disable"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced;
++i;
/*! \page config /*! \page config
- <b>pulse [n] [x] [y]</b> pulses pixel at coordinates (x,y) n number of times. Used in EIGER only. Only put! \c Returns \c ("successful", "unsuccessful") - <b>pulse [n] [x] [y]</b> pulses pixel at coordinates (x,y) n number of times. Used in EIGER only. Only put! \c Returns \c ("successful", "unsuccessful")
*/ */
@ -958,6 +964,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
- \ref settingssett "Settings and Threshold": commands to configure settings and threshold of detector - \ref settingssett "Settings and Threshold": commands to configure settings and threshold of detector
- \ref settingsdacs "DACs": commands to configure DACs of detector - \ref settingsdacs "DACs": commands to configure DACs of detector
- \ref settingsadcs "ADCs": commands to readout ADCs of detector - \ref settingsadcs "ADCs": commands to readout ADCs of detector
- \ref settingstmp "Temp Control": commands to monitor and handle temperature overshoot (only JUNGFRAU)
*/ */
/* trim/cal directories */ /* trim/cal directories */
@ -1562,6 +1569,33 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
/* temperature control */
/*! \page settings
\section settingsadcs Temp Control
commands to monitor and handle temperature overshoot (only JUNGFRAU)
*/
/*! \page settings
- <b>temp_threshold</b> Sets/gets the threshold temperature. JUNGFRAU ONLY. \c Returns \c (double"°C")
*/
descrToFuncMap[i].m_pFuncName="temp_threshold"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTempControl;
++i;
/*! \page settings
- <b>temp_control</b> Enables/Disables the temperature control. 1 enables, 0 disables. JUNGFRAU ONLY. \c Returns \c int
*/
descrToFuncMap[i].m_pFuncName="temp_control"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTempControl;
++i;
/*! \page settings
- <b>temp_event</b> Resets/gets over-temperative event. Put only with option 0 to clear event. Gets 1 if temperature went over threshold and control is enabled, else 0. /Disables the temperature control. JUNGFRAU ONLY. \c Returns \c int
*/
descrToFuncMap[i].m_pFuncName="temp_event"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTempControl;
++i;
/* file name */ /* file name */
@ -4475,7 +4509,7 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
myDet->loadSettingsFile(sval,-1); myDet->loadSettingsFile(sval,-1);
} }
} }
return string(myDet->getSettingsFile()); return myDet->getSettingsFile();
} else if (cmd=="trim") { } else if (cmd=="trim") {
if (action==GET_ACTION) if (action==GET_ACTION)
return string("cannot get!"); return string("cannot get!");
@ -5287,6 +5321,80 @@ string slsDetectorCommand::helpADC(int narg, char *args[], int action) {
return os.str(); return os.str();
} }
string slsDetectorCommand::cmdTempControl(int narg, char *args[], int action) {
char answer[1000]="";
int val = -1;
if (action==HELP_ACTION)
return helpTempControl(narg, args, action);
myDet->setOnline(ONLINE_FLAG);
if (cmd == "temp_threshold") {
if (action==PUT_ACTION) {
double fval=0.0;
if (!sscanf(args[1],"%lf", &fval))
return string("cannot scan temp control value ")+string(args[1]);
val = fval * 1000;
myDet->setThresholdTemperature(val);
}
val = myDet->setThresholdTemperature();
if (val == -1)
sprintf(answer,"%d",val);
else
sprintf(answer,"%.2f°C", (double)val/1000.000);
}
else if (cmd == "temp_control") {
if (action==PUT_ACTION) {
if (!sscanf(args[1],"%d", &val))
return string("cannot scan temp control value ")+string(args[1]);
if ((val!=0) && (val!=1))
return string ("temp_control option must be 0 or 1");
myDet->setTemperatureControl(val);
}
sprintf(answer,"%d", myDet->setTemperatureControl());
}
else if (cmd == "temp_event") {
if (action==PUT_ACTION) {
if (!sscanf(args[1],"%d", &val))
return string("cannot scan temp control value ")+string(args[1]);
if (val!=0)
return string ("temp_event option must be 0 to clear event");
myDet->setTemperatureEvent(val);
}
sprintf(answer,"%d", myDet->setTemperatureEvent());
}
else
return string ("cannot scan command " + cmd);
return string(answer);
}
string slsDetectorCommand::helpTempControl(int narg, char *args[], int action) {
ostringstream os;
if (action==PUT_ACTION || action==HELP_ACTION) {
os << "temp_threshold t \t sets the threshold temperature. Jungfrau only" << std::endl;
os << "temp_control t \t Enables/Disables the temperature control. 1 enables, 0 disables. JUNGFRAU ONLY" << std::endl;
os << "temp_event t \t Resets over-temperative event. Put only with option 0 to clear event. JUNGFRAU ONLY." << std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION) {
os << "temp_threshold \t gets the threshold temperature. Jungfrau only." << std::endl;
os << "temp_control \t gets temperature control enable. 1 enabled, 0 disabled. JUNGFRAU ONLY" << std::endl;
os << "temp_event \t gets over-temperative event. Gets 1 if temperature went over threshold and control is enabled, else 0. /Disables the temperature control. JUNGFRAU ONLY." << std::endl;
}
return os.str();
}
string slsDetectorCommand::cmdTiming(int narg, char *args[], int action){ string slsDetectorCommand::cmdTiming(int narg, char *args[], int action){
#ifdef VERBOSE #ifdef VERBOSE
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
@ -5752,7 +5860,9 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
} }
sprintf(ans,"%d",myDet->powerChip()); sprintf(ans,"%d",myDet->powerChip());
return string(ans); return string(ans);
} else if (cmd=="led") { }
else if (cmd=="led") {
char ans[100]; char ans[100];
int val=0; int val=0;
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
@ -5766,6 +5876,19 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
sprintf(ans,"%d",~(myDet->readRegister(0x4d))&1); sprintf(ans,"%d",~(myDet->readRegister(0x4d))&1);
return string(ans); return string(ans);
} }
else if (cmd=="auto_comp_disable") {
char ans[100];
myDet->setOnline(ONLINE_FLAG);
if (action==PUT_ACTION){
int ival = -1;
if (!sscanf(args[1],"%d",&ival))
return string("could not scan auto_comp_control parameter " + string(args[1]));
myDet->setAutoComparatorDisableMode(ival);
}
sprintf(ans,"%d",myDet->setAutoComparatorDisableMode());
return string(ans);
}
else else
return string("unknown command ")+cmd; return string("unknown command ")+cmd;
@ -5785,6 +5908,7 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
os << "led s \t sets led status (0 off, 1 on)" << std::endl; os << "led s \t sets led status (0 off, 1 on)" << std::endl;
os << "powerchip i \t powers on or off the chip. i = 1 for on, i = 0 for off" << std::endl; os << "powerchip i \t powers on or off the chip. i = 1 for on, i = 0 for off" << std::endl;
os << "auto_comp_disable i \t Currently not implemented. this mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us). 1 enables mode, 0 disables mode. By default, mode is disabled (comparator is enabled throughout). (JUNGFRAU only). " << std::endl;
} }
if (action==GET_ACTION || action==HELP_ACTION) { if (action==GET_ACTION || action==HELP_ACTION) {
@ -5794,6 +5918,7 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
os << "led \t returns led status (0 off, 1 on)" << std::endl; os << "led \t returns led status (0 off, 1 on)" << std::endl;
os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, unknown" << std::endl; os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, unknown" << std::endl;
os << "powerchip \t gets if the chip has been powered on or off" << std::endl; os << "powerchip \t gets if the chip has been powered on or off" << std::endl;
os << "auto_comp_disable \t Currently not implemented. gets if the automatic comparator diable mode is enabled/disabled" << std::endl;
} }
return os.str(); return os.str();

View File

@ -82,6 +82,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
static string helpImage(int narg, char *args[], int action); static string helpImage(int narg, char *args[], int action);
static string helpCounter(int narg, char *args[], int action); static string helpCounter(int narg, char *args[], int action);
static string helpADC(int narg, char *args[], int action); static string helpADC(int narg, char *args[], int action);
static string helpTempControl(int narg, char *args[], int action);
static string helpEnablefwrite(int narg, char *args[], int action); static string helpEnablefwrite(int narg, char *args[], int action);
static string helpOverwrite(int narg, char *args[], int action); static string helpOverwrite(int narg, char *args[], int action);
static string helpReceiver(int narg, char *args[], int action); static string helpReceiver(int narg, char *args[], int action);
@ -155,6 +156,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
string cmdImage(int narg, char *args[], int action); string cmdImage(int narg, char *args[], int action);
string cmdCounter(int narg, char *args[], int action); string cmdCounter(int narg, char *args[], int action);
string cmdADC(int narg, char *args[], int action); string cmdADC(int narg, char *args[], int action);
string cmdTempControl(int narg, char *args[], int action);
string cmdEnablefwrite(int narg, char *args[], int action); string cmdEnablefwrite(int narg, char *args[], int action);
string cmdOverwrite(int narg, char *args[], int action); string cmdOverwrite(int narg, char *args[], int action);
string cmdReceiver(int narg, char *args[], int action); string cmdReceiver(int narg, char *args[], int action);

View File

@ -255,7 +255,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/** /**
returns currently the loaded trimfile/settingsfile name returns currently the loaded trimfile/settingsfile name
*/ */
virtual const char *getSettingsFile()=0; virtual string getSettingsFile()=0;
/** /**
@ -582,6 +582,12 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/ */
virtual int powerChip(int ival= -1)=0; virtual int powerChip(int ival= -1)=0;
/** automatic comparator disable for Jungfrau only
\param ival on is 1, off is 0, -1 to get
\returns OK or FAIL
*/
virtual int setAutoComparatorDisableMode(int ival= -1)=0;
/** saves the modules settings/trimbits writing to a file /** saves the modules settings/trimbits writing to a file
\param fname file name . Axtension is automatically generated! \param fname file name . Axtension is automatically generated!
\param imod module number, -1 means all modules \param imod module number, -1 means all modules
@ -618,6 +624,30 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/ */
virtual dacs_t getADC(dacIndex index, int imod=-1)=0; virtual dacs_t getADC(dacIndex index, int imod=-1)=0;
/**
set/gets threshold temperature (Jungfrau only)
\param val value in millidegrees, -1 gets
\param imod module number, -1 is all
\returns threshold temperature in millidegrees
*/
virtual int setThresholdTemperature(int val=-1, int imod=-1)=0;
/**
enables/disables temperature control (Jungfrau only)
\param val value, -1 gets
\param imod module number, -1 is all
\returns temperature control enable
*/
virtual int setTemperatureControl(int val=-1, int imod=-1)=0;
/**
Resets/ gets over-temperature event (Jungfrau only)
\param val value, -1 gets
\param imod module number, -1 is all
\returns over-temperature event
*/
virtual int setTemperatureEvent(int val=-1, int imod=-1)=0;
/** /**
get the maximum size of the detector get the maximum size of the detector
\param d dimension \param d dimension

View File

@ -17,7 +17,7 @@ Here are the definitions, but the actual implementation should be done for each
// basic tests // basic tests
void checkFirmwareCompatibility(); void checkFirmwareCompatibility(int flag);
#ifdef JUNGFRAUD #ifdef JUNGFRAUD
int checkType(); int checkType();
u_int32_t testFpga(void); u_int32_t testFpga(void);
@ -35,6 +35,7 @@ u_int64_t getFirmwareVersion();
#ifdef MYTHEND #ifdef MYTHEND
int64_t getModuleId(enum idMode arg, int imod); int64_t getModuleId(enum idMode arg, int imod);
#elif JUNGFRAUD #elif JUNGFRAUD
u_int64_t getFirmwareAPIVersion();
u_int16_t getHardwareVersionNumber(); u_int16_t getHardwareVersionNumber();
u_int16_t getHardwareSerialNumber(); u_int16_t getHardwareSerialNumber();
#endif #endif
@ -68,6 +69,7 @@ uint32_t readRegister(uint32_t offset);
// firmware functions (resets) // firmware functions (resets)
#ifdef JUNGFRAUD #ifdef JUNGFRAUD
int powerChip (int on); int powerChip (int on);
int autoCompDisable(int on);
void cleanFifos(); void cleanFifos();
void resetCore(); void resetCore();
void resetPeripheral(); void resetPeripheral();
@ -168,6 +170,9 @@ int calibratePedestal(int frames);
void resetPLL(); void resetPLL();
u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val); u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val);
void configurePll(); void configurePll();
int setThresholdTemperature(int val);
int setTemperatureControl(int val);
int setTemperatureEvent(int val);
extern void eraseFlash(); // programfpga.h extern void eraseFlash(); // programfpga.h
extern int startWritingFPGAprogram(FILE** filefp); // programfpga.h extern int startWritingFPGAprogram(FILE** filefp); // programfpga.h
extern void stopWritingFPGAprogram(FILE* filefp); // programfpga.h extern void stopWritingFPGAprogram(FILE* filefp); // programfpga.h
@ -191,7 +196,9 @@ int setAllTrimbits(int val);
int getAllTrimbits(); int getAllTrimbits();
int getBebFPGATemp(); int getBebFPGATemp();
int activate(int enable); int activate(int enable);
int setNetworkParameter(enum NETWORKINDEX mode, int value); #endif
#if defined(JUNGFRAUD) || defined(EIGERD)
int setNetworkParameter(enum NETWORKINDEX mode, int value);
#endif #endif

View File

@ -10,7 +10,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
#include <string.h>
extern int sockfd; extern int sockfd;
@ -23,11 +23,19 @@ int main(int argc, char *argv[]){
int portno, b; int portno, b;
int retval=OK; int retval=OK;
int sd, fd; int sd, fd;
int debugflag = 0;
// if socket crash, ignores SISPIPE, prevents global signal handler // if socket crash, ignores SISPIPE, prevents global signal handler
// subsequent read/write to socket gives error - must handle locally // subsequent read/write to socket gives error - must handle locally
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
// circumvent the basic tests
if(argc > 1) {
if(!strcasecmp(argv[1],"-debug")){
debugflag = 1;
argc=1;
}
}
#ifdef STOP_SERVER #ifdef STOP_SERVER
char cmd[100]; char cmd[100];
@ -40,9 +48,10 @@ int main(int argc, char *argv[]){
"********************************************************\n\n" "********************************************************\n\n"
, portno); , portno);
b=1; b=1;
basictests(); basictests(debugflag);
#ifdef STOP_SERVER #ifdef STOP_SERVER
sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1); sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1);
//cprintf(BLUE,"cmd:%s\n", cmd);
system(cmd); system(cmd);
#endif #endif
} else { } else {
@ -74,8 +83,10 @@ int main(int argc, char *argv[]){
printf("function table assigned \n"); printf("function table assigned \n");
#endif #endif
if (b)
printf("\nReady...\n\n"); printf("\nControl Server Ready...\n\n");
else
printf("\nStop Server Ready...\n\n");
/* waits for connection */ /* waits for connection */
while(retval!=GOODBYE) { while(retval!=GOODBYE) {

View File

@ -37,7 +37,8 @@ int sockfd; // (updated in slsDetectorServer) as extern
int (*flist[NUM_DET_FUNCTIONS])(int); int (*flist[NUM_DET_FUNCTIONS])(int);
char mess[MAX_STR_LENGTH]; char mess[MAX_STR_LENGTH];
int dataBytes = 10; int dataBytes = 10;
int isControlServer = 0;
int debugflag = 0;
/* initialization functions */ /* initialization functions */
@ -46,9 +47,10 @@ int printSocketReadError() {
return FAIL; return FAIL;
} }
void basictests() { void basictests(int flag) {
debugflag = flag;
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
checkFirmwareCompatibility(); checkFirmwareCompatibility(debugflag);
#endif #endif
} }
@ -59,8 +61,10 @@ void init_detector(int controlserver) {
#endif #endif
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
if (controlserver) if (controlserver) {
isControlServer = 1;
initControlServer(); initControlServer();
}
else initStopServer(); else initStopServer();
#endif #endif
strcpy(mess,"dummy message"); strcpy(mess,"dummy message");
@ -177,6 +181,11 @@ const char* getFunctionName(enum detFuncs func) {
case F_ACTIVATE: return "F_ACTIVATE"; case F_ACTIVATE: return "F_ACTIVATE";
case F_PREPARE_ACQUISITION: return "F_PREPARE_ACQUISITION"; case F_PREPARE_ACQUISITION: return "F_PREPARE_ACQUISITION";
case F_CLEANUP_ACQUISITION: return "F_CLEANUP_ACQUISITION"; case F_CLEANUP_ACQUISITION: return "F_CLEANUP_ACQUISITION";
case F_THRESHOLD_TEMP: return "F_THRESHOLD_TEMP";
case F_TEMP_CONTROL: return "F_TEMP_CONTROL";
case F_TEMP_EVENT: return "F_TEMP_EVENT";
case F_AUTO_COMP_DISABLE: return "F_AUTO_COMP_DISABLE";
default: return "Unknown Function"; default: return "Unknown Function";
} }
} }
@ -255,6 +264,10 @@ void function_table() {
flist[F_ACTIVATE] = &set_activate; flist[F_ACTIVATE] = &set_activate;
flist[F_PREPARE_ACQUISITION] = &prepare_acquisition; flist[F_PREPARE_ACQUISITION] = &prepare_acquisition;
flist[F_CLEANUP_ACQUISITION] = &cleanup_acquisition; flist[F_CLEANUP_ACQUISITION] = &cleanup_acquisition;
flist[F_THRESHOLD_TEMP] = &threshold_temp;
flist[F_TEMP_CONTROL] = &temp_control;
flist[F_TEMP_EVENT] = &temp_event;
flist[F_AUTO_COMP_DISABLE] = &auto_comp_disable;
// check // check
if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) { if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) {
@ -2974,7 +2987,12 @@ int set_speed(int file_des) {
switch (arg) { switch (arg) {
#ifdef JUNGFRAUD #ifdef JUNGFRAUD
case ADC_PHASE: case ADC_PHASE:
adcPhase(val); retval = adcPhase(val);
if ((retval!=val) && (val>=0)) {
ret=FAIL;
sprintf(mess,"could not change set adc phase: should be %d but is %d \n", val, retval);
cprintf(RED, "Warning: %s", mess);
}
break; break;
#endif #endif
#ifdef MYTHEND #ifdef MYTHEND
@ -3461,6 +3479,26 @@ int configure_mac(int file_des) {
cprintf(RED, "Warning: %s", mess); cprintf(RED, "Warning: %s", mess);
} }
else { else {
#ifdef EIGERD
// change mac to hardware mac, (for 1 gbe) change ip to hardware ip
if (idetectormacadd != getDetectorMAC()){
printf("*************************************************\n");
printf("WARNING: actual detector mac address %llx does not match the one from client %llx\n",getDetectorMAC(),idetectormacadd);
idetectormacadd = getDetectorMAC();
printf("WARNING: Matched detectormac to the hardware mac now\n");
printf("*************************************************\n");
}
//only for 1Gbe
if(!enableTenGigabitEthernet(-1)){
if (detipad != getDetectorIP()){
printf("*************************************************\n");
printf("WARNING: actual detector ip address %x does not match the one from client %x\n",getDetectorIP(),detipad);
detipad = getDetectorIP();
printf("WARNING: Matched detector ip to the hardware ip now\n");
printf("*************************************************\n");
}
}
#endif
retval=configureMAC(ipad,imacadd,idetectormacadd,detipad,udpport,udpport2,0); //digitalTestBit); retval=configureMAC(ipad,imacadd,idetectormacadd,detipad,udpport,udpport2,0); //digitalTestBit);
if(retval==-1) { if(retval==-1) {
ret = FAIL; ret = FAIL;
@ -3487,9 +3525,16 @@ int configure_mac(int file_des) {
// send return argument // send return argument
if (ret==FAIL) { if (ret==FAIL) {
n += sendData(file_des,mess,sizeof(mess),OTHER); n += sendData(file_des,mess,sizeof(mess),OTHER);
} else } else {
n += sendData(file_des,&retval,sizeof(retval),INT32); n += sendData(file_des,&retval,sizeof(retval),INT32);
#ifdef EIGERD
char arg[2][50];
memset(arg,0,sizeof(arg));
sprintf(arg[0],"%llx",idetectormacadd);
sprintf(arg[1],"%x",detipad);
n += sendData(file_des,arg,sizeof(arg),OTHER);
#endif
}
// return ok / fail // return ok / fail
return ret; return ret;
} }
@ -4401,7 +4446,7 @@ int set_network_parameter(int file_des) {
int retval=-1; int retval=-1;
sprintf(mess,"set network parameter failed\n"); sprintf(mess,"set network parameter failed\n");
#ifndef EIGERD #if !defined(EIGERD) && !defined(JUNGFRAUD)
//to receive any arguments //to receive any arguments
while (n > 0) while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
@ -4422,7 +4467,7 @@ int set_network_parameter(int file_des) {
if (n < 0) return printSocketReadError(); if (n < 0) return printSocketReadError();
// execute action // execute action
if (differentClients && lockStatus && value<0) { if (differentClients && lockStatus && value >= 0) {
ret = FAIL; ret = FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP); sprintf(mess,"Detector locked by %s\n",lastClientIP);
cprintf(RED, "Warning: %s", mess); cprintf(RED, "Warning: %s", mess);
@ -4433,17 +4478,27 @@ int set_network_parameter(int file_des) {
printf("setting network parameter mode %d to %d\n",(int)mode,value); printf("setting network parameter mode %d to %d\n",(int)mode,value);
#endif #endif
switch (mode) { switch (mode) {
#ifdef EIGERD
case FLOW_CONTROL_10G:
index = FLOWCTRL_10G;
break;
case DETECTOR_TXN_DELAY_LEFT: case DETECTOR_TXN_DELAY_LEFT:
index = TXN_LEFT; index = TXN_LEFT;
break; break;
case DETECTOR_TXN_DELAY_RIGHT: case DETECTOR_TXN_DELAY_RIGHT:
index = TXN_RIGHT; index = TXN_RIGHT;
break; break;
#endif
case DETECTOR_TXN_DELAY_FRAME: case DETECTOR_TXN_DELAY_FRAME:
index = TXN_FRAME; index = TXN_FRAME;
break; #ifdef JUNGFRAUD
case FLOW_CONTROL_10G: if (value > MAX_TIMESLOT_VAL) {
index = FLOWCTRL_10G; ret=FAIL;
sprintf(mess,"Transmission delay %d should be in range: 0 - %d\n", value, MAX_TIMESLOT_VAL);
cprintf(RED, "Warning: %s", mess);
}
#endif
break; break;
default: default:
ret=FAIL; ret=FAIL;
@ -4601,6 +4656,9 @@ int program_fpga(int file_des) {
#ifdef VERY_VERBOSE #ifdef VERY_VERBOSE
printf("Done with program receiving command\n"); printf("Done with program receiving command\n");
#endif #endif
if (isControlServer)
basictests(debugflag);
init_detector(isControlServer);
} }
#endif #endif
if (ret==OK) if (ret==OK)
@ -4646,7 +4704,9 @@ int reset_fpga(int file_des) {
} }
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
else { else {
initControlServer(); if (isControlServer)
basictests(debugflag);
initControlServer(isControlServer);
ret = FORCE_UPDATE; ret = FORCE_UPDATE;
} }
#endif #endif
@ -4707,7 +4767,10 @@ int power_chip(int file_des) {
ret=OK; ret=OK;
} else { } else {
ret=FAIL; ret=FAIL;
sprintf(mess,"Powering chip failed, wrote %d but read %d\n", arg, retval); if(setTemperatureEvent(-1) == 1)
sprintf(mess,"Powering chip failed due to over-temperature event. Clear event & power chip again. Wrote %d, read %d \n", arg, retval);
else
sprintf(mess,"Powering chip failed, wrote %d but read %d\n", arg, retval);
cprintf(RED, "Warning: %s", mess); cprintf(RED, "Warning: %s", mess);
} }
} }
@ -4883,3 +4946,255 @@ int cleanup_acquisition(int file_des) {
} }
int threshold_temp(int file_des) {
int ret=OK,ret1=OK;
int n=0;
int retval=-1;
sprintf(mess,"could not set/get threshold temperature\n");
#ifndef JUNGFRAUD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Threshold Temp) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
int arg[2]={-1,-1};
int val=-1;
// receive arguments
n = receiveData(file_des,arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
val=arg[0];
//ignoring imod
if (val > MAX_THRESHOLD_TEMP_VAL) {
ret=FAIL;
sprintf(mess,"Threshold Temp %d should be in range: 0 - %d\n", val, MAX_THRESHOLD_TEMP_VAL);
cprintf(RED, "Warning: %s", mess);
}
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
#ifdef VERBOSE
printf("Setting Threshold Temperature to %d\n", val);
#endif
retval=setThresholdTemperature(val);
}
#endif
#ifdef VERBOSE
printf("Threshold temperature is %d\n", retval);
#endif
if (ret==OK && differentClients && val >= 0)
ret=FORCE_UPDATE;
#endif
// ret could be swapped during sendData
ret1 = ret;
// send ok / fail
n = sendData(file_des,&ret1,sizeof(ret),INT32);
// send return argument
if (ret!=FAIL) {
n += sendData(file_des,&retval,sizeof(retval),INT32);
} else {
n += sendData(file_des,mess,sizeof(mess),OTHER);
}
// return ok / fail
return ret;
}
int temp_control(int file_des) {
int ret=OK,ret1=OK;
int n=0;
int retval=-1;
sprintf(mess,"could not set/get temperature control\n");
#ifndef JUNGFRAUD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Temperature control) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
int arg[2]={-1,-1};
int val=-1;
// receive arguments
n = receiveData(file_des,arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
val=arg[0];
//ignoring imod
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
#ifdef VERBOSE
printf("Setting Temperature control to %d\n", val);
#endif
retval=setTemperatureControl(val);
}
#endif
#ifdef VERBOSE
printf("Temperature control is %d\n", retval);
#endif
if (ret==OK && differentClients && val >= 0)
ret=FORCE_UPDATE;
#endif
// ret could be swapped during sendData
ret1 = ret;
// send ok / fail
n = sendData(file_des,&ret1,sizeof(ret),INT32);
// send return argument
if (ret!=FAIL) {
n += sendData(file_des,&retval,sizeof(retval),INT32);
} else {
n += sendData(file_des,mess,sizeof(mess),OTHER);
}
// return ok / fail
return ret;
}
int temp_event(int file_des) {
int ret=OK,ret1=OK;
int n=0;
int retval=-1;
sprintf(mess,"could not set/get temperature event\n");
#ifndef JUNGFRAUD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Temperature Event) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
int arg[2]={-1,-1};
int val=-1;
// receive arguments
n = receiveData(file_des,arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
val=arg[0];
//ignoring imod
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
#ifdef VERBOSE
printf("Setting Temperature Event to %d\n", val);
#endif
retval=setTemperatureEvent(val);
}
#endif
#ifdef VERBOSE
printf("Temperature Event is %d\n", retval);
#endif
if (ret==OK && differentClients && val >= 0)
ret=FORCE_UPDATE;
#endif
// ret could be swapped during sendData
ret1 = ret;
// send ok / fail
n = sendData(file_des,&ret1,sizeof(ret),INT32);
// send return argument
if (ret!=FAIL) {
n += sendData(file_des,&retval,sizeof(retval),INT32);
} else {
n += sendData(file_des,mess,sizeof(mess),OTHER);
}
// return ok / fail
return ret;
}
int auto_comp_disable(int file_des) {
int ret=OK,ret1=OK;
int n=0;
int retval=-1;
sprintf(mess,"auto comp disable failed\n");
#ifndef JUNGFRAUD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Auto Comp Disable) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
ret = FAIL;
sprintf(mess,"Function (Auto Comp Disable) is not yet implemented for this detector\n");
cprintf(RED, "%s", mess);
/* will be connected after teh fpga upgrade
// receive arguments
int arg=-1;
n = receiveData(file_des,&arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
// execute action
if (differentClients && lockStatus && arg!=-1) {
ret = FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
cprintf(RED, "Warning: %s", mess);
}
#ifdef SLS_DETECTOR_FUNCTION_LIST
else {
#ifdef VERBOSE
printf("Auto Comp Disable to %d\n", arg);
#endif
retval=autoCompDisable(arg);
#ifdef VERBOSE
printf("Auto comp disable set to: %d\n",retval);
#endif
if (retval==arg || arg<0) {
ret=OK;
} else {
ret=FAIL;
sprintf(mess,"Atuo Comp Disable failed, wrote %d but read %d\n", arg, retval);
cprintf(RED, "Warning: %s", mess);
}
}
#endif
if (ret==OK && differentClients)
ret=FORCE_UPDATE;
*/
#endif
// ret could be swapped during sendData
ret1 = ret;
// send ok / fail
n = sendData(file_des,&ret1,sizeof(ret),INT32);
// send return argument
if (ret==FAIL) {
n += sendData(file_des,mess,sizeof(mess),OTHER);
} else
n += sendData(file_des,&retval,sizeof(retval),INT32);
// return ok / fail
return ret;
}

View File

@ -6,7 +6,7 @@
// initialization functions // initialization functions
int printSocketReadError(); int printSocketReadError();
void basictests(); void basictests(int);
void init_detector(int); void init_detector(int);
int decode_function(int); int decode_function(int);
const char* getFunctionName(enum detFuncs func); const char* getFunctionName(enum detFuncs func);
@ -88,6 +88,9 @@ int power_chip(int);
int set_activate(int); int set_activate(int);
int prepare_acquisition(int); int prepare_acquisition(int);
int cleanup_acquisition(int); int cleanup_acquisition(int);
int threshold_temp(int);
int temp_control(int);
int temp_event(int);
int auto_comp_disable(int);
#endif #endif