mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 08:10:02 +02:00
supports frames with many samples for jctb - obtained by faking number of chips in case of many samples
This commit is contained in:
parent
a149d7fb2e
commit
9ac08e5e76
@ -401,7 +401,8 @@ enum speedVariable {
|
|||||||
PHASE_SHIFT, /**< adds phase shift */
|
PHASE_SHIFT, /**< adds phase shift */
|
||||||
OVERSAMPLING, /**< oversampling for analog detectors */
|
OVERSAMPLING, /**< oversampling for analog detectors */
|
||||||
ADC_CLOCK, /**< adc clock divider */
|
ADC_CLOCK, /**< adc clock divider */
|
||||||
ADC_PHASE /**< adc clock phase */
|
ADC_PHASE, /**< adc clock phase */
|
||||||
|
ADC_PIPELINE /**< adc pipeline */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
//#define TESTADC
|
//#define TESTADC
|
||||||
|
#define TESTADC1
|
||||||
|
|
||||||
|
|
||||||
#include "server_defs.h"
|
#include "server_defs.h"
|
||||||
@ -34,7 +35,10 @@ const int nModY=1;
|
|||||||
int nModBoard;
|
int nModBoard;
|
||||||
int nModX=NMAXMOD;
|
int nModX=NMAXMOD;
|
||||||
int dynamicRange=16;//32;
|
int dynamicRange=16;//32;
|
||||||
|
int nSamples=1;
|
||||||
|
|
||||||
int dataBytes=NMAXMOD*NCHIP*NCHAN*2;
|
int dataBytes=NMAXMOD*NCHIP*NCHAN*2;
|
||||||
|
|
||||||
int storeInRAM=0;
|
int storeInRAM=0;
|
||||||
int ROI_flag=0;
|
int ROI_flag=0;
|
||||||
int adcConfigured=-1;
|
int adcConfigured=-1;
|
||||||
@ -50,7 +54,8 @@ int phase_shift=0;//DEFAULT_PHASE_SHIFT;
|
|||||||
int ipPacketSize=DEFAULT_IP_PACKETSIZE;
|
int ipPacketSize=DEFAULT_IP_PACKETSIZE;
|
||||||
int udpPacketSize=DEFAULT_UDP_PACKETSIZE;
|
int udpPacketSize=DEFAULT_UDP_PACKETSIZE;
|
||||||
|
|
||||||
u_int32_t clkDivider[2]={160,32};
|
u_int32_t clkDivider[2]={32,16};
|
||||||
|
int32_t clkPhase[2]={0,0};
|
||||||
|
|
||||||
|
|
||||||
int ififostart, ififostop, ififostep, ififo;
|
int ififostart, ififostop, ififostep, ififo;
|
||||||
@ -307,28 +312,28 @@ int cleanFifo(){
|
|||||||
|
|
||||||
int setDAQRegister()
|
int setDAQRegister()
|
||||||
{
|
{
|
||||||
u_int32_t addr, reg, val;
|
/* u_int32_t addr, reg, val; */
|
||||||
addr=DAQ_REG;
|
/* addr=DAQ_REG; */
|
||||||
|
|
||||||
//depended on adcval
|
/* //depended on adcval */
|
||||||
int packetlength=0x7f;
|
/* int packetlength=0x7f; */
|
||||||
if(!ROI_flag) packetlength=0x13f;
|
/* if(!ROI_flag) packetlength=0x13f; */
|
||||||
|
|
||||||
//depended on pcb rev
|
/* //depended on pcb rev */
|
||||||
int tokenTiming = TOKEN_TIMING_REV2;
|
/* int tokenTiming = TOKEN_TIMING_REV2; */
|
||||||
if((bus_r(PCB_REV_REG)&BOARD_REVISION_MASK)==1)
|
/* if((bus_r(PCB_REV_REG)&BOARD_REVISION_MASK)==1) */
|
||||||
tokenTiming= TOKEN_TIMING_REV1;
|
/* tokenTiming= TOKEN_TIMING_REV1; */
|
||||||
|
|
||||||
|
|
||||||
val = (packetlength<<16) + tokenTiming;
|
/* val = (packetlength<<16) + tokenTiming; */
|
||||||
//val=34+(42<<8)+(packetlength<<16);
|
/* //val=34+(42<<8)+(packetlength<<16); */
|
||||||
|
|
||||||
reg=bus_r(addr);
|
/* reg=bus_r(addr); */
|
||||||
bus_w(addr,val);
|
/* bus_w(addr,val); */
|
||||||
reg=bus_r(addr);
|
/* reg=bus_r(addr); */
|
||||||
//#ifdef VERBOSE
|
/* //#ifdef VERBOSE */
|
||||||
printf("DAQ reg 0x15:%x\n",reg);
|
/* printf("DAQ reg 0x15:%x\n",reg); */
|
||||||
//#endif
|
/* //#endif */
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -369,27 +374,30 @@ u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val, int trig) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
printf("*********** pll busy: %08x\n",bus_r(STATUS_REG)&PLL_RECONFIG_BUSY);
|
||||||
|
|
||||||
bus_w(PLL_PARAM_REG,val);
|
bus_w(PLL_PARAM_REG,val);
|
||||||
printf("param: %x\n",val);
|
// printf("param: %x\n",val);
|
||||||
|
|
||||||
|
|
||||||
vv=reg<<PLL_CNTR_ADDR_OFF;
|
vv=reg<<PLL_CNTR_ADDR_OFF;
|
||||||
bus_w(PLL_CNTRL_REG,vv);
|
bus_w(PLL_CNTRL_REG,vv);
|
||||||
printf("wrote: %08x\n",vv);
|
usleep(10000);
|
||||||
usleep(1000);
|
// printf("wrote: %08x\n",vv);
|
||||||
vv=(1<<PLL_CNTR_WRITE_BIT)|(reg<<PLL_CNTR_ADDR_OFF)|(trig<<15);
|
// vv=(1<<PLL_CNTR_WRITE_BIT)|(reg<<PLL_CNTR_ADDR_OFF)|(trig<<15);
|
||||||
bus_w(PLL_CNTRL_REG,vv);//15 is trigger for the tap
|
bus_w(PLL_CNTRL_REG,vv|(1<<PLL_CNTR_WRITE_BIT) );//15 is trigger for the tap
|
||||||
|
// printf("----------- pll busy: %08x\n",bus_r(STATUS_REG)&PLL_RECONFIG_BUSY);
|
||||||
|
// printf("wrote: %08x\n",vv);
|
||||||
|
// usleep(10000);
|
||||||
|
|
||||||
printf("wrote: %08x\n",vv);
|
|
||||||
usleep(1000);
|
// vv=(reg<<PLL_CNTR_ADDR_OFF);
|
||||||
vv=(reg<<PLL_CNTR_ADDR_OFF);
|
// printf("wrote: %08x\n",vv);
|
||||||
printf("wrote: %08x\n",vv);
|
|
||||||
bus_w(PLL_CNTRL_REG,vv);
|
bus_w(PLL_CNTRL_REG,vv);
|
||||||
usleep(1000);
|
usleep(10000);
|
||||||
|
printf("+++++++++ pll busy: %08x\n",bus_r(STATUS_REG)&PLL_RECONFIG_BUSY);
|
||||||
|
|
||||||
while(bus_r(STATUS_REG)&PLL_RECONFIG_BUSY) {
|
|
||||||
printf("set: reconfig busy");
|
|
||||||
}
|
|
||||||
// bus_w(PLL_CNTRL_REG,(1<<PLL_CNTR_READ_BIT)|(reg<<PLL_CNTR_ADDR_OFF));
|
// bus_w(PLL_CNTRL_REG,(1<<PLL_CNTR_READ_BIT)|(reg<<PLL_CNTR_ADDR_OFF));
|
||||||
// usleep(1000);
|
// usleep(1000);
|
||||||
// val=bus_r(PLL_PARAM_OUT_REG);
|
// val=bus_r(PLL_PARAM_OUT_REG);
|
||||||
@ -417,18 +425,18 @@ u_int32_t getPllReconfigReg(u_int32_t reg, int trig) {
|
|||||||
usleep(100);
|
usleep(100);
|
||||||
|
|
||||||
val=(1<<PLL_CNTR_READ_BIT)|(reg<<PLL_CNTR_ADDR_OFF)|(trig<<15);
|
val=(1<<PLL_CNTR_READ_BIT)|(reg<<PLL_CNTR_ADDR_OFF)|(trig<<15);
|
||||||
printf("wrote: %08x\n",val);
|
// printf("wrote: %08x\n",val);
|
||||||
bus_w(PLL_CNTRL_REG,val);//15 is trigger for the tap
|
bus_w(PLL_CNTRL_REG,val);//15 is trigger for the tap
|
||||||
// printf("read: %08x\n",bus_r(PLL_CNTRL_REG));
|
// printf("read: %08x\n",bus_r(PLL_CNTRL_REG));
|
||||||
usleep(100);
|
// usleep(100);
|
||||||
/* for (i=0; i<10; i++) { */
|
/* for (i=0; i<10; i++) { */
|
||||||
vv=bus_r(PLL_PARAM_OUT_REG);
|
// vv=bus_r(PLL_PARAM_OUT_REG);
|
||||||
printf("addr %x reg: %x\n",reg,vv);
|
// printf("addr %x reg: %x\n",reg,vv);
|
||||||
/* usleep(100); */
|
/* usleep(100); */
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
val=(reg<<PLL_CNTR_ADDR_OFF);
|
val=(reg<<PLL_CNTR_ADDR_OFF);
|
||||||
printf("wrote: %08x\n",val);
|
// printf("wrote: %08x\n",val);
|
||||||
bus_w(PLL_CNTRL_REG,val);
|
bus_w(PLL_CNTRL_REG,val);
|
||||||
usleep(100);
|
usleep(100);
|
||||||
|
|
||||||
@ -448,6 +456,89 @@ void resetPLL() {
|
|||||||
bus_w(PLL_CNTRL_REG, 0);
|
bus_w(PLL_CNTRL_REG, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void configurePll(int i) {
|
||||||
|
|
||||||
|
|
||||||
|
u_int32_t l=0x0c;
|
||||||
|
u_int32_t h=0x0d;
|
||||||
|
u_int32_t val;
|
||||||
|
int32_t phase=0, inv=0, ic=0;
|
||||||
|
|
||||||
|
u_int32_t tot;
|
||||||
|
u_int32_t odd=1;//0;
|
||||||
|
|
||||||
|
// printf("PLL reconfig reset\N"); bus_w(PLL_CNTRL_REG,(1<<PLL_CNTR_RECONFIG_RESET_BIT)); usleep(100); bus_w(PLL_CNTRL_REG, 0);
|
||||||
|
|
||||||
|
|
||||||
|
printf("PLL mode\n"); setPllReconfigReg(PLL_MODE_REG,1,0);
|
||||||
|
// usleep(10000);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (i<2) {
|
||||||
|
|
||||||
|
tot= PLL_VCO_FREQ_MHZ/clkDivider[i];
|
||||||
|
l=tot/2;
|
||||||
|
h=l;
|
||||||
|
if (tot>2*l) {
|
||||||
|
h=l+1;
|
||||||
|
odd=1;
|
||||||
|
}
|
||||||
|
printf("Counter %d: Low is %d, High is %d\n",i, l,h);
|
||||||
|
|
||||||
|
|
||||||
|
val= (i<<18)| (odd<<17) | l | (h<<8);
|
||||||
|
|
||||||
|
printf("Counter %d, val: %08x\n", i, val); setPllReconfigReg(PLL_C_COUNTER_REG, val,0);
|
||||||
|
// usleep(20);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// if (mode==1) {
|
||||||
|
// } else {
|
||||||
|
printf("phase in %d\n",clkPhase[0]);
|
||||||
|
|
||||||
|
if (clkPhase[0]>0) {
|
||||||
|
inv=0;
|
||||||
|
phase=clkPhase[0];
|
||||||
|
} else {
|
||||||
|
inv=1;
|
||||||
|
phase=-1*clkPhase[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("phase out %d %08x\n",phase,phase);
|
||||||
|
val=phase | (inv<<16);;// | (inv<<21);
|
||||||
|
|
||||||
|
printf("Phase, val: %08x\n", val); setPllReconfigReg(PLL_PHASE_SHIFT_REG,val,0); //shifts counter 0
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Start reconfig\n"); setPllReconfigReg(PLL_START_REG, 1,0);
|
||||||
|
|
||||||
|
// bus_w(PLL_CNTRL_REG, 0);
|
||||||
|
printf("Status register\n"); getPllReconfigReg(PLL_STATUS_REG,0);
|
||||||
|
// sleep(1);
|
||||||
|
|
||||||
|
// printf("PLL mode\n"); setPllReconfigReg(PLL_MODE_REG,0,0);
|
||||||
|
usleep(10000);
|
||||||
|
/* if (mode!=1) { */
|
||||||
|
/* printf("reset pll\n"); */
|
||||||
|
/* bus_w(PLL_CNTRL_REG,((1<<PLL_CNTR_PLL_RESET_BIT))); //reset PLL */
|
||||||
|
/* usleep(100); */
|
||||||
|
/* bus_w(PLL_CNTRL_REG, 0); */
|
||||||
|
|
||||||
|
|
||||||
|
/* } */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
u_int32_t setClockDivider(int d, int ic) {
|
u_int32_t setClockDivider(int d, int ic) {
|
||||||
|
|
||||||
|
|
||||||
@ -456,10 +547,9 @@ u_int32_t setClockDivider(int d, int ic) {
|
|||||||
u_int32_t val;
|
u_int32_t val;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
u_int32_t tot=800/d;
|
u_int32_t tot= PLL_VCO_FREQ_MHZ/d;
|
||||||
u_int32_t odd=0;
|
u_int32_t odd=0;
|
||||||
|
|
||||||
|
|
||||||
// int ic=0 is run clk; ic=1 is adc clk
|
// int ic=0 is run clk; ic=1 is adc clk
|
||||||
printf("set clk divider %d to %d\n", ic, d);
|
printf("set clk divider %d to %d\n", ic, d);
|
||||||
if (ic>1)
|
if (ic>1)
|
||||||
@ -480,54 +570,17 @@ u_int32_t setClockDivider(int d, int ic) {
|
|||||||
|
|
||||||
|
|
||||||
clkDivider[ic]=d;
|
clkDivider[ic]=d;
|
||||||
|
configurePll(ic);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bus_w(PLL_CNTRL_REG,(1<<PLL_CNTR_RECONFIG_RESET_BIT)); //reset pll reconfig
|
|
||||||
usleep(100);
|
|
||||||
bus_w(PLL_CNTRL_REG, 0);
|
|
||||||
usleep(10000);
|
|
||||||
|
|
||||||
|
|
||||||
setPllReconfigReg(PLL_MODE_REG,1,0);
|
|
||||||
usleep(10000);
|
|
||||||
|
|
||||||
// getPllReconfigReg(PLL_MODE_REG,0);
|
|
||||||
|
|
||||||
|
|
||||||
for (i=0; i<1; i++) {
|
|
||||||
tot=800/clkDivider[i];
|
|
||||||
l=tot/2;
|
|
||||||
h=l;
|
|
||||||
if (tot>2*l) {
|
|
||||||
h=l+1;
|
|
||||||
odd=1;
|
|
||||||
}
|
|
||||||
printf("Counter %d: Low is %d, High is %d\n",i, l,h);
|
|
||||||
|
|
||||||
|
|
||||||
val= (i<<18)| (odd<<17) | l | (h<<8);
|
|
||||||
|
|
||||||
printf("Counter %d, val: %08x\n", i, val);
|
|
||||||
|
|
||||||
setPllReconfigReg(PLL_C_COUNTER_REG, val,0);
|
|
||||||
usleep(10000);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setPllReconfigReg(PLL_START_REG, 1,1);
|
|
||||||
usleep(100000);
|
|
||||||
bus_w(PLL_CNTRL_REG, 0);
|
|
||||||
|
|
||||||
return clkDivider[ic];
|
return clkDivider[ic];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int phaseStep(int st, int ic){
|
int phaseStep(int st, int ic){
|
||||||
|
|
||||||
u_int32_t addr;
|
u_int32_t addr, val=( (1<<PLL_CNTR_UPDN_BIT)| (1<<PLL_CNTR_CNTSEL_OFF) | (1<< PLL_CNTR_PHASE_EN_BIT));
|
||||||
/* int ic=0 is run clk; ic=1 is adc clk */
|
/* int ic=0 is run clk; ic=1 is adc clk */
|
||||||
|
|
||||||
/* if (st>0) */
|
/* if (st>0) */
|
||||||
@ -537,25 +590,30 @@ int phaseStep(int st, int ic){
|
|||||||
/* st*=-1; */
|
/* st*=-1; */
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
bus_w(PLL_CNTRL_REG,(1<<PLL_CNTR_RECONFIG_RESET_BIT)); //reset PLL and pll reconfig
|
int i;
|
||||||
usleep(100);
|
if (st>65535 || st<-65535)
|
||||||
bus_w(PLL_CNTRL_REG, 0);
|
return -1;
|
||||||
|
|
||||||
bus_w(PLL_CNTRL_REG, 0);
|
printf("ic=%d; phase %d\n", ic, st);
|
||||||
setPllReconfigReg(PLL_MODE_REG,1,0);
|
|
||||||
getPllReconfigReg(PLL_MODE_REG,0);
|
|
||||||
|
|
||||||
|
|
||||||
setPllReconfigReg(PLL_PHASE_SHIFT_REG,st|(ic<<21),0); //shifts counter 0
|
if (ic==1)
|
||||||
printf("shift %08x\n",st|(ic<<21));
|
clkPhase[0]=-st;
|
||||||
setPllReconfigReg(PLL_START_REG, 1,1);
|
else if (ic==0)
|
||||||
usleep(100000);
|
clkPhase[0]=st;
|
||||||
bus_w(PLL_CNTRL_REG, 0);
|
|
||||||
|
|
||||||
//setClockDivider(clkDivider[ic],ic);
|
|
||||||
|
|
||||||
|
|
||||||
return st;
|
|
||||||
|
/* printf("Changin phase %d\n",st); */
|
||||||
|
/* for (i=0; i<st; i++) { */
|
||||||
|
/* bus_w(PLL_CNTRL_REG,0); */
|
||||||
|
/* bus_w(PLL_CNTRL_REG,val); */
|
||||||
|
|
||||||
|
/* } */
|
||||||
|
/* sleep(1); */
|
||||||
|
// bus_w(PLL_CNTRL_REG,0);
|
||||||
|
configurePll(2);
|
||||||
|
return clkPhase[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -597,6 +655,14 @@ u_int32_t getClockDivider(int ic) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
u_int32_t adcPipeline(int d) {
|
||||||
|
if (d>=0)
|
||||||
|
bus_w(DAQ_REG, d);
|
||||||
|
return bus_r(DAQ_REG)&0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
u_int32_t setSetLength(int d) {
|
u_int32_t setSetLength(int d) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1146,12 +1212,12 @@ int64_t getFrames(){
|
|||||||
int64_t setExposureTime(int64_t value){
|
int64_t setExposureTime(int64_t value){
|
||||||
/* time is in ns */
|
/* time is in ns */
|
||||||
if (value!=-1)
|
if (value!=-1)
|
||||||
value*=(1E-9*CLK_FREQ);
|
value*=(1E-3*clkDivider[0]);//(1E-9*CLK_FREQ);
|
||||||
return set64BitReg(value,SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG)/(1E-9*CLK_FREQ);
|
return set64BitReg(value,SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG)/(1E-3*clkDivider[0]);//(1E-9*CLK_FREQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t getExposureTime(){
|
int64_t getExposureTime(){
|
||||||
return get64BitReg(GET_EXPTIME_LSB_REG, GET_EXPTIME_MSB_REG)/(1E-9*CLK_FREQ);
|
return get64BitReg(GET_EXPTIME_LSB_REG, GET_EXPTIME_MSB_REG)/(1E-3*clkDivider[0]);//(1E-9*CLK_FREQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t setGates(int64_t value){
|
int64_t setGates(int64_t value){
|
||||||
@ -1165,28 +1231,29 @@ int64_t getGates(){
|
|||||||
int64_t setPeriod(int64_t value){
|
int64_t setPeriod(int64_t value){
|
||||||
/* time is in ns */
|
/* time is in ns */
|
||||||
if (value!=-1) {
|
if (value!=-1) {
|
||||||
value*=(1E-9*CLK_FREQ);
|
// value*=(1E-9*CLK_FREQ);
|
||||||
|
value*=(1E-3*clkDivider[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return set64BitReg(value,SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/(1E-9*CLK_FREQ);
|
return set64BitReg(value,SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/(1E-3*clkDivider[0]);//(1E-9*CLK_FREQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t getPeriod(){
|
int64_t getPeriod(){
|
||||||
return get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG)/(1E-9*CLK_FREQ);
|
return get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG)/(1E-3*clkDivider[0]);//(1E-9*CLK_FREQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t setDelay(int64_t value){
|
int64_t setDelay(int64_t value){
|
||||||
/* time is in ns */
|
/* time is in ns */
|
||||||
if (value!=-1) {
|
if (value!=-1) {
|
||||||
value*=(1E-9*CLK_FREQ);
|
value*=(1E-3*clkDivider[0]);//(1E-9*CLK_FREQ);
|
||||||
}
|
}
|
||||||
return set64BitReg(value,SET_DELAY_LSB_REG, SET_DELAY_MSB_REG)/(1E-9*CLK_FREQ);
|
return set64BitReg(value,SET_DELAY_LSB_REG, SET_DELAY_MSB_REG)/(1E-3*clkDivider[0]);//(1E-9*CLK_FREQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t getDelay(){
|
int64_t getDelay(){
|
||||||
return get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG)/(1E-9*CLK_FREQ);
|
return get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG)/(1E-3*clkDivider[0]);//(1E-9*CLK_FREQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t setTrains(int64_t value){
|
int64_t setTrains(int64_t value){
|
||||||
@ -1477,7 +1544,7 @@ int setADC(int adc){
|
|||||||
if(adc==-1) ROI_flag=0;
|
if(adc==-1) ROI_flag=0;
|
||||||
else ROI_flag=1;
|
else ROI_flag=1;
|
||||||
|
|
||||||
setDAQRegister();//token timing
|
// setDAQRegister();//token timing
|
||||||
cleanFifo();//adc sync
|
cleanFifo();//adc sync
|
||||||
|
|
||||||
//with gotthard module
|
//with gotthard module
|
||||||
@ -1894,144 +1961,80 @@ u_int32_t fifo_full(void)
|
|||||||
|
|
||||||
u_int16_t* fifo_read_event()
|
u_int16_t* fifo_read_event()
|
||||||
{
|
{
|
||||||
|
int i=0;
|
||||||
|
|
||||||
|
|
||||||
int i=0, j=0;
|
|
||||||
#ifdef VIRTUAL
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#ifdef VERBOSE
|
|
||||||
printf("before looping\n");
|
|
||||||
volatile u_int32_t fs;
|
|
||||||
u_int16_t *dum;
|
u_int16_t *dum;
|
||||||
//#endif
|
|
||||||
volatile u_int32_t t = bus_r16(LOOK_AT_ME_REG);
|
volatile u_int32_t t = bus_r16(LOOK_AT_ME_REG);
|
||||||
|
|
||||||
#ifdef VERBOSE
|
|
||||||
printf("Data bytes is %d\n", dataBytes);
|
|
||||||
printf("lookatmereg=x%x\n",t);
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
while ((t&0x1)==0)
|
|
||||||
{
|
|
||||||
t = bus_r(LOOK_AT_ME_REG);
|
|
||||||
if (!runBusy()){
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
bus_w(DUMMY_REG,0);
|
bus_w(DUMMY_REG,0);
|
||||||
while(t==0) {
|
while(t!=0xffffffff) {
|
||||||
#ifdef VERYVERBOSE
|
if (runBusy()==0) {
|
||||||
printf("before readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
t = bus_r(LOOK_AT_ME_REG);
|
||||||
#endif
|
if (t!=0xffffffff) {
|
||||||
#ifdef VERYVERBOSE
|
printf("no frame found and acquisition finished - exiting\n");
|
||||||
printf("look at me reg:%08x\n",bus_r(LOOK_AT_ME_REG));
|
printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
||||||
#endif
|
return NULL;
|
||||||
if (runBusy()==0) {
|
} else {
|
||||||
t = bus_r(LOOK_AT_ME_REG);
|
// printf("status idle, look at me %x status %x\n", bus_r(LOOK_AT_ME_REG),runState());
|
||||||
#ifdef VERYVERBOSE
|
break;
|
||||||
printf("status should be idle!..look at me reg:%08x\n",bus_r(LOOK_AT_ME_REG));
|
}
|
||||||
#endif
|
}
|
||||||
if (t==0) {
|
t = bus_r(LOOK_AT_ME_REG);
|
||||||
//#ifdef VERBOSE
|
printf(".");
|
||||||
printf("no frame found - exiting\n");
|
|
||||||
printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
|
||||||
//#endif
|
|
||||||
#ifdef VERYVERBOSE
|
|
||||||
printf("returning null\n");
|
|
||||||
printf("lookatmereg=x%x\n",t);
|
|
||||||
#endif
|
|
||||||
return NULL;
|
|
||||||
} else {
|
|
||||||
//#ifdef VERBOSE
|
|
||||||
printf("no frame found %x status %x\n", bus_r(LOOK_AT_ME_REG),runState());
|
|
||||||
//#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
t = bus_r(LOOK_AT_ME_REG);
|
|
||||||
#ifdef VERYVERBOSE
|
|
||||||
printf("before starting while loop again: look at me reg:%08x\n\n",bus_r(LOOK_AT_ME_REG));
|
|
||||||
#endif
|
|
||||||
if (i%1000==0)
|
|
||||||
printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
#ifdef VERYVERBOSE
|
// printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
||||||
printf(" out of while loop!\n");
|
|
||||||
#endif
|
|
||||||
#ifdef VERYVERBOSE
|
|
||||||
printf("before readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
|
||||||
i=0;
|
|
||||||
for (i=0; i<32; i++) {
|
|
||||||
// printf("Fifo %d (%04x) status :\n", i,FIFO_STATUS_REG | i);
|
|
||||||
fs=bus_r16(FIFO_STATUS_REG| i);
|
|
||||||
if (fs&0xfff0fff)
|
|
||||||
printf("before %d: %x\n",i, fs);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* dma_memcpy(now_ptr,values ,dataBytes); */
|
/* dma_memcpy(now_ptr,values ,dataBytes); */
|
||||||
/* #else */
|
/* #else */
|
||||||
for (i=0; i<32; i++) {
|
for (i=0; i<32; i++) {
|
||||||
dum=((u_int16_t*)(now_ptr))+i;
|
dum=((u_int16_t*)(now_ptr))+i;
|
||||||
bus_w(DUMMY_REG,i<<1);
|
bus_w(DUMMY_REG,i<<1);
|
||||||
#ifdef TESTADC
|
// usleep(10);
|
||||||
printf("%d s:%04x ",i,bus_r16(FIFO_STATUS_REG));
|
bus_w(DUMMY_REG,(i<<1) | 1);
|
||||||
#endif
|
// usleep(10);
|
||||||
|
bus_w(DUMMY_REG,i<<1);
|
||||||
bus_w(DUMMY_REG,(i<<1) | 1);
|
/* usleep(10); */
|
||||||
bus_w(DUMMY_REG,i<<1);
|
*dum=bus_r16(FIFO_DATA_REG);
|
||||||
*dum=bus_r16(FIFO_DATA_REG);// | i); //values[i];
|
|
||||||
#ifdef TESTADC
|
|
||||||
printf("d:%04x s:%04x\n",*dum&0x3fff, bus_r16(FIFO_STATUS_REG));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
//#endif
|
printf("*");
|
||||||
printf("-");
|
|
||||||
//memcpy(now_ptr,values ,dataBytes); //this reads the fifo twice...
|
|
||||||
|
|
||||||
#ifdef VERYVERBOSE
|
|
||||||
printf("after readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
|
||||||
i=0;
|
|
||||||
for (i=0; i<32; i++) {
|
|
||||||
fs=bus_r16(FIFO_STATUS_REG| i);
|
|
||||||
if (fs&0xfff0fff)
|
|
||||||
printf("after %d: %x\n",i, fs);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VERYVERBOSE
|
|
||||||
int a;
|
|
||||||
for (a=0;a<8; a=a+2)
|
|
||||||
printf("\n%d %d: x%04x x%04x ",a+1,a,*(now_ptr+a+1),*(now_ptr+a) );
|
|
||||||
// for (a=2554;a<2560; a=a+2)
|
|
||||||
// printf("\n%d %d: x%04x x%04x ",a+1,a,*(now_ptr+a+1),*(now_ptr+a) );
|
|
||||||
printf("********\n");
|
|
||||||
//memcpy(now_ptr, values, dataBytes);
|
|
||||||
//#endif
|
|
||||||
//#ifdef VERYVERBOSE
|
|
||||||
printf("Copying to ptr %08x %d\n",(unsigned int)(now_ptr), dataBytes);
|
|
||||||
printf("after readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (storeInRAM>0) {
|
|
||||||
now_ptr+=dataBytes;
|
|
||||||
}
|
|
||||||
#ifdef VERYVERBOSE
|
|
||||||
printf("lookatmereg=x%x\n",t);
|
|
||||||
#endif
|
|
||||||
return ram_values;
|
return ram_values;
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
u_int16_t* fifo_read_frame()
|
||||||
|
{
|
||||||
|
u_int16_t *dum;
|
||||||
|
int ns=0;
|
||||||
|
now_ptr=(char*)ram_values;
|
||||||
|
while(ns<nSamples) {
|
||||||
|
dum=fifo_read_event();
|
||||||
|
if (dum==NULL) break;
|
||||||
|
now_ptr+=dataBytes;
|
||||||
|
ns++;
|
||||||
|
}
|
||||||
|
// printf("%x %d\n",dum, ns);
|
||||||
|
if (ns==0) return NULL;
|
||||||
|
printf("+\n");
|
||||||
|
return ram_values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
u_int32_t* decode_data(int *datain)
|
u_int32_t* decode_data(int *datain)
|
||||||
{
|
{
|
||||||
u_int32_t *dataout;
|
u_int32_t *dataout;
|
||||||
@ -2097,6 +2100,14 @@ u_int32_t* decode_data(int *datain)
|
|||||||
|
|
||||||
|
|
||||||
int setDynamicRange(int dr) {
|
int setDynamicRange(int dr) {
|
||||||
|
|
||||||
|
if (dr%16==0 && dr>0) {
|
||||||
|
dynamicRange=16;
|
||||||
|
nSamples=dr/16;
|
||||||
|
dataBytes=NMAXMOD*NCHIP*NCHAN*2;
|
||||||
|
}
|
||||||
|
allocateRAM();
|
||||||
|
printf("Setting dataBytes to %d: dr %d; samples %d\n",dataBytes, dynamicRange, nSamples);
|
||||||
return getDynamicRange();
|
return getDynamicRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2106,8 +2117,8 @@ int setDynamicRange(int dr) {
|
|||||||
|
|
||||||
|
|
||||||
int getDynamicRange() {
|
int getDynamicRange() {
|
||||||
dynamicRange=16;
|
// dynamicRange=16;
|
||||||
return dynamicRange;
|
return dynamicRange*nSamples;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2156,18 +2167,9 @@ int setStoreInRAM(int b) {
|
|||||||
|
|
||||||
int allocateRAM() {
|
int allocateRAM() {
|
||||||
size_t size;
|
size_t size;
|
||||||
u_int32_t nt, nf;
|
|
||||||
nt=setTrains(-1);
|
|
||||||
nf=setFrames(-1);
|
size=dataBytes*nSamples;
|
||||||
if (nt==0) nt=1;
|
|
||||||
if (nf==0) nf=1;
|
|
||||||
// ret=clearRAM();
|
|
||||||
if (storeInRAM) {
|
|
||||||
size=dataBytes*nf*nt;
|
|
||||||
if (size<dataBytes)
|
|
||||||
size=dataBytes;
|
|
||||||
} else
|
|
||||||
size=dataBytes;
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("\nnmodx=%d nmody=%d dynamicRange=%d dataBytes=%d nFrames=%d nTrains=%d, size=%d\n",nModX,nModY,dynamicRange,dataBytes,nf,nt,(int)size );
|
printf("\nnmodx=%d nmody=%d dynamicRange=%d dataBytes=%d nFrames=%d nTrains=%d, size=%d\n",nModX,nModY,dynamicRange,dataBytes,nf,nt,(int)size );
|
||||||
@ -2175,52 +2177,45 @@ int allocateRAM() {
|
|||||||
|
|
||||||
if (size==ram_size) {
|
if (size==ram_size) {
|
||||||
|
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
printf("RAM of size %d already allocated: nothing to be done\n",(int) size);
|
printf("RAM of size %d already allocated: nothing to be done\n",(int) size);
|
||||||
#endif
|
//#endif
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
printf("reallocating ram %x\n",(unsigned int)ram_values);
|
printf("reallocating ram %x, size %d\n",(unsigned int)ram_values, size);
|
||||||
#endif
|
//#endif
|
||||||
// clearRAM();
|
|
||||||
// ram_values=malloc(size);
|
|
||||||
//+2 was added since dma_memcpy would switch the 16 bit values and the mem is 32 bit
|
//+2 was added since dma_memcpy would switch the 16 bit values and the mem is 32 bit
|
||||||
ram_values=realloc(ram_values,size)+2;
|
|
||||||
|
// while (nSamples>1) {
|
||||||
|
|
||||||
|
clearRAM();
|
||||||
|
ram_values=malloc(size);
|
||||||
|
// ram_values=realloc(ram_values,size)+2;
|
||||||
|
// if (ram_values)
|
||||||
|
// break;
|
||||||
|
// nSamples--;
|
||||||
|
//}
|
||||||
|
|
||||||
if (ram_values) {
|
if (ram_values) {
|
||||||
now_ptr=(char*)ram_values;
|
now_ptr=(char*)ram_values;
|
||||||
#ifdef VERBOSE
|
|
||||||
|
//#ifdef VERBOSE
|
||||||
printf("ram allocated 0x%x of size %d to %x\n",(int)now_ptr,(unsigned int) size,(unsigned int)(now_ptr+size));
|
printf("ram allocated 0x%x of size %d to %x\n",(int)now_ptr,(unsigned int) size,(unsigned int)(now_ptr+size));
|
||||||
#endif
|
//#endif
|
||||||
ram_size=size;
|
ram_size=size;
|
||||||
return OK;
|
return OK;
|
||||||
} else {
|
|
||||||
printf("could not allocate %d bytes\n",(int)size);
|
|
||||||
if (storeInRAM==1) {
|
|
||||||
printf("retrying\n");
|
|
||||||
storeInRAM=0;
|
|
||||||
size=dataBytes;
|
|
||||||
ram_values=realloc(ram_values,size)+2;
|
|
||||||
if (ram_values==NULL)
|
|
||||||
printf("Fatal error: there must be a memory leak somewhere! You can't allocate even one frame!\n");
|
|
||||||
else {
|
|
||||||
now_ptr=(char*)ram_values;
|
|
||||||
ram_size=size;
|
|
||||||
#ifdef VERBOSE
|
|
||||||
printf("ram allocated 0x%x of size %d to %x\n",(int)now_ptr,(unsigned int) size,(unsigned int)(now_ptr+size));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
printf("Fatal error: there must be a memory leak somewhere! You can't allocate even one frame!\n");
|
|
||||||
}
|
|
||||||
return FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
printf("Fatal error: there must be a memory leak somewhere! You can't allocate even one frame!\n");
|
||||||
|
return FAIL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2330,7 +2325,7 @@ int prepareADC(){
|
|||||||
|
|
||||||
|
|
||||||
bus_w(ADC_LATCH_DISABLE_REG,0x0); // enable all ADCs
|
bus_w(ADC_LATCH_DISABLE_REG,0x0); // enable all ADCs
|
||||||
bus_w(DAQ_REG,0xd); //adc pipeline=13
|
bus_w(DAQ_REG,0x12); //adc pipeline=18
|
||||||
|
|
||||||
bus_w(ADC_OFFSET_REG,0xbbbbbbbb);
|
bus_w(ADC_OFFSET_REG,0xbbbbbbbb);
|
||||||
// bus_w(ADC_INVERSION_REG,0x1f6170c6);
|
// bus_w(ADC_INVERSION_REG,0x1f6170c6);
|
||||||
|
@ -51,6 +51,7 @@ u_int32_t getTotClockDivider();
|
|||||||
u_int32_t setTotDutyCycle(int d);
|
u_int32_t setTotDutyCycle(int d);
|
||||||
u_int32_t getTotDutyCycle();
|
u_int32_t getTotDutyCycle();
|
||||||
u_int32_t setOversampling(int d);
|
u_int32_t setOversampling(int d);
|
||||||
|
u_int32_t adcPipeline(int d);
|
||||||
|
|
||||||
u_int32_t setExtSignal(int d, enum externalSignalFlag mode);
|
u_int32_t setExtSignal(int d, enum externalSignalFlag mode);
|
||||||
int getExtSignal(int d);
|
int getExtSignal(int d);
|
||||||
@ -134,6 +135,7 @@ u_int32_t fifo_full(void);
|
|||||||
|
|
||||||
|
|
||||||
u_int16_t* fifo_read_event();
|
u_int16_t* fifo_read_event();
|
||||||
|
u_int16_t* fifo_read_frame();
|
||||||
u_int32_t* decode_data(int* datain);
|
u_int32_t* decode_data(int* datain);
|
||||||
//u_int32_t move_data(u_int64_t* datain, u_int64_t* dataout);
|
//u_int32_t move_data(u_int64_t* datain, u_int64_t* dataout);
|
||||||
int setDynamicRange(int dr);
|
int setDynamicRange(int dr);
|
||||||
|
@ -503,6 +503,15 @@
|
|||||||
#define PLL_CNTR_WRITE_BIT 2
|
#define PLL_CNTR_WRITE_BIT 2
|
||||||
#define PLL_CNTR_PLL_RESET_BIT 3
|
#define PLL_CNTR_PLL_RESET_BIT 3
|
||||||
|
|
||||||
|
|
||||||
|
#define PLL_CNTR_PHASE_EN_BIT 8
|
||||||
|
#define PLL_CNTR_UPDN_BIT 9
|
||||||
|
#define PLL_CNTR_CNTSEL_OFF 10
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define PLL_MODE_REG 0x0
|
#define PLL_MODE_REG 0x0
|
||||||
#define PLL_STATUS_REG 0x1
|
#define PLL_STATUS_REG 0x1
|
||||||
#define PLL_START_REG 0x2
|
#define PLL_START_REG 0x2
|
||||||
@ -525,6 +534,8 @@
|
|||||||
#define PPL_BW_PARAM_DEFAULT 0x2EE0
|
#define PPL_BW_PARAM_DEFAULT 0x2EE0
|
||||||
#define PPL_VCO_PARAM_DEFAULT 0x1
|
#define PPL_VCO_PARAM_DEFAULT 0x1
|
||||||
|
|
||||||
|
#define PLL_VCO_FREQ_MHZ 480//800
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ enum detectorType myDetectorType=GENERIC;
|
|||||||
extern int nModX;
|
extern int nModX;
|
||||||
extern int nModY;
|
extern int nModY;
|
||||||
extern int dataBytes;
|
extern int dataBytes;
|
||||||
|
extern int nSamples;
|
||||||
extern int dynamicRange;
|
extern int dynamicRange;
|
||||||
extern int storeInRAM;
|
extern int storeInRAM;
|
||||||
|
|
||||||
@ -153,6 +154,8 @@ int init_detector(int b, int checkType) {
|
|||||||
strcpy(lastClientIP,"none");
|
strcpy(lastClientIP,"none");
|
||||||
strcpy(thisClientIP,"none1");
|
strcpy(thisClientIP,"none1");
|
||||||
lockStatus=0;
|
lockStatus=0;
|
||||||
|
|
||||||
|
allocateRAM();
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1938,6 +1941,11 @@ int get_run_status(int file_des) {
|
|||||||
|
|
||||||
int read_frame(int file_des) {
|
int read_frame(int file_des) {
|
||||||
|
|
||||||
|
|
||||||
|
int ns=0;
|
||||||
|
u_int16_t* p=NULL;
|
||||||
|
|
||||||
|
|
||||||
if (differentClients==1 && lockStatus==1) {
|
if (differentClients==1 && lockStatus==1) {
|
||||||
dataret=FAIL;
|
dataret=FAIL;
|
||||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||||
@ -1949,81 +1957,39 @@ int read_frame(int file_des) {
|
|||||||
return dataret;
|
return dataret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
p=fifo_read_frame();
|
||||||
if (storeInRAM==0) {
|
if (p) {
|
||||||
if ((dataretval=(char*)fifo_read_event())) {
|
nframes++;
|
||||||
dataret=OK;
|
dataretval=(char*)ram_values;
|
||||||
#ifdef VERYVERBOSE
|
dataret=OK;
|
||||||
printf("Sending ptr %x %d\n",(unsigned int)(dataretval), dataBytes);
|
|
||||||
#endif
|
|
||||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
|
||||||
sendDataOnly(file_des,dataretval,dataBytes);
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("sent %d bytes \n",dataBytes);
|
printf("sending data of %d frames\n",nframes);
|
||||||
printf("dataret OK\n");
|
|
||||||
#endif
|
#endif
|
||||||
return OK;
|
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||||
} else {
|
#ifdef VERYVERBOSE
|
||||||
//might add delay????
|
printf("sending pointer %x of size %d\n",(unsigned int)(dataretval),dataBytes*nSamples);
|
||||||
if(getFrames()>-1) {
|
#endif
|
||||||
|
sendDataOnly(file_des,dataretval,dataBytes*nSamples);
|
||||||
|
} else {
|
||||||
|
if (getFrames()>-1) {
|
||||||
dataret=FAIL;
|
dataret=FAIL;
|
||||||
sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+1));
|
sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+2));
|
||||||
printf("%s\n",mess);
|
printf("%s\n",mess);
|
||||||
} else {
|
} else {
|
||||||
dataret=FINISHED;
|
dataret=FINISHED;
|
||||||
sprintf(mess,"acquisition successfully finished\n");
|
sprintf(mess,"acquisition successfully finished\n");
|
||||||
printf("%s\n",mess);
|
printf("%s\n",mess);
|
||||||
|
if (differentClients)
|
||||||
|
dataret=FORCE_UPDATE;
|
||||||
}
|
}
|
||||||
#ifdef VERYVERBOSE
|
|
||||||
printf("%d %d %x %s\n",(int)(sizeof(mess)),(int)(strlen(mess)),(unsigned int)( mess),mess);
|
|
||||||
#endif
|
|
||||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
|
||||||
sendDataOnly(file_des,mess,sizeof(mess));
|
|
||||||
#ifdef VERYVERBOSE
|
|
||||||
printf("message sent %s\n",mess);
|
|
||||||
#endif
|
|
||||||
printf("dataret %d\n",dataret);
|
|
||||||
return dataret;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
nframes=0;
|
|
||||||
while(fifo_read_event()) {
|
|
||||||
nframes++;
|
|
||||||
}
|
|
||||||
dataretval=(char*)ram_values;
|
|
||||||
dataret=OK;
|
|
||||||
#ifdef VERBOSE
|
|
||||||
printf("sending data of %d frames\n",nframes);
|
|
||||||
#endif
|
|
||||||
for (iframes=0; iframes<nframes; iframes++) {
|
|
||||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
|
||||||
#ifdef VERYVERBOSE
|
|
||||||
printf("sending pointer %x of size %d\n",(unsigned int)(dataretval),dataBytes);
|
|
||||||
#endif
|
|
||||||
sendDataOnly(file_des,dataretval,dataBytes);
|
|
||||||
dataretval+=dataBytes;
|
|
||||||
}
|
|
||||||
if (getFrames()>-2) {
|
|
||||||
dataret=FAIL;
|
|
||||||
sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+2));
|
|
||||||
printf("%s\n",mess);
|
|
||||||
} else {
|
|
||||||
dataret=FINISHED;
|
|
||||||
sprintf(mess,"acquisition successfully finished\n");
|
|
||||||
printf("%s\n",mess);
|
|
||||||
if (differentClients)
|
|
||||||
dataret=FORCE_UPDATE;
|
|
||||||
}
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Frames left %d\n",(int)(getFrames()));
|
printf("Frames left %d\n",(int)(getFrames()));
|
||||||
#endif
|
#endif
|
||||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||||
sendDataOnly(file_des,mess,sizeof(mess));
|
sendDataOnly(file_des,mess,sizeof(mess));
|
||||||
printf("dataret %d\n",dataret);
|
|
||||||
return dataret;
|
|
||||||
}
|
}
|
||||||
printf("dataret %d\n",dataret);
|
|
||||||
return dataret;
|
return dataret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2164,9 +2130,9 @@ int set_timer(int file_des) {
|
|||||||
printf(mess);
|
printf(mess);
|
||||||
printf("set timer failed\n");
|
printf("set timer failed\n");
|
||||||
} else if (ind==FRAME_NUMBER) {
|
} else if (ind==FRAME_NUMBER) {
|
||||||
ret=allocateRAM();
|
// ret=allocateRAM();
|
||||||
if (ret!=OK)
|
// if (ret!=OK)
|
||||||
sprintf(mess, "could not allocate RAM for %lld frames\n", tns);
|
// sprintf(mess, "could not allocate RAM for %lld frames\n", tns);
|
||||||
}
|
}
|
||||||
|
|
||||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||||
@ -2291,7 +2257,7 @@ int set_dynamic_range(int file_des) {
|
|||||||
int retval;
|
int retval;
|
||||||
int ret=OK;
|
int ret=OK;
|
||||||
|
|
||||||
|
printf("Set dynamic range?\n");
|
||||||
sprintf(mess,"can't set dynamic range\n");
|
sprintf(mess,"can't set dynamic range\n");
|
||||||
|
|
||||||
|
|
||||||
@ -2313,10 +2279,11 @@ int set_dynamic_range(int file_des) {
|
|||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
sprintf(mess,"set dynamic range failed\n");
|
sprintf(mess,"set dynamic range failed\n");
|
||||||
} else {
|
} else {
|
||||||
ret=allocateRAM();
|
/* ret=allocateRAM(); */
|
||||||
if (ret!=OK)
|
/* if (ret!=OK) */
|
||||||
sprintf(mess,"Could not allocate RAM for the dynamic range selected\n");
|
/* sprintf(mess,"Could not allocate RAM for the dynamic range selected\n"); */
|
||||||
else if (differentClients)
|
// else
|
||||||
|
if (differentClients)
|
||||||
ret=FORCE_UPDATE;
|
ret=FORCE_UPDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2457,6 +2424,11 @@ int set_speed(int file_des) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case ADC_PIPELINE:
|
||||||
|
retval=adcPipeline(val);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
@ -2486,6 +2458,15 @@ int set_speed(int file_des) {
|
|||||||
retval=getClockDivider(1);
|
retval=getClockDivider(1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ADC_PHASE:
|
||||||
|
retval=-1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case ADC_PIPELINE:
|
||||||
|
retval=adcPipeline(-1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
|
@ -612,6 +612,10 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
|||||||
|
|
||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*thisDetector->dynamicRange/8;
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*thisDetector->dynamicRange/8;
|
||||||
|
|
||||||
|
if(thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||||
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*thisDetector->dynamicRange/8;
|
||||||
|
|
||||||
|
}
|
||||||
if(thisDetector->myDetectorType==MYTHEN){
|
if(thisDetector->myDetectorType==MYTHEN){
|
||||||
if (thisDetector->dynamicRange==24 || thisDetector->timerValue[PROBES_NUMBER]>0)
|
if (thisDetector->dynamicRange==24 || thisDetector->timerValue[PROBES_NUMBER]>0)
|
||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
|
||||||
@ -1540,6 +1544,11 @@ int slsDetector::setNumberOfModules(int n, dimension d){
|
|||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(thisDetector->myDetectorType==JUNGFRAUCTB){
|
||||||
|
|
||||||
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*dr/8;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "Data size is " << thisDetector->dataBytes << std::endl;
|
std::cout<< "Data size is " << thisDetector->dataBytes << std::endl;
|
||||||
@ -3363,9 +3372,9 @@ int* slsDetector::getDataFromDetector(int *retval){
|
|||||||
} else {
|
} else {
|
||||||
n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes);
|
n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes);
|
||||||
|
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
std::cout<< "Received "<< n << " data bytes" << std::endl;
|
std::cout<< "Received "<< n << " data bytes" << std::endl;
|
||||||
#endif
|
// #endif
|
||||||
if (n!=thisDetector->dataBytes) {
|
if (n!=thisDetector->dataBytes) {
|
||||||
std::cout<< "wrong data size received: received " << n << " but expected " << thisDetector->dataBytes << std::endl;
|
std::cout<< "wrong data size received: received " << n << " but expected " << thisDetector->dataBytes << std::endl;
|
||||||
thisDetector->stoppedFlag=1;
|
thisDetector->stoppedFlag=1;
|
||||||
@ -3376,7 +3385,7 @@ int* slsDetector::getDataFromDetector(int *retval){
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// cout << "get data returning " << endl;
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -3401,12 +3410,13 @@ int* slsDetector::readAll(){
|
|||||||
|
|
||||||
while ((retval=getDataFromDetector())){
|
while ((retval=getDataFromDetector())){
|
||||||
i++;
|
i++;
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
std::cout<< i << std::endl;
|
std::cout<< i << std::endl;
|
||||||
//#else
|
//#else
|
||||||
//std::cout << "-" << flush ;
|
//std::cout << "-" << flush ;
|
||||||
#endif
|
//#endif
|
||||||
dataQueue.push(retval);
|
dataQueue.push(retval);
|
||||||
|
std::cout<< "pushed" << std::endl;
|
||||||
}
|
}
|
||||||
controlSocket->Disconnect();
|
controlSocket->Disconnect();
|
||||||
}
|
}
|
||||||
@ -4097,6 +4107,9 @@ int slsDetector::setDynamicRange(int n){
|
|||||||
#endif
|
#endif
|
||||||
if (n==24)
|
if (n==24)
|
||||||
n=32;
|
n=32;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
if (connectControl() == OK){
|
if (connectControl() == OK){
|
||||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
@ -4121,24 +4134,31 @@ int slsDetector::setDynamicRange(int n){
|
|||||||
if (ret!=FAIL && retval>0) {
|
if (ret!=FAIL && retval>0) {
|
||||||
/* checking the number of probes to chose the data size */
|
/* checking the number of probes to chose the data size */
|
||||||
|
|
||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*retval/8;
|
|
||||||
|
|
||||||
if(thisDetector->myDetectorType==MYTHEN){
|
|
||||||
if (thisDetector->timerValue[PROBES_NUMBER]!=0)
|
|
||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
|
|
||||||
|
|
||||||
if (retval==32)
|
|
||||||
thisDetector->dynamicRange=24;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
thisDetector->dynamicRange=retval;
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*retval/8;
|
||||||
|
|
||||||
|
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||||
|
thisDetector->nChip[X]=retval/16;
|
||||||
|
thisDetector->nChips=thisDetector->nChip[X]*thisDetector->nChip[Y];
|
||||||
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*retval/8;
|
||||||
|
}
|
||||||
|
if(thisDetector->myDetectorType==MYTHEN){
|
||||||
|
if (thisDetector->timerValue[PROBES_NUMBER]!=0)
|
||||||
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
|
||||||
|
|
||||||
|
if (retval==32)
|
||||||
|
thisDetector->dynamicRange=24;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
thisDetector->dynamicRange=retval;
|
||||||
|
|
||||||
|
|
||||||
|
//#ifdef VERBOSE
|
||||||
std::cout<< "Dynamic range set to "<< thisDetector->dynamicRange << std::endl;
|
std::cout<< "Dynamic range set to "<< thisDetector->dynamicRange << std::endl;
|
||||||
std::cout<< "Data bytes "<< thisDetector->dataBytes << std::endl;
|
std::cout<< "Data bytes "<< thisDetector->dataBytes << std::endl;
|
||||||
#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4368,11 +4388,14 @@ int slsDetector::executeTrimming(trimMode mode, int par1, int par2, int imod){
|
|||||||
double* slsDetector::decodeData(int *datain, double *fdata) {
|
double* slsDetector::decodeData(int *datain, double *fdata) {
|
||||||
|
|
||||||
double *dataout;
|
double *dataout;
|
||||||
if (fdata)
|
if (fdata) {
|
||||||
dataout=fdata;
|
dataout=fdata;
|
||||||
else
|
// printf("not allocating fdata!\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
dataout=new double[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
dataout=new double[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
||||||
|
// printf("allocating fdata!\n");
|
||||||
|
}
|
||||||
const int bytesize=8;
|
const int bytesize=8;
|
||||||
|
|
||||||
int ival=0;
|
int ival=0;
|
||||||
|
@ -204,11 +204,11 @@ class slsDetectorActions : public virtual slsDetectorBase
|
|||||||
*/
|
*/
|
||||||
virtual int setAllTrimbits(int val, int imod=-1)=0;
|
virtual int setAllTrimbits(int val, int imod=-1)=0;
|
||||||
|
|
||||||
/** returns the detector type
|
/* /\** returns the detector type */
|
||||||
\param pos position in the multi detector structure (is -1 returns type of detector with id -1)
|
/* \param pos position in the multi detector structure (is -1 returns type of detector with id -1) */
|
||||||
\returns type
|
/* \returns type */
|
||||||
*/
|
/* *\/ */
|
||||||
virtual detectorType getDetectorsType(int pos=-1)=0;
|
/* virtual detectorType getDetectorsType(int pos=-1)=0; */
|
||||||
|
|
||||||
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
|
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
|
||||||
virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0;
|
virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0;
|
||||||
|
@ -77,6 +77,12 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
|
|||||||
/** virtual destructor */
|
/** virtual destructor */
|
||||||
virtual ~slsDetectorBase(){};
|
virtual ~slsDetectorBase(){};
|
||||||
|
|
||||||
|
/** returns the detector type
|
||||||
|
\param pos position in the multi detector structure (is -1 returns type of detector with id -1)
|
||||||
|
\returns type
|
||||||
|
*/
|
||||||
|
virtual detectorType getDetectorsType(int pos=-1)=0;
|
||||||
|
|
||||||
string getDetectorDeveloper(){return string("PSI");};
|
string getDetectorDeveloper(){return string("PSI");};
|
||||||
// protected:
|
// protected:
|
||||||
|
|
||||||
|
@ -828,6 +828,13 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
|||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed;
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="adcpipeline"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* settings dump/retrieve */
|
/* settings dump/retrieve */
|
||||||
descrToFuncMap[i].m_pFuncName="config";
|
descrToFuncMap[i].m_pFuncName="config";
|
||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdConfiguration;
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdConfiguration;
|
||||||
@ -3939,6 +3946,8 @@ string slsDetectorCommand::cmdSpeed(int narg, char *args[], int action) {
|
|||||||
index=ADC_CLOCK;
|
index=ADC_CLOCK;
|
||||||
else if (cmd=="adcphase")
|
else if (cmd=="adcphase")
|
||||||
index=ADC_PHASE;
|
index=ADC_PHASE;
|
||||||
|
else if (cmd=="adcpipeline")
|
||||||
|
index=ADC_PIPELINE;
|
||||||
else
|
else
|
||||||
return string("could not decode speed variable ")+cmd;
|
return string("could not decode speed variable ")+cmd;
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
|||||||
// int getPositions(double *pos=NULL){return angularConversion::getPositions(pos);};
|
// int getPositions(double *pos=NULL){return angularConversion::getPositions(pos);};
|
||||||
|
|
||||||
using slsDetectorBase::setFlatFieldCorrection;
|
using slsDetectorBase::setFlatFieldCorrection;
|
||||||
|
using slsDetectorBase::getDetectorsType;
|
||||||
using postProcessing::setBadChannelCorrection;
|
using postProcessing::setBadChannelCorrection;
|
||||||
|
|
||||||
int enableFlatFieldCorrection(int i=-1) {if (i>0) setFlatFieldCorrectionFile("default"); else if (i==0) setFlatFieldCorrectionFile(""); return getFlatFieldCorrection();};
|
int enableFlatFieldCorrection(int i=-1) {if (i>0) setFlatFieldCorrectionFile("default"); else if (i==0) setFlatFieldCorrectionFile(""); return getFlatFieldCorrection();};
|
||||||
@ -126,12 +127,6 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
|||||||
virtual string setHostname(const char* name, int pos=-1)=0;
|
virtual string setHostname(const char* name, int pos=-1)=0;
|
||||||
|
|
||||||
|
|
||||||
/** returns the detector type
|
|
||||||
\param pos position in the multi detector structure (is -1 returns type of detector with id -1)
|
|
||||||
\returns type
|
|
||||||
*/
|
|
||||||
virtual detectorType getDetectorsType(int pos=-1)=0;
|
|
||||||
|
|
||||||
/** returns the detector type
|
/** returns the detector type
|
||||||
\param pos position in the multi detector structure (is -1 returns type of detector with id -1)
|
\param pos position in the multi detector structure (is -1 returns type of detector with id -1)
|
||||||
\returns type
|
\returns type
|
||||||
|
@ -21,6 +21,11 @@ string fileIO::createFileName() {
|
|||||||
frameIndex, \
|
frameIndex, \
|
||||||
detIndex \
|
detIndex \
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (getDetectorsType()==JUNGFRAUCTB) {
|
||||||
|
nBytes=2*getTotalNumberOfChannels();
|
||||||
|
} else
|
||||||
|
nBytes=getDataBytes();
|
||||||
return currentFileName;
|
return currentFileName;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -86,8 +91,6 @@ int fileIO::writeDataFile(ofstream &outfile, int *data, int offset){
|
|||||||
|
|
||||||
int fileIO::writeDataFile(void *data, int iframe) {
|
int fileIO::writeDataFile(void *data, int iframe) {
|
||||||
|
|
||||||
// cout << "fileIO writeDataFile" << endl;
|
|
||||||
|
|
||||||
if (iframe<0)
|
if (iframe<0)
|
||||||
iframe=frameIndex;
|
iframe=frameIndex;
|
||||||
|
|
||||||
@ -100,8 +103,9 @@ int fileIO::writeDataFile(void *data, int iframe) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (filefd){
|
if (filefd){
|
||||||
fileIOStatic::writeBinaryDataFile(filefd,getDataBytes(), data);
|
// fileIOStatic::writeBinaryDataFile(filefd,getDataBytes(), data);
|
||||||
iframe++;
|
fileIOStatic::writeBinaryDataFile(filefd,nBytes, data);
|
||||||
|
iframe++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((iframe%(*framesPerFile)==0) || (iframe<0)) {
|
if ((iframe%(*framesPerFile)==0) || (iframe<0)) {
|
||||||
|
@ -319,6 +319,8 @@ yes */
|
|||||||
// int fformat;
|
// int fformat;
|
||||||
|
|
||||||
|
|
||||||
|
int nBytes;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -412,6 +412,7 @@ class fileIOStatic {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int writeBinaryDataFile(FILE *sfilefd, size_t nbytes, void *data){ \
|
static int writeBinaryDataFile(FILE *sfilefd, size_t nbytes, void *data){ \
|
||||||
|
// cout << "bin " << sfilefd << " " << nbytes << " " << data << endl;
|
||||||
fwrite(data, 1, nbytes, sfilefd); \
|
fwrite(data, 1, nbytes, sfilefd); \
|
||||||
return slsDetectorDefs::OK; \
|
return slsDetectorDefs::OK; \
|
||||||
};
|
};
|
||||||
|
@ -9,17 +9,17 @@
|
|||||||
|
|
||||||
//#define VERBOSE
|
//#define VERBOSE
|
||||||
|
|
||||||
static void* startProcessData(void *n){\
|
static void* startProcessData(void *n){
|
||||||
postProcessing *myDet=(postProcessing*)n;\
|
postProcessing *myDet=(postProcessing*)n;
|
||||||
myDet->processData(1);\
|
myDet->processData(1);
|
||||||
pthread_exit(NULL);\
|
pthread_exit(NULL);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void* startProcessDataNoDelete(void *n){\
|
static void* startProcessDataNoDelete(void *n){
|
||||||
postProcessing *myDet=(postProcessing*)n;\
|
postProcessing *myDet=(postProcessing*)n;
|
||||||
myDet->processData(0);\
|
myDet->processData(0);
|
||||||
pthread_exit(NULL);\
|
pthread_exit(NULL);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,10 +65,10 @@ postProcessing::~postProcessing(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void postProcessing::processFrame(int *myData, int delflag) {
|
void postProcessing::processFrame(int *myData, int delflag, int jctb) {
|
||||||
|
|
||||||
string fname;
|
string fname;
|
||||||
// double *fdata=NULL;
|
//double *fdata=NULL;
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "start processing"<< endl;
|
cout << "start processing"<< endl;
|
||||||
@ -136,7 +136,7 @@ void postProcessing::processFrame(int *myData, int delflag) {
|
|||||||
if (dataReady){
|
if (dataReady){
|
||||||
|
|
||||||
// cout << "callback arg "<< getCurrentProgress()<< " " << (fname+string(".raw")).c_str() << " " << getTotalNumberOfChannels() << endl;
|
// cout << "callback arg "<< getCurrentProgress()<< " " << (fname+string(".raw")).c_str() << " " << getTotalNumberOfChannels() << endl;
|
||||||
|
// cout << "DATAREADY 1" <<endl;
|
||||||
thisData=new detectorData(fdata,NULL,NULL,getCurrentProgress(),(fname+string(".raw")).c_str(),getTotalNumberOfChannels());
|
thisData=new detectorData(fdata,NULL,NULL,getCurrentProgress(),(fname+string(".raw")).c_str(),getTotalNumberOfChannels());
|
||||||
dataReady(thisData, currentFrameIndex, pCallbackArg);
|
dataReady(thisData, currentFrameIndex, pCallbackArg);
|
||||||
delete thisData;
|
delete thisData;
|
||||||
@ -155,19 +155,20 @@ void postProcessing::processFrame(int *myData, int delflag) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
delete [] myData;
|
|
||||||
if (fdata)
|
if (fdata)
|
||||||
delete [] fdata;
|
delete [] fdata;
|
||||||
myData=NULL;
|
|
||||||
fdata=NULL;
|
fdata=NULL;
|
||||||
|
|
||||||
|
|
||||||
|
// if (jctb==0) {
|
||||||
|
delete [] myData;
|
||||||
|
myData=NULL;
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Pop data queue " << *fileIndex << endl;
|
cout << "Pop data queue " << *fileIndex << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
popDataQueue(); //remove the data from the queue
|
popDataQueue(); //remove the data from the queue
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Data queue popped" << endl;
|
cout << "Data queue popped" << endl;
|
||||||
@ -177,7 +178,7 @@ void postProcessing::processFrame(int *myData, int delflag) {
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "process frame returning " << endl;
|
cout << "process frame returning " << endl;
|
||||||
#endif
|
#endif
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +279,7 @@ data queue size unlock
|
|||||||
|
|
||||||
if (dataReady) {
|
if (dataReady) {
|
||||||
// cout << "callback arg "<< getCurrentProgress()<< " " << (fname+ext).c_str() << " " << np << endl;
|
// cout << "callback arg "<< getCurrentProgress()<< " " << (fname+ext).c_str() << " " << np << endl;
|
||||||
|
//cout << "ADATREADY 2 " << endl;
|
||||||
thisData=new detectorData(val,err,ang,getCurrentProgress(),(fname+ext).c_str(),np);
|
thisData=new detectorData(val,err,ang,getCurrentProgress(),(fname+ext).c_str(),np);
|
||||||
dataReady(thisData, currentFrameIndex, pCallbackArg);
|
dataReady(thisData, currentFrameIndex, pCallbackArg);
|
||||||
delete thisData;
|
delete thisData;
|
||||||
@ -398,20 +399,35 @@ void* postProcessing::processData(int delflag) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
queuesize=dataQueueSize();
|
queuesize=dataQueueSize();
|
||||||
|
|
||||||
|
|
||||||
int *myData;
|
int *myData;
|
||||||
|
char *p;
|
||||||
int dum=1;
|
int dum=1;
|
||||||
|
int nf=1, ii, nch;
|
||||||
|
int jctb=0;
|
||||||
|
|
||||||
|
|
||||||
|
// if (getDetectorsType()==JUNGFRAUCTB) {
|
||||||
|
// nch=getTotalNumberOfChannels();
|
||||||
|
// nf= getDataBytes()/(nch*2);
|
||||||
|
// cout << "WILL PROCESS " << nf << "SAMPLES AND " << nch <<"CHANNELS PER FRAME!" << endl;
|
||||||
|
// jctb=1;
|
||||||
|
// }// else
|
||||||
|
// // cout << "NOOT A JCTB" << endl;
|
||||||
|
|
||||||
fdata=NULL;
|
fdata=NULL;
|
||||||
|
|
||||||
while(dum | *threadedProcessing) { // ????????????????????????
|
while(dum | *threadedProcessing) { // ????????????????????????
|
||||||
/* IF THERE ARE DATA PROCESS THEM*/
|
/* IF THERE ARE DATA PROCESS THEM*/
|
||||||
|
// cout << "loop" << endl;
|
||||||
while((queuesize=dataQueueSize())>0) {
|
while((queuesize=dataQueueSize())>0) {
|
||||||
/** Pop data queue */
|
/** Pop data queue */
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
cout << "data foun"<< endl<<endl;;
|
cout << "data found"<< endl<<endl;;
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
myData=dataQueueFront(); // get the data from the queue
|
myData=dataQueueFront(); // get the data from the queue
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -419,38 +435,55 @@ void* postProcessing::processData(int delflag) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (myData) {
|
if (myData) {
|
||||||
processFrame(myData,delflag);
|
|
||||||
}
|
|
||||||
|
// if (jctb) {
|
||||||
|
// p=(char*)myData;
|
||||||
|
// for (ii=0; ii<nf; ii++) {
|
||||||
|
// processFrame((int*)p,delflag, 1);
|
||||||
|
// p+=2*nch;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// delete [] myData;
|
||||||
|
// myData=NULL;
|
||||||
|
|
||||||
|
// popDataQueue(); //remove the data from the queue
|
||||||
|
|
||||||
|
// } else
|
||||||
|
processFrame(myData,delflag,0);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "frame processed"<< endl;
|
cout << "frame processed"<< endl;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/** IF detector acquisition is done, let the acquire() thread know to finish up and force join thread */
|
||||||
/** IF detector acquisition is done, let the acquire() thread know to finish up and force join thread */
|
|
||||||
if(acquiringDone){
|
if(acquiringDone){
|
||||||
sem_post(&sem_queue);
|
sem_post(&sem_queue);
|
||||||
// cout << "Sem posted" << endl;
|
// cout << "Sem posted" << endl;
|
||||||
} //else
|
} //else
|
||||||
// cout << "Sem not posted" << endl;
|
// cout << "Sem not posted" << endl;
|
||||||
|
|
||||||
|
|
||||||
/* IF THERE ARE NO DATA look if acquisition is finished */
|
/* IF THERE ARE NO DATA look if acquisition is finished */
|
||||||
if (checkJoinThread()) {
|
if (checkJoinThread()) {
|
||||||
if (dataQueueSize()==0) {
|
if (dataQueueSize()==0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dum=0;
|
dum=0;
|
||||||
usleep(500);
|
usleep(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fdata) {
|
if (fdata) {
|
||||||
delete [] fdata;
|
cout << "delete fdata "<< endl;
|
||||||
|
delete [] fdata;
|
||||||
|
|
||||||
|
cout << "delete done "<< endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//receiver
|
//receiver
|
||||||
else{
|
else{
|
||||||
/*
|
/*
|
||||||
//without gui loop
|
//without gui loop
|
||||||
while(1){
|
while(1){
|
||||||
if (checkJoinThread()) break;
|
if (checkJoinThread()) break;
|
||||||
@ -539,6 +572,7 @@ void* postProcessing::processData(int delflag) {
|
|||||||
fdata = decodeData(receiverData);
|
fdata = decodeData(receiverData);
|
||||||
delete [] receiverData;
|
delete [] receiverData;
|
||||||
if ((fdata) && (dataReady)){
|
if ((fdata) && (dataReady)){
|
||||||
|
// cout << "DATAREADY 3" << endl;
|
||||||
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentfName,getTotalNumberOfChannels());
|
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentfName,getTotalNumberOfChannels());
|
||||||
dataReady(thisData, currentfIndex, pCallbackArg);
|
dataReady(thisData, currentfIndex, pCallbackArg);
|
||||||
delete thisData;
|
delete thisData;
|
||||||
|
@ -165,7 +165,7 @@ s
|
|||||||
\returns nothing
|
\returns nothing
|
||||||
|
|
||||||
*/
|
*/
|
||||||
void processFrame(int* myData, int delflag);
|
void processFrame(int* myData, int delflag, int jctb=0);
|
||||||
|
|
||||||
/** processes the data
|
/** processes the data
|
||||||
\param delflag 0 leaves the data in the final data queue
|
\param delflag 0 leaves the data in the final data queue
|
||||||
@ -228,6 +228,7 @@ s
|
|||||||
virtual int getNMods()=0;
|
virtual int getNMods()=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int GetCurrentPositionIndex(){ pthread_mutex_lock(&mp); int retval=getCurrentPositionIndex(); pthread_mutex_unlock(&mp); return retval;};
|
int GetCurrentPositionIndex(){ pthread_mutex_lock(&mp); int retval=getCurrentPositionIndex(); pthread_mutex_unlock(&mp); return retval;};
|
||||||
void IncrementPositionIndex(){ pthread_mutex_lock(&mp); incrementPositionIndex(); pthread_mutex_unlock(&mp);};
|
void IncrementPositionIndex(){ pthread_mutex_lock(&mp); incrementPositionIndex(); pthread_mutex_unlock(&mp);};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user