mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-14 00:12:11 +02:00
timing command added, several bugs concerning the synchronization of multiple detectors fixed
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@134 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
b755c533f0
commit
5e086b9ee6
@ -1,5 +1,5 @@
|
|||||||
CFLAGS= -DC_ONLY
|
CFLAGS= -DC_ONLY
|
||||||
#FLAGS=-DVERBOSE
|
FLAGS=-DVERBOSE
|
||||||
INCLUDES= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand
|
INCLUDES= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand
|
||||||
#-I eigerDetector -ImythenDetector -IgotthardDetector
|
#-I eigerDetector -ImythenDetector -IgotthardDetector
|
||||||
#EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/SL5-x86/ -Wl,-R/usr/local/epics/base/lib/SL5-x86 -lca -lCom
|
#EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/SL5-x86/ -Wl,-R/usr/local/epics/base/lib/SL5-x86 -lca -lCom
|
||||||
|
@ -347,7 +347,7 @@ int sendChip(int file_des, sls_detector_chip *myChip) {
|
|||||||
|
|
||||||
int sendModule(int file_des, sls_detector_module *myMod) {
|
int sendModule(int file_des, sls_detector_module *myMod) {
|
||||||
int ts=0;
|
int ts=0;
|
||||||
int idac;
|
//int idac;
|
||||||
int nChips=myMod->nchip;
|
int nChips=myMod->nchip;
|
||||||
int nChans=myMod->nchan;
|
int nChans=myMod->nchan;
|
||||||
int nAdcs=myMod->nadc;
|
int nAdcs=myMod->nadc;
|
||||||
|
@ -557,15 +557,23 @@ int multiSlsDetector::setMaster(int i) {
|
|||||||
|
|
||||||
int ret=-1, slave=0;
|
int ret=-1, slave=0;
|
||||||
masterFlags f;
|
masterFlags f;
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "settin master in position " << i << endl;
|
||||||
|
#endif
|
||||||
if (i>=0 && i<thisMultiDetector->numberOfDetectors) {
|
if (i>=0 && i<thisMultiDetector->numberOfDetectors) {
|
||||||
if (detectors[i]) {
|
if (detectors[i]) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "detector position " << i << " ";
|
||||||
|
#endif
|
||||||
thisMultiDetector->masterPosition=i;
|
thisMultiDetector->masterPosition=i;
|
||||||
detectors[i]->setMaster(IS_MASTER);
|
detectors[i]->setMaster(IS_MASTER);
|
||||||
}
|
}
|
||||||
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
|
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
|
||||||
if (i!=id) {
|
if (i!=id) {
|
||||||
if (detectors[id]) {
|
if (detectors[id]) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "detector position " << id << " ";
|
||||||
|
#endif
|
||||||
detectors[id]->setMaster(IS_SLAVE);
|
detectors[id]->setMaster(IS_SLAVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -574,15 +582,22 @@ int multiSlsDetector::setMaster(int i) {
|
|||||||
} else if (i==-2) {
|
} else if (i==-2) {
|
||||||
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
|
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
|
||||||
if (detectors[id]) {
|
if (detectors[id]) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "detector position " << id << " ";
|
||||||
|
#endif
|
||||||
detectors[id]->setMaster(NO_MASTER);
|
detectors[id]->setMaster(NO_MASTER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check return value
|
||||||
|
|
||||||
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
|
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
|
||||||
if (detectors[id]) {
|
if (detectors[id]) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "detector position " << id << " ";
|
||||||
|
#endif
|
||||||
f=detectors[id]->setMaster(GET_MASTER);
|
f=detectors[id]->setMaster(GET_MASTER);
|
||||||
switch (f) {
|
switch (f) {
|
||||||
case NO_MASTER:
|
case NO_MASTER:
|
||||||
@ -597,6 +612,7 @@ int multiSlsDetector::setMaster(int i) {
|
|||||||
break;
|
break;
|
||||||
case IS_SLAVE:
|
case IS_SLAVE:
|
||||||
slave=1;
|
slave=1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ret=-2;
|
ret=-2;
|
||||||
}
|
}
|
||||||
@ -2832,6 +2848,7 @@ int multiSlsDetector::dumpDetectorSetup(string const fname, int level){
|
|||||||
"frames",\
|
"frames",\
|
||||||
"cycles",\
|
"cycles",\
|
||||||
"probes",\
|
"probes",\
|
||||||
|
"timing",\
|
||||||
"fineoff",\
|
"fineoff",\
|
||||||
"ratecorr",\
|
"ratecorr",\
|
||||||
"startscript",\
|
"startscript",\
|
||||||
@ -2858,7 +2875,7 @@ int multiSlsDetector::dumpDetectorSetup(string const fname, int level){
|
|||||||
"badchannels",\
|
"badchannels",\
|
||||||
"angconv"
|
"angconv"
|
||||||
};
|
};
|
||||||
int nvar=38;
|
int nvar=39;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ u_int32_t progressMask=0;
|
|||||||
|
|
||||||
int ififostart, ififostop, ififostep, ififo;
|
int ififostart, ififostop, ififostep, ififo;
|
||||||
|
|
||||||
int masterMode=NO_MASTER, syncMode=NO_SYNCHRONIZATION;
|
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};
|
enum externalSignalFlag signals[4]={EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF};
|
||||||
|
|
||||||
@ -244,21 +244,52 @@ u_int32_t getTotDutyCycle() {
|
|||||||
u_int32_t setExtSignal(int d, enum externalSignalFlag mode) {
|
u_int32_t setExtSignal(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[]={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;
|
u_int32_t c;
|
||||||
int off=d*SIGNAL_OFFSET;
|
// int off=d*SIGNAL_OFFSET;
|
||||||
c=bus_r(EXT_SIGNAL_REG);
|
c=bus_r(EXT_SIGNAL_REG);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (d>=0 && d<4) {
|
if (d>=0 && d<4) {
|
||||||
signals[d]=mode;
|
signals[d]=mode;
|
||||||
|
#ifdef VERBOSE
|
||||||
// if output signal, set it!
|
printf("settings signal variable number %d to value %04x\n", d, signals[d]);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (mode<=RO_TRIGGER_OUT_FALLING_EDGE && mode>=GATE_OUT_ACTIVE_HIGH && signals[d]!=MASTER_SLAVE_SYNCHRONIZATION)
|
// if output signal, set it!
|
||||||
bus_w(EXT_SIGNAL_REG,((modes[mode])<<off)|(c&~(SIGNAL_MASK<<off)));
|
|
||||||
|
switch (mode) {
|
||||||
|
case GATE_IN_ACTIVE_HIGH:
|
||||||
|
case GATE_IN_ACTIVE_LOW:
|
||||||
|
if (timingMode==GATE_FIX_NUMBER || timingMode==GATE_WITH_START_TRIGGER)
|
||||||
|
setFPGASignal(d,mode);
|
||||||
|
else
|
||||||
|
setFPGASignal(d,SIGNAL_OFF);
|
||||||
|
break;
|
||||||
|
case TRIGGER_IN_RISING_EDGE:
|
||||||
|
case TRIGGER_IN_FALLING_EDGE:
|
||||||
|
if (timingMode==TRIGGER_EXPOSURE || timingMode==GATE_WITH_START_TRIGGER)
|
||||||
|
setFPGASignal(d,mode);
|
||||||
|
else
|
||||||
|
setFPGASignal(d,SIGNAL_OFF);
|
||||||
|
break;
|
||||||
|
case RO_TRIGGER_IN_RISING_EDGE:
|
||||||
|
case RO_TRIGGER_IN_FALLING_EDGE:
|
||||||
|
if (timingMode==TRIGGER_READOUT)
|
||||||
|
setFPGASignal(d,mode);
|
||||||
|
else
|
||||||
|
setFPGASignal(d,SIGNAL_OFF);
|
||||||
|
break;
|
||||||
|
case MASTER_SLAVE_SYNCHRONIZATION:
|
||||||
|
setSynchronization(syncMode);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setFPGASignal(d,mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getExtSignal(d);
|
return getExtSignal(d);
|
||||||
@ -273,9 +304,13 @@ u_int32_t setFPGASignal(int d, enum externalSignalFlag mode) {
|
|||||||
int off=d*SIGNAL_OFFSET;
|
int off=d*SIGNAL_OFFSET;
|
||||||
c=bus_r(EXT_SIGNAL_REG);
|
c=bus_r(EXT_SIGNAL_REG);
|
||||||
|
|
||||||
if (mode<=RO_TRIGGER_OUT_FALLING_EDGE && mode>=0)
|
|
||||||
bus_w(EXT_SIGNAL_REG,((modes[mode])<<off)|(c&~(SIGNAL_MASK<<off)));
|
|
||||||
|
|
||||||
|
if (mode<=RO_TRIGGER_OUT_FALLING_EDGE && mode>=0) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("writing signal register number %d mode %04x\n",d, modes[mode]);
|
||||||
|
#endif
|
||||||
|
bus_w(EXT_SIGNAL_REG,((modes[mode])<<off)|(c&~(SIGNAL_MASK<<off)));
|
||||||
|
}
|
||||||
return getExtSignal(d);
|
return getExtSignal(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,9 +328,12 @@ int getExtSignal(int d) {
|
|||||||
/* return -1; */
|
/* return -1; */
|
||||||
|
|
||||||
|
|
||||||
if (d>=0 && d<4)
|
if (d>=0 && d<4) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("gettings signal variable number %d value %04x\n", d, signals[d]);
|
||||||
|
#endif
|
||||||
return signals[d];
|
return signals[d];
|
||||||
else
|
} else
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -308,9 +346,14 @@ int getFPGASignal(int d) {
|
|||||||
int off=d*SIGNAL_OFFSET;
|
int off=d*SIGNAL_OFFSET;
|
||||||
int mode=((bus_r(EXT_SIGNAL_REG)&(SIGNAL_MASK<<off))>>off);
|
int mode=((bus_r(EXT_SIGNAL_REG)&(SIGNAL_MASK<<off))>>off);
|
||||||
|
|
||||||
if (mode<RO_TRIGGER_OUT_FALLING_EDGE)
|
if (mode<=RO_TRIGGER_OUT_FALLING_EDGE) {
|
||||||
|
if (modes[mode]!=SIGNAL_OFF && signals[d]!=MASTER_SLAVE_SYNCHRONIZATION)
|
||||||
|
signals[d]=modes[mode];
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("gettings signal register number %d value %04x\n", d, modes[mode]);
|
||||||
|
#endif
|
||||||
return modes[mode];
|
return modes[mode];
|
||||||
else
|
} else
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -342,7 +385,8 @@ int setTiming(int ti) {
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
switch (ti) {
|
switch (ti) {
|
||||||
case AUTO_TIMING:
|
case AUTO_TIMING:
|
||||||
|
timingMode=ti;
|
||||||
// disable all gates/triggers in except if used for master/slave synchronization
|
// disable all gates/triggers in except if used for master/slave synchronization
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
if (getFPGASignal(i)>0 && getFPGASignal(i)<GATE_OUT_ACTIVE_HIGH && signals[i]!=MASTER_SLAVE_SYNCHRONIZATION)
|
if (getFPGASignal(i)>0 && getFPGASignal(i)<GATE_OUT_ACTIVE_HIGH && signals[i]!=MASTER_SLAVE_SYNCHRONIZATION)
|
||||||
@ -350,7 +394,8 @@ int setTiming(int ti) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TRIGGER_EXPOSURE:
|
case TRIGGER_EXPOSURE:
|
||||||
|
timingMode=ti;
|
||||||
// if one of the signals is configured to be trigger, set it and unset possible gates
|
// if one of the signals is configured to be trigger, set it and unset possible gates
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
if (signals[i]==TRIGGER_IN_RISING_EDGE || signals[i]==TRIGGER_IN_FALLING_EDGE)
|
if (signals[i]==TRIGGER_IN_RISING_EDGE || signals[i]==TRIGGER_IN_FALLING_EDGE)
|
||||||
@ -365,7 +410,8 @@ int setTiming(int ti) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
case TRIGGER_READOUT:
|
case TRIGGER_READOUT:
|
||||||
|
timingMode=ti;
|
||||||
// if one of the signals is configured to be trigger, set it and unset possible gates
|
// if one of the signals is configured to be trigger, set it and unset possible gates
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
||||||
@ -377,7 +423,8 @@ int setTiming(int ti) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GATE_FIX_NUMBER:
|
case GATE_FIX_NUMBER:
|
||||||
|
timingMode=ti;
|
||||||
// if one of the signals is configured to be trigger, set it and unset possible gates
|
// if one of the signals is configured to be trigger, set it and unset possible gates
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
||||||
@ -391,7 +438,8 @@ int setTiming(int ti) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
case GATE_WITH_START_TRIGGER:
|
case GATE_WITH_START_TRIGGER:
|
||||||
|
timingMode=ti;
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
||||||
setFPGASignal(i,SIGNAL_OFF);
|
setFPGASignal(i,SIGNAL_OFF);
|
||||||
@ -433,6 +481,8 @@ int setTiming(int ti) {
|
|||||||
ret=AUTO_TIMING;
|
ret=AUTO_TIMING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// timingMode=ret;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -454,7 +504,7 @@ int setConfigurationRegister(int d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int setToT(int d) {
|
int setToT(int d) {
|
||||||
int ret=0;
|
// int ret=0;
|
||||||
int reg;
|
int reg;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Setting ToT to %d\n",d);
|
printf("Setting ToT to %d\n",d);
|
||||||
@ -479,7 +529,7 @@ int setToT(int d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int setContinousReadOut(int d) {
|
int setContinousReadOut(int d) {
|
||||||
int ret=0;
|
// int ret=0;
|
||||||
int reg;
|
int reg;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Setting Continous readout to %d\n",d);
|
printf("Setting Continous readout to %d\n",d);
|
||||||
@ -619,7 +669,7 @@ int getNModBoard() {
|
|||||||
|
|
||||||
int setNMod(int n) {
|
int setNMod(int n) {
|
||||||
|
|
||||||
int fifo;
|
// int fifo;
|
||||||
// int ifsta, ifsto, ifste;
|
// int ifsta, ifsto, ifste;
|
||||||
int imod;
|
int imod;
|
||||||
int rval;
|
int rval;
|
||||||
@ -872,7 +922,7 @@ int64_t setProbes(int64_t value){
|
|||||||
int64_t setProgress() {
|
int64_t setProgress() {
|
||||||
|
|
||||||
//????? eventually call after setting the registers
|
//????? eventually call after setting the registers
|
||||||
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -880,7 +930,7 @@ int64_t getProgress() {
|
|||||||
|
|
||||||
|
|
||||||
//should be done in firmware!!!!
|
//should be done in firmware!!!!
|
||||||
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1176,13 +1226,13 @@ u_int32_t* fifo_read_event()
|
|||||||
u_int32_t* decode_data(int *datain)
|
u_int32_t* decode_data(int *datain)
|
||||||
{
|
{
|
||||||
u_int32_t *dataout;
|
u_int32_t *dataout;
|
||||||
const char one=1;
|
// const char one=1;
|
||||||
const int bytesize=8;
|
const int bytesize=8;
|
||||||
char *ptr=(char*)datain;
|
char *ptr=(char*)datain;
|
||||||
//int nbits=dynamicRange;
|
//int nbits=dynamicRange;
|
||||||
int ipos=0, ichan=0;;
|
int ipos=0, ichan=0;;
|
||||||
//int nch, boff=0;
|
//int nch, boff=0;
|
||||||
int ibyte, ibit;
|
int ibyte;//, ibit;
|
||||||
char iptr;
|
char iptr;
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -1324,7 +1374,7 @@ int getDynamicRange() {
|
|||||||
int testBus() {
|
int testBus() {
|
||||||
u_int32_t j;
|
u_int32_t j;
|
||||||
u_int64_t i, n, nt;
|
u_int64_t i, n, nt;
|
||||||
char cmd[100];
|
//char cmd[100];
|
||||||
u_int32_t val=0x0;
|
u_int32_t val=0x0;
|
||||||
int ifail=OK;
|
int ifail=OK;
|
||||||
// printf("%s\n",cmd);
|
// printf("%s\n",cmd);
|
||||||
@ -1453,20 +1503,22 @@ int clearRAM() {
|
|||||||
|
|
||||||
int setMaster(int f) {
|
int setMaster(int f) {
|
||||||
|
|
||||||
int i, s;
|
int i;
|
||||||
switch(f) {
|
switch(f) {
|
||||||
case NO_MASTER:
|
case NO_MASTER:
|
||||||
|
// switch of gates or triggers
|
||||||
masterMode=NO_MASTER;
|
masterMode=NO_MASTER;
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
setFPGASignal(i,SIGNAL_OFF);
|
setFPGASignal(i,SIGNAL_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case IS_MASTER:
|
case IS_MASTER:
|
||||||
// configure gate or trigger out
|
// configure gate or trigger out
|
||||||
|
masterMode=IS_MASTER;
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
masterMode=IS_MASTER;
|
|
||||||
switch (syncMode) {
|
switch (syncMode) {
|
||||||
case NO_SYNCHRONIZATION:
|
case NO_SYNCHRONIZATION:
|
||||||
setFPGASignal(i,SIGNAL_OFF);
|
setFPGASignal(i,SIGNAL_OFF);
|
||||||
@ -1485,11 +1537,12 @@ int setMaster(int f) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case IS_SLAVE:
|
case IS_SLAVE:
|
||||||
// configure gate or trigger in
|
// configure gate or trigger in
|
||||||
|
masterMode=IS_SLAVE;
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
masterMode=IS_SLAVE;
|
|
||||||
switch (syncMode) {
|
switch (syncMode) {
|
||||||
case NO_SYNCHRONIZATION:
|
case NO_SYNCHRONIZATION:
|
||||||
setFPGASignal(i,SIGNAL_OFF);
|
setFPGASignal(i,SIGNAL_OFF);
|
||||||
@ -1508,12 +1561,71 @@ int setMaster(int f) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// configure gate or trigger in
|
break;
|
||||||
default:
|
default:
|
||||||
//do nothing
|
//do nothing
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch(masterMode) {
|
||||||
|
case NO_MASTER:
|
||||||
|
return NO_MASTER;
|
||||||
|
|
||||||
|
|
||||||
|
case IS_MASTER:
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
switch (syncMode) {
|
||||||
|
case NO_SYNCHRONIZATION:
|
||||||
|
return IS_MASTER;
|
||||||
|
case MASTER_GATES:
|
||||||
|
if (getFPGASignal(i)==GATE_OUT_ACTIVE_HIGH)
|
||||||
|
return IS_MASTER;
|
||||||
|
else
|
||||||
|
return NO_MASTER;
|
||||||
|
case MASTER_TRIGGERS:
|
||||||
|
if (getFPGASignal(i)==TRIGGER_OUT_RISING_EDGE)
|
||||||
|
return IS_MASTER;
|
||||||
|
else
|
||||||
|
return NO_MASTER;
|
||||||
|
case SLAVE_STARTS_WHEN_MASTER_STOPS:
|
||||||
|
if (getFPGASignal(i)==RO_TRIGGER_OUT_RISING_EDGE)
|
||||||
|
return IS_MASTER;
|
||||||
|
else
|
||||||
|
return NO_MASTER;
|
||||||
|
default:
|
||||||
|
return NO_MASTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case IS_SLAVE:
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
switch (syncMode) {
|
||||||
|
case NO_SYNCHRONIZATION:
|
||||||
|
return IS_SLAVE;
|
||||||
|
case MASTER_GATES:
|
||||||
|
if (getFPGASignal(i)==GATE_IN_ACTIVE_HIGH)
|
||||||
|
return IS_SLAVE;
|
||||||
|
else
|
||||||
|
return NO_MASTER;
|
||||||
|
case MASTER_TRIGGERS:
|
||||||
|
case SLAVE_STARTS_WHEN_MASTER_STOPS:
|
||||||
|
if (getFPGASignal(i)==TRIGGER_IN_RISING_EDGE)
|
||||||
|
return IS_SLAVE;
|
||||||
|
else
|
||||||
|
return NO_MASTER;
|
||||||
|
default:
|
||||||
|
return NO_MASTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return masterMode;
|
return masterMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1533,10 +1645,9 @@ int setSynchronization(int s) {
|
|||||||
// disable external signals?
|
// disable external signals?
|
||||||
case MASTER_GATES:
|
case MASTER_GATES:
|
||||||
// configure gate in or out
|
// configure gate in or out
|
||||||
|
syncMode=MASTER_GATES;
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
syncMode=MASTER_GATES;
|
|
||||||
if (masterMode==IS_MASTER)
|
if (masterMode==IS_MASTER)
|
||||||
setFPGASignal(i,GATE_OUT_ACTIVE_HIGH);
|
setFPGASignal(i,GATE_OUT_ACTIVE_HIGH);
|
||||||
else if (masterMode==IS_SLAVE)
|
else if (masterMode==IS_SLAVE)
|
||||||
@ -1546,45 +1657,86 @@ int setSynchronization(int s) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case MASTER_TRIGGERS:
|
case MASTER_TRIGGERS:
|
||||||
// configure trigger in or out
|
// configure trigger in or out
|
||||||
|
syncMode=MASTER_TRIGGERS;
|
||||||
|
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
syncMode=MASTER_TRIGGERS;
|
|
||||||
if (masterMode==IS_MASTER)
|
if (masterMode==IS_MASTER)
|
||||||
setFPGASignal(i,TRIGGER_OUT_RISING_EDGE);
|
setFPGASignal(i,TRIGGER_OUT_RISING_EDGE);
|
||||||
else if (masterMode==IS_SLAVE)
|
else if (masterMode==IS_SLAVE)
|
||||||
setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
|
setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case SLAVE_STARTS_WHEN_MASTER_STOPS:
|
case SLAVE_STARTS_WHEN_MASTER_STOPS:
|
||||||
// configure trigger in or out
|
// configure trigger in or out
|
||||||
|
syncMode=SLAVE_STARTS_WHEN_MASTER_STOPS;
|
||||||
|
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
syncMode=SLAVE_STARTS_WHEN_MASTER_STOPS;
|
|
||||||
if (masterMode==IS_MASTER)
|
if (masterMode==IS_MASTER)
|
||||||
setFPGASignal(i,RO_TRIGGER_OUT_RISING_EDGE);
|
setFPGASignal(i,RO_TRIGGER_OUT_RISING_EDGE);
|
||||||
else if (masterMode==IS_SLAVE)
|
else if (masterMode==IS_SLAVE)
|
||||||
setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
|
setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//do nothing
|
//do nothing
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
return syncMode;
|
switch (syncMode) {
|
||||||
|
|
||||||
|
case NO_SYNCHRONIZATION:
|
||||||
|
return NO_SYNCHRONIZATION;
|
||||||
|
|
||||||
|
case MASTER_GATES:
|
||||||
|
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
if (masterMode==IS_MASTER && getFPGASignal(i)==GATE_OUT_ACTIVE_HIGH)
|
||||||
|
return MASTER_GATES;
|
||||||
|
else if (masterMode==IS_SLAVE && getFPGASignal(i)==GATE_IN_ACTIVE_HIGH)
|
||||||
|
return MASTER_GATES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NO_SYNCHRONIZATION;
|
||||||
|
|
||||||
|
case MASTER_TRIGGERS:
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
if (masterMode==IS_MASTER && getFPGASignal(i)==TRIGGER_OUT_RISING_EDGE)
|
||||||
|
return MASTER_TRIGGERS;
|
||||||
|
else if (masterMode==IS_SLAVE && getFPGASignal(i)==TRIGGER_IN_RISING_EDGE)
|
||||||
|
return MASTER_TRIGGERS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NO_SYNCHRONIZATION;
|
||||||
|
|
||||||
|
case SLAVE_STARTS_WHEN_MASTER_STOPS:
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
if (masterMode==IS_MASTER && getFPGASignal(i)==RO_TRIGGER_OUT_RISING_EDGE)
|
||||||
|
return SLAVE_STARTS_WHEN_MASTER_STOPS;
|
||||||
|
else if (masterMode==IS_SLAVE && getFPGASignal(i)==TRIGGER_IN_RISING_EDGE)
|
||||||
|
return SLAVE_STARTS_WHEN_MASTER_STOPS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NO_SYNCHRONIZATION;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return NO_SYNCHRONIZATION;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return NO_SYNCHRONIZATION;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,8 @@ u_int32_t setWaitStates(int d);
|
|||||||
u_int32_t getWaitStates();
|
u_int32_t getWaitStates();
|
||||||
u_int32_t setTotClockDivider(int d);
|
u_int32_t setTotClockDivider(int d);
|
||||||
u_int32_t getTotClockDivider();
|
u_int32_t getTotClockDivider();
|
||||||
u_int32_t setTotClockDutyCycle(int d);
|
u_int32_t setTotDutyCycle(int d);
|
||||||
u_int32_t getTotClockDutyCycle();
|
u_int32_t getTotDutyCycle();
|
||||||
|
|
||||||
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);
|
||||||
@ -75,7 +75,7 @@ int64_t setGates(int64_t value);
|
|||||||
int64_t getGates();
|
int64_t getGates();
|
||||||
|
|
||||||
int64_t setDelay(int64_t value);
|
int64_t setDelay(int64_t value);
|
||||||
int64_t getDelaye();
|
int64_t getDelay();
|
||||||
|
|
||||||
int64_t setPeriod(int64_t value);
|
int64_t setPeriod(int64_t value);
|
||||||
int64_t getPeriod();
|
int64_t getPeriod();
|
||||||
|
@ -431,7 +431,7 @@ int program_one_dac(int addr, int value, int imod) {
|
|||||||
int im;
|
int im;
|
||||||
int idac;
|
int idac;
|
||||||
int v=value;
|
int v=value;
|
||||||
int reg, mask;
|
// int reg, mask;
|
||||||
|
|
||||||
// sls_detector_module *myMod;
|
// sls_detector_module *myMod;
|
||||||
control=9+addr;
|
control=9+addr;
|
||||||
@ -660,7 +660,7 @@ float initDACbyIndexDACU(int ind, int val, int imod) {
|
|||||||
|
|
||||||
int cs=daccs[ind];
|
int cs=daccs[ind];
|
||||||
int addr=dacaddr[ind];
|
int addr=dacaddr[ind];
|
||||||
int iv;
|
// int iv;
|
||||||
int im;
|
int im;
|
||||||
|
|
||||||
if (val>=0) {
|
if (val>=0) {
|
||||||
@ -705,7 +705,7 @@ int getThresholdEnergy() {
|
|||||||
float g[3]=DEFAULTGAIN;
|
float g[3]=DEFAULTGAIN;
|
||||||
float o[3]=DEFAULTOFFSET;
|
float o[3]=DEFAULTOFFSET;
|
||||||
float myg=-1, myo=-1;
|
float myg=-1, myo=-1;
|
||||||
int dacu;
|
// int dacu;
|
||||||
int imod;
|
int imod;
|
||||||
int ethr=-1;
|
int ethr=-1;
|
||||||
int ret=FAIL;
|
int ret=FAIL;
|
||||||
|
@ -58,13 +58,16 @@ int init_detector( int b) {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
testFpga();
|
testFpga();
|
||||||
#ifdef MCB_FUNCS
|
|
||||||
if (b) {
|
if (b) {
|
||||||
|
#ifdef MCB_FUNCS
|
||||||
initDetector();
|
initDetector();
|
||||||
setSettings(GET_SETTINGS);
|
setSettings(GET_SETTINGS);
|
||||||
testRAM();
|
testRAM();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
|
||||||
|
setMaster(GET_MASTER);
|
||||||
|
setSynchronization(GET_SYNCHRONIZATION_MODE);
|
||||||
|
}
|
||||||
strcpy(mess,"dummy message");
|
strcpy(mess,"dummy message");
|
||||||
strcpy(lastClientIP,"none");
|
strcpy(lastClientIP,"none");
|
||||||
strcpy(thisClientIP,"none1");
|
strcpy(thisClientIP,"none1");
|
||||||
@ -1313,7 +1316,7 @@ int set_module(int file_des) {
|
|||||||
float *myAdc=malloc(NADC*sizeof(int));
|
float *myAdc=malloc(NADC*sizeof(int));
|
||||||
int retval, n;
|
int retval, n;
|
||||||
int ret=OK;
|
int ret=OK;
|
||||||
int dr, ow;
|
int dr;//, ow;
|
||||||
|
|
||||||
dr=setDynamicRange(-1);
|
dr=setDynamicRange(-1);
|
||||||
|
|
||||||
@ -2624,7 +2627,7 @@ int send_update(int file_des) {
|
|||||||
int ret=OK;
|
int ret=OK;
|
||||||
enum detectorSettings t;
|
enum detectorSettings t;
|
||||||
int thr, n;
|
int thr, n;
|
||||||
int it;
|
// int it;
|
||||||
int64_t retval, tns=-1;
|
int64_t retval, tns=-1;
|
||||||
|
|
||||||
|
|
||||||
@ -2678,7 +2681,7 @@ int set_master(int file_des) {
|
|||||||
enum masterFlags arg;
|
enum masterFlags arg;
|
||||||
int n;
|
int n;
|
||||||
int ret=OK;
|
int ret=OK;
|
||||||
int regret=OK;
|
// int regret=OK;
|
||||||
|
|
||||||
|
|
||||||
sprintf(mess,"can't set master flags\n");
|
sprintf(mess,"can't set master flags\n");
|
||||||
@ -2725,7 +2728,7 @@ int set_synchronization(int file_des) {
|
|||||||
enum synchronizationMode arg;
|
enum synchronizationMode arg;
|
||||||
int n;
|
int n;
|
||||||
int ret=OK;
|
int ret=OK;
|
||||||
int regret=OK;
|
//int regret=OK;
|
||||||
|
|
||||||
|
|
||||||
sprintf(mess,"can't set synchronization mode\n");
|
sprintf(mess,"can't set synchronization mode\n");
|
||||||
|
@ -44,7 +44,7 @@ int trim_with_noise(int countlim, int nsigma, int im)
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
int retval=OK, retval1=OK, retval2=OK;
|
int retval1=OK, retval2=OK;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Trimming using noise\n");
|
printf("Trimming using noise\n");
|
||||||
#endif
|
#endif
|
||||||
@ -83,7 +83,7 @@ int trim_with_beam(int countlim, int nsigma, int im) //rpc
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
int retval=OK, retval1=OK, retval2=OK;
|
int retval1=OK, retval2=OK;
|
||||||
|
|
||||||
printf("Trimming using beam\n");
|
printf("Trimming using beam\n");
|
||||||
//return OK;
|
//return OK;
|
||||||
@ -118,7 +118,7 @@ int trim_with_beam(int countlim, int nsigma, int im) //rpc
|
|||||||
int trim_improve(int maxit, int par2, int im) //rpc
|
int trim_improve(int maxit, int par2, int im) //rpc
|
||||||
{
|
{
|
||||||
|
|
||||||
int retval=OK, retval1=OK, retval2=OK;
|
int retval1=OK, retval2=OK;
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
|
@ -4864,6 +4864,7 @@ int slsDetector::dumpDetectorSetup(string const fname, int level){
|
|||||||
"frames",\
|
"frames",\
|
||||||
"cycles",\
|
"cycles",\
|
||||||
"probes",\
|
"probes",\
|
||||||
|
"timing",\
|
||||||
"fineoff",\
|
"fineoff",\
|
||||||
"ratecorr",\
|
"ratecorr",\
|
||||||
"startscript",\
|
"startscript",\
|
||||||
@ -4892,7 +4893,7 @@ int slsDetector::dumpDetectorSetup(string const fname, int level){
|
|||||||
"trimbits",\
|
"trimbits",\
|
||||||
"extsig"
|
"extsig"
|
||||||
};
|
};
|
||||||
int nvar=40;
|
int nvar=41;
|
||||||
int iv=0;
|
int iv=0;
|
||||||
string fname1;
|
string fname1;
|
||||||
ofstream outfile;
|
ofstream outfile;
|
||||||
@ -5497,7 +5498,7 @@ masterFlags slsDetector::setMaster(masterFlags flag) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "Readout flag set to "<< retval << std::endl;
|
std::cout<< "Master flag set to "<< retval << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -879,6 +879,7 @@ string slsDetectorCommand::cmdRemove(int narg, char *args[], int action){
|
|||||||
return string("cannot get");
|
return string("cannot get");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string slsDetectorCommand::helpRemove(int narg, char *args[], int action){
|
string slsDetectorCommand::helpRemove(int narg, char *args[], int action){
|
||||||
return string("remove det \t removes a detector. det can either be the detector hostname or the detector position. Returns the total number of detectors in the multidetector structure\n");
|
return string("remove det \t removes a detector. det can either be the detector hostname or the detector position. Returns the total number of detectors in the multidetector structure\n");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user