mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-28 01:00:02 +02:00
merged with developer a lot of bug fixes from 14 sep to 30 sep
This commit is contained in:
commit
984698efad
@ -59,10 +59,10 @@ using namespace std;
|
||||
#define COULD_NOT_PULSE_CHIP 0x0000000000100000ULL
|
||||
#define COULD_NOT_SET_RATE_CORRECTION 0x0000000000200000ULL
|
||||
#define DETECTOR_NETWORK_PARAMETER 0x0000000000400000ULL
|
||||
#define RATE_CORRECTION_NOT_32BIT 0x0000000000800000ULL
|
||||
#define RATE_CORRECTION_NOT_32or16BIT 0x0000000000800000ULL
|
||||
#define RATE_CORRECTION_NO_TAU_PROVIDED 0x0000000001000000ULL
|
||||
#define DATA_STREAMING_IN_RECEIVER 0x0000000002000000ULL
|
||||
|
||||
#define PROGRAMMING_ERROR 0x0000000002000000ULL
|
||||
#define DATA_STREAMING_IN_RECEIVER 0x0000000004000000ULL
|
||||
// 0x00000000FFFFFFFFULL
|
||||
/** @short class returning all error messages for error mask */
|
||||
class errorDefs {
|
||||
@ -193,12 +193,15 @@ public:
|
||||
if(slsErrorMask&DETECTOR_NETWORK_PARAMETER)
|
||||
retval.append("Could not set/get detector network parameter\n");
|
||||
|
||||
if(slsErrorMask&RATE_CORRECTION_NOT_32BIT)
|
||||
retval.append("Rate correction Deactivated, must be in 32 bit mode\n");
|
||||
if(slsErrorMask&RATE_CORRECTION_NOT_32or16BIT)
|
||||
retval.append("Rate correction Deactivated, must be in 32 or 16 bit mode\n");
|
||||
|
||||
if(slsErrorMask&RATE_CORRECTION_NO_TAU_PROVIDED)
|
||||
retval.append("Rate correction Deactivated. No default tau provided in file\n");
|
||||
|
||||
if(slsErrorMask&PROGRAMMING_ERROR)
|
||||
retval.append("Could not program FPGA\n");
|
||||
|
||||
if(slsErrorMask&DATA_STREAMING_IN_RECEIVER)
|
||||
retval.append("Could not set/reset Data Streaming in Receiver\n");
|
||||
|
||||
|
@ -104,7 +104,9 @@ enum {
|
||||
F_GET_RATE_CORRECT, /** < get rate correction tau */
|
||||
|
||||
F_ACTIVATE, /** < activate/deactivate readout */
|
||||
F_SET_NETWORK_PARAMETER /**< set network parameters such as transmission delay, flow control */
|
||||
F_SET_NETWORK_PARAMETER, /**< set network parameters such as transmission delay, flow control */
|
||||
|
||||
F_PROGRAM_FPGA /**< program FPGA */
|
||||
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
|
@ -50,7 +50,7 @@ int64_t Feb_Control_subframe_exposure_time_in_10nsec;
|
||||
double Feb_Control_exposure_period_in_sec;
|
||||
|
||||
int64_t Feb_Control_RateTable_Tau_in_nsec = -1;
|
||||
int64_t Feb_Control_RateTable_Subexptime_in_nsec = -1;
|
||||
int64_t Feb_Control_RateTable_Period_in_nsec = -1;
|
||||
|
||||
unsigned int Feb_Control_trimbit_size;
|
||||
unsigned int* Feb_Control_last_downloaded_trimbits;
|
||||
@ -64,7 +64,7 @@ int Feb_control_master = 0;
|
||||
|
||||
unsigned int Feb_Control_rate_correction_table[1024];
|
||||
double Feb_Control_rate_meas[16384];
|
||||
|
||||
double ratemax=-1;
|
||||
|
||||
void Module_Module(struct Module* mod,unsigned int number, unsigned int address_top){
|
||||
unsigned int i;
|
||||
@ -1371,6 +1371,7 @@ int Feb_Control_SetExposureTime(double the_exposure_time_in_sec){
|
||||
return 1;
|
||||
}
|
||||
double Feb_Control_GetExposureTime(){return Feb_Control_exposure_time_in_sec;}
|
||||
int64_t Feb_Control_GetExposureTime_in_nsec(){return (int64_t)(Feb_Control_exposure_time_in_sec*(1E9));}
|
||||
|
||||
int Feb_Control_SetSubFrameExposureTime(int64_t the_subframe_exposure_time_in_10nsec){
|
||||
Feb_Control_subframe_exposure_time_in_10nsec = the_subframe_exposure_time_in_10nsec;
|
||||
@ -1789,26 +1790,40 @@ int Feb_Control_PulseChip(int npulses){
|
||||
|
||||
|
||||
int64_t Feb_Control_Get_RateTable_Tau_in_nsec(){ return Feb_Control_RateTable_Tau_in_nsec;}
|
||||
int64_t Feb_Control_Get_RateTable_Subexptime_in_nsec(){ return Feb_Control_RateTable_Subexptime_in_nsec;}
|
||||
int64_t Feb_Control_Get_RateTable_Period_in_nsec(){ return Feb_Control_RateTable_Period_in_nsec;}
|
||||
|
||||
//returns -1 if slope is too high
|
||||
int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec){
|
||||
|
||||
double sub_expure_time_in_sec = (double)(Feb_Control_GetSubFrameExposureTime())/(double)1e9;
|
||||
//period = exptime if 16bit, period = subexptime if 32 bit
|
||||
int dr = Feb_Control_GetDynamicRange();
|
||||
double period_in_sec = (double)(Feb_Control_GetSubFrameExposureTime())/(double)1e9;
|
||||
if(dr == 16)
|
||||
period_in_sec = Feb_Control_GetExposureTime();
|
||||
|
||||
|
||||
double tau_in_sec = (double)tau_in_Nsec/(double)1e9;
|
||||
printf(" tau %lf %lf ", (double)tau_in_Nsec, (double) tau_in_sec);
|
||||
|
||||
unsigned int np = 16384; //max slope 16 * 1024
|
||||
double b0[1024];
|
||||
double m[1024];
|
||||
|
||||
if(tau_in_sec<0||sub_expure_time_in_sec<0){
|
||||
printf("Error tau %f and sub_expure_time %f must be greater than 0.\n", tau_in_sec, sub_expure_time_in_sec);
|
||||
if(tau_in_sec<0||period_in_sec<0){
|
||||
if(dr == 32)
|
||||
printf("Error tau %lf and sub_exposure_time %lf must be greater than 0.\n", tau_in_sec, period_in_sec);
|
||||
else
|
||||
printf("Error tau %lf and exposure_time %lf must be greater than 0.\n", tau_in_sec, period_in_sec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cprintf(BLUE, "Changing Rate Correction Table tau:%0.8f sec, period:%f sec",tau_in_sec,period_in_sec);
|
||||
|
||||
printf("\tCalculating table for tau of %lld ns.\n", tau_in_Nsec);
|
||||
int i;
|
||||
for(i=0;i<np;i++)
|
||||
Feb_Control_rate_meas[i] = i*exp(-i/sub_expure_time_in_sec*tau_in_sec);
|
||||
for(i=0;i<np;i++){
|
||||
Feb_Control_rate_meas[i] = i*exp(-i/period_in_sec*tau_in_sec);
|
||||
if(Feb_Control_rate_meas[i] > ratemax) ratemax= Feb_Control_rate_meas[i];
|
||||
}
|
||||
|
||||
/*
|
||||
b : index/address of block ram/rate correction table
|
||||
@ -1827,13 +1842,11 @@ int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec){
|
||||
*/
|
||||
|
||||
int next_i=0;
|
||||
double beforemax;
|
||||
b0[0] = 0;
|
||||
m[0] = 1;
|
||||
|
||||
for(i=0; i<1024; i++)
|
||||
Feb_Control_rate_correction_table[i] = 65535;
|
||||
|
||||
Feb_Control_rate_correction_table[0] = (((int)(m[0]+0.5)&0xf)<<14) | ((int)(b0[0]+0.5)&0x3fff);
|
||||
Feb_Control_rate_correction_table[0] = (((int)(m[0]+0.5)&0xf)<<14) | ((int)(b0[0]+0.5)&0x3fff);
|
||||
|
||||
int b=0;
|
||||
for(b=1;b<1024;b++){
|
||||
@ -1841,9 +1854,13 @@ int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec){
|
||||
double s=0,sx=0,sy=0,sxx=0,sxy=0;
|
||||
for(;;next_i++){
|
||||
if(next_i>=np){
|
||||
for(; b<1024; b++){
|
||||
if(beforemax>ratemax) b0[b] = beforemax;
|
||||
else b0[b] = ratemax;
|
||||
m[b] = 15;
|
||||
Feb_Control_rate_correction_table[b] = (((int)(m[b]+0.5)&0xf)<<14) | ((int)(b0[b]+0.5)&0x3fff);
|
||||
}
|
||||
b=1024;
|
||||
b0[b] = 16383;
|
||||
m[b] = 15;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1867,17 +1884,20 @@ int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec){
|
||||
double delta = s*sxx - sx*sx;
|
||||
b0[b] = (sxx*sy - sx*sxy)/delta;
|
||||
m[b] = (s*sxy - sx*sy) /delta;
|
||||
|
||||
beforemax= b0[b];
|
||||
|
||||
if(m[b]<0||m[b]>15){
|
||||
m[b]=15;
|
||||
b0[b]=16383;
|
||||
if(beforemax>ratemax) b0[b] = beforemax;
|
||||
else b0[b] = ratemax;
|
||||
}
|
||||
/*printf("After Loop s: %f,\t sx: %f,\t sy: %f,\t sxx: %f,\t sxy: %f,\t "
|
||||
"next_i: %d,\t b: %d,\t Feb_Control_rate_meas[next_i]: %f\n",
|
||||
s, sx, sy, sxx, sxy, next_i, b, Feb_Control_rate_meas[next_i]);*/
|
||||
// cout<<s<<" "<<sx<<" "<<sy<<" "<<sxx<<" "<<" "<<sxy<<" "<<delta<<" "<<m[b]<<" "<<b0[b]<<endl;
|
||||
}else{
|
||||
b0[b] = 16383;
|
||||
if(beforemax>ratemax) b0[b] = beforemax;
|
||||
else b0[b] = ratemax;
|
||||
m[b] = 15;
|
||||
}
|
||||
Feb_Control_rate_correction_table[b] = (((int)(m[b]+0.5)&0xf)<<14) | ((int)(b0[b]+0.5)&0x3fff);
|
||||
@ -1886,11 +1906,11 @@ int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec){
|
||||
|
||||
if(Feb_Control_SetRateCorrectionTable(Feb_Control_rate_correction_table)){
|
||||
Feb_Control_RateTable_Tau_in_nsec = tau_in_Nsec;
|
||||
Feb_Control_RateTable_Subexptime_in_nsec = Feb_Control_GetSubFrameExposureTime();
|
||||
Feb_Control_RateTable_Period_in_nsec = period_in_sec;
|
||||
return 1;
|
||||
}else{
|
||||
Feb_Control_RateTable_Tau_in_nsec = -1;
|
||||
Feb_Control_RateTable_Subexptime_in_nsec = -1;
|
||||
Feb_Control_RateTable_Period_in_nsec = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1943,7 +1963,7 @@ int Feb_Control_GetRateCorrectionVariable(){ return (Feb_Control_subFrameMode&DA
|
||||
void Feb_Control_SetRateCorrectionVariable(int activate_rate_correction){
|
||||
if(activate_rate_correction){
|
||||
Feb_Control_subFrameMode |= DAQ_NEXPOSURERS_ACTIVATE_RATE_CORRECTION;
|
||||
printf("Rate correction activated. Note: the rate correction applied only when run in auto summing mode.\n");
|
||||
printf("Rate correction activated.\n");
|
||||
}else{
|
||||
Feb_Control_subFrameMode &= ~DAQ_NEXPOSURERS_ACTIVATE_RATE_CORRECTION;
|
||||
printf("Rate correction deactivated.\n");
|
||||
@ -1958,11 +1978,12 @@ int Feb_Control_PrintCorrectedValues(){
|
||||
lsb = i&3;
|
||||
base = Feb_Control_rate_correction_table[i>>2] & 0x3fff;
|
||||
slope = ((Feb_Control_rate_correction_table[i>>2] & 0x3c000) >> 14);
|
||||
delta = slope*lsb;
|
||||
corr = delta+base;
|
||||
if(base==16383 && slope==15) corr=4095;
|
||||
|
||||
printf("Readout Input: %d,\tBase:%d,\tSlope:%d,\tLSB:%d,\tDelta:%d\tResult:%d\tReal:%f\n",
|
||||
delta = slope*lsb;
|
||||
corr = delta+base;
|
||||
if(slope==15) corr= 3*slope+base;
|
||||
|
||||
printf("Readout Input: %d,\tBase:%d,\tSlope:%d,\tLSB:%d,\tDelta:%d\tResult:%d\tReal:%lf\n",
|
||||
i, base, slope, lsb, delta, corr, Feb_Control_rate_meas[i]);
|
||||
}
|
||||
return 1;
|
||||
|
@ -159,6 +159,7 @@ int Feb_Control_GetModuleNumber();
|
||||
unsigned int Feb_Control_GetNExposures();
|
||||
int Feb_Control_SetExposureTime(double the_exposure_time_in_sec);
|
||||
double Feb_Control_GetExposureTime();
|
||||
int64_t Feb_Control_GetExposureTime_in_nsec();
|
||||
int Feb_Control_SetSubFrameExposureTime(int64_t the_subframe_exposure_time_in_10nsec);
|
||||
int64_t Feb_Control_GetSubFrameExposureTime();
|
||||
int Feb_Control_SetExposurePeriod(double the_exposure_period_in_sec);
|
||||
@ -185,7 +186,7 @@ int Feb_Control_GetModuleNumber();
|
||||
int Feb_Control_PulseChip(int npulses);
|
||||
|
||||
int64_t Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
int64_t Feb_Control_Get_RateTable_Subexptime_in_nsec();
|
||||
int64_t Feb_Control_Get_RateTable_Period_in_nsec();
|
||||
int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec);
|
||||
int Feb_Control_SetRateCorrectionTable(unsigned int *table);
|
||||
int Feb_Control_GetRateCorrectionVariable();
|
||||
|
Binary file not shown.
@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
|
||||
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git/eigerDetectorServer
|
||||
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
|
||||
Repsitory UUID: e9878a26ffb7e57c6e6724215e46ae5634871e64
|
||||
Revision: 231
|
||||
Repsitory UUID: c829da8894d7532ecedd7f41099f93de60d9ab00
|
||||
Revision: 240
|
||||
Branch: developer
|
||||
Last Changed Author: Dhanya_Maliakal
|
||||
Last Changed Rev: 336
|
||||
Last Changed Date: 2016-08-24 16:47:14 +0200
|
||||
Last Changed Rev: 22
|
||||
Last Changed Date: 2016-09-29 10:28:37 +0200
|
||||
|
@ -1,11 +1,11 @@
|
||||
//#define SVNPATH ""
|
||||
#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git/eigerDetectorServer"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUID "e9878a26ffb7e57c6e6724215e46ae5634871e64"
|
||||
//#define SVNREV 0x336
|
||||
#define SVNREPUUID "c829da8894d7532ecedd7f41099f93de60d9ab00"
|
||||
//#define SVNREV 0x22
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTH "Dhanya_Maliakal"
|
||||
#define SVNREV 0x336
|
||||
#define SVNDATE 0x20160824
|
||||
#define SVNREV 0x22
|
||||
#define SVNDATE 0x20160929
|
||||
//
|
||||
|
@ -130,7 +130,7 @@ int initDetector(){
|
||||
detectorGain[i] = default_gain_values[(int)STANDARD];
|
||||
for(i=0;i<NOFFSET;i++)
|
||||
detectorOffset[i] = default_offset_values[(int)STANDARD];
|
||||
thisSettings = STANDARD;/**UNITIALIZED*/
|
||||
thisSettings = UNINITIALIZED;
|
||||
/*sChan=noneSelected;
|
||||
sChip=noneSelected;
|
||||
sMod=noneSelected;
|
||||
@ -533,12 +533,29 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec){//in nanosec (will never b
|
||||
return 0;
|
||||
}
|
||||
|
||||
//when dynamic range changes, use old tau
|
||||
else if(custom_tau_in_nsec == -1)
|
||||
custom_tau_in_nsec = Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
|
||||
|
||||
int dr = Feb_Control_GetDynamicRange();
|
||||
//get period = subexptime if 32bit , else period = exptime if 16 bit
|
||||
int64_t actual_period = Feb_Control_GetSubFrameExposureTime(); //already in nsec
|
||||
if(dr == 16)
|
||||
actual_period = Feb_Control_GetExposureTime_in_nsec();
|
||||
|
||||
int64_t ratetable_period_in_nsec = Feb_Control_Get_RateTable_Period_in_nsec();
|
||||
int64_t tau_in_nsec = Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
int64_t subexp_in_nsec = Feb_Control_Get_RateTable_Subexptime_in_nsec();
|
||||
|
||||
|
||||
//same setting
|
||||
if((tau_in_nsec == custom_tau_in_nsec) && (subexp_in_nsec == Feb_Control_GetSubFrameExposureTime())){
|
||||
if((tau_in_nsec == custom_tau_in_nsec) && (ratetable_period_in_nsec == actual_period)){
|
||||
if(dr == 32)
|
||||
printf("Rate Table already created before: Same Tau %lldns, Same subexptime %lldns\n",
|
||||
tau_in_nsec,subexp_in_nsec);
|
||||
tau_in_nsec,ratetable_period_in_nsec);
|
||||
else
|
||||
printf("Rate Table already created before: Same Tau %lldns, Same exptime %lldns\n",
|
||||
tau_in_nsec,ratetable_period_in_nsec);
|
||||
}
|
||||
//different setting, calculate table
|
||||
else{
|
||||
@ -731,7 +748,9 @@ int setThresholdEnergy(int ev, int imod){
|
||||
}
|
||||
|
||||
enum detectorSettings setSettings(enum detectorSettings sett, int imod){
|
||||
if(sett != GET_SETTINGS)
|
||||
if(sett == UNINITIALIZED){
|
||||
return thisSettings;
|
||||
}if(sett != GET_SETTINGS)
|
||||
thisSettings = sett;
|
||||
return thisSettings;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorSoftware
|
||||
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
|
||||
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
|
||||
Repsitory UUID: e9878a26ffb7e57c6e6724215e46ae5634871e64
|
||||
Revision: 1149
|
||||
Repsitory UUID: c829da8894d7532ecedd7f41099f93de60d9ab00
|
||||
Revision: 1167
|
||||
Branch: developer
|
||||
Last Changed Author: Dhanya_Maliakal
|
||||
Last Changed Rev: 1149
|
||||
Last Changed Date: 2016-08-24 16:47:14 +0200
|
||||
Last Changed Rev: 1167
|
||||
Last Changed Date: 2016-09-29 10:28:37 +0200
|
||||
|
11
slsDetectorSoftware/jungfrauDetectorServer/README.txt
Normal file
11
slsDetectorSoftware/jungfrauDetectorServer/README.txt
Normal file
@ -0,0 +1,11 @@
|
||||
add the following to /etc/rc before using programfpga command before cat motd
|
||||
|
||||
|
||||
#registering 7th and 9th pin to linux kernel
|
||||
echo 7 > /sys/class/gpio/export
|
||||
echo 9 > /sys/class/gpio/export
|
||||
#define direction for the linux kernel
|
||||
echo in > /sys/class/gpio/gpio7/direction
|
||||
echo out > /sys/class/gpio/gpio9/direction
|
||||
#needed, else all write errors when server starts up, because linux tries to take control fof gpio
|
||||
echo 1 > /sys/class/gpio/gpio9/value
|
@ -114,6 +114,8 @@ int masterMode=NO_MASTER, syncMode=NO_SYNCHRONIZATION, timingMode=AUTO_TIMING;
|
||||
enum externalSignalFlag signals[4]={EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF};
|
||||
|
||||
int withGotthard = 0;
|
||||
char mtdvalue[10];
|
||||
|
||||
|
||||
/**is not const because this value will change after initDetector, is removed from mcb_funcs.c cuz its not used anywhere
|
||||
* why is this used anywhere instead of macro*/
|
||||
@ -3377,4 +3379,117 @@ int setDac(int dacnum,int dacvalue){
|
||||
}
|
||||
|
||||
|
||||
void eraseFlash(){
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("\n at eraseFlash \n");
|
||||
#endif
|
||||
|
||||
char command[255];
|
||||
sprintf(command,"flash_eraseall %s",mtdvalue);
|
||||
system(command);
|
||||
printf("flash erased\n");
|
||||
}
|
||||
|
||||
|
||||
int startWritingFPGAprogram(FILE** filefp){
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("\n at startWritingFPGAprogram \n");
|
||||
#endif
|
||||
|
||||
//getting the drive
|
||||
char output[255];
|
||||
FILE* fp = popen("awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd", "r");
|
||||
fgets(output, sizeof(output), fp);
|
||||
pclose(fp);
|
||||
strcpy(mtdvalue,"/dev/");
|
||||
char* pch = strtok(output,":");
|
||||
if(pch == NULL){
|
||||
cprintf(RED,"Could not get mtd value\n");
|
||||
return FAIL;
|
||||
}
|
||||
strcat(mtdvalue,pch);
|
||||
printf ("\nFlash drive found: %s\n",mtdvalue);
|
||||
|
||||
|
||||
//define the gpio pins
|
||||
system("echo 7 > /sys/class/gpio/export");
|
||||
system("echo 9 > /sys/class/gpio/export");
|
||||
//define their direction
|
||||
system("echo in > /sys/class/gpio/gpio7/direction");
|
||||
system("echo out > /sys/class/gpio/gpio9/direction");
|
||||
//tell FPGA to not touch flash
|
||||
system("echo 0 > /sys/class/gpio/gpio9/value");
|
||||
|
||||
//writing the program to flash
|
||||
*filefp = fopen(mtdvalue, "w");
|
||||
if(*filefp == NULL){
|
||||
cprintf(RED,"Unable to open %s in write mode\n",mtdvalue);
|
||||
return FAIL;
|
||||
}
|
||||
printf("flash ready for writing\n");
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int stopWritingFPGAprogram(FILE* filefp){
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("\n at stopWritingFPGAprogram \n");
|
||||
#endif
|
||||
|
||||
int wait = 0;
|
||||
if(filefp!= NULL){
|
||||
fclose(filefp);
|
||||
wait = 1;
|
||||
}
|
||||
|
||||
|
||||
//tell FPGA to touch flash to program itself
|
||||
system("echo 1 > /sys/class/gpio/gpio9/value");
|
||||
|
||||
if(wait){
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("Waiting for FPGA to program from flash\n");
|
||||
#endif
|
||||
//waiting for success or done
|
||||
char output[255];
|
||||
int res=0;
|
||||
while(res == 0){
|
||||
FILE* sysFile = popen("cat /sys/class/gpio/gpio7/value", "r");
|
||||
fgets(output, sizeof(output), sysFile);
|
||||
pclose(sysFile);
|
||||
sscanf(output,"%d",&res);
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("gpi07 returned %d\n",res);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
printf("FPGA has picked up the program from flash\n\n");
|
||||
|
||||
//undefine the pins
|
||||
system("echo 7 > /sys/class/gpio/unexport");
|
||||
system("echo 9 > /sys/class/gpio/unexport");
|
||||
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp){
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("\n at writeFPGAProgram \n");
|
||||
cprintf(BLUE,"address of fpgasrc:%p\n",(void *)fpgasrc);
|
||||
cprintf(BLUE,"fsize:%d\n",fsize);
|
||||
cprintf(BLUE,"pointer:%p\n",(void*)filefp);
|
||||
#endif
|
||||
|
||||
if(fwrite((void*)fpgasrc , sizeof(char) , fsize , filefp )!= fsize){
|
||||
cprintf(RED,"Could not write FPGA source to flash\n");
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VERY_VERBOSE
|
||||
cprintf(BLUE,"program written to flash\n");
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -184,6 +184,11 @@ int setDac(int dacnum,int dacvalue);
|
||||
ROI *setROI(int nroi,ROI* arg,int *retvalsize, int *ret);
|
||||
int getChannels();
|
||||
|
||||
void eraseFlash();
|
||||
int startWritingFPGAprogram(FILE** filefp);
|
||||
int stopWritingFPGAprogram(FILE* filefp);
|
||||
int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp);
|
||||
|
||||
/*
|
||||
|
||||
u_int32_t setNBits(u_int32_t);
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
slsDetectorSoftware/jungfrauDetectorServer/jungfrauDetectorServerv2.2.1
Executable file
BIN
slsDetectorSoftware/jungfrauDetectorServer/jungfrauDetectorServerv2.2.1
Executable file
Binary file not shown.
@ -331,6 +331,7 @@ int function_table() {
|
||||
flist[F_CALIBRATE_PEDESTAL]=&calibrate_pedestal;
|
||||
flist[F_SET_CTB_PATTERN]=&set_ctb_pattern;
|
||||
flist[F_WRITE_ADC_REG]=&write_adc_register;
|
||||
flist[F_PROGRAM_FPGA]=&program_fpga;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -3501,3 +3502,129 @@ int write_adc_register(int file_des) {
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int program_fpga(int file_des) {
|
||||
int ret=OK;
|
||||
int n;
|
||||
const size_t maxprogramsize = 2 * 1024 *1024;
|
||||
size_t unitprogramsize = 0;
|
||||
int currentPointer = 0;
|
||||
|
||||
char* fpgasrc = (char*)malloc(maxprogramsize);
|
||||
size_t filesize = 0;
|
||||
size_t totalsize = 0;
|
||||
|
||||
FILE* fp = NULL;
|
||||
|
||||
sprintf(mess,"Program FPGA\n");
|
||||
|
||||
//filesize
|
||||
n = receiveDataOnly(file_des,&filesize,sizeof(filesize));
|
||||
if (n < 0) {
|
||||
sprintf(mess,"Error reading from socket\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
totalsize = filesize;
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("\n\n Total size is:%d\n",totalsize);
|
||||
#endif
|
||||
|
||||
//opening file pointer to flash and telling FPGA to not touch flash
|
||||
if(startWritingFPGAprogram(&fp) != OK){
|
||||
sprintf(mess,"Could not write to flash. Error at startup.\n");
|
||||
cprintf(RED,"%s",mess);
|
||||
ret=FAIL;
|
||||
filesize = 0;
|
||||
}
|
||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||
if (ret==FAIL)
|
||||
n += sendDataOnly(file_des,mess,sizeof(mess));
|
||||
|
||||
|
||||
//erasing flash
|
||||
if(ret != FAIL)
|
||||
eraseFlash();
|
||||
|
||||
|
||||
//writing to flash part by part
|
||||
while(filesize){
|
||||
|
||||
unitprogramsize = maxprogramsize; //2mb
|
||||
if(unitprogramsize > filesize) //less than 2mb
|
||||
unitprogramsize = filesize;
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("unit size to receive is:%d\n",unitprogramsize);
|
||||
printf("filesize:%d currentpointer:%d\n",filesize,currentPointer);
|
||||
#endif
|
||||
//receive
|
||||
n = receiveDataOnly(file_des,fpgasrc,unitprogramsize);
|
||||
if (n < 0) {
|
||||
sprintf(mess,"Error reading from socket\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
|
||||
if(!(unitprogramsize - filesize)){
|
||||
fpgasrc[unitprogramsize]='\0';
|
||||
filesize-=unitprogramsize;
|
||||
unitprogramsize++;
|
||||
}else
|
||||
filesize-=unitprogramsize;
|
||||
|
||||
|
||||
if (ret==OK) {
|
||||
if (differentClients==1 && lockStatus==1) {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
} else{
|
||||
ret = writeFPGAProgram(fpgasrc,unitprogramsize,fp);
|
||||
}
|
||||
}
|
||||
|
||||
if(ret!=FAIL){
|
||||
if (differentClients)
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
/* send answer */
|
||||
/* send OK/failed */
|
||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||
if (ret==FAIL) {
|
||||
n += sendDataOnly(file_des,mess,sizeof(mess));
|
||||
cprintf(RED,"Failure: Breaking out of program receiving\n");
|
||||
break;
|
||||
}
|
||||
|
||||
//print progress
|
||||
printf("Writing to Flash:%d%%\r",(int) (((double)(totalsize-filesize)/totalsize)*100) );
|
||||
fflush(stdout);
|
||||
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
//closing file pointer to flash and informing FPGA
|
||||
if(stopWritingFPGAprogram(fp) == FAIL){
|
||||
sprintf(mess,"Could not write to flash. Error at end.\n");
|
||||
cprintf(RED,"%s",mess);
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||
if (ret==FAIL)
|
||||
n += sendDataOnly(file_des,mess,sizeof(mess));
|
||||
|
||||
|
||||
//free resources
|
||||
free(fpgasrc);
|
||||
if(fp!=NULL)
|
||||
fclose(fp);
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("Done with program receiving command\n");
|
||||
#endif
|
||||
/*return ok/fail*/
|
||||
return ret;
|
||||
}
|
||||
|
@ -95,4 +95,6 @@ int set_roi(int);
|
||||
int set_ctb_pattern(int);
|
||||
|
||||
int write_adc_register(int);;
|
||||
|
||||
int program_fpga(int);
|
||||
#endif
|
||||
|
@ -3955,6 +3955,21 @@ int multiSlsDetector::executeTrimming(trimMode mode, int par1, int par2, int imo
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::programFPGA(string fname){
|
||||
int ret=OK, ret1=OK;
|
||||
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||
if (detectors[i]) {
|
||||
ret=detectors[i]->programFPGA(fname);
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
if (ret!=OK)
|
||||
ret1=FAIL;
|
||||
}
|
||||
}
|
||||
return ret1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::loadSettingsFile(string fname, int imod) {
|
||||
|
@ -488,6 +488,11 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
|
||||
int decodeNMod(int i, int &idet, int &imod);
|
||||
|
||||
/** programs FPGA with pof file
|
||||
\param fname file name
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
int programFPGA(string fname);
|
||||
|
||||
/** loads the modules settings/trimbits reading from a file - file name extension is automatically generated! */
|
||||
int loadSettingsFile(string fname, int nmod=0);
|
||||
|
@ -1,11 +1,11 @@
|
||||
//#define SVNPATH ""
|
||||
#define SVNURLLIB "git@git.psi.ch:sls_detectors_software/sls_detector_software.git"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUIDLIB "e9878a26ffb7e57c6e6724215e46ae5634871e64"
|
||||
//#define SVNREV 0x1149
|
||||
#define SVNREPUUIDLIB "c829da8894d7532ecedd7f41099f93de60d9ab00"
|
||||
//#define SVNREV 0x1167
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTHLIB "Dhanya_Maliakal"
|
||||
#define SVNREVLIB 0x1149
|
||||
#define SVNDATELIB 0x20160824
|
||||
#define SVNREVLIB 0x1167
|
||||
#define SVNDATELIB 0x20160929
|
||||
//
|
||||
|
@ -4008,8 +4008,16 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
setTotalProgress();
|
||||
}
|
||||
|
||||
//if eiger, rate corr on, a put statement, dr=32 &setting subexp or dr =16 & setting exptime, set ratecorr to update table
|
||||
double r;
|
||||
if((index == SUBFRAME_ACQUISITION_TIME) && (thisDetector->myDetectorType == EIGER) && (t>=0) && getRateCorrection(r)){
|
||||
if( (thisDetector->myDetectorType == EIGER) &&
|
||||
getRateCorrection(r) &&
|
||||
(t>=0) &&
|
||||
|
||||
(((index == SUBFRAME_ACQUISITION_TIME) && (thisDetector->dynamicRange == 32))||
|
||||
((index == ACQUISITION_TIME) && (thisDetector->dynamicRange == 16)))
|
||||
|
||||
&& (t>=0) && getRateCorrection(r)){
|
||||
setRateCorrection(r);
|
||||
}
|
||||
|
||||
@ -4514,8 +4522,12 @@ int slsDetector::setDynamicRange(int n){
|
||||
if (rateret==FAIL) {
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
if(strstr(mess,"Rate Correction")!=NULL)
|
||||
setErrorMask((getErrorMask())|(RATE_CORRECTION_NOT_32BIT));
|
||||
if(strstr(mess,"Rate Correction")!=NULL){
|
||||
if(strstr(mess,"32")!=NULL)
|
||||
setErrorMask((getErrorMask())|(RATE_CORRECTION_NOT_32or16BIT));
|
||||
else
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION));
|
||||
}
|
||||
}
|
||||
}
|
||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
@ -5089,7 +5101,7 @@ int slsDetector::setRateCorrection(double t){
|
||||
if(strstr(mess,"default tau")!=NULL)
|
||||
setErrorMask((getErrorMask())|(RATE_CORRECTION_NO_TAU_PROVIDED));
|
||||
if(strstr(mess,"32")!=NULL)
|
||||
setErrorMask((getErrorMask())|(RATE_CORRECTION_NOT_32BIT));
|
||||
setErrorMask((getErrorMask())|(RATE_CORRECTION_NOT_32or16BIT));
|
||||
else
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION));
|
||||
}
|
||||
@ -6369,6 +6381,197 @@ int slsDetector::writeSettingsFile(string fname, int imod, int* iodelay){
|
||||
|
||||
|
||||
|
||||
int slsDetector::programFPGA(string fname){
|
||||
int ret=FAIL;
|
||||
|
||||
if(thisDetector->myDetectorType != JUNGFRAU){
|
||||
std::cout << "Not implemented for this detector" << std::endl;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
//check if it exists
|
||||
struct stat st;
|
||||
if(stat(fname.c_str(),&st)){
|
||||
std::cout << "Programming file does not exist" << endl;
|
||||
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
//create destination file name,replaces original filename with Jungfrau.rawbin
|
||||
string destfname;
|
||||
size_t found = fname.find_last_of("/\\");
|
||||
if(found == string::npos)
|
||||
destfname = "";
|
||||
else
|
||||
destfname = fname.substr(0,found+1);
|
||||
destfname.append("Jungfrau_MCB.rawbin");
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Converting " << fname << " to " << destfname << std::endl;
|
||||
#endif
|
||||
int filepos,x,y,i;
|
||||
FILE* src = fopen(fname.c_str(),"rb");
|
||||
FILE* dst = fopen(destfname.c_str(),"wb");
|
||||
// Remove header (0...11C)
|
||||
for (filepos=0; filepos < 0x11C; filepos++)
|
||||
fgetc(src);
|
||||
// Write 0x80 times 0xFF (0...7F)
|
||||
for (filepos=0; filepos < 0x80; filepos++)
|
||||
fputc(0xFF,dst);
|
||||
// Swap bits and write to file
|
||||
for (filepos=0x80; filepos < 0x1000000; filepos++) {
|
||||
x = fgetc(src);
|
||||
if (x < 0) break;
|
||||
|
||||
y=0;
|
||||
for (i=0; i < 8; i++)
|
||||
y=y| ( (( x & (1<<i) ) >> i) << (7-i) ); // This swaps the bits
|
||||
|
||||
fputc(y,dst);
|
||||
}
|
||||
if (filepos < 0x1000000){
|
||||
std::cout << "Could not convert programming file. EOF before end of flash" << std::endl;
|
||||
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout << "File has been converted to " << destfname << std::endl;
|
||||
#endif
|
||||
|
||||
//loading file to memory
|
||||
FILE* fp = fopen(destfname.c_str(),"r");
|
||||
if(fp == NULL){
|
||||
std::cout << "Could not open rawbin file" << std::endl;
|
||||
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
|
||||
return FAIL;
|
||||
}
|
||||
if(fseek(fp,0,SEEK_END)){
|
||||
std::cout << "Seek error in rawbin file" << std::endl;
|
||||
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
|
||||
return FAIL;
|
||||
}
|
||||
size_t filesize = ftell(fp);
|
||||
if(filesize == -1){
|
||||
std::cout << "Could not get length of rawbin file" << std::endl;
|
||||
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
|
||||
return FAIL;
|
||||
}
|
||||
rewind(fp);
|
||||
char* fpgasrc = (char*)malloc(filesize+1);
|
||||
if(fpgasrc == NULL){
|
||||
std::cout << "Could not allocate size of program" << std::endl;
|
||||
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
|
||||
return FAIL;
|
||||
}
|
||||
if(fread(fpgasrc, sizeof(char), filesize, fp) != filesize){
|
||||
std::cout << "Could not read rawbin file" << std::endl;
|
||||
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if(fclose(fp)){
|
||||
std::cout << "Could not close rawbin file" << std::endl;
|
||||
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Successfully loaded the rawbin file to program memory" << std::endl;
|
||||
#endif
|
||||
|
||||
const size_t maxprogramsize = 2 * 1024 *1024;
|
||||
size_t unitprogramsize = 0;
|
||||
int currentPointer = 0;
|
||||
size_t totalsize = filesize;
|
||||
|
||||
int fnum=F_PROGRAM_FPGA;
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
int64_t retval = -1;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Sending programming binary to detector " << endl;
|
||||
#endif
|
||||
if (setOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
||||
if (connectControl() == OK){
|
||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
controlSocket->SendDataOnly(&filesize,sizeof(filesize));
|
||||
|
||||
//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())|(PROGRAMMING_ERROR));
|
||||
filesize = 0;
|
||||
}
|
||||
|
||||
if(ret!=FAIL){
|
||||
std::cout<< "This can take awhile. Please be patient..." << endl;
|
||||
printf("Erasing Flash:%d%%\r",0);
|
||||
std::cout << flush;
|
||||
//erasing takes 65 seconds, printing here (otherwise need threads in server-unnecessary)
|
||||
int count = 66;
|
||||
while(count>0){
|
||||
usleep(1 * 1000 * 1000);
|
||||
count--;
|
||||
printf("Erasing Flash:%d%%\r",(int) (((double)(65-count)/65)*100));
|
||||
std::cout << flush;
|
||||
}
|
||||
std::cout<<std::endl;
|
||||
printf("Writing to Flash:%d%%\r",0);
|
||||
std::cout << flush;
|
||||
}
|
||||
|
||||
//sending program in parts of 2mb each
|
||||
while(filesize > 0){
|
||||
|
||||
unitprogramsize = maxprogramsize; //2mb
|
||||
if(unitprogramsize > filesize) //less than 2mb
|
||||
unitprogramsize = filesize;
|
||||
#ifdef VERBOSE
|
||||
std::cout << "unitprogramsize:" << unitprogramsize << "\t filesize:" << filesize << std::endl;
|
||||
#endif
|
||||
controlSocket->SendDataOnly(fpgasrc+currentPointer,unitprogramsize);
|
||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==FAIL) {
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
|
||||
//stops writing
|
||||
break;
|
||||
}
|
||||
filesize-=unitprogramsize;
|
||||
currentPointer+=unitprogramsize;
|
||||
|
||||
//print progress
|
||||
printf("Writing to Flash:%d%%\r",(int) (((double)(totalsize-filesize)/totalsize)*100));
|
||||
std::cout << flush;
|
||||
|
||||
}
|
||||
std::cout<<std::endl;
|
||||
|
||||
//check ending error
|
||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==FAIL) {
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
|
||||
}
|
||||
|
||||
|
||||
disconnectControl();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
}
|
||||
}
|
||||
|
||||
//free resources
|
||||
free(fpgasrc);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsDetector::loadSettingsFile(string fname, int imod) {
|
||||
|
||||
sls_detector_module *myMod=NULL;
|
||||
|
@ -522,7 +522,12 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** programs FPGA with pof file
|
||||
\param fname file name
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
int programFPGA(string fname);
|
||||
|
||||
/** loads the modules settings/trimbits reading from a file
|
||||
\param fname file name . If not specified, extension is automatically generated!
|
||||
\param imod module number, -1 means all modules
|
||||
|
@ -441,6 +441,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="programfpga";
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced;
|
||||
i++;
|
||||
|
||||
/* versions/ serial numbers getId */
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="moduleversion"; //
|
||||
@ -4259,80 +4263,97 @@ string slsDetectorCommand::helpSpeed(int narg, char *args[], int action) {
|
||||
|
||||
string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
|
||||
|
||||
int retval;
|
||||
char answer[1000]="";
|
||||
int retval;
|
||||
char answer[1000]="";
|
||||
|
||||
if (action==HELP_ACTION)
|
||||
return helpAdvanced(narg, args, action);
|
||||
|
||||
if (cmd=="flags") {
|
||||
if (action==HELP_ACTION)
|
||||
return helpAdvanced(narg, args, action);
|
||||
|
||||
readOutFlags flag=GET_READOUT_FLAGS;
|
||||
if (cmd=="flags") {
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
string sval=string(args[1]);
|
||||
if (sval=="none")
|
||||
flag=NORMAL_READOUT;
|
||||
else if (sval=="storeinram")
|
||||
flag=STORE_IN_RAM;
|
||||
else if (sval=="tot")
|
||||
flag=TOT_MODE;
|
||||
else if (sval=="continous")
|
||||
flag=CONTINOUS_RO;
|
||||
else if (sval=="parallel")
|
||||
flag=PARALLEL;
|
||||
else if (sval=="nonparallel")
|
||||
flag=NONPARALLEL;
|
||||
else if (sval=="safe")
|
||||
flag=SAFE;
|
||||
else
|
||||
return string("could not scan flag ")+string(args[1]);
|
||||
}
|
||||
|
||||
readOutFlags flag=GET_READOUT_FLAGS;
|
||||
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
if (action==PUT_ACTION) {
|
||||
string sval=string(args[1]);
|
||||
if (sval=="none")
|
||||
flag=NORMAL_READOUT;
|
||||
else if (sval=="storeinram")
|
||||
flag=STORE_IN_RAM;
|
||||
else if (sval=="tot")
|
||||
flag=TOT_MODE;
|
||||
else if (sval=="continous")
|
||||
flag=CONTINOUS_RO;
|
||||
else if (sval=="parallel")
|
||||
flag=PARALLEL;
|
||||
else if (sval=="nonparallel")
|
||||
flag=NONPARALLEL;
|
||||
else if (sval=="safe")
|
||||
flag=SAFE;
|
||||
else
|
||||
return string("could not scan flag ")+string(args[1]);
|
||||
}
|
||||
|
||||
retval = myDet->setReadOutFlags(flag);
|
||||
|
||||
if(retval == NORMAL_READOUT)
|
||||
return string("none");
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
|
||||
if(retval & STORE_IN_RAM)
|
||||
strcat(answer,"storeinram ");
|
||||
if(retval & TOT_MODE)
|
||||
strcat(answer,"tot ");
|
||||
if(retval & CONTINOUS_RO)
|
||||
strcat(answer,"continous ");
|
||||
if(retval & PARALLEL)
|
||||
strcat(answer,"parallel ");
|
||||
if(retval & NONPARALLEL)
|
||||
strcat(answer,"nonparallel ");
|
||||
if(retval & SAFE)
|
||||
strcat(answer,"safe ");
|
||||
if(strlen(answer))
|
||||
return string(answer);
|
||||
retval = myDet->setReadOutFlags(flag);
|
||||
|
||||
return string("unknown");
|
||||
if(retval == NORMAL_READOUT)
|
||||
return string("none");
|
||||
|
||||
} else if (cmd=="extsig") {
|
||||
externalSignalFlag flag=GET_EXTERNAL_SIGNAL_FLAG;
|
||||
int is=-1;
|
||||
if (sscanf(args[0],"extsig:%d",&is))
|
||||
;
|
||||
else
|
||||
return string("could not scan signal number ")+string(args[0]);
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
flag=myDet->externalSignalType(args[1]);
|
||||
if (flag==GET_EXTERNAL_SIGNAL_FLAG)
|
||||
return string("could not scan external signal mode ")+string(args[1]);
|
||||
}
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
|
||||
return myDet->externalSignalType(myDet->setExternalSignalFlags(flag,is));
|
||||
if(retval & STORE_IN_RAM)
|
||||
strcat(answer,"storeinram ");
|
||||
if(retval & TOT_MODE)
|
||||
strcat(answer,"tot ");
|
||||
if(retval & CONTINOUS_RO)
|
||||
strcat(answer,"continous ");
|
||||
if(retval & PARALLEL)
|
||||
strcat(answer,"parallel ");
|
||||
if(retval & NONPARALLEL)
|
||||
strcat(answer,"nonparallel ");
|
||||
if(retval & SAFE)
|
||||
strcat(answer,"safe ");
|
||||
if(strlen(answer))
|
||||
return string(answer);
|
||||
|
||||
} else
|
||||
return string("could not decode flag ")+cmd;
|
||||
return string("unknown");
|
||||
|
||||
} else if (cmd=="extsig") {
|
||||
externalSignalFlag flag=GET_EXTERNAL_SIGNAL_FLAG;
|
||||
int is=-1;
|
||||
if (sscanf(args[0],"extsig:%d",&is))
|
||||
;
|
||||
else
|
||||
return string("could not scan signal number ")+string(args[0]);
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
flag=myDet->externalSignalType(args[1]);
|
||||
if (flag==GET_EXTERNAL_SIGNAL_FLAG)
|
||||
return string("could not scan external signal mode ")+string(args[1]);
|
||||
}
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
|
||||
return myDet->externalSignalType(myDet->setExternalSignalFlags(flag,is));
|
||||
|
||||
} else if (cmd=="programfpga") {
|
||||
if (action==GET_ACTION)
|
||||
return string("cannot get");
|
||||
|
||||
if (narg<2)
|
||||
return string("wrong usage: should specify programming file");
|
||||
if(strstr(args[1],".pof")==NULL)
|
||||
return string("wrong usage: should specify programming file with .pof extension");
|
||||
|
||||
string sval=string(args[1]);
|
||||
#ifdef VERBOSE
|
||||
std::cout<< " programming file " << sval << std::endl;
|
||||
#endif
|
||||
if(myDet->programFPGA(sval) == OK)
|
||||
return string("programming successful");
|
||||
return string("programming unsuccessful");
|
||||
}
|
||||
else
|
||||
return string("could not decode flag ")+cmd;
|
||||
|
||||
}
|
||||
|
||||
@ -4344,6 +4365,7 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
|
||||
|
||||
os << "extsig:i mode \t sets the mode of the external signal i. can be \n \t \t \t off, \n \t \t \t gate_in_active_high, \n \t \t \t gate_in_active_low, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t ro_trigger_in_rising_edge, \n \t \t \t ro_trigger_in_falling_edge, \n \t \t \t gate_out_active_high, \n \t \t \t gate_out_active_low, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge, \n \t \t \t ro_trigger_out_rising_edge, \n \t \t \t ro_trigger_out_falling_edge" << std::endl;
|
||||
os << "flags mode \t sets the readout flags to mode. can be none, storeinram, tot, continous, parallel, nonparallel, safe, unknown" << std::endl;
|
||||
os << "programfpga f \t programs the fpga with file f with .pof" << std::endl;
|
||||
|
||||
}
|
||||
if (action==GET_ACTION || action==HELP_ACTION) {
|
||||
|
@ -491,6 +491,12 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
*/
|
||||
virtual int loadSettingsFile(string fname, int imod=-1)=0;
|
||||
|
||||
/** programs FPGA with pof file
|
||||
\param fname file name
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
virtual int programFPGA(string fname)=0;
|
||||
|
||||
|
||||
|
||||
/** saves the modules settings/trimbits writing to a file
|
||||
|
@ -1932,6 +1932,7 @@ int set_module(int file_des) {
|
||||
case LOWGAIN:
|
||||
case VERYHIGHGAIN:
|
||||
case VERYLOWGAIN:
|
||||
case UNINITIALIZED:
|
||||
break;
|
||||
default:
|
||||
sprintf(mess,"This setting %d does not exist for this detector\n",myModule.reg);
|
||||
@ -2787,15 +2788,26 @@ int set_dynamic_range(int file_des) {
|
||||
#endif
|
||||
}
|
||||
if(ret == OK){
|
||||
int old_dr = setDynamicRange(-1);
|
||||
retval=setDynamicRange(dr);
|
||||
if (dr>=0 && retval!=dr)
|
||||
ret=FAIL;
|
||||
//look at rate correction only if dr change worked
|
||||
if((ret==OK) && (dr!=32) && (dr!=-1) && (getRateCorrectionEnable())){
|
||||
if((ret==OK) && (dr!=32) && (dr!=16) && (dr!=-1) && (getRateCorrectionEnable())){
|
||||
setRateCorrection(0);
|
||||
strcpy(mess,"Switching off Rate Correction. Must be in 32 bit mode\n");
|
||||
strcpy(mess,"Switching off Rate Correction. Must be in 32 or 16 bit mode\n");
|
||||
cprintf(RED,"%s",mess);
|
||||
rateret = FAIL;
|
||||
}else{
|
||||
//setting it if dr changed from 16 to 32 or vice versa with tau value as in rate table
|
||||
if((dr!=-1) && (old_dr != dr) && getRateCorrectionEnable() && (dr == 16 || dr == 32)){
|
||||
setRateCorrection(-1); //tau_ns will not be -1 here
|
||||
if(!getRateCorrectionEnable()){
|
||||
strcpy(mess,"Deactivating Rate Correction. Could not set it.\n");
|
||||
cprintf(RED,"%s",mess);
|
||||
ret=FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -3977,9 +3989,9 @@ int set_rate_correct(int file_des) {
|
||||
|
||||
//set rate
|
||||
else{
|
||||
//not 32 bit mode
|
||||
if((setDynamicRange(-1)!=32) && (tau_ns!=0)){
|
||||
strcpy(mess,"Rate correction Deactivated, must be in 32 bit mode\n");
|
||||
//not 32 or 16 bit mode
|
||||
if((setDynamicRange(-1)!=32) && (setDynamicRange(-1)!=16) && (tau_ns!=0)){
|
||||
strcpy(mess,"Rate correction Deactivated, must be in 32 or 16 bit mode\n");
|
||||
cprintf(RED,"%s",mess);
|
||||
ret=FAIL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user