added storage cells

This commit is contained in:
2018-04-13 15:05:43 +02:00
parent bdcccb7732
commit e024774323
14 changed files with 218 additions and 56 deletions

View File

@ -392,7 +392,9 @@ void setupDetector() {
setSpeed(CLOCK_DIVIDER, HALF_SPEED);
cleanFifos();
resetCore();
configureASICTimer();
bus_w(ADC_PORT_INVERT_REG, ADC_PORT_INVERT_VAL);
//Initialization of acquistion parameters
setSettings(DEFAULT_SETTINGS,-1);
@ -411,6 +413,8 @@ void setupDetector() {
setThresholdTemperature(DEFAULT_TMP_THRSHLD);
// reset temp event
setTemperatureEvent(0);
}
@ -434,7 +438,7 @@ int powerChip (int on){
}
return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_ENABLE_MSK) >> CHIP_POWER_ENABLE_OFST);
/* temporary setup until new firmware fixes bug */
/**temporary fix until power reg status can be read */
//return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_STATUS_MSK) >> CHIP_POWER_STATUS_OFST);
}
@ -502,10 +506,9 @@ int getPhase() {
}
void configureASICTimer() {
cprintf(RED," in here\n");
//cprintf(RED,"asic reg:0x%x\n", bus_r(ASIC_CTRL_REG));
//bus_w(ASIC_CTRL_REG, (bus_r(ASIC_CTRL_REG) & ~ASIC_CTRL_PRCHRG_TMR_MSK) | ASIC_CTRL_PRCHRG_TMR_VAL);
//bus_w(ASIC_CTRL_REG, (bus_r(ASIC_CTRL_REG) & ~ASIC_CTRL_DS_TMR_MSK) | ASIC_CTRL_DS_TMR_VAL);
printf("\nConfiguring ASIC Timer\n");
bus_w(ASIC_CTRL_REG, (bus_r(ASIC_CTRL_REG) & ~ASIC_CTRL_PRCHRG_TMR_MSK) | ASIC_CTRL_PRCHRG_TMR_VAL);
bus_w(ASIC_CTRL_REG, (bus_r(ASIC_CTRL_REG) & ~ASIC_CTRL_DS_TMR_MSK) | ASIC_CTRL_DS_TMR_VAL);
}
@ -644,9 +647,9 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
case ACQUISITION_TIME:
if(val >= 0){
printf("\nSetting exptime: %lldns\n", (long long int)val);
val *= (1E-3 * CLK_RUN);
val *= (1E-3 * CLK_RUN); /*(-2)*/
}
retval = set64BitReg(val, SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG) / (1E-3 * CLK_RUN);
retval = set64BitReg(val, SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG) / (1E-3 * CLK_RUN);/*(+2)*/
printf("Getting exptime: %lldns\n", (long long int)retval);
break;
@ -675,6 +678,16 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
printf("Getting #cycles: %lld\n", (long long int)retval);
break;
case STORAGE_CELL_NUMBER:
if(val >= 0) {
printf("\nSetting #storage cells to %lld\n", (long long int)val);
bus_w(CONTROL_REG, (bus_r(CONTROL_REG) & ~CONTROL_STORAGE_CELL_NUM_MSK) |
((val << CONTROL_STORAGE_CELL_NUM_OFST) & CONTROL_STORAGE_CELL_NUM_MSK));
}
retval = ((bus_r(CONTROL_REG) & CONTROL_STORAGE_CELL_NUM_MSK) >> CONTROL_STORAGE_CELL_NUM_OFST);
printf("Getting #storage cells: %lld\n", (long long int)retval);
break;
default:
cprintf(RED,"Warning: Timer Index not implemented for this detector: %d\n", ind);
break;

View File

@ -93,16 +93,18 @@ enum NETWORKINDEX { TXN_FRAME };
#define ADC_PORT_INVERT_VAL (0x453b2a9c)
#define MAX_TIMESLOT_VAL (0x1F)
#define MAX_THRESHOLD_TEMP_VAL (127999) //millidegrees
#define MAX_STORAGE_CELL_VAL (15) //0xF
#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 CONFIG_HALF_SPEED (CONFIG_TDMA_DISABLE_VAL + CONFIG_HALF_SPEED_20MHZ_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_QUARTER_SPEED_VAL (0x0f)
#define ADC_PHASE_HALF_SPEED (0x48) //72
#define ADC_PHASE_QUARTER_SPEED (0x48) //72
#define ADC_OFST_HALF_SPEED_VAL (0x1f) //(0x20)
#define ADC_OFST_QUARTER_SPEED_VAL (0x0f) //(0x0f)
#define ADC_PHASE_HALF_SPEED (0x2D) //45
#define ADC_PHASE_QUARTER_SPEED (0x2D) //45
#define ADC_PORT_INVERT_VAL (0x453b2a9c)
/* Maybe not required for jungfrau */
#define NTRIMBITS (6)

View File

@ -1995,19 +1995,7 @@ void multiSlsDetector::resetFinalDataQueue() {
/*
set or read the acquisition timers
enum timerIndex {
FRAME_NUMBER,
ACQUISITION_TIME,
FRAME_PERIOD,
DELAY_AFTER_TRIGGER,
GATES_NUMBER,
PROBES_NUMBER
CYCLES_NUMBER,
GATE_INTEGRATED_TIME
}
*/
int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t){
int64_t ret=-100;

View File

@ -4746,10 +4746,6 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
cout << "Changing samples: data size = " << thisDetector->dataBytes <<endl;
}
/* set progress */
if ((index==FRAME_NUMBER) || (index==CYCLES_NUMBER)) {
setTotalProgress();
}
if(t!=-1){
if ((thisDetector->myDetectorType==MYTHEN)&&(index==PROBES_NUMBER)) {
@ -4758,7 +4754,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
}
/* set progress */
if ((index==FRAME_NUMBER) || (index==CYCLES_NUMBER)) {
if ((index==FRAME_NUMBER) || (index==CYCLES_NUMBER) || (index==STORAGE_CELL_NUMBER)) {
setTotalProgress();
}
@ -4780,7 +4776,9 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
//send acquisiton time/period/subexptime/frame/cycles/samples to receiver
if((index==FRAME_NUMBER)||(index==FRAME_PERIOD)||(index==CYCLES_NUMBER)||(index==ACQUISITION_TIME) || (index==SUBFRAME_ACQUISITION_TIME) || (index==SAMPLES_JCTB)){
if((index==FRAME_NUMBER)||(index==FRAME_PERIOD)||(index==CYCLES_NUMBER)||
(index==ACQUISITION_TIME) || (index==SUBFRAME_ACQUISITION_TIME) ||
(index==SAMPLES_JCTB) || (index==STORAGE_CELL_NUMBER)){
string timername = getTimerType(index);
if(ret != FAIL){
int64_t args[2];
@ -4791,15 +4789,14 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
//set #frames * #cycles
if((index==FRAME_NUMBER)||(index==CYCLES_NUMBER)){
timername.assign("(Number of Frames) * (Number of cycles)");
if((index==FRAME_NUMBER)||(index==CYCLES_NUMBER)||(index==STORAGE_CELL_NUMBER)){
timername.assign("(Number of Frames) * (Number of cycles) * (Number of storage cells)");
args[1] = thisDetector->timerValue[FRAME_NUMBER] *
((thisDetector->timerValue[CYCLES_NUMBER] > 0) ? (thisDetector->timerValue[CYCLES_NUMBER]) : 1) *
((thisDetector->timerValue[STORAGE_CELL_NUMBER] > 0) ? (thisDetector->timerValue[STORAGE_CELL_NUMBER])+1 : 1);
#ifdef VERBOSE
std::cout << "Setting/Getting " << timername << " " << index <<" to/from receiver " << args[1] << std::endl;
std::cout << "Setting/Getting " << timername << " " << index <<" to/from receiver " << args[1] << std::endl;
#endif
if(thisDetector->timerValue[CYCLES_NUMBER]==0)
args[1] = thisDetector->timerValue[FRAME_NUMBER];
else
args[1] = thisDetector->timerValue[FRAME_NUMBER]*thisDetector->timerValue[CYCLES_NUMBER];
}
#ifdef VERBOSE
// set period/exptime/subexptime
@ -5123,7 +5120,7 @@ int slsDetector::setPort(portType index, int num){
int slsDetector::setTotalProgress() {
int nf=1, npos=1, nscan[MAX_SCAN_LEVELS]={1,1}, nc=1, nm=1;
int nf=1, npos=1, nscan[MAX_SCAN_LEVELS]={1,1}, nc=1, nm=1, ns=1;
if (thisDetector->timerValue[FRAME_NUMBER])
nf=thisDetector->timerValue[FRAME_NUMBER];
@ -5131,6 +5128,9 @@ int slsDetector::setTotalProgress() {
if (thisDetector->timerValue[CYCLES_NUMBER]>0)
nc=thisDetector->timerValue[CYCLES_NUMBER];
if (thisDetector->timerValue[STORAGE_CELL_NUMBER]>0)
ns=thisDetector->timerValue[STORAGE_CELL_NUMBER]+1;
if (thisDetector->numberOfPositions>0)
npos=thisDetector->numberOfPositions;
@ -5144,12 +5144,13 @@ int slsDetector::setTotalProgress() {
if ((thisDetector->nScanSteps[1]>0) && (thisDetector->actionMask & (1 << (MAX_ACTIONS+1))))
nscan[1]=thisDetector->nScanSteps[1];
thisDetector->totalProgress=nf*nc*npos*nm*nscan[0]*nscan[1];
thisDetector->totalProgress=nf*nc*ns*npos*nm*nscan[0]*nscan[1];
#ifdef VERBOSE
cout << "nc " << nc << endl;
cout << "nm " << nm << endl;
cout << "nf " << nf << endl;
cout << "ns " << ns << endl;
cout << "npos " << npos << endl;
cout << "nscan[0] " << nscan[0] << endl;
cout << "nscan[1] " << nscan[1] << endl;

View File

@ -833,8 +833,8 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0;
}};
/** returns string from timer index
\param s can be FRAME_NUMBER,ACQUISITION_TIME,FRAME_PERIOD, DELAY_AFTER_TRIGGER,GATES_NUMBER,PROBES_NUMBER, CYCLES_NUMBER, ACTUAL_TIME,MEASUREMENT_TIME, PROGRESS,MEASUREMENTS_NUMBER,FRAMES_FROM_START,FRAMES_FROM_START_PG,SAMPLES_JCTB,SUBFRAME_ACQUISITION_TIME
\returns string frame_number,acquisition_time,frame_period, delay_after_trigger,gates_number,probes_number, cycles_number, actual_time,measurement_time, progress,measurements_number,frames_from_start,frames_from_start_pg,samples_jctb,subframe_acquisition_time
\param s can be FRAME_NUMBER,ACQUISITION_TIME,FRAME_PERIOD, DELAY_AFTER_TRIGGER,GATES_NUMBER,PROBES_NUMBER, CYCLES_NUMBER, ACTUAL_TIME,MEASUREMENT_TIME, PROGRESS,MEASUREMENTS_NUMBER,FRAMES_FROM_START,FRAMES_FROM_START_PG,SAMPLES_JCTB,SUBFRAME_ACQUISITION_TIME,STORAGE_CELL_NUMBER
\returns string frame_number,acquisition_time,frame_period, delay_after_trigger,gates_number,probes_number, cycles_number, actual_time,measurement_time, progress,measurements_number,frames_from_start,frames_from_start_pg,samples_jctb,subframe_acquisition_time,storage_cell_number
*/
static string getTimerType(timerIndex t){ \
switch (t) { \
@ -853,6 +853,7 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0;
case FRAMES_FROM_START_PG: return string("frames_from_start_pg"); \
case SAMPLES_JCTB: return string("samples_jctb"); \
case SUBFRAME_ACQUISITION_TIME: return string("subframe_acquisition_time"); \
case STORAGE_CELL_NUMBER: return string("storage_cell_number"); \
default: return string("unknown"); \
}};

View File

@ -635,6 +635,14 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
++i;
/*! \page timing
- <b>storagecells [i]</b> sets/gets number of storage cells per acquisition. For very advanced users only! For JUNGFRAU only. Range: 0-15. The #images = #frames * #cycles * (#storagecells +1). \c Returns \c (long long int)
*/
descrToFuncMap[i].m_pFuncName="storagecells"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
++i;
/* read only timers */
/*! \page timing
@ -5621,6 +5629,8 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {
index=MEASUREMENTS_NUMBER;
else if (cmd=="samples")
index=SAMPLES_JCTB;
else if (cmd=="storagecells")
index=STORAGE_CELL_NUMBER;
else
return string("could not decode timer ")+cmd;
@ -5672,6 +5682,7 @@ string slsDetectorCommand::helpTimer(int narg, char *args[], int action) {
os << "cycles t \t sets the number of cycles (e.g. number of triggers)" << std::endl;
os << "probes t \t sets the number of probes to accumulate (max 3! cycles should be set to 1, frames to the number of pump-probe events)" << std::endl;
os << "samples t \t sets the number of samples expected from the jctb" << std::endl;
os << "storagecells t \t sets number of storage cells per acquisition. For very advanced users only! For JUNGFRAU only. Range: 0-15. The #images = #frames * #cycles * (#storagecells+1)." << std::endl;
os << std::endl;
@ -5685,8 +5696,8 @@ string slsDetectorCommand::helpTimer(int narg, char *args[], int action) {
os << "frames \t gets the number of frames per cycle (e.g. after each trigger)" << std::endl;
os << "cycles \t gets the number of cycles (e.g. number of triggers)" << std::endl;
os << "probes \t gets the number of probes to accumulate" << std::endl;
os << "samples t \t gets the number of samples expected from the jctb" << std::endl;
os << "samples \t gets the number of samples expected from the jctb" << std::endl;
os << "storagecells \t gets number of storage cells per acquisition.For JUNGFRAU only." << std::endl;
os << std::endl;
}

View File

@ -2708,6 +2708,14 @@ int set_timer(int file_des) {
printf("setting timer %d to %lld ns\n",ind,tns);
#endif
switch(ind) {
#ifdef JUNGFRAUD
case STORAGE_CELL_NUMBER:
if (tns > MAX_STORAGE_CELL_VAL) {
ret=FAIL;
strcpy(mess,"Max Storage cell number should not exceed 15\n");
break;
}
#endif
#ifdef EIGERD
case SUBFRAME_ACQUISITION_TIME:
if (tns > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ){
@ -2740,6 +2748,8 @@ int set_timer(int file_des) {
cprintf(RED, "%s", mess);
break;
}
#if defined(MYTHEND) || defined(GOTTHARD)
if (ret == OK && ind==FRAME_NUMBER) {
ret=allocateRAM();