mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 21:07:13 +02:00
Solved problem with MYTHEN readout
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@820 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -13,7 +13,8 @@ INSTMODE= 0777
|
||||
SRCS= server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
|
||||
OBJS= $(SRCS:%.c=%.o)
|
||||
|
||||
VFLAGS= -DVERBOSE
|
||||
VFLAGS=
|
||||
#-DVERBOSE
|
||||
#-DVERYVERBOSE
|
||||
CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS -DDACS_INT $(VFLAGS)
|
||||
#-Werror
|
||||
|
@ -298,7 +298,9 @@ u_int32_t setExtSignal(int d, enum externalSignalFlag mode) {
|
||||
u_int32_t setFPGASignal(int d, enum externalSignalFlag mode) {
|
||||
|
||||
|
||||
int modes[]={EXT_SIG_OFF, EXT_GATE_IN_ACTIVEHIGH, EXT_GATE_IN_ACTIVELOW,EXT_TRIG_IN_RISING,EXT_TRIG_IN_FALLING,EXT_RO_TRIG_IN_RISING, EXT_RO_TRIG_IN_FALLING,EXT_GATE_OUT_ACTIVEHIGH, EXT_GATE_OUT_ACTIVELOW, EXT_TRIG_OUT_RISING, EXT_TRIG_OUT_FALLING, EXT_RO_TRIG_OUT_RISING, EXT_RO_TRIG_OUT_FALLING};
|
||||
int modes[]={SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW,TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE,RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE,RO_TRIGGER_OUT_FALLING_EDGE};
|
||||
|
||||
// int modes[]={EXT_SIG_OFF, EXT_GATE_IN_ACTIVEHIGH, EXT_GATE_IN_ACTIVELOW,EXT_TRIG_IN_RISING,EXT_TRIG_IN_FALLING,EXT_RO_TRIG_IN_RISING, EXT_RO_TRIG_IN_FALLING,EXT_GATE_OUT_ACTIVEHIGH, EXT_GATE_OUT_ACTIVELOW, EXT_TRIG_OUT_RISING, EXT_TRIG_OUT_FALLING, EXT_RO_TRIG_OUT_RISING, EXT_RO_TRIG_OUT_FALLING};
|
||||
|
||||
u_int32_t c;
|
||||
int off=d*SIGNAL_OFFSET;
|
||||
@ -383,7 +385,7 @@ int setTiming(int ti) {
|
||||
int g=-1, t=-1, rot=-1;
|
||||
|
||||
int i;
|
||||
|
||||
printf("*********************************Setting timing mode %d!\n", ti);
|
||||
switch (ti) {
|
||||
case AUTO_TIMING:
|
||||
timingMode=ti;
|
||||
@ -425,6 +427,7 @@ int setTiming(int ti) {
|
||||
|
||||
case GATE_FIX_NUMBER:
|
||||
timingMode=ti;
|
||||
printf("*********************************Setting gating!\n");
|
||||
// if one of the signals is configured to be trigger, set it and unset possible gates
|
||||
for (i=0; i<4; i++) {
|
||||
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
||||
@ -1148,6 +1151,8 @@ u_int32_t fifo_full(void)
|
||||
u_int32_t* fifo_read_event()
|
||||
{
|
||||
|
||||
int ir=0;
|
||||
|
||||
#ifdef VERBOSE
|
||||
int ichip;
|
||||
int ichan;
|
||||
@ -1167,17 +1172,24 @@ u_int32_t* fifo_read_event()
|
||||
printf("Waiting for data status %x\n",runState());
|
||||
#endif
|
||||
if (runBusy()==0) {
|
||||
/* for (ir=0; ir<100; ir++) { */
|
||||
/* //usleep(100); */
|
||||
/* //printf("check %d\n", ir); */
|
||||
/* if (runBusy()==1) */
|
||||
/* break; */
|
||||
/* } */
|
||||
/* if (ir==100) { */
|
||||
if (bus_r(LOOK_AT_ME_REG)==0) {
|
||||
#ifdef VERBOSE
|
||||
//#ifdef VERBOSE
|
||||
printf("no frame found - exiting ");
|
||||
|
||||
printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
||||
/* for (ichip=0; ichip<nModBoard*NCHIP; ichip++) {
|
||||
if ((fifoReadCounter(ichip)&FIFO_COUNTER_MASK)%128)
|
||||
printf("FIFO %d contains %d words\n",ichip,(fifoReadCounter(ichip)&FIFO_COUNTER_MASK));
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
// for (ichip=0; ichip<nModBoard*NCHIP; ichip++) {
|
||||
// if ((fifoReadCounter(ichip)&FIFO_COUNTER_MASK)%128)
|
||||
// printf("FIFO %d contains %d words\n",ichip,(fifoReadCounter(ichip)&FIFO_COUNTER_MASK));
|
||||
// }
|
||||
|
||||
//#endif
|
||||
return NULL;
|
||||
} else {
|
||||
#ifdef VERYVERBOSE
|
||||
@ -1185,6 +1197,8 @@ u_int32_t* fifo_read_event()
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
/* } else */
|
||||
/* printf("run busy error workaround %d \n", ir); */
|
||||
}
|
||||
}
|
||||
#ifdef VERYVERBOSE
|
||||
|
Binary file not shown.
@ -3147,7 +3147,6 @@ string slsDetectorCommand::cmdRegister(int narg, char *args[], int action) {
|
||||
sprintf(answer,"%x",myDet->writeRegister(addr,myDet->readRegister(addr)| 1<<n));
|
||||
if (cmd=="clearbit")
|
||||
sprintf(answer,"%x",myDet->writeRegister(addr,myDet->readRegister(addr) & ~(1<<n)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -330,9 +330,9 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
cout << "check data queue size " << endl;
|
||||
#endif
|
||||
/*while (dataQueueSize()){
|
||||
#ifdef VERBOSE
|
||||
//#ifdef VERBOSE
|
||||
cout << "AAAAAAAAA check data queue size " << endl;
|
||||
#endif
|
||||
//#endif
|
||||
usleep(100000);
|
||||
}*/
|
||||
|
||||
|
@ -240,17 +240,24 @@ TH1F* energyCalibration::createMedianHistogram(TH2F* h2, int ch0, int nch) {
|
||||
TH1F *h1=NULL;
|
||||
|
||||
double val=-1;
|
||||
double me=0;
|
||||
|
||||
|
||||
h1=new TH1F("median","Median",h2->GetYaxis()->GetNbins(),h2->GetYaxis()->GetXmin(),h2->GetYaxis()->GetXmax());
|
||||
|
||||
|
||||
for (int ib=0; ib<h1->GetXaxis()->GetNbins(); ib++) {
|
||||
me=0;
|
||||
for (int ich=0; ich<nch; ich++) {
|
||||
x[ich]=h2->GetBinContent(ch0+ich+1,ib+1);
|
||||
me+=x[ich];
|
||||
}
|
||||
cout << ib << " calculating median ch0=" << ch0 << " nch=" << nch << endl;
|
||||
val=energyCalibrationFunctions::median(x, nch);
|
||||
cout << "median=" << val << " mean= " << me/nch << endl;
|
||||
h1->SetBinContent(ib+1,val);
|
||||
}
|
||||
delete [] x;
|
||||
return h1;
|
||||
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "usersFunctions.h"
|
||||
#endif
|
||||
|
||||
//#define VERBOSE
|
||||
|
||||
static void* startProcessData(void *n){\
|
||||
postProcessing *myDet=(postProcessing*)n;\
|
||||
@ -38,9 +39,9 @@ postProcessing::postProcessing(): expTime(NULL), ang(NULL), val(NULL), err(NULL)
|
||||
pRawDataArg = 0;
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
registerDataCallback(&defaultDataReadyFunc, NULL);
|
||||
#endif
|
||||
//#ifdef VERBOSE
|
||||
// registerDataCallback(&defaultDataReadyFunc, NULL);
|
||||
//#endif
|
||||
#ifdef EXTPP
|
||||
registerRawDataCallback(&defaultRawDataReadyFunc, NULL);
|
||||
#endif
|
||||
@ -128,7 +129,8 @@ void postProcessing::processFrame(int *myData, int delflag) {
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((*correctionMask) & ~(1<<WRITE_FILE)) {
|
||||
if ((*correctionMask) & ~((1<<WRITE_FILE) | (1<<OVERWRITE_FILE))) {
|
||||
// cout << "cmask is not 0: " << *correctionMask << " - " << ((*correctionMask) & (1<<I0_NORMALIZATION)) << "-" << ((*correctionMask) & (1<<OVERWRITE_FILE)) << endl;
|
||||
doProcessing(fdata,delflag, fname);
|
||||
} else
|
||||
if (dataReady){
|
||||
@ -233,6 +235,21 @@ void postProcessing::doProcessing(double *lfdata, int delflag, string fname) {
|
||||
cout << "add frame" << endl;
|
||||
#endif
|
||||
|
||||
/**ot them
|
||||
start processing
|
||||
prog incremented
|
||||
decode
|
||||
fname is //run_f0_0
|
||||
??????????????????????????????????????????? do processing - data size is 30720
|
||||
arrays allocated
|
||||
npos is 0
|
||||
exptime is 10.00
|
||||
init dataset
|
||||
add frame
|
||||
data queue size lock
|
||||
data queue size unlock
|
||||
**/
|
||||
|
||||
addFrame(lfdata,currentPosition, currentI0, t, fname, 0);
|
||||
// cout << "++++++++++++++++++++" << GetCurrentPositionIndex() << " " << npos << " " << positionFinished() << " " << dataQueueSize() << endl;
|
||||
if ((GetCurrentPositionIndex()>=npos && dataQueueSize()) || npos<2) {
|
||||
@ -393,7 +410,7 @@ void* postProcessing::processData(int delflag) {
|
||||
while((queuesize=dataQueueSize())>0) {
|
||||
/** Pop data queue */
|
||||
#ifdef VERBOSE
|
||||
cout << "data found"<< endl<<endl;;
|
||||
cout << "data foun"<< endl<<endl;;
|
||||
#endif
|
||||
|
||||
myData=dataQueueFront(); // get the data from the queue
|
||||
@ -404,12 +421,18 @@ void* postProcessing::processData(int delflag) {
|
||||
if (myData) {
|
||||
processFrame(myData,delflag);
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
cout << "frame processed"<< endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** IF detector acquisition is done, let the acquire() thread know to finish up and force join thread */
|
||||
if(acquiringDone){
|
||||
sem_post(&sem_queue);
|
||||
}
|
||||
// cout << "Sem posted" << endl;
|
||||
} //else
|
||||
// cout << "Sem not posted" << endl;
|
||||
|
||||
|
||||
/* IF THERE ARE NO DATA look if acquisition is finished */
|
||||
if (checkJoinThread()) {
|
||||
|
Reference in New Issue
Block a user