mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 03:10:02 +02:00
Works with firmware version 100527
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@18 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
aeab347db6
commit
8a5bc0750d
@ -117,7 +117,7 @@ enum detectorType {
|
|||||||
PILATUS, /**< pilatus */
|
PILATUS, /**< pilatus */
|
||||||
EIGER, /**< eiger */
|
EIGER, /**< eiger */
|
||||||
GOTTHARD, /**< gotthard */
|
GOTTHARD, /**< gotthard */
|
||||||
PICASSO, /**< mythen */
|
PICASSO, /**< picasso */
|
||||||
AGIPD /**< agipd */
|
AGIPD /**< agipd */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ enum detectorSettings{
|
|||||||
\see ::sls_detector_channel
|
\see ::sls_detector_channel
|
||||||
*/
|
*/
|
||||||
enum channelRegisterBit {
|
enum channelRegisterBit {
|
||||||
TRIMBIT_OFF, /**< offset of trimbit value in the channel register */
|
TRIMBIT_OFF=0, /**< offset of trimbit value in the channel register */
|
||||||
COMPARATOR_ENABLE=0x100, /**< mask of the comparator enable bit */
|
COMPARATOR_ENABLE=0x100, /**< mask of the comparator enable bit */
|
||||||
ANALOG_SIGNAL_ENABLE=0x200, /**< mask of the analogue output enable bit */
|
ANALOG_SIGNAL_ENABLE=0x200, /**< mask of the analogue output enable bit */
|
||||||
CALIBRATION_ENABLE=0x300, /**< mask of the calibration input enable bit */
|
CALIBRATION_ENABLE=0x300, /**< mask of the calibration input enable bit */
|
||||||
@ -307,6 +307,8 @@ enum timerIndex {
|
|||||||
enum speedVariable {
|
enum speedVariable {
|
||||||
CLOCK_DIVIDER, /**< readout clock divider */
|
CLOCK_DIVIDER, /**< readout clock divider */
|
||||||
WAIT_STATES, /**< wait states for bus read */
|
WAIT_STATES, /**< wait states for bus read */
|
||||||
|
TOT_CLOCK_DIVIDER, /**< wait states for bus read */
|
||||||
|
TOT_DUTY_CYCLE, /**< wait states for bus read */
|
||||||
SET_SIGNAL_LENGTH /**< set/clear signal length */
|
SET_SIGNAL_LENGTH /**< set/clear signal length */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -332,7 +334,9 @@ enum readOutFlags {
|
|||||||
READ_HITS=0x2, /**< return only the number of the channel which counted ate least one */
|
READ_HITS=0x2, /**< return only the number of the channel which counted ate least one */
|
||||||
ZERO_COMPRESSION=0x4,/**< returned data are 0-compressed */
|
ZERO_COMPRESSION=0x4,/**< returned data are 0-compressed */
|
||||||
PUMP_PROBE_MODE=0x8,/**<pump-probe mode */
|
PUMP_PROBE_MODE=0x8,/**<pump-probe mode */
|
||||||
BACKGROUND_CORRECTIONS=0x1000 /**<background corrections */
|
BACKGROUND_CORRECTIONS=0x1000, /**<background corrections */
|
||||||
|
TOT_MODE=0x2000,/**<pump-probe mode */
|
||||||
|
CONTINOUS_RO=0x4000/**<pump-probe mode */
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
trimming modes
|
trimming modes
|
||||||
|
@ -357,9 +357,10 @@ string mythenDetector::executeLine(int narg, char *args[], int action) {
|
|||||||
if (var=="nmod") {
|
if (var=="nmod") {
|
||||||
if (action==PUT_ACTION) {
|
if (action==PUT_ACTION) {
|
||||||
sscanf(args[1],"%d",&ival);
|
sscanf(args[1],"%d",&ival);
|
||||||
setNumberOfModules(ival);
|
//setNumberOfModules(ival);
|
||||||
}
|
} else
|
||||||
sprintf(answer,"%d",setNumberOfModules(GET_FLAG));
|
ival=GET_FLAG;
|
||||||
|
sprintf(answer,"%d",setNumberOfModules(ival));
|
||||||
return string(answer);
|
return string(answer);
|
||||||
} else if (var=="maxmod") {
|
} else if (var=="maxmod") {
|
||||||
if (action==PUT_ACTION) {
|
if (action==PUT_ACTION) {
|
||||||
@ -370,9 +371,9 @@ string mythenDetector::executeLine(int narg, char *args[], int action) {
|
|||||||
} else if (var.find("extsig")==0) {
|
} else if (var.find("extsig")==0) {
|
||||||
istringstream vvstr(var.substr(7));
|
istringstream vvstr(var.substr(7));
|
||||||
vvstr >> ival;
|
vvstr >> ival;
|
||||||
externalSignalFlag flag=GET_EXTERNAL_SIGNAL_FLAG;
|
externalSignalFlag flag=GET_EXTERNAL_SIGNAL_FLAG, ret;
|
||||||
if (action==PUT_ACTION) {
|
if (action==PUT_ACTION) {
|
||||||
sval=string(args[1]);
|
sval=string(args[1]);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "sig " << ival << " flag " << sval;
|
std::cout<< "sig " << ival << " flag " << sval;
|
||||||
#endif
|
#endif
|
||||||
@ -389,10 +390,11 @@ string mythenDetector::executeLine(int narg, char *args[], int action) {
|
|||||||
else if (sval=="trigger_out_falling_edge") flag=TRIGGER_OUT_FALLING_EDGE;
|
else if (sval=="trigger_out_falling_edge") flag=TRIGGER_OUT_FALLING_EDGE;
|
||||||
else if (sval=="ro_trigger_out_rising_edge") flag=RO_TRIGGER_OUT_RISING_EDGE;
|
else if (sval=="ro_trigger_out_rising_edge") flag=RO_TRIGGER_OUT_RISING_EDGE;
|
||||||
else if (sval=="ro_trigger_out_falling_edge") flag=RO_TRIGGER_OUT_FALLING_EDGE;
|
else if (sval=="ro_trigger_out_falling_edge") flag=RO_TRIGGER_OUT_FALLING_EDGE;
|
||||||
setExternalSignalFlags(flag,ival);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
switch (setExternalSignalFlags( GET_EXTERNAL_SIGNAL_FLAG,ival)) {
|
ret= setExternalSignalFlags(flag,ival);
|
||||||
|
switch (ret) {
|
||||||
case SIGNAL_OFF:
|
case SIGNAL_OFF:
|
||||||
return string( "off");
|
return string( "off");
|
||||||
case GATE_IN_ACTIVE_HIGH:
|
case GATE_IN_ACTIVE_HIGH:
|
||||||
@ -473,18 +475,19 @@ string mythenDetector::executeLine(int narg, char *args[], int action) {
|
|||||||
sprintf(answer,"%x",digitalTest(DETECTOR_BUS_TEST));
|
sprintf(answer,"%x",digitalTest(DETECTOR_BUS_TEST));
|
||||||
return string(answer);
|
return string(answer);
|
||||||
} else if (var=="settings") {
|
} else if (var=="settings") {
|
||||||
|
detectorSettings sett=GET_SETTINGS;
|
||||||
if (action==PUT_ACTION) {
|
if (action==PUT_ACTION) {
|
||||||
sval=string(args[1]);
|
sval=string(args[1]);
|
||||||
detectorSettings sett=GET_SETTINGS;
|
|
||||||
if (sval=="standard")
|
if (sval=="standard")
|
||||||
sett=STANDARD;
|
sett=STANDARD;
|
||||||
else if (sval=="fast")
|
else if (sval=="fast")
|
||||||
sett=FAST;
|
sett=FAST;
|
||||||
else if (sval=="highgain")
|
else if (sval=="highgain")
|
||||||
sett=HIGHGAIN;
|
sett=HIGHGAIN;
|
||||||
setSettings(sett);
|
//setSettings(sett);
|
||||||
}
|
}
|
||||||
switch (setSettings( GET_SETTINGS)) {
|
//switch (setSettings( GET_SETTINGS)) {
|
||||||
|
switch (setSettings(sett)) {
|
||||||
case STANDARD:
|
case STANDARD:
|
||||||
return string("standard");
|
return string("standard");
|
||||||
case FAST:
|
case FAST:
|
||||||
@ -516,7 +519,6 @@ string mythenDetector::executeLine(int narg, char *args[], int action) {
|
|||||||
sscanf(args[1],"%f",&fval);// in seconds!
|
sscanf(args[1],"%f",&fval);// in seconds!
|
||||||
setTimer(ACQUISITION_TIME,fval*1E+9);
|
setTimer(ACQUISITION_TIME,fval*1E+9);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(answer,"%f",(float)setTimer(ACQUISITION_TIME)*1E-9);
|
sprintf(answer,"%f",(float)setTimer(ACQUISITION_TIME)*1E-9);
|
||||||
return string(answer);
|
return string(answer);
|
||||||
} else if (var=="period") {
|
} else if (var=="period") {
|
||||||
@ -578,10 +580,14 @@ string mythenDetector::executeLine(int narg, char *args[], int action) {
|
|||||||
readOutFlags flag=GET_READOUT_FLAGS;
|
readOutFlags flag=GET_READOUT_FLAGS;
|
||||||
if (sval=="none")
|
if (sval=="none")
|
||||||
flag=NORMAL_READOUT;
|
flag=NORMAL_READOUT;
|
||||||
else if (sval=="pumpprobe")
|
//else if (sval=="pumpprobe")
|
||||||
flag=PUMP_PROBE_MODE;
|
// flag=PUMP_PROBE_MODE;
|
||||||
else if (sval=="storeinram")
|
else if (sval=="storeinram")
|
||||||
flag=STORE_IN_RAM;
|
flag=STORE_IN_RAM;
|
||||||
|
else if (sval=="tot")
|
||||||
|
flag=TOT_MODE;
|
||||||
|
else if (sval=="continous")
|
||||||
|
flag=CONTINOUS_RO;
|
||||||
setReadOutFlags(flag);
|
setReadOutFlags(flag);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -591,6 +597,10 @@ string mythenDetector::executeLine(int narg, char *args[], int action) {
|
|||||||
return string("none");
|
return string("none");
|
||||||
case STORE_IN_RAM:
|
case STORE_IN_RAM:
|
||||||
return string("storeinram");
|
return string("storeinram");
|
||||||
|
case TOT_MODE:
|
||||||
|
return string("tot");
|
||||||
|
case CONTINOUS_RO:
|
||||||
|
return string("continous");
|
||||||
default:
|
default:
|
||||||
return string("unknown");
|
return string("unknown");
|
||||||
}
|
}
|
||||||
@ -694,6 +704,20 @@ string mythenDetector::executeLine(int narg, char *args[], int action) {
|
|||||||
sprintf(answer,"%d", setSpeed(WAIT_STATES));
|
sprintf(answer,"%d", setSpeed(WAIT_STATES));
|
||||||
return string(answer);
|
return string(answer);
|
||||||
|
|
||||||
|
} else if (var=="totdivider") {
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
sscanf(args[1],"%d",&ival);
|
||||||
|
setSpeed(TOT_CLOCK_DIVIDER,ival);
|
||||||
|
}
|
||||||
|
sprintf(answer,"%d", setSpeed(TOT_CLOCK_DIVIDER));
|
||||||
|
return string(answer);
|
||||||
|
} else if (var=="totdutycycle") {
|
||||||
|
if (action==PUT_ACTION) {
|
||||||
|
sscanf(args[1],"%d",&ival);
|
||||||
|
setSpeed(TOT_DUTY_CYCLE,ival);
|
||||||
|
}
|
||||||
|
sprintf(answer,"%d", setSpeed(TOT_DUTY_CYCLE));
|
||||||
|
return string(answer);
|
||||||
}
|
}
|
||||||
return ("Unknown command");
|
return ("Unknown command");
|
||||||
|
|
||||||
@ -973,8 +997,8 @@ int mythenDetector::readConfigurationFile(string const fname){
|
|||||||
string::size_type pos;
|
string::size_type pos;
|
||||||
int iargval;
|
int iargval;
|
||||||
int interrupt=0;
|
int interrupt=0;
|
||||||
char *args[2];
|
char *args[100];
|
||||||
for (int ia=0; ia<2; ia++) {
|
for (int ia=0; ia<100; ia++) {
|
||||||
args[ia]=new char[1000];
|
args[ia]=new char[1000];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1055,8 +1079,8 @@ int mythenDetector::writeConfigurationFile(string const fname){
|
|||||||
int nvar=14;
|
int nvar=14;
|
||||||
ofstream outfile;
|
ofstream outfile;
|
||||||
int iv=0;
|
int iv=0;
|
||||||
char *args[2];
|
char *args[100];
|
||||||
for (int ia=0; ia<2; ia++) {
|
for (int ia=0; ia<100; ia++) {
|
||||||
args[ia]=new char[1000];
|
args[ia]=new char[1000];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1218,8 +1242,9 @@ int mythenDetector::retrieveDetectorSetup(string fname1, int level){
|
|||||||
if (level==2) {
|
if (level==2) {
|
||||||
fname=fname1+string(".config");
|
fname=fname1+string(".config");
|
||||||
readConfigurationFile(fname);
|
readConfigurationFile(fname);
|
||||||
fname=fname+string(".det");
|
fname=fname1+string(".det");
|
||||||
}
|
} else
|
||||||
|
fname=fname1;
|
||||||
infile.open(fname.c_str(), ios_base::in);
|
infile.open(fname.c_str(), ios_base::in);
|
||||||
if (infile.is_open()) {
|
if (infile.is_open()) {
|
||||||
while (infile.good() and interrupt==0) {
|
while (infile.good() and interrupt==0) {
|
||||||
@ -1241,10 +1266,13 @@ int mythenDetector::retrieveDetectorSetup(string fname1, int level){
|
|||||||
iargval=0;
|
iargval=0;
|
||||||
while (ssstr.good()) {
|
while (ssstr.good()) {
|
||||||
ssstr >> sargname;
|
ssstr >> sargname;
|
||||||
if (ssstr.good()) {
|
// if (ssstr.good()) {
|
||||||
strcpy(args[iargval],sargname.c_str());
|
strcpy(args[iargval],sargname.c_str());
|
||||||
|
#ifdef VERBOSE
|
||||||
|
std::cout<< args[iargval] << std::endl;
|
||||||
|
#endif
|
||||||
iargval++;
|
iargval++;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
if (level==2) {
|
if (level==2) {
|
||||||
executeLine(iargval,args,PUT_ACTION);
|
executeLine(iargval,args,PUT_ACTION);
|
||||||
@ -1467,7 +1495,7 @@ int mythenDetector::writeTrimFile(string fname, sls_detector_module mod){
|
|||||||
outfile.close();
|
outfile.close();
|
||||||
return OK;
|
return OK;
|
||||||
} else {
|
} else {
|
||||||
std::cout<< "could not open file " << fname << std::endl;
|
std::cout<< "could not open trim file " << fname << std::endl;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1492,16 +1520,14 @@ int mythenDetector::writeDataFile(string fname, float *data, float *err, float *
|
|||||||
int idata;
|
int idata;
|
||||||
if (data==NULL)
|
if (data==NULL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
#ifdef VERBOSE
|
|
||||||
std::cout<< "writing data to file " << fname << std::endl;
|
|
||||||
#endif
|
|
||||||
// args|=0x10; // one line per channel!
|
// args|=0x10; // one line per channel!
|
||||||
|
|
||||||
outfile.open (fname.c_str(),ios_base::out);
|
outfile.open (fname.c_str(),ios_base::out);
|
||||||
if (outfile.is_open())
|
if (outfile.is_open())
|
||||||
{
|
{
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "Writing to file " << fname << std::endl;
|
std::cout<< "writeDataFile Writing to file " << fname << std::endl;
|
||||||
#endif
|
#endif
|
||||||
for (int ichan=0; ichan<nch; ichan++) {
|
for (int ichan=0; ichan<nch; ichan++) {
|
||||||
if (ang==NULL) {
|
if (ang==NULL) {
|
||||||
@ -1975,6 +2001,10 @@ void mythenDetector::acquire(int delflag){
|
|||||||
#endif
|
#endif
|
||||||
thisDetector->progressIndex=0;
|
thisDetector->progressIndex=0;
|
||||||
|
|
||||||
|
resetFinalDataQueue();
|
||||||
|
resetDataQueue();
|
||||||
|
|
||||||
|
|
||||||
jointhread=0;
|
jointhread=0;
|
||||||
queuesize=0;
|
queuesize=0;
|
||||||
if (thisDetector->threadedProcessing) {
|
if (thisDetector->threadedProcessing) {
|
||||||
@ -2037,7 +2067,7 @@ void mythenDetector::acquire(int delflag){
|
|||||||
} else if (ip<(np-1))
|
} else if (ip<(np-1))
|
||||||
thisDetector->fileIndex=thisDetector->fileIndex-thisDetector->timerValue[FRAME_NUMBER];
|
thisDetector->fileIndex=thisDetector->fileIndex-thisDetector->timerValue[FRAME_NUMBER];
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Setting file index to " << thisDetector->fileIndex << endl;
|
cout << "------------------------------------------------------Setting file index to " << thisDetector->fileIndex << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2108,10 +2138,20 @@ void* mythenDetector::processData(int delflag) {
|
|||||||
//delete [] myData;
|
//delete [] myData;
|
||||||
// myData=NULL;
|
// myData=NULL;
|
||||||
/** write raw data file */
|
/** write raw data file */
|
||||||
|
if (thisDetector->correctionMask==0 && delflag==1) {
|
||||||
if (thisDetector->correctionMask!=0 || delflag==0) {
|
#ifdef ACQVERBOSE
|
||||||
|
std::cout<< "------------------------------------no processing "<< delflag <<std::endl;
|
||||||
|
#endif
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "********************** no processing: writing file " << createFileName().append(".raw") << endl;
|
||||||
|
#endif
|
||||||
writeDataFile (createFileName().append(".raw"), fdata, NULL, NULL, 'i');
|
writeDataFile (createFileName().append(".raw"), fdata, NULL, NULL, 'i');
|
||||||
|
delete [] fdata;
|
||||||
|
} else {
|
||||||
|
writeDataFile (createFileName().append(".raw"), fdata, NULL, NULL, 'i');
|
||||||
|
#ifdef VERBOSE
|
||||||
|
std::cout << "********************** if (thisDetector->correctionMask!=0 || delflag==0) { writing raw data file " << createFileName() <<" " << thisDetector->correctionMask<< " " << delflag << endl;
|
||||||
|
#endif
|
||||||
/** rate correction */
|
/** rate correction */
|
||||||
if (thisDetector->correctionMask&(1<<RATE_CORRECTION)) {
|
if (thisDetector->correctionMask&(1<<RATE_CORRECTION)) {
|
||||||
rcdata=new float[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
rcdata=new float[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
||||||
@ -2172,7 +2212,10 @@ void* mythenDetector::processData(int delflag) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (thisDetector->correctionMask!=0)
|
if (thisDetector->correctionMask!=0)
|
||||||
writeDataFile (createFileName().append(".dat"), ffcdata, ffcerr,ang);
|
#ifdef VERBOSE
|
||||||
|
std::cout << "********************** writing dat data file if (thisDetector->correctionMask!=0) { " << createFileName() <<" " << thisDetector->correctionMask << endl;
|
||||||
|
#endif
|
||||||
|
writeDataFile (createFileName().append(".dat"), ffcdata, ffcerr,ang);
|
||||||
|
|
||||||
|
|
||||||
addToMerging(ang, ffcdata, ffcerr, mergingBins, mergingCounts,mergingErrors, mergingMultiplicity);
|
addToMerging(ang, ffcdata, ffcerr, mergingBins, mergingCounts,mergingErrors, mergingMultiplicity);
|
||||||
@ -2187,6 +2230,9 @@ void* mythenDetector::processData(int delflag) {
|
|||||||
/** file writing */
|
/** file writing */
|
||||||
currentPositionIndex++;
|
currentPositionIndex++;
|
||||||
if (thisDetector->correctionMask!=0)
|
if (thisDetector->correctionMask!=0)
|
||||||
|
#ifdef VERBOSE
|
||||||
|
std::cout << "********************** writing dat data file if ((currentPositionIndex==thisDetector->numberOfPositions) || (currentPositionIndex==0))" << createFileName() << endl;
|
||||||
|
#endif
|
||||||
writeDataFile (createFileName().append(".dat"),mergingCounts, mergingErrors, mergingBins,'f',np);
|
writeDataFile (createFileName().append(".dat"),mergingCounts, mergingErrors, mergingBins,'f',np);
|
||||||
if (delflag) {
|
if (delflag) {
|
||||||
delete [] mergingBins;
|
delete [] mergingBins;
|
||||||
@ -2201,7 +2247,7 @@ void* mythenDetector::processData(int delflag) {
|
|||||||
|
|
||||||
finalDataQueue.push(thisData);
|
finalDataQueue.push(thisData);
|
||||||
#ifdef ACQVERBOSE
|
#ifdef ACQVERBOSE
|
||||||
std::cout<< "------------------------------------pushing final data queue " << finalDataQueue.size() << std::endl;
|
std::cout<< "------------------------------------pushing final data queue " << finalDataQueue.size() << " " << createFileName() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2214,8 +2260,12 @@ void* mythenDetector::processData(int delflag) {
|
|||||||
delete [] ang;
|
delete [] ang;
|
||||||
//}
|
//}
|
||||||
} else {
|
} else {
|
||||||
if (thisDetector->correctionMask!=0)
|
if (thisDetector->correctionMask!=0) {
|
||||||
writeDataFile (createFileName().append(".dat"), ffcdata, ffcerr);
|
writeDataFile (createFileName().append(".dat"), ffcdata, ffcerr);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
std::cout << "********************** if (thisDetector->correctionMask!=0) writing dat data file " << createFileName() << endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if (delflag) {
|
if (delflag) {
|
||||||
if (ffcdata)
|
if (ffcdata)
|
||||||
delete [] ffcdata;
|
delete [] ffcdata;
|
||||||
@ -2224,25 +2274,17 @@ void* mythenDetector::processData(int delflag) {
|
|||||||
if (ang)
|
if (ang)
|
||||||
delete [] ang;
|
delete [] ang;
|
||||||
} else {
|
} else {
|
||||||
if (thisDetector->correctionMask!=0)
|
if (thisDetector->correctionMask!=0) {
|
||||||
thisData=new detectorData(ffcdata,ffcerr,NULL,thisDetector->progressIndex+1,(createFileName().append(".dat")).c_str(),thisDetector->nChans*thisDetector->nChips*thisDetector->nMods);
|
thisData=new detectorData(ffcdata,ffcerr,NULL,thisDetector->progressIndex+1,(createFileName().append(".dat")).c_str(),thisDetector->nChans*thisDetector->nChips*thisDetector->nMods);
|
||||||
else
|
} else {
|
||||||
thisData=new detectorData(ffcdata,ffcerr,NULL,thisDetector->progressIndex+1,(createFileName().append(".raw")).c_str(),thisDetector->nChans*thisDetector->nChips*thisDetector->nMods);
|
thisData=new detectorData(ffcdata,ffcerr,NULL,thisDetector->progressIndex+1,(createFileName().append(".raw")).c_str(),thisDetector->nChans*thisDetector->nChips*thisDetector->nMods);
|
||||||
|
}
|
||||||
finalDataQueue.push(thisData);
|
finalDataQueue.push(thisData);
|
||||||
#ifdef ACQVERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "------------------------------------pushing final data queue " << finalDataQueue.size() << std::endl;
|
std::cout<< "------------------------------------pushing final data queue with " << createFileName() << " " <<finalDataQueue.size() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
#ifdef ACQVERBOSE
|
|
||||||
std::cout<< "------------------------------------no processing "<< delflag <<std::endl;
|
|
||||||
#endif
|
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << "writing file " << createFileName().append(".raw") << endl;
|
|
||||||
#endif
|
|
||||||
writeDataFile (createFileName().append(".raw"), fdata, NULL, NULL, 'i');
|
|
||||||
delete [] fdata;
|
|
||||||
}
|
}
|
||||||
thisDetector->fileIndex++;
|
thisDetector->fileIndex++;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -2279,11 +2321,11 @@ void* mythenDetector::processData(int delflag) {
|
|||||||
|
|
||||||
|
|
||||||
if (jointhread) {
|
if (jointhread) {
|
||||||
#ifdef ACQVERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "acquisition finished " << dataQueue.size() << " empty " << !dataQueue.empty() << std::endl;
|
std::cout<< "acquisition finished " << dataQueue.size() << " empty " << !dataQueue.empty() << "final data queue size: " << finalDataQueue.size() <<std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
if (dataQueue.size()==0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dum=0;
|
dum=0;
|
||||||
} // ????????????????????????
|
} // ????????????????????????
|
||||||
@ -2315,9 +2357,9 @@ void mythenDetector::startThread(int delflag) {
|
|||||||
// param.sched_priority = 5;
|
// param.sched_priority = 5;
|
||||||
// scheduling parameters of main thread
|
// scheduling parameters of main thread
|
||||||
ret = pthread_setschedparam(pthread_self(), policy, &mparam);
|
ret = pthread_setschedparam(pthread_self(), policy, &mparam);
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
printf("current priority is %d\n",param.sched_priority);
|
// printf("current priority is %d\n",param.sched_priority);
|
||||||
#endif
|
//#endif
|
||||||
if (delflag)
|
if (delflag)
|
||||||
ret = pthread_create(&dataProcessingThread, &tattr,startProcessData, (void*)this);
|
ret = pthread_create(&dataProcessingThread, &tattr,startProcessData, (void*)this);
|
||||||
else
|
else
|
||||||
|
@ -76,7 +76,7 @@ enum {GET_ACTION, PUT_ACTION, READOUT_ACTION};
|
|||||||
*/
|
*/
|
||||||
int dumpDetectorSetup(string const fname, int level=0);
|
int dumpDetectorSetup(string const fname, int level=0);
|
||||||
/**
|
/**
|
||||||
retrieves alld possible detector parameters from file calling executeLine
|
retrieves all possible detector parameters from file calling executeLine
|
||||||
\param fname file to be read
|
\param fname file to be read
|
||||||
*/
|
*/
|
||||||
int retrieveDetectorSetup(string const fname, int level=0);
|
int retrieveDetectorSetup(string const fname, int level=0);
|
||||||
@ -301,7 +301,7 @@ enum {GET_ACTION, PUT_ACTION, READOUT_ACTION};
|
|||||||
\param delflag if 1 the data are deleted, else left there for further processing (or plotting?)
|
\param delflag if 1 the data are deleted, else left there for further processing (or plotting?)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void acquire(int delflag);
|
void acquire(int delflag=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
get current timer value on the stop socket
|
get current timer value on the stop socket
|
||||||
|
@ -13,13 +13,13 @@ INSTMODE= 0777
|
|||||||
SRCS= server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
|
SRCS= server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
|
||||||
OBJS= $(SRCS:%.c=%.o)
|
OBJS= $(SRCS:%.c=%.o)
|
||||||
|
|
||||||
CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS
|
CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS -DVERBOSE
|
||||||
#-DVERBOSE
|
#-DVERYVERBOSE
|
||||||
# -DVERYVERBOSE
|
|
||||||
#-Werror
|
#-Werror
|
||||||
|
|
||||||
LDLIBS+= -lm
|
LDLIBS+= -lm
|
||||||
|
|
||||||
|
mythen: $(PROGS)
|
||||||
all: $(PROGS)
|
all: $(PROGS)
|
||||||
|
|
||||||
boot: $(OBJS)
|
boot: $(OBJS)
|
||||||
@ -28,12 +28,14 @@ $(PROGS): $(OBJS)
|
|||||||
echo $(OBJS)
|
echo $(OBJS)
|
||||||
$(CC) $(LDFLAGS) $^ $(LDLIBS) $(CFLAGS) -o $@
|
$(CC) $(LDFLAGS) $^ $(LDLIBS) $(CFLAGS) -o $@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
install: $(PROGS)
|
install: $(PROGS)
|
||||||
$(INSTALL) -d $(INSTDIR)
|
$(INSTALL) -d $(INSTDIR)
|
||||||
$(INSTALL) -m $(INSTMODE) $(PROGS) $(INSTDIR)
|
$(INSTALL) -m $(INSTMODE) $(PROGS) $(INSTDIR)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(PROGS) *.o
|
rm -rf $(PROGS) $(PICASSO) *.o
|
||||||
|
|
||||||
depend:
|
depend:
|
||||||
makedepend -Y -- $(CFLAGS) -- $(SRCS) 2>/dev/null
|
makedepend -Y -- $(CFLAGS) -- $(SRCS) 2>/dev/null
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
|
#ifndef PICASSOD
|
||||||
#include "server_defs.h"
|
#include "server_defs.h"
|
||||||
|
#else
|
||||||
|
#include "picasso_defs.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "firmware_funcs.h"
|
#include "firmware_funcs.h"
|
||||||
#include "mcb_funcs.h"
|
#include "mcb_funcs.h"
|
||||||
#include "registers.h"
|
#include "registers.h"
|
||||||
@ -207,14 +211,28 @@ u_int32_t getTotClockDivider() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
u_int32_t setTotDutyCycle(int d) {
|
||||||
|
u_int32_t c;
|
||||||
|
c=bus_r(SPEED_REG);
|
||||||
|
bus_w(SPEED_REG,(d<<TOTCLK_DUTYCYCLE_OFFSET)|(c&~(TOTCLK_DUTYCYCLE_MASK)));
|
||||||
|
return ((bus_r(SPEED_REG)& TOTCLK_DUTYCYCLE_MASK)>>TOTCLK_DUTYCYCLE_OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
u_int32_t getTotDutyCycle() {
|
||||||
|
u_int32_t clk_div;
|
||||||
|
clk_div=((bus_r(SPEED_REG)&TOTCLK_DUTYCYCLE_MASK)>>TOTCLK_DUTYCYCLE_OFFSET);
|
||||||
|
return clk_div;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
u_int32_t setExtSignal(int d, enum externalSignalFlag mode) {
|
u_int32_t setExtSignal(int d, enum externalSignalFlag mode) {
|
||||||
|
|
||||||
int modes[]={-1,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 (mode<=RO_TRIGGER_OUT_FALLING_EDGE)
|
if (mode<=RO_TRIGGER_OUT_FALLING_EDGE && mode>=0)
|
||||||
bus_w(EXT_SIGNAL_REG,((modes[mode])<<off)|(c&~(SIGNAL_MASK<<off)));
|
bus_w(EXT_SIGNAL_REG,((modes[mode])<<off)|(c&~(SIGNAL_MASK<<off)));
|
||||||
|
|
||||||
|
|
||||||
@ -239,6 +257,70 @@ int getExtSignal(int d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int setConfigurationRegister(int d) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Setting configuration register to %x",d);
|
||||||
|
#endif
|
||||||
|
if (d>=0) {
|
||||||
|
bus_w(CONFIG_REG,d);
|
||||||
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("configuration register is %x", bus_r(CONFIG_REG));
|
||||||
|
#endif
|
||||||
|
return bus_r(CONFIG_REG);
|
||||||
|
}
|
||||||
|
|
||||||
|
int setToT(int d) {
|
||||||
|
int ret=0;
|
||||||
|
int reg;
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Setting ToT to %d\n",d);
|
||||||
|
#endif
|
||||||
|
reg=bus_r(CONFIG_REG);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Before: ToT is %x\n", reg);
|
||||||
|
#endif
|
||||||
|
if (d>0) {
|
||||||
|
bus_w(CONFIG_REG,reg|TOT_ENABLE_BIT);
|
||||||
|
} else if (d==0) {
|
||||||
|
bus_w(CONFIG_REG,reg&(~TOT_ENABLE_BIT));
|
||||||
|
}
|
||||||
|
reg=bus_r(CONFIG_REG);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("ToT is %x\n", reg);
|
||||||
|
#endif
|
||||||
|
if (reg&TOT_ENABLE_BIT)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int setContinousReadOut(int d) {
|
||||||
|
int ret=0;
|
||||||
|
int reg;
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Setting Continous readout to %d\n",d);
|
||||||
|
#endif
|
||||||
|
reg=bus_r(CONFIG_REG);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Before: Continous readout is %x\n", reg);
|
||||||
|
#endif
|
||||||
|
if (d>0) {
|
||||||
|
bus_w(CONFIG_REG,reg|CONT_RO_ENABLE_BIT);
|
||||||
|
} else if (d==0) {
|
||||||
|
bus_w(CONFIG_REG,reg&(~CONT_RO_ENABLE_BIT));
|
||||||
|
}
|
||||||
|
reg=bus_r(CONFIG_REG);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Continous readout is %x\n", reg);
|
||||||
|
#endif
|
||||||
|
if (reg&CONT_RO_ENABLE_BIT)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
u_int64_t getMcsNumber() {
|
u_int64_t getMcsNumber() {
|
||||||
|
|
||||||
FILE *fp=NULL;
|
FILE *fp=NULL;
|
||||||
@ -353,30 +435,113 @@ int getNModBoard() {
|
|||||||
int setNMod(int n) {
|
int setNMod(int n) {
|
||||||
|
|
||||||
int fifo;
|
int fifo;
|
||||||
int ifsta, ifsto, ifste;
|
// int ifsta, ifsto, ifste;
|
||||||
if (n>0 && n<=getNModBoard()) {
|
int imod;
|
||||||
nModX=n;
|
int rval;
|
||||||
dataBytes=nModX*nModY*NCHIP*NCHAN*dynamicRange/8;
|
int reg;
|
||||||
allocateRAM();
|
|
||||||
|
int shiftfifo=SHIFTFIFO;
|
||||||
|
int ntot=getNModBoard();
|
||||||
|
|
||||||
|
switch (dynamicRange) {
|
||||||
|
case 16:
|
||||||
|
shiftfifo=SHIFTFIFO-1;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
shiftfifo=SHIFTFIFO-2;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
shiftfifo=SHIFTFIFO-3;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
shiftfifo=SHIFTFIFO-5;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
shiftfifo=SHIFTFIFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("SetNMod called arg %d -- dr %d shiftfifo %d\n",n,dynamicRange,shiftfifo);
|
||||||
|
#endif
|
||||||
|
if (n>0 && n<=ntot) {
|
||||||
|
nModX=n;
|
||||||
|
// dataBytes=nModX*nModY*NCHIP*NCHAN*dynamicRange/8;
|
||||||
|
//allocateRAM();
|
||||||
|
|
||||||
|
|
||||||
/* should enable all fifos*/
|
/* should enable all fifos*/
|
||||||
bus_w(FIFO_CNTRL_REG_OFF+(ALLFIFO<<SHIFTMOD), FIFO_RESET_BIT | FIFO_DISABLE_TOGGLE_BIT);
|
/* // bus_w(FIFO_CNTRL_REG_OFF+(ALLFIFO<<SHIFTFIFO), FIFO_RESET_BIT | FIFO_DISABLE_TOGGLE_BIT);
|
||||||
|
bus_w(FIFO_CNTRL_REG_OFF+(ALLFIFO<<shiftfifo), FIFO_RESET_BIT | FIFO_DISABLE_TOGGLE_BIT);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("a %08x r %08x\n",FIFO_CNTRL_REG_OFF+(ALLFIFO<<shiftfifo),FIFO_RESET_BIT | FIFO_DISABLE_TOGGLE_BIT);
|
||||||
|
for (ififo=0; ififo<ntot*NCHIP; ififo++) {
|
||||||
|
printf("%d %08x\n",ififo,bus_r(FIFO_COUNTR_REG_OFF+(ififo<<shiftfifo)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ifste=dynamicRange/32;
|
||||||
|
ifsta=nModX*NCHIP*ifste;
|
||||||
|
ifsto=ntot*NCHIP*ifste;
|
||||||
|
*/
|
||||||
/*d isable the fifos relative to the unused modules */
|
/*d isable the fifos relative to the unused modules */
|
||||||
|
|
||||||
ifste=NCHAN*dynamicRange/32;
|
for (ififo=0; ififo<ntot*NCHIP; ififo++) {
|
||||||
ifsta=nModX*NCHIP*ifste;
|
//for (ififo=ifsta; ififo<ifsto; ififo+=ifste) {
|
||||||
ifsto=nModBoard*NCHIP*ifste;
|
//fifocntrl[ififo]=FIFO_DISABLE_TOGGLE_BIT;
|
||||||
|
|
||||||
for (ififo=ifsta; ififo<ifsto; ififo+=ifste) {
|
reg=bus_r(FIFO_COUNTR_REG_OFF+(ififo<<shiftfifo));
|
||||||
//fifocntrl[ififo]=FIFO_DISABLE_TOGGLE_BIT;
|
|
||||||
bus_w(FIFO_CNTRL_REG_OFF+(ififo<<SHIFTMOD), FIFO_DISABLE_TOGGLE_BIT);
|
#ifdef VERBOSE
|
||||||
printf("Disabling fifo %d\n",ififo);
|
printf("Fifo %d is %x",ififo,reg);
|
||||||
|
#endif
|
||||||
|
if (ififo<n*NCHIP) {
|
||||||
|
if (reg&FIFO_DISABLED_BIT)
|
||||||
|
bus_w(FIFO_CNTRL_REG_OFF+(ififo<<shiftfifo), FIFO_DISABLE_TOGGLE_BIT);
|
||||||
|
} else {
|
||||||
|
if ((reg&FIFO_DISABLED_BIT)==0)
|
||||||
|
bus_w(FIFO_CNTRL_REG_OFF+(ififo<<shiftfifo), FIFO_DISABLE_TOGGLE_BIT);
|
||||||
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf(" done %x\n",bus_r(FIFO_COUNTR_REG_OFF+(ififo<<shiftfifo)));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// ifste=dynamicRange/32;
|
||||||
|
nModX=0;
|
||||||
|
for (imod=0; imod<ntot; imod++) {
|
||||||
|
rval=0;
|
||||||
|
for (ififo=imod*NCHIP; ififo<(imod+1)*NCHIP; ififo++) {//
|
||||||
|
//for (ififo=imod*NCHIP*ifste; ififo<(imod+1)*NCHIP*ifste; ififo+=ifste) {
|
||||||
|
if ((bus_r(FIFO_COUNTR_REG_OFF+(ififo<<shiftfifo))&FIFO_DISABLED_BIT)==0){
|
||||||
|
rval=1; // checks if at least one fifo of the module is enabled
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("%x Fifo %d is enabled\n",(bus_r(FIFO_COUNTR_REG_OFF+(ififo<<shiftfifo))), ififo);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
|
else printf("%x Fifo %d is disabled\n",(bus_r(FIFO_COUNTR_REG_OFF+(ififo<<shiftfifo))),ififo);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (rval) {
|
||||||
|
nModX++;
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Module %d is enabled --total %d\n",imod,nModX );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
|
else printf("Module %d is disabled --total %d\n",imod,nModX );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("There are %d modules enabled\n",nModX);
|
||||||
|
#endif
|
||||||
|
// dataBytes=nModX*nModY*NCHIP*NCHAN*dynamicRange/8;
|
||||||
|
// allocateRAM();
|
||||||
|
getDynamicRange();
|
||||||
|
|
||||||
return nModX;
|
return nModX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,6 +684,32 @@ int64_t getProbes(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int setDACRegister(int idac, int val, int imod) {
|
||||||
|
u_int32_t addr, reg, mask;
|
||||||
|
int off;
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Settings dac %d module %d register to %d\n",idac,imod,val);
|
||||||
|
#endif
|
||||||
|
if ((idac%2)==0) {
|
||||||
|
addr=MOD_DACS1_REG;
|
||||||
|
} else {
|
||||||
|
addr=MOD_DACS2_REG;
|
||||||
|
}
|
||||||
|
off=(idac%3)*10;
|
||||||
|
mask=~((0x3ff)<<off);
|
||||||
|
|
||||||
|
if (val>=0 && val<DAC_DR) {
|
||||||
|
reg=bus_r(addr+(imod<<SHIFTMOD));
|
||||||
|
reg&=mask;
|
||||||
|
reg|=(val<<off);
|
||||||
|
bus_w(addr+(imod<<SHIFTMOD),reg);
|
||||||
|
}
|
||||||
|
val=(bus_r(addr+(imod<<SHIFTMOD))>>off)&0x3ff;
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Dac %d module %d register is %d\n",idac,imod,val);
|
||||||
|
#endif
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -625,9 +816,27 @@ u_int32_t getNBits()
|
|||||||
u_int32_t fifoReadCounter(int fifonum)
|
u_int32_t fifoReadCounter(int fifonum)
|
||||||
{
|
{
|
||||||
int rval=0;
|
int rval=0;
|
||||||
rval=bus_r(FIFO_COUNTR_REG_OFF+(fifonum<<SHIFTFIFO));
|
int shiftfifo;
|
||||||
|
switch (dynamicRange) {
|
||||||
|
case 16:
|
||||||
|
shiftfifo=SHIFTFIFO-1;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
shiftfifo=SHIFTFIFO-2;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
shiftfifo=SHIFTFIFO-3;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
shiftfifo=SHIFTFIFO-5;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
shiftfifo=SHIFTFIFO;
|
||||||
|
}
|
||||||
|
|
||||||
|
rval=bus_r(FIFO_COUNTR_REG_OFF+(fifonum<<shiftfifo));
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("FIFO %d countains %x words\n",fifonum, rval);
|
printf("FIFO %d contains %x words\n",fifonum, rval);
|
||||||
#endif
|
#endif
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
@ -656,17 +865,25 @@ u_int32_t* fifo_read_event()
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
while (bus_r(LOOK_AT_ME_REG)==0) {
|
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
printf("Waiting for data\n");
|
printf("before looping\n");
|
||||||
|
for (ichip=0; ichip<nModBoard*NCHIP; ichip++) {
|
||||||
|
fifoReadCounter(ichip);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
while(bus_r(LOOK_AT_ME_REG)==0) {
|
||||||
|
//#ifdef VERYVERBOSE
|
||||||
|
printf("Waiting for data status %x\n",runState());
|
||||||
|
//#endif
|
||||||
if (runBusy()==0) {
|
if (runBusy()==0) {
|
||||||
if (bus_r(LOOK_AT_ME_REG)==0) {
|
if (bus_r(LOOK_AT_ME_REG)==0) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("no frame found %x status %x\n", bus_r(LOOK_AT_ME_REG),runState());
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
printf("no frame found\n");
|
|
||||||
for (ichip=0; ichip<nModBoard*NCHIP; ichip++) {
|
for (ichip=0; ichip<nModBoard*NCHIP; ichip++) {
|
||||||
fifoReadCounter(ichip);
|
fifoReadCounter(ichip);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
@ -674,7 +891,7 @@ u_int32_t* fifo_read_event()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERBOSE
|
||||||
printf("before readout\n");
|
printf("before readout\n");
|
||||||
for (ichip=0; ichip<nModBoard*NCHIP; ichip++) {
|
for (ichip=0; ichip<nModBoard*NCHIP; ichip++) {
|
||||||
fifoReadCounter(ichip);
|
fifoReadCounter(ichip);
|
||||||
@ -694,7 +911,6 @@ u_int32_t* fifo_read_event()
|
|||||||
now_ptr+=dataBytes;
|
now_ptr+=dataBytes;
|
||||||
}
|
}
|
||||||
return ram_values;
|
return ram_values;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -711,6 +927,9 @@ u_int32_t* decode_data(int *datain)
|
|||||||
int ibyte, ibit;
|
int ibyte, ibit;
|
||||||
char iptr;
|
char iptr;
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Decoding data for DR %d\n",dynamicRange);
|
||||||
|
#endif
|
||||||
dataout=malloc(nChans*nChips*nModX*4);
|
dataout=malloc(nChans*nChips*nModX*4);
|
||||||
ichan=0;
|
ichan=0;
|
||||||
switch (dynamicRange) {
|
switch (dynamicRange) {
|
||||||
@ -761,15 +980,18 @@ u_int32_t* decode_data(int *datain)
|
|||||||
|
|
||||||
int setDynamicRange(int dr) {
|
int setDynamicRange(int dr) {
|
||||||
int ow;
|
int ow;
|
||||||
|
int nm;
|
||||||
|
|
||||||
u_int32_t np=getProbes();
|
u_int32_t np=getProbes();
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
printf("probes==%02x\n",np);
|
printf("probes==%02x\n",np);
|
||||||
#endif
|
#endif
|
||||||
if (dr>0) {
|
if (dr>0) {
|
||||||
if (dr<=1) {
|
nm=setNMod(-1);
|
||||||
|
if (dr==1) {
|
||||||
dynamicRange=1;
|
dynamicRange=1;
|
||||||
ow=5;
|
ow=5;
|
||||||
} else if (dr<=4) {
|
} else if (dr<=4) {
|
||||||
dynamicRange=4;
|
dynamicRange=4;
|
||||||
ow=4;
|
ow=4;
|
||||||
} else if (dr<=8) {
|
} else if (dr<=8) {
|
||||||
@ -785,7 +1007,7 @@ int setDynamicRange(int dr) {
|
|||||||
setCSregister(ALLMOD);
|
setCSregister(ALLMOD);
|
||||||
initChipWithProbes(0, ow,np, ALLMOD);
|
initChipWithProbes(0, ow,np, ALLMOD);
|
||||||
putout("0000000000000000",ALLMOD);
|
putout("0000000000000000",ALLMOD);
|
||||||
|
setNMod(nm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,11 +33,16 @@ 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 getTotClockDutyCycle();
|
||||||
|
|
||||||
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);
|
||||||
|
int setConfigurationRegister(int d);
|
||||||
|
int setToT(int d);
|
||||||
|
int setContinousReadOut(int d);
|
||||||
|
|
||||||
|
int setDACRegister(int idac, int val, int imod);
|
||||||
|
|
||||||
|
|
||||||
u_int64_t getMcsNumber();
|
u_int64_t getMcsNumber();
|
||||||
|
@ -5,9 +5,13 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include "registers.h"
|
||||||
|
|
||||||
|
#ifndef PICASSOD
|
||||||
#include "server_defs.h"
|
#include "server_defs.h"
|
||||||
|
#else
|
||||||
|
#include "picasso_defs.h"
|
||||||
|
#endif
|
||||||
#include "firmware_funcs.h"
|
#include "firmware_funcs.h"
|
||||||
#include "mcb_funcs.h"
|
#include "mcb_funcs.h"
|
||||||
|
|
||||||
@ -48,7 +52,9 @@ int initDetector() {
|
|||||||
int imod;
|
int imod;
|
||||||
// sls_detector_module *myModule;
|
// sls_detector_module *myModule;
|
||||||
int n=getNModBoard();
|
int n=getNModBoard();
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Board is for %d modules\n",n);
|
||||||
|
#endif
|
||||||
detectorModules=malloc(n*sizeof(sls_detector_module));
|
detectorModules=malloc(n*sizeof(sls_detector_module));
|
||||||
detectorChips=malloc(n*NCHIP*sizeof(int));
|
detectorChips=malloc(n*NCHIP*sizeof(int));
|
||||||
|
|
||||||
@ -92,10 +98,14 @@ int initDetector() {
|
|||||||
putout("0000000000000000",ALLMOD);
|
putout("0000000000000000",ALLMOD);
|
||||||
|
|
||||||
/* initialize dynamic range etc. */
|
/* initialize dynamic range etc. */
|
||||||
nModX=n;
|
dynamicRange=getDynamicRange();
|
||||||
dataBytes=nModX*NCHIP*NCHAN*4;
|
nModX=setNMod(-1);
|
||||||
dynamicRange=32;
|
|
||||||
initChip(0, 1,ALLMOD);
|
//dataBytes=nModX*NCHIP*NCHAN*4;
|
||||||
|
// dynamicRange=32;
|
||||||
|
// initChip(0, 0,ALLMOD);
|
||||||
|
//nModX=n;
|
||||||
|
//
|
||||||
// allocateRAM();
|
// allocateRAM();
|
||||||
|
|
||||||
|
|
||||||
@ -419,6 +429,8 @@ 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;
|
||||||
|
|
||||||
// sls_detector_module *myMod;
|
// sls_detector_module *myMod;
|
||||||
control=9+addr;
|
control=9+addr;
|
||||||
|
|
||||||
@ -472,15 +484,109 @@ int program_one_dac(int addr, int value, int imod) {
|
|||||||
//(detectorModules+imod)->dacs[idac]=v;
|
//(detectorModules+imod)->dacs[idac]=v;
|
||||||
detectorDacs[idac+NDAC*imod]=v;
|
detectorDacs[idac+NDAC*imod]=v;
|
||||||
//#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
|
#ifdef VERBOSE
|
||||||
printf("module=%d index=%d, val=%d addr=%x\n",imod, idac, v, detectorDacs+idac+NDAC*imod);
|
printf("module=%d index=%d, val=%d addr=%x\n",imod, idac, v, detectorDacs+idac+NDAC*imod);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
setDACRegister(idac,v,imod);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
reg=bus_r(MOD_DACS1_REG+(imod<<SHIFTMOD));
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("DACS register 1 is %x\n",reg);
|
||||||
|
#endif
|
||||||
|
if ((idac%2)==0) {
|
||||||
|
|
||||||
|
#ifdef VERYVERBOSE
|
||||||
|
printf("DACS %d div2 should be 0 is %d\n",idac, idac%2);
|
||||||
|
#endif
|
||||||
|
mask=~((0x3ff)<<((idac%3)*10));
|
||||||
|
reg&=mask;
|
||||||
|
reg|=(v<<((idac%3)*10));
|
||||||
|
#ifdef VERYVERBOSE
|
||||||
|
printf("DACS %d div3 is %d\n",idac, idac%3);
|
||||||
|
#endif
|
||||||
|
bus_w(MOD_DACS1_REG+(imod<<SHIFTMOD), reg);
|
||||||
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("after setting dac %d module %d -- %x -- %x\n",idac, imod, reg, bus_r(MOD_DACS1_REG+(imod<<SHIFTMOD)));
|
||||||
|
#endif
|
||||||
|
reg=bus_r(MOD_DACS2_REG+(imod<<SHIFTMOD));
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("DACS register 2 is %x\n",reg);
|
||||||
|
#endif
|
||||||
|
if ((idac%2)==1) {
|
||||||
|
#ifdef VERYVERBOSE
|
||||||
|
printf("DACS %d div2 should be 1 is %d\n",idac, idac%2);
|
||||||
|
#endif
|
||||||
|
mask=~((0x3ff)<<((idac%3)*10));
|
||||||
|
reg&=mask;
|
||||||
|
reg|=(v<<((idac%3)*10));
|
||||||
|
#ifdef VERYVERBOSE
|
||||||
|
printf("DACS %d div3 is %d\n",idac, idac%3);
|
||||||
|
#endif
|
||||||
|
bus_w(MOD_DACS2_REG+(imod<<SHIFTMOD), reg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("after setting dac %d module %d -- %x -- %x\n",idac, imod, reg, bus_r(MOD_DACS2_REG+(imod<<SHIFTMOD)));
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
//#endif
|
//#endif
|
||||||
} else if (imod==ALLMOD) {
|
} else if (imod==ALLMOD) {
|
||||||
for (im=0; im<getNModBoard(); im++) {
|
for (im=0; im<getNModBoard(); im++) {
|
||||||
detectorDacs[idac+NDAC*im]=v;
|
detectorDacs[idac+NDAC*im]=v;
|
||||||
//#ifdef VERBOSE
|
|
||||||
|
/*
|
||||||
|
#ifdef VERBOSE
|
||||||
printf("all: module=%d index=%d, val=%d addr=%x\n",im, idac, v,detectorDacs+idac+NDAC*im);
|
printf("all: module=%d index=%d, val=%d addr=%x\n",im, idac, v,detectorDacs+idac+NDAC*im);
|
||||||
//#endif
|
#endif
|
||||||
// (detectorModules+im)->dacs[idac]=v;
|
// (detectorModules+im)->dacs[idac]=v;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
reg=bus_r(MOD_DACS1_REG+(imod<<SHIFTMOD));
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("DACS register 1 is %x\n",reg);
|
||||||
|
#endif
|
||||||
|
if ((idac%2)==0) {
|
||||||
|
#ifdef VERYVERBOSE
|
||||||
|
printf("DACS %d div2 should be 0 is %d\n",idac, idac%2);
|
||||||
|
#endif
|
||||||
|
mask=~((0x3ff)<<((idac%3)*10));
|
||||||
|
reg&=mask;
|
||||||
|
reg|=(v<<((idac%3)*10));
|
||||||
|
#ifdef VERYVERBOSE
|
||||||
|
printf("DACS %d div3 is %d\n",idac, idac%3);
|
||||||
|
#endif
|
||||||
|
bus_w(MOD_DACS1_REG+(imod<<SHIFTMOD), reg);
|
||||||
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("after setting dac %d module %d -- %x -- %x\n",idac, im, reg, bus_r(MOD_DACS1_REG+(im<<SHIFTMOD)));
|
||||||
|
#endif
|
||||||
|
reg=bus_r(MOD_DACS2_REG+(im<<SHIFTMOD));
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("DACS register 2 is %x\n",reg);
|
||||||
|
#endif
|
||||||
|
if ((idac%2)==1) {
|
||||||
|
#ifdef VERYVERBOSE
|
||||||
|
printf("DACS %d div2 should be 1 is %d\n",idac, idac%2);
|
||||||
|
#endif
|
||||||
|
mask=~((0x3ff)<<((idac%3)*10));
|
||||||
|
reg&=mask;
|
||||||
|
reg|=(v<<((idac%3)*10));
|
||||||
|
#ifdef VERYVERBOSE
|
||||||
|
printf("DACS %d div3 is %d\n",idac, idac%3);
|
||||||
|
#endif
|
||||||
|
bus_w(MOD_DACS2_REG+(im<<SHIFTMOD), reg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("after setting dac %d module %d -- %x -- %x addr %d\n",idac, im, reg, bus_r(MOD_DACS2_REG+(im<<SHIFTMOD)));
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
setDACRegister(idac,v,im);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -564,15 +670,32 @@ float initDACbyIndexDACU(int ind, int val, int imod) {
|
|||||||
*/
|
*/
|
||||||
//return val;
|
//return val;
|
||||||
}
|
}
|
||||||
if (imod>=0 && imod<nModX)
|
if (imod>=0 && imod<nModX) {
|
||||||
return detectorDacs[ind+imod*NDAC];
|
// return detectorDacs[ind+imod*NDAC];
|
||||||
|
return setDACRegister(ind, -1, imod);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
//iv=detectorDacs[ind];
|
//iv=detectorDacs[ind];
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("mod 0 of %d dac %d val %d\n",nModX,ind,setDACRegister(ind, -1, 0));
|
||||||
|
#endif
|
||||||
for (im=1; im<nModX; im++) {
|
for (im=1; im<nModX; im++) {
|
||||||
if (detectorDacs[ind+im*NDAC]!=detectorDacs[ind])
|
#ifdef VERBOSE
|
||||||
|
printf("mod %d dac %d val %d\n",im,ind,setDACRegister(ind, -1, im));
|
||||||
|
#endif
|
||||||
|
//if (detectorDacs[ind+im*NDAC]!=detectorDacs[ind]) {
|
||||||
|
|
||||||
|
if (setDACRegister(ind, -1, im)!=setDACRegister(ind, -1, 0)) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("mod %d returning -1\n",im);
|
||||||
|
#endif
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return detectorDacs[ind];
|
#ifdef VERBOSE
|
||||||
|
printf("returning %d\n",setDACRegister(ind, -1, 0));
|
||||||
|
#endif
|
||||||
|
return setDACRegister(ind, -1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -609,13 +732,17 @@ int getThresholdEnergy() {
|
|||||||
//myo=-1;
|
//myo=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myg>0 && myo>0)
|
if (myg>0 && myo>0) {
|
||||||
ethr=(myo-detectorDacs[VTHRESH+imod*NDAC])*1000/myg;
|
//ethr=(myo-detectorDacs[VTHRESH+imod*NDAC])*1000/myg;
|
||||||
// else
|
|
||||||
|
ethr=(myo-setDACRegister(VTHRESH,-1,imod))*1000/myg;
|
||||||
|
// else
|
||||||
// ethr=-1;
|
// ethr=-1;
|
||||||
|
|
||||||
|
}
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("module=%d gain=%f, offset=%f, dacu=%f\n",imod, myg, myo, detectorDacs[VTHRESH+imod*NDAC]);
|
//printf("module=%d gain=%f, offset=%f, dacu=%f\n",imod, myg, myo, detectorDacs[VTHRESH+imod*NDAC]);
|
||||||
|
printf("module=%d gain=%f, offset=%f, dacu=%f\n",imod, myg, myo,setDACRegister(VTHRESH,-1,imod));
|
||||||
printf("Threshold energy of module %d is %d eV\n", imod, ethr);
|
printf("Threshold energy of module %d is %d eV\n", imod, ethr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -688,13 +815,15 @@ int setThresholdEnergy(int ethr) {
|
|||||||
|
|
||||||
|
|
||||||
float getDACbyIndexDACU(int ind, int imod) {
|
float getDACbyIndexDACU(int ind, int imod) {
|
||||||
|
/*
|
||||||
if (detectorDacs) {
|
if (detectorDacs) {
|
||||||
if (imod<getNModBoard())
|
if (imod<getNModBoard())
|
||||||
if (ind<(detectorModules+imod)->ndac)
|
if (ind<(detectorModules+imod)->ndac)
|
||||||
return (detectorDacs[ind+imod*NDAC]);
|
return (detectorDacs[ind+imod*NDAC]);
|
||||||
}
|
}
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
*/
|
||||||
|
return setDACRegister(ind, -1, imod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -782,10 +911,15 @@ int setSettings(int i) {
|
|||||||
} //else {
|
} //else {
|
||||||
imod=0;
|
imod=0;
|
||||||
/* check settings for module 0 */
|
/* check settings for module 0 */
|
||||||
isett=UNDEFINED;
|
isett=UNDEFINED;/*
|
||||||
irgpr=detectorDacs[4+imod*NDAC];
|
irgpr=detectorDacs[4+imod*NDAC];
|
||||||
irgsh1=detectorDacs[imod*NDAC+RGSH1];
|
irgsh1=detectorDacs[imod*NDAC+RGSH1];
|
||||||
irgsh2=detectorDacs[imod*NDAC+RGSH2];
|
irgsh2=detectorDacs[imod*NDAC+RGSH2];
|
||||||
|
*/
|
||||||
|
|
||||||
|
irgpr=setDACRegister(4,-1,imod);
|
||||||
|
irgsh1=setDACRegister(RGSH1,-1,imod);
|
||||||
|
irgsh2=setDACRegister(RGSH2,-1,imod);
|
||||||
for (is=STANDARD; is<UNDEFINED; is++) {
|
for (is=STANDARD; is<UNDEFINED; is++) {
|
||||||
if (irgpr==rgpr[is] && irgsh1==rgsh1[is] && irgsh2==rgsh2[is]) {
|
if (irgpr==rgpr[is] && irgsh1==rgsh1[is] && irgsh2==rgsh2[is]) {
|
||||||
isett=is;
|
isett=is;
|
||||||
@ -796,14 +930,25 @@ int setSettings(int i) {
|
|||||||
#endif
|
#endif
|
||||||
for (imod=1; imod<nModX; imod++) {
|
for (imod=1; imod<nModX; imod++) {
|
||||||
if (isett!=UNDEFINED) {
|
if (isett!=UNDEFINED) {
|
||||||
|
irgpr=setDACRegister(4,-1,imod);
|
||||||
|
irgsh1=setDACRegister(RGSH1,-1,imod);
|
||||||
|
irgsh2=setDACRegister(RGSH2,-1,imod);
|
||||||
|
/*
|
||||||
irgpr=detectorDacs[4+imod*NDAC];
|
irgpr=detectorDacs[4+imod*NDAC];
|
||||||
irgsh1=detectorDacs[imod*NDAC+RGSH1];
|
irgsh1=detectorDacs[imod*NDAC+RGSH1];
|
||||||
irgsh2=detectorDacs[imod*NDAC+RGSH2];
|
irgsh2=detectorDacs[imod*NDAC+RGSH2];
|
||||||
|
*/
|
||||||
if (irgpr!=rgpr[isett] || irgsh1!=rgsh1[isett] || irgsh2!=rgsh2[isett]) {
|
if (irgpr!=rgpr[isett] || irgsh1!=rgsh1[isett] || irgsh2!=rgsh2[isett]) {
|
||||||
isett=UNDEFINED;
|
isett=UNDEFINED;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Settings of module %d are undefined\n",imod);
|
printf("Settings of module %d are undefined\n",imod);
|
||||||
|
printf("%d %d %d \n", irgpr, irgsh1, irgsh2);
|
||||||
|
printf("dacs 1: %08x dacs2: %08x\n",bus_r(MOD_DACS1_REG+(imod<<SHIFTMOD)), bus_r(MOD_DACS2_REG+(imod<<SHIFTMOD)));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -827,12 +972,15 @@ int setSettings(int i) {
|
|||||||
int initChannelbyNumber(sls_detector_channel myChan) {
|
int initChannelbyNumber(sls_detector_channel myChan) {
|
||||||
int reg=myChan.reg;
|
int reg=myChan.reg;
|
||||||
int ft=reg & TRIM_DR;
|
int ft=reg & TRIM_DR;
|
||||||
int cae=(reg>>(NTRIMBITS+1))&1;
|
int cae=(reg>>(NTRIMBITS))&1;
|
||||||
int ae=(reg>>(NTRIMBITS+2))&1;
|
int ae=(reg>>(NTRIMBITS+1))&1;
|
||||||
int coe=(reg>>(NTRIMBITS+3))&1;
|
int coe=(reg>>(NTRIMBITS+2))&1;
|
||||||
int ocoe=(reg>>(NTRIMBITS+4))&1;
|
int ocoe=(reg>>(NTRIMBITS+3))&1;
|
||||||
int counts=(reg>>(NTRIMBITS+5));
|
int counts=(reg>>(NTRIMBITS+4));
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Initializing channel %d chip %d module %d reg %x\n",myChan.chan,myChan.chip,myChan.module, reg);
|
||||||
|
printf("trim %d, cae %d, ae %d, coe %d, ocoe %d, counts %d\n",ft, cae, ae, coe, ocoe, counts);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (myChan.chip<0)
|
if (myChan.chip<0)
|
||||||
setCSregister(myChan.module);
|
setCSregister(myChan.module);
|
||||||
@ -845,6 +993,13 @@ int initChannelbyNumber(sls_detector_channel myChan) {
|
|||||||
selChannel(myChan.chan,myChan.module);
|
selChannel(myChan.chan,myChan.module);
|
||||||
|
|
||||||
initChannel(ft,cae,ae, coe, ocoe, counts,myChan.module);
|
initChannel(ft,cae,ae, coe, ocoe, counts,myChan.module);
|
||||||
|
|
||||||
|
setDynamicRange(dynamicRange);
|
||||||
|
|
||||||
|
setCSregister(ALLMOD);
|
||||||
|
clearSSregister(ALLMOD);
|
||||||
|
putout("0000000000000000",ALLMOD);
|
||||||
|
|
||||||
return myChan.reg;
|
return myChan.reg;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -938,9 +1093,10 @@ int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts, int imod)
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
// printf("im=%d ichi=%d icha=%d tot=%d reg=%x\n",im,ichip, ichan, im*NCHAN*NCHIP+ichip*NCHAN+ichan,detectorChans[im*NCHAN*NCHIP+ichip*NCHAN+ichan]);
|
// printf("im=%d ichi=%d icha=%d tot=%d reg=%x\n",im,ichip, ichan, im*NCHAN*NCHIP+ichip*NCHAN+ichan,detectorChans[im*NCHAN*NCHIP+ichip*NCHAN+ichan]);
|
||||||
#endif
|
#endif
|
||||||
detectorChans[im*NCHAN*NCHIP+ichip*NCHAN+ichan]= ft | (cae<<(NTRIMBITS+1)) | (ae<<(NTRIMBITS+2)) | (coe<<(NTRIMBITS+3)) | (ocoe<<(NTRIMBITS+4)) | (counts<<(NTRIMBITS+5));
|
detectorChans[im*NCHAN*NCHIP+ichip*NCHAN+ichan]= ft | (cae<<(NTRIMBITS+1)) | (ae<<(NTRIMBITS+2)) | (coe<<(NTRIMBITS+3)) | (ocoe<<(NTRIMBITS+4)) | (counts<<(NTRIMBITS+5));
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
// printf("imod=%d ichip=%d ichan=%d addr=%x reg=%x\n",im,ichip,ichan,detectorChans+im*NCHAN*NCHIP+ichip*NCHAN+ichan, detectorChans[im*NCHAN*NCHIP+ichip*NCHAN+ichan]);
|
//printf("imod=%d ichip=%d ichan=%d addr=%x reg=%x\n",im,ichip,ichan,detectorChans+im*NCHAN*NCHIP+ichip*NCHAN+ichan, detectorChans[im*NCHAN*NCHIP+ichip*NCHAN+ichan]);
|
||||||
|
// printf("imod=%d ichip=%d ichan=%d addr=%x reg=%x\n",im,ichip,ichan,detectorChans+im*NCHAN*NCHIP+ichip*NCHAN+ichan, detectorChans[im*NCHAN*NCHIP+ichip*NCHAN+ichan]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1307,13 +1463,13 @@ int initChipWithProbes(int obe, int ow,int nprobes, int imod){
|
|||||||
omask=16;
|
omask=16;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
omask=1;
|
omask=0;//1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
regval=(omask<<OUTMUX_OFFSET)|(nprobes<<PROBES_OFFSET)|(obe<<OUTBUF_OFFSET);
|
regval=(omask<<OUTMUX_OFFSET)|(nprobes<<PROBES_OFFSET)|(obe<<OUTBUF_OFFSET);
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERBOSE
|
||||||
printf("shift in will be %08x\n",regval);
|
printf("initChip: shift in will be %08x\n",regval);
|
||||||
#endif
|
#endif
|
||||||
/* clearing shift in register */
|
/* clearing shift in register */
|
||||||
|
|
||||||
|
@ -56,16 +56,20 @@
|
|||||||
|
|
||||||
#define GET_SHIFT_IN_REG 0x022000
|
#define GET_SHIFT_IN_REG 0x022000
|
||||||
|
|
||||||
#define MCB_CNTRL_REG_OFF 0x100000
|
#define MOD_DACS1_REG 0x030000
|
||||||
#define MCB_DOUT_REG_OFF 0x200000
|
#define MOD_DACS2_REG 0x040000
|
||||||
#define FIFO_CNTRL_REG_OFF 0x300000
|
|
||||||
#define FIFO_COUNTR_REG_OFF 0x400000
|
#define MCB_CNTRL_REG_OFF 0x100000
|
||||||
#define FIFO_DATA_REG_OFF 0x800000
|
#define MCB_DOUT_REG_OFF 0x200000
|
||||||
|
#define FIFO_CNTRL_REG_OFF 0x300000
|
||||||
|
#define FIFO_COUNTR_REG_OFF 0x400000
|
||||||
|
#define FIFO_DATA_REG_OFF 0x800000
|
||||||
|
|
||||||
#define SHIFTMOD 2
|
#define SHIFTMOD 2
|
||||||
#define SHIFTFIFO 9
|
#define SHIFTFIFO 9
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* values defined for FPGA */
|
/* values defined for FPGA */
|
||||||
#define MCSNUM 0x0
|
#define MCSNUM 0x0
|
||||||
#define MCSVERSION 0x101
|
#define MCSVERSION 0x101
|
||||||
@ -99,13 +103,17 @@
|
|||||||
#define SOME_FIFO_FULL_BIT 0x00008000 // error!
|
#define SOME_FIFO_FULL_BIT 0x00008000 // error!
|
||||||
#define ALL_FIFO_EMPTY_BIT 0x00010000 // data ready
|
#define ALL_FIFO_EMPTY_BIT 0x00010000 // data ready
|
||||||
|
|
||||||
|
/* for fifo status register */
|
||||||
|
#define FIFO_DISABLED_BIT 0x81000000
|
||||||
|
#define FIFO_ERROR_BIT 0x08000000
|
||||||
|
#define FIFO_EMPTY_BIT 0x04000000
|
||||||
|
#define FIFO_DATA_READY_BIT 0x02000000
|
||||||
|
#define FIFO_COUNTER_MASK 0x00ffffff
|
||||||
|
|
||||||
/* for config register */
|
/* for config register */
|
||||||
|
|
||||||
#define TOT_ENABLE_BIT 0x00000002
|
#define TOT_ENABLE_BIT 0x00000002
|
||||||
#define TIMED_GATE_BIT 0x00000004
|
#define TIMED_GATE_BIT 0x00000004
|
||||||
#define TIMED_GATE_BIT 0x00000004
|
|
||||||
#define CONT_RO_ENABLE_BIT 0x00080000
|
#define CONT_RO_ENABLE_BIT 0x00080000
|
||||||
|
|
||||||
|
|
||||||
@ -120,7 +128,8 @@
|
|||||||
#define WAIT_STATES_OFFSET 12
|
#define WAIT_STATES_OFFSET 12
|
||||||
#define TOTCLK_DIVIDER_MASK 0xff000000
|
#define TOTCLK_DIVIDER_MASK 0xff000000
|
||||||
#define TOTCLK_DIVIDER_OFFSET 24
|
#define TOTCLK_DIVIDER_OFFSET 24
|
||||||
|
#define TOTCLK_DUTYCYCLE_MASK 0x00ff0000
|
||||||
|
#define TOTCLK_DUTYCYCLE_OFFSET 16
|
||||||
|
|
||||||
/* for external signal register */
|
/* for external signal register */
|
||||||
|
|
||||||
|
@ -34,19 +34,20 @@ int main(int argc, char *argv[])
|
|||||||
b=0;
|
b=0;
|
||||||
printf("opening stop server on port %d\n",portno);
|
printf("opening stop server on port %d\n",portno);
|
||||||
}
|
}
|
||||||
#ifndef VIRTUAL
|
|
||||||
system("bus -a 0xb0000000 -w 0xd0008");
|
|
||||||
#endif
|
|
||||||
init_detector(b);
|
init_detector(b);
|
||||||
|
|
||||||
|
|
||||||
bindSocket(portno);
|
bindSocket(portno);
|
||||||
if (getServerError())
|
if (getServerError()) {
|
||||||
|
printf("server error!\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* assign function table */
|
/* assign function table */
|
||||||
function_table();
|
function_table();
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("function table assigned \n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* waits for connection */
|
/* waits for connection */
|
||||||
|
@ -38,5 +38,5 @@
|
|||||||
#define CLK_FREQ 100E+6
|
#define CLK_FREQ 100E+6
|
||||||
|
|
||||||
|
|
||||||
#define THIS_SOFTWARE_VERSION 0x20090205
|
#define THIS_SOFTWARE_VERSION 0x20100429
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
#include "server_funcs.h"
|
#include "server_funcs.h"
|
||||||
|
#ifndef PICASSOD
|
||||||
#include "server_defs.h"
|
#include "server_defs.h"
|
||||||
|
#else
|
||||||
|
#include "picasso_defs.h"
|
||||||
|
#endif
|
||||||
#include "firmware_funcs.h"
|
#include "firmware_funcs.h"
|
||||||
#include "mcb_funcs.h"
|
#include "mcb_funcs.h"
|
||||||
#include "trimming_funcs.h"
|
#include "trimming_funcs.h"
|
||||||
@ -36,9 +40,18 @@ char mess[1000];
|
|||||||
|
|
||||||
|
|
||||||
int init_detector( int b) {
|
int init_detector( int b) {
|
||||||
|
#ifndef PICASSOD
|
||||||
|
printf("This is a MYTHEN detector with %d chips per module\n", NCHIP);
|
||||||
|
#else
|
||||||
|
printf("This is a PICASSO detector with %d chips per module\n", NCHIP);
|
||||||
|
#endif
|
||||||
mapCSP0();
|
mapCSP0();
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
system("bus -a 0xb0000000 -w 0xd0008");
|
system("bus -a 0xb0000000 -w 0xd0008");
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("setting wait states \n");
|
||||||
|
system("bus -a 0xb0000000");
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
testFpga();
|
testFpga();
|
||||||
#ifdef MCB_FUNCS
|
#ifdef MCB_FUNCS
|
||||||
@ -133,7 +146,7 @@ int M_nofunc(int fnum){
|
|||||||
sprintf(mess,"Unrecognized Function %d\n",fnum);
|
sprintf(mess,"Unrecognized Function %d\n",fnum);
|
||||||
printf(mess);
|
printf(mess);
|
||||||
sendDataOnly(&retval,sizeof(retval));
|
sendDataOnly(&retval,sizeof(retval));
|
||||||
sendDataOnly(mess,strlen(mess)+1);
|
sendDataOnly(mess,sizeof(mess));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +156,7 @@ int exit_server(int fnum) {
|
|||||||
sendDataOnly(&retval,sizeof(retval));
|
sendDataOnly(&retval,sizeof(retval));
|
||||||
printf("closing server.");
|
printf("closing server.");
|
||||||
sprintf(mess,"closing server");
|
sprintf(mess,"closing server");
|
||||||
sendDataOnly(mess,strlen(mess)+1);
|
sendDataOnly(mess,sizeof(mess));
|
||||||
return GOODBYE;
|
return GOODBYE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +229,7 @@ int get_detector_type(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
n += sendDataOnly(&ret,sizeof(ret));
|
n += sendDataOnly(&ret,sizeof(ret));
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
/*return ok/fail*/
|
/*return ok/fail*/
|
||||||
return retval;
|
return retval;
|
||||||
@ -247,23 +260,27 @@ int set_number_of_modules(int fnum) {
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Setting the number of modules in dimension %d to %d\n",dim,nm );
|
printf("Setting the number of modules in dimension %d to %d\n",dim,nm );
|
||||||
#endif
|
#endif
|
||||||
if (nm!=GET_FLAG) {
|
|
||||||
|
//if (nm!=GET_FLAG) {
|
||||||
if (dim!=X) {
|
if (dim!=X) {
|
||||||
retval=FAIL;
|
retval=FAIL;
|
||||||
sprintf(mess,"Can't change module number in dimension %d\n",dim);
|
sprintf(mess,"Can't change module number in dimension %d\n",dim);
|
||||||
} else {
|
} else {
|
||||||
setNMod(nm);
|
ret=setNMod(nm);
|
||||||
if (nModX==nm)
|
if (nModX==nm || nm==GET_FLAG)
|
||||||
retval=OK;
|
retval=OK;
|
||||||
else
|
else
|
||||||
retval=FAIL;
|
retval=FAIL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
/*} else {
|
||||||
|
if (dim==Y) {
|
||||||
|
ret=nModY;
|
||||||
|
} else if (dim==X) {
|
||||||
|
ret=setNMod(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dim==X)
|
*/
|
||||||
ret=nModX;
|
|
||||||
else if (dim==Y)
|
|
||||||
ret=nModY;
|
|
||||||
|
|
||||||
/* send answer */
|
/* send answer */
|
||||||
/* send OK/failed */
|
/* send OK/failed */
|
||||||
@ -272,7 +289,7 @@ int set_number_of_modules(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
n += sendDataOnly(&ret,sizeof(ret));
|
n += sendDataOnly(&ret,sizeof(ret));
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
/*return ok/fail*/
|
/*return ok/fail*/
|
||||||
return retval;
|
return retval;
|
||||||
@ -324,7 +341,7 @@ int get_max_number_of_modules(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
n += sendDataOnly(&ret,sizeof(ret));
|
n += sendDataOnly(&ret,sizeof(ret));
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -386,7 +403,7 @@ int set_external_signal_flag(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
n += sendDataOnly(&retval,sizeof(retval));
|
n += sendDataOnly(&retval,sizeof(retval));
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -447,7 +464,7 @@ enum externalCommunicationMode{
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
n += sendDataOnly(&ret,sizeof(ret));
|
n += sendDataOnly(&ret,sizeof(ret));
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*return ok/fail*/
|
/*return ok/fail*/
|
||||||
@ -530,7 +547,7 @@ int get_id(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
n += sendDataOnly(&retval,sizeof(retval));
|
n += sendDataOnly(&retval,sizeof(retval));
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*return ok/fail*/
|
/*return ok/fail*/
|
||||||
@ -620,7 +637,7 @@ int digital_test(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
n += sendDataOnly(&retval,sizeof(retval));
|
n += sendDataOnly(&retval,sizeof(retval));
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*return ok/fail*/
|
/*return ok/fail*/
|
||||||
@ -672,7 +689,7 @@ int write_register(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
n += sendDataOnly(&retval,sizeof(retval));
|
n += sendDataOnly(&retval,sizeof(retval));
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*return ok/fail*/
|
/*return ok/fail*/
|
||||||
@ -723,7 +740,7 @@ int read_register(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
n += sendDataOnly(&retval,sizeof(retval));
|
n += sendDataOnly(&retval,sizeof(retval));
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*return ok/fail*/
|
/*return ok/fail*/
|
||||||
@ -817,7 +834,7 @@ int set_dac(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
n += sendDataOnly(&retval,sizeof(retval));
|
n += sendDataOnly(&retval,sizeof(retval));
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Maybe this is done inside the initialization funcs */
|
/* Maybe this is done inside the initialization funcs */
|
||||||
@ -903,7 +920,7 @@ int get_adc(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
n += sendDataOnly(&retval,sizeof(retval));
|
n += sendDataOnly(&retval,sizeof(retval));
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*return ok/fail*/
|
/*return ok/fail*/
|
||||||
@ -961,7 +978,7 @@ int set_channel(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
n += sendDataOnly(&retval,sizeof(retval));
|
n += sendDataOnly(&retval,sizeof(retval));
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1032,7 +1049,7 @@ int get_channel(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
ret=sendChannel(&retval);
|
ret=sendChannel(&retval);
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1095,7 +1112,7 @@ int set_chip(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
n += sendDataOnly(&retval,sizeof(retval));
|
n += sendDataOnly(&retval,sizeof(retval));
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1153,7 +1170,7 @@ int get_chip(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
ret=sendChip(&retval);
|
ret=sendChip(&retval);
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1247,7 +1264,7 @@ int set_module(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
n += sendDataOnly(&retval,sizeof(retval));
|
n += sendDataOnly(&retval,sizeof(retval));
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
free(myChip);
|
free(myChip);
|
||||||
free(myChan);
|
free(myChan);
|
||||||
@ -1344,7 +1361,7 @@ int get_module(int fnum) {
|
|||||||
/* send return argument */
|
/* send return argument */
|
||||||
ret=sendModule(&myModule);
|
ret=sendModule(&myModule);
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1396,7 +1413,7 @@ int get_threshold_energy(int fnum) {
|
|||||||
/* send answer */
|
/* send answer */
|
||||||
n = sendDataOnly(&ret,sizeof(ret));
|
n = sendDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
} else
|
} else
|
||||||
n += sendDataOnly(&retval,sizeof(retval));
|
n += sendDataOnly(&retval,sizeof(retval));
|
||||||
|
|
||||||
@ -1450,7 +1467,7 @@ int set_threshold_energy(int fnum) {
|
|||||||
/* send answer */
|
/* send answer */
|
||||||
n = sendDataOnly(&ret,sizeof(ret));
|
n = sendDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
} else
|
} else
|
||||||
n += sendDataOnly(&retval,sizeof(retval));
|
n += sendDataOnly(&retval,sizeof(retval));
|
||||||
|
|
||||||
@ -1502,7 +1519,7 @@ int set_settings(int fnum) {
|
|||||||
/* send answer */
|
/* send answer */
|
||||||
n = sendDataOnly(&ret,sizeof(ret));
|
n = sendDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
} else
|
} else
|
||||||
n += sendDataOnly(&retval,sizeof(retval));
|
n += sendDataOnly(&retval,sizeof(retval));
|
||||||
|
|
||||||
@ -1531,7 +1548,7 @@ int start_acquisition(int fnum) {
|
|||||||
|
|
||||||
n = sendDataOnly(&ret,sizeof(ret));
|
n = sendDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -1555,7 +1572,7 @@ int stop_acquisition(int fnum) {
|
|||||||
|
|
||||||
n = sendDataOnly(&ret,sizeof(ret));
|
n = sendDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -1580,7 +1597,7 @@ int start_readout(int fnum) {
|
|||||||
|
|
||||||
n = sendDataOnly(&ret,sizeof(ret));
|
n = sendDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -1625,7 +1642,7 @@ int get_run_status(int fnum) {
|
|||||||
|
|
||||||
n = sendDataOnly(&ret,sizeof(ret));
|
n = sendDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
} else {
|
} else {
|
||||||
n += sendDataOnly(&s,sizeof(s));
|
n += sendDataOnly(&s,sizeof(s));
|
||||||
}
|
}
|
||||||
@ -1660,17 +1677,17 @@ int read_frame(int fnum) {
|
|||||||
if(getFrames()>-2) {
|
if(getFrames()>-2) {
|
||||||
dataret=FAIL;
|
dataret=FAIL;
|
||||||
sprintf(mess,"no data and run stopped: %d frames left\n",getFrames()+2);
|
sprintf(mess,"no data and run stopped: %d frames left\n",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);
|
||||||
}
|
}
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
printf("%d %d %x %s\n",strlen(mess)+1,strlen(mess), mess,mess);
|
printf("%d %d %x %s\n",sizeof(mess),strlen(mess), mess,mess);
|
||||||
#endif
|
#endif
|
||||||
sendDataOnly(&dataret,sizeof(dataret));
|
sendDataOnly(&dataret,sizeof(dataret));
|
||||||
sendDataOnly(mess,strlen(mess)+1);//sizeof(mess));
|
sendDataOnly(mess,sizeof(mess));//sizeof(mess));//sizeof(mess));
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
printf("message sent\n",mess);
|
printf("message sent\n",mess);
|
||||||
#endif
|
#endif
|
||||||
@ -1707,7 +1724,7 @@ int read_frame(int fnum) {
|
|||||||
printf("Frames left %d\n",getFrames());
|
printf("Frames left %d\n",getFrames());
|
||||||
#endif
|
#endif
|
||||||
sendDataOnly(&dataret,sizeof(dataret));
|
sendDataOnly(&dataret,sizeof(dataret));
|
||||||
sendDataOnly(mess,strlen(mess)+1);
|
sendDataOnly(mess,sizeof(mess));
|
||||||
return dataret;
|
return dataret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1750,7 +1767,7 @@ int start_and_read_all(int fnum) {
|
|||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
sprintf(mess,"could not start state machine\n");
|
sprintf(mess,"could not start state machine\n");
|
||||||
sendDataOnly(&ret,sizeof(ret));
|
sendDataOnly(&ret,sizeof(ret));
|
||||||
sendDataOnly(mess,strlen(mess)+1);
|
sendDataOnly(mess,sizeof(mess));
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("could not start state machine\n");
|
printf("could not start state machine\n");
|
||||||
@ -1848,7 +1865,7 @@ int set_timer(int fnum) {
|
|||||||
printf("returning error\n");
|
printf("returning error\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
n = sendDataOnly(mess,strlen(mess)+1);
|
n = sendDataOnly(mess,sizeof(mess));
|
||||||
} else {
|
} else {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("returning ok %d\n",sizeof(retval));
|
printf("returning ok %d\n",sizeof(retval));
|
||||||
@ -1924,7 +1941,7 @@ int get_time_left(int fnum) {
|
|||||||
|
|
||||||
n = sendDataOnly(&ret,sizeof(ret));
|
n = sendDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
n += sendDataOnly(mess,strlen(mess)+1);
|
n += sendDataOnly(mess,sizeof(mess));
|
||||||
} else {
|
} else {
|
||||||
n = sendDataOnly(&retval,sizeof(retval));
|
n = sendDataOnly(&retval,sizeof(retval));
|
||||||
}
|
}
|
||||||
@ -1999,7 +2016,7 @@ int set_dynamic_range(int fnum) {
|
|||||||
|
|
||||||
n = sendDataOnly(&ret,sizeof(ret));
|
n = sendDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
n = sendDataOnly(mess,strlen(mess)+1);
|
n = sendDataOnly(mess,sizeof(mess));
|
||||||
} else {
|
} else {
|
||||||
n = sendDataOnly(&retval,sizeof(retval));
|
n = sendDataOnly(&retval,sizeof(retval));
|
||||||
}
|
}
|
||||||
@ -2045,30 +2062,42 @@ int set_speed(int fnum) {
|
|||||||
if (ret==OK) {
|
if (ret==OK) {
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case CLOCK_DIVIDER:
|
case CLOCK_DIVIDER:
|
||||||
if (val>0)
|
if (val>=0)
|
||||||
retval=setClockDivider(val);
|
retval=setClockDivider(val);
|
||||||
else
|
else
|
||||||
retval=getClockDivider();
|
retval=getClockDivider();
|
||||||
break;
|
break;
|
||||||
case WAIT_STATES:
|
case WAIT_STATES:
|
||||||
if (val>0)
|
if (val>=0)
|
||||||
retval=setWaitStates(val);
|
retval=setWaitStates(val);
|
||||||
else
|
else
|
||||||
retval=getWaitStates();
|
retval=getWaitStates();
|
||||||
break;
|
break;
|
||||||
case SET_SIGNAL_LENGTH:
|
case SET_SIGNAL_LENGTH:
|
||||||
if (val>0)
|
if (val>=0)
|
||||||
retval=setSetLength(val);
|
retval=setSetLength(val);
|
||||||
else
|
else
|
||||||
retval=getSetLength();
|
retval=getSetLength();
|
||||||
break;
|
break;
|
||||||
|
case TOT_CLOCK_DIVIDER:
|
||||||
|
if (val>=0)
|
||||||
|
retval=setTotClockDivider(val);
|
||||||
|
else
|
||||||
|
retval=getTotClockDivider();
|
||||||
|
break;
|
||||||
|
case TOT_DUTY_CYCLE:
|
||||||
|
if (val>=0)
|
||||||
|
retval=setTotDutyCycle(val);
|
||||||
|
else
|
||||||
|
retval=getTotDutyCycle();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
n = sendDataOnly(&ret,sizeof(ret));
|
n = sendDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
n = sendDataOnly(mess,strlen(mess)+1);
|
n = sendDataOnly(mess,sizeof(mess));
|
||||||
} else {
|
} else {
|
||||||
n = sendDataOnly(&retval,sizeof(retval));
|
n = sendDataOnly(&retval,sizeof(retval));
|
||||||
}
|
}
|
||||||
@ -2083,6 +2112,7 @@ int set_readout_flags(int fnum) {
|
|||||||
enum readOutFlags arg;
|
enum readOutFlags arg;
|
||||||
int n;
|
int n;
|
||||||
int ret=OK;
|
int ret=OK;
|
||||||
|
int regret=OK;
|
||||||
|
|
||||||
|
|
||||||
sprintf(mess,"can't set readout flags\n");
|
sprintf(mess,"can't set readout flags\n");
|
||||||
@ -2105,30 +2135,50 @@ int set_readout_flags(int fnum) {
|
|||||||
case GET_READOUT_FLAGS:
|
case GET_READOUT_FLAGS:
|
||||||
break;
|
break;
|
||||||
case STORE_IN_RAM:
|
case STORE_IN_RAM:
|
||||||
ret=setStoreInRAM(1);
|
if (setStoreInRAM(1)==OK)
|
||||||
|
ret=OK;
|
||||||
|
else
|
||||||
|
ret=FAIL;
|
||||||
break;
|
break;
|
||||||
case PUMP_PROBE_MODE:
|
case TOT_MODE:
|
||||||
|
if(setToT(1))
|
||||||
|
ret=OK;
|
||||||
|
else
|
||||||
|
ret=FAIL;
|
||||||
|
break;
|
||||||
|
case CONTINOUS_RO:
|
||||||
|
if (setContinousReadOut(1))
|
||||||
|
ret=OK;
|
||||||
|
else
|
||||||
|
ret=FAIL;
|
||||||
|
break;
|
||||||
|
// case PUMP_PROBE_MODE:
|
||||||
//set number of probes
|
//set number of probes
|
||||||
initChipWithProbes(0,0,2, ALLMOD);
|
//initChipWithProbes(0,0,2, ALLMOD);
|
||||||
break;
|
//break;
|
||||||
default:
|
default:
|
||||||
ret=setStoreInRAM(0);
|
ret=setStoreInRAM(0);
|
||||||
|
regret=setConfigurationRegister(0);
|
||||||
ret=OK;
|
ret=OK;
|
||||||
}
|
}
|
||||||
|
retval=NORMAL_READOUT;
|
||||||
|
|
||||||
if (storeInRAM)
|
if (storeInRAM)
|
||||||
retval=STORE_IN_RAM;
|
retval=STORE_IN_RAM;
|
||||||
else if (getProbes())
|
//else if (getProbes())
|
||||||
retval=PUMP_PROBE_MODE;
|
// retval=PUMP_PROBE_MODE;
|
||||||
else
|
//else
|
||||||
retval=NORMAL_READOUT;
|
if (setToT(-1))
|
||||||
|
retval|=TOT_MODE;
|
||||||
|
if (setContinousReadOut(-1))
|
||||||
|
retval|=CONTINOUS_RO;
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
printf("set readout flags failed\n");
|
printf("set readout flags failed\n");
|
||||||
sprintf(mess,"Could not allocate RAM\n");
|
sprintf(mess,"Could not allocate RAM\n");
|
||||||
}
|
}
|
||||||
n = sendDataOnly(&ret,sizeof(ret));
|
n = sendDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
n = sendDataOnly(mess,strlen(mess)+1);
|
n = sendDataOnly(mess,sizeof(mess));
|
||||||
} else {
|
} else {
|
||||||
n = sendDataOnly(&retval,sizeof(retval));
|
n = sendDataOnly(&retval,sizeof(retval));
|
||||||
}
|
}
|
||||||
@ -2211,7 +2261,7 @@ int execute_trimming(int fnum) {
|
|||||||
}
|
}
|
||||||
n = sendDataOnly(&ret,sizeof(ret));
|
n = sendDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
n = sendDataOnly(mess,strlen(mess)+1);
|
n = sendDataOnly(mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
|
#ifndef PICASSOD
|
||||||
#include "server_defs.h"
|
#include "server_defs.h"
|
||||||
|
#else
|
||||||
|
#include "picasso_defs.h"
|
||||||
|
#endif
|
||||||
#include "trimming_funcs.h"
|
#include "trimming_funcs.h"
|
||||||
#include "mcb_funcs.h"
|
#include "mcb_funcs.h"
|
||||||
#include "firmware_funcs.h"
|
#include "firmware_funcs.h"
|
||||||
@ -156,6 +159,8 @@ int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) {
|
|||||||
int modma, modmi, nm;
|
int modma, modmi, nm;
|
||||||
int thr, thrstep=5, nthr=31;
|
int thr, thrstep=5, nthr=31;
|
||||||
|
|
||||||
|
int *fifodata;
|
||||||
|
|
||||||
float vthreshmean, vthreshSTDev;
|
float vthreshmean, vthreshSTDev;
|
||||||
int *thrmi, *thrma;
|
int *thrmi, *thrma;
|
||||||
float c;
|
float c;
|
||||||
@ -166,6 +171,8 @@ int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) {
|
|||||||
int nvalid=0;
|
int nvalid=0;
|
||||||
u_int32_t *scan;
|
u_int32_t *scan;
|
||||||
int ithr;
|
int ithr;
|
||||||
|
sls_detector_channel myChan;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setFrames(1);
|
setFrames(1);
|
||||||
@ -195,7 +202,11 @@ int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) {
|
|||||||
clearSSregister(im);
|
clearSSregister(im);
|
||||||
usleep(500);
|
usleep(500);
|
||||||
*/
|
*/
|
||||||
|
myChan.chan=-1;
|
||||||
|
myChan.chip=-1;
|
||||||
|
myChan.module=ALLMOD;
|
||||||
|
myChan.reg=COMPARATOR_ENABLE;
|
||||||
|
initChannelbyNumber(myChan);
|
||||||
|
|
||||||
|
|
||||||
for (ithr=0; ithr<nthr; ithr++) {
|
for (ithr=0; ithr<nthr; ithr++) {
|
||||||
@ -209,9 +220,15 @@ int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) {
|
|||||||
} else
|
} else
|
||||||
initDACbyIndexDACU(VTHRESH,thr+thrstep,imod);
|
initDACbyIndexDACU(VTHRESH,thr+thrstep,imod);
|
||||||
}
|
}
|
||||||
setCSregister(ALLMOD);
|
|
||||||
|
/* setCSregister(ALLMOD);
|
||||||
setSSregister(ALLMOD);
|
setSSregister(ALLMOD);
|
||||||
initChannel(0,0,0,1,0,0,im);
|
initChannel(0,0,0,1,0,0,im);
|
||||||
|
setDynamicRange(32);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
counterClear(ALLMOD);
|
counterClear(ALLMOD);
|
||||||
clearSSregister(ALLMOD);
|
clearSSregister(ALLMOD);
|
||||||
usleep(500);
|
usleep(500);
|
||||||
@ -219,7 +236,8 @@ int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) {
|
|||||||
while (runBusy()) {
|
while (runBusy()) {
|
||||||
}
|
}
|
||||||
usleep(500);
|
usleep(500);
|
||||||
scan=decode_data(fifo_read_event());
|
fifodata=fifo_read_event();
|
||||||
|
scan=decode_data(fifodata);
|
||||||
for (imod=modmi; imod<modma; imod++) {
|
for (imod=modmi; imod<modma; imod++) {
|
||||||
for (ichan=0; ichan<nChans*nChips; ichan++){
|
for (ichan=0; ichan<nChans*nChips; ichan++){
|
||||||
ich=imod*nChips*nChans+ichan;
|
ich=imod*nChips*nChans+ichan;
|
||||||
@ -311,6 +329,10 @@ int trim_with_level(int countlim, int im) {
|
|||||||
int *inttrim;
|
int *inttrim;
|
||||||
int modma, modmi, nm;
|
int modma, modmi, nm;
|
||||||
int retval=OK;
|
int retval=OK;
|
||||||
|
int *fifodata;
|
||||||
|
sls_detector_channel myChan;
|
||||||
|
printf("trimming module number %d", im);
|
||||||
|
|
||||||
|
|
||||||
#ifdef MCB_FUNCS
|
#ifdef MCB_FUNCS
|
||||||
setFrames(1);
|
setFrames(1);
|
||||||
@ -332,10 +354,19 @@ int trim_with_level(int countlim, int im) {
|
|||||||
|
|
||||||
for (itrim=0; itrim<TRIM_DR+1; itrim++) {
|
for (itrim=0; itrim<TRIM_DR+1; itrim++) {
|
||||||
fifoReset();
|
fifoReset();
|
||||||
setCSregister(im);
|
|
||||||
setSSregister(im);
|
|
||||||
printf("Trimbit %d\n",itrim);
|
printf("Trimbit %d\n",itrim);
|
||||||
initChannel(itrim,0,0,1,0,0,im);
|
myChan.chan=-1;
|
||||||
|
myChan.chip=-1;
|
||||||
|
myChan.module=ALLMOD;
|
||||||
|
myChan.reg=COMPARATOR_ENABLE|(itrim<<TRIMBIT_OFF);
|
||||||
|
initChannelbyNumber(myChan);
|
||||||
|
|
||||||
|
/*
|
||||||
|
setCSregister(im);
|
||||||
|
setSSregister(im);
|
||||||
|
initChannel(itrim,0,0,1,0,0,ALLMOD);
|
||||||
|
setDynamicRange(32);
|
||||||
|
*/
|
||||||
setCSregister(ALLMOD);
|
setCSregister(ALLMOD);
|
||||||
setSSregister(ALLMOD);
|
setSSregister(ALLMOD);
|
||||||
counterClear(ALLMOD);
|
counterClear(ALLMOD);
|
||||||
@ -346,19 +377,21 @@ int trim_with_level(int countlim, int im) {
|
|||||||
}
|
}
|
||||||
usleep(500);
|
usleep(500);
|
||||||
|
|
||||||
scan=decode_data(fifo_read_event());
|
fifodata=fifo_read_event();
|
||||||
|
scan=decode_data(fifodata);
|
||||||
for (imod=modmi; imod<modma; imod++) {
|
for (imod=modmi; imod<modma; imod++) {
|
||||||
for (ichan=0; ichan<nChans*nChips; ichan++) {
|
for (ichan=0; ichan<nChans*nChips; ichan++) {
|
||||||
ich=ichan+imod*nChans*nChips;
|
ich=ichan+imod*nChans*nChips;
|
||||||
if (inttrim[ich]==-1) {
|
if (inttrim[ich]==-1) {
|
||||||
if (scan[ich]>countlim){
|
if (scan[ich]>countlim){
|
||||||
inttrim[ich]=itrim;
|
inttrim[ich]=itrim;
|
||||||
if (scan[ich]>2*countlim || itrim==0) {
|
if (scan[ich]>2*countlim && itrim>0) {
|
||||||
#ifdef VERBOSE
|
//if (scan[ich]>2*countlim || itrim==0) {
|
||||||
printf("Channel %d trimbit %d counted %d countlim %d\n",ich,itrim,scan[ich],countlim);
|
inttrim[ich]=itrim-1;
|
||||||
#endif
|
|
||||||
inttrim[ich]=itrim-1;
|
|
||||||
}
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Channel %d trimbit %d counted %d (%08x) countlim %d\n",ich,itrim,scan[ich],fifodata[ich],countlim);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -380,12 +413,12 @@ int trim_with_level(int countlim, int im) {
|
|||||||
ich=ichan+imod*nChans*nChips+ichip*nChans;
|
ich=ichan+imod*nChans*nChips+ichip*nChans;
|
||||||
if (*(inttrim+ich)==-1) {
|
if (*(inttrim+ich)==-1) {
|
||||||
*(inttrim+ich)=TRIM_DR;
|
*(inttrim+ich)=TRIM_DR;
|
||||||
printf("could not trim channel %d chip %d module %d - set to %d\n", ichan, ichip, imod, *(inttrim+ich) );
|
// printf("could not trim channel %d chip %d module %d - set to %d\n", ichan, ichip, imod, *(inttrim+ich) );
|
||||||
retval=FAIL;
|
retval=FAIL;
|
||||||
}
|
}
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
else
|
// else
|
||||||
printf("channel %d trimbit %d\n",ich,*(inttrim+ich) );
|
// printf("channel %d trimbit %d\n",ich,*(inttrim+ich) );
|
||||||
#endif
|
#endif
|
||||||
initChannel(inttrim[ich],0,0,1,0,0,imod);
|
initChannel(inttrim[ich],0,0,1,0,0,imod);
|
||||||
}
|
}
|
||||||
@ -453,7 +486,7 @@ int choose_vthresh() {
|
|||||||
int vthresh;
|
int vthresh;
|
||||||
int im=ALLMOD;
|
int im=ALLMOD;
|
||||||
int modma, modmi, nm;
|
int modma, modmi, nm;
|
||||||
|
int *fifodata;
|
||||||
|
|
||||||
setFrames(1);
|
setFrames(1);
|
||||||
// setNMod(getNModBoard());
|
// setNMod(getNModBoard());
|
||||||
@ -469,6 +502,8 @@ int choose_vthresh() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
setDynamicRange(32);
|
||||||
|
|
||||||
setCSregister(ALLMOD);
|
setCSregister(ALLMOD);
|
||||||
setSSregister(ALLMOD);
|
setSSregister(ALLMOD);
|
||||||
counterClear(ALLMOD);
|
counterClear(ALLMOD);
|
||||||
@ -480,7 +515,8 @@ int choose_vthresh() {
|
|||||||
}
|
}
|
||||||
usleep(500);
|
usleep(500);
|
||||||
|
|
||||||
scan=decode_data(fifo_read_event());
|
fifodata=fifo_read_event();
|
||||||
|
scan=decode_data(fifodata);
|
||||||
|
|
||||||
|
|
||||||
for (imod=modmi; imod<modma; imod++) {
|
for (imod=modmi; imod<modma; imod++) {
|
||||||
@ -498,6 +534,7 @@ int choose_vthresh() {
|
|||||||
free(scan);
|
free(scan);
|
||||||
while(change_flag && iteration<maxiterations) {
|
while(change_flag && iteration<maxiterations) {
|
||||||
|
|
||||||
|
setDynamicRange(32);
|
||||||
fifoReset();
|
fifoReset();
|
||||||
setCSregister(ALLMOD);
|
setCSregister(ALLMOD);
|
||||||
setSSregister(ALLMOD);
|
setSSregister(ALLMOD);
|
||||||
@ -508,7 +545,9 @@ int choose_vthresh() {
|
|||||||
while (runBusy()) {
|
while (runBusy()) {
|
||||||
}
|
}
|
||||||
usleep(500);
|
usleep(500);
|
||||||
scan=decode_data(fifo_read_event());
|
|
||||||
|
fifodata=fifo_read_event();
|
||||||
|
scan=decode_data(fifodata);
|
||||||
|
|
||||||
change_flag=0;
|
change_flag=0;
|
||||||
printf("Vthresh iteration %3d 0f %3d\n",iteration, maxiterations);
|
printf("Vthresh iteration %3d 0f %3d\n",iteration, maxiterations);
|
||||||
@ -571,6 +610,7 @@ int trim_with_median(int stop, int im) {
|
|||||||
int me[nModX];
|
int me[nModX];
|
||||||
int modma, modmi, nm;
|
int modma, modmi, nm;
|
||||||
int trim;
|
int trim;
|
||||||
|
int *fifodata;
|
||||||
|
|
||||||
setFrames(1);
|
setFrames(1);
|
||||||
// setNMod(getNModBoard());
|
// setNMod(getNModBoard());
|
||||||
@ -617,6 +657,7 @@ int trim_with_median(int stop, int im) {
|
|||||||
**************/
|
**************/
|
||||||
while(change_flag && iteration<stop) {
|
while(change_flag && iteration<stop) {
|
||||||
|
|
||||||
|
setDynamicRange(32);
|
||||||
fifoReset();
|
fifoReset();
|
||||||
setCSregister(ALLMOD);
|
setCSregister(ALLMOD);
|
||||||
setSSregister(ALLMOD);
|
setSSregister(ALLMOD);
|
||||||
@ -627,7 +668,9 @@ int trim_with_median(int stop, int im) {
|
|||||||
while (runBusy()) {
|
while (runBusy()) {
|
||||||
}
|
}
|
||||||
usleep(500);
|
usleep(500);
|
||||||
scan=decode_data(fifo_read_event());
|
fifodata=fifo_read_event();
|
||||||
|
scan=decode_data(fifodata);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********* calculates median every time ***********/
|
/********* calculates median every time ***********/
|
||||||
|
@ -1409,11 +1409,11 @@ int slsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod){
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "Setting channel "<< ichan << " " << ichip << " " << imod << " to " << reg << std::endl;
|
std::cout<< "Setting channel "<< ichan << " " << ichip << " " << imod << " to " << reg << std::endl;
|
||||||
#endif
|
#endif
|
||||||
int mmin=imod, mmax=imod+1, chimin=ichip, chimax=ichip+1, chamin=ichan, chamax=ichan+1;
|
//int mmin=imod, mmax=imod+1, chimin=ichip, chimax=ichip+1, chamin=ichan, chamax=ichan+1;
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (imod==-1) {
|
/* if (imod==-1) {
|
||||||
mmin=0;
|
mmin=0;
|
||||||
mmax=thisDetector->nModsMax;
|
mmax=thisDetector->nModsMax;
|
||||||
}
|
}
|
||||||
@ -1426,19 +1426,19 @@ int slsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod){
|
|||||||
if (ichan==-1) {
|
if (ichan==-1) {
|
||||||
chamin=0;
|
chamin=0;
|
||||||
chamax=thisDetector->nChans;
|
chamax=thisDetector->nChans;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
for (int im=mmin; im<mmax; im++) {
|
// for (int im=mmin; im<mmax; im++) {
|
||||||
for (int ichi=chimin; ichi<chimax; ichi++) {
|
// for (int ichi=chimin; ichi<chimax; ichi++) {
|
||||||
for (int icha=chamin; icha<chamax; icha++) {
|
// for (int icha=chamin; icha<chamax; icha++) {
|
||||||
myChan.chan=icha;
|
myChan.chan=ichan;//icha;
|
||||||
myChan.chip=ichi;
|
myChan.chip=ichip;//ichi;
|
||||||
myChan.module=im;
|
myChan.module=imod;//im;
|
||||||
myChan.reg=reg;
|
myChan.reg=reg;
|
||||||
ret=setChannel(myChan);
|
ret=setChannel(myChan);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1450,9 +1450,9 @@ int slsDetector::setChannel(sls_detector_channel chan){
|
|||||||
int ret=FAIL;
|
int ret=FAIL;
|
||||||
char mess[100];
|
char mess[100];
|
||||||
|
|
||||||
int icha=chan.chan;
|
int ichan=chan.chan;
|
||||||
int ichi=chan.chip;
|
int ichip=chan.chip;
|
||||||
int im=chan.module;
|
int imod=chan.module;
|
||||||
|
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
if (controlSocket) {
|
if (controlSocket) {
|
||||||
@ -1475,7 +1475,39 @@ int slsDetector::setChannel(sls_detector_channel chan){
|
|||||||
|
|
||||||
if (ret==OK) {
|
if (ret==OK) {
|
||||||
if (chanregs) {
|
if (chanregs) {
|
||||||
|
|
||||||
|
int mmin=imod, mmax=imod+1, chimin=ichip, chimax=ichip+1, chamin=ichan, chamax=ichan+1;
|
||||||
|
|
||||||
|
if (imod==-1) {
|
||||||
|
mmin=0;
|
||||||
|
mmax=thisDetector->nModsMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ichip==-1) {
|
||||||
|
chimin=0;
|
||||||
|
chimax=thisDetector->nChips;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ichan==-1) {
|
||||||
|
chamin=0;
|
||||||
|
chamax=thisDetector->nChans;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (int im=mmin; im<mmax; im++) {
|
||||||
|
for (int ichi=chimin; ichi<chimax; ichi++) {
|
||||||
|
for (int icha=chamin; icha<chamax; icha++) {
|
||||||
|
|
||||||
*(chanregs+im*thisDetector->nChans*thisDetector->nChips+ichi*thisDetector->nChips+icha)=retval;
|
*(chanregs+im*thisDetector->nChans*thisDetector->nChips+ichi*thisDetector->nChips+icha)=retval;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -2122,15 +2154,26 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti
|
|||||||
oscfn << thisDetector->calDir << ssettings << "/calibration.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
oscfn << thisDetector->calDir << ssettings << "/calibration.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
||||||
//
|
//
|
||||||
trimfname=ostfn.str();
|
trimfname=ostfn.str();
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << trimfname << endl;
|
||||||
|
#endif
|
||||||
if (readTrimFile(trimfname,myMod)) {
|
if (readTrimFile(trimfname,myMod)) {
|
||||||
calfname=oscfn.str();
|
calfname=oscfn.str();
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << calfname << endl;
|
||||||
|
#endif
|
||||||
readCalibrationFile(calfname,myMod->gain, myMod->offset);
|
readCalibrationFile(calfname,myMod->gain, myMod->offset);
|
||||||
setModule(*myMod);
|
setModule(*myMod);
|
||||||
} else {
|
} else {
|
||||||
ostringstream ostfn,oscfn;
|
ostringstream ostfn,oscfn;
|
||||||
ostfn << thisDetector->trimDir << ssettings << ssettings << ".trim";
|
ostfn << thisDetector->trimDir << ssettings << ssettings << ".trim";
|
||||||
oscfn << thisDetector->calDir << ssettings << ssettings << ".cal";
|
oscfn << thisDetector->calDir << ssettings << ssettings << ".cal";
|
||||||
|
calfname=oscfn.str();
|
||||||
trimfname=ostfn.str();
|
trimfname=ostfn.str();
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << trimfname << endl;
|
||||||
|
cout << calfname << endl;
|
||||||
|
#endif
|
||||||
if (readTrimFile(trimfname,myMod)) {
|
if (readTrimFile(trimfname,myMod)) {
|
||||||
calfname=oscfn.str();
|
calfname=oscfn.str();
|
||||||
readCalibrationFile(calfname,myMod->gain, myMod->offset);
|
readCalibrationFile(calfname,myMod->gain, myMod->offset);
|
||||||
@ -2468,6 +2511,26 @@ detectorData* slsDetector::popFinalDataQueue() {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void slsDetector::resetDataQueue() {
|
||||||
|
int *retval=NULL;
|
||||||
|
while( !dataQueue.empty() ) {
|
||||||
|
retval=dataQueue.front();
|
||||||
|
dataQueue.pop();
|
||||||
|
delete [] retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void slsDetector::resetFinalDataQueue() {
|
||||||
|
detectorData *retval=NULL;
|
||||||
|
while( !finalDataQueue.empty() ) {
|
||||||
|
retval=finalDataQueue.front();
|
||||||
|
finalDataQueue.pop();
|
||||||
|
delete retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
set or read the acquisition timers
|
set or read the acquisition timers
|
||||||
enum timerIndex {
|
enum timerIndex {
|
||||||
@ -2707,19 +2770,19 @@ int slsDetector::setReadOutFlags(readOutFlags flag){
|
|||||||
|
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
if (controlSocket) {
|
if (controlSocket) {
|
||||||
if (controlSocket->Connect()>=0) {
|
if (controlSocket->Connect()>=0) {
|
||||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
controlSocket->SendDataOnly(&flag,sizeof(flag));
|
controlSocket->SendDataOnly(&flag,sizeof(flag));
|
||||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||||
} else {
|
} else {
|
||||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
thisDetector->roFlags=retval;
|
thisDetector->roFlags=retval;
|
||||||
}
|
}
|
||||||
controlSocket->Disconnect();
|
controlSocket->Disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (flag!=GET_READOUT_FLAGS)
|
if (flag!=GET_READOUT_FLAGS)
|
||||||
|
@ -946,6 +946,30 @@ typedef struct sharedSlsDetector {
|
|||||||
\sa finalDataQueue
|
\sa finalDataQueue
|
||||||
*/
|
*/
|
||||||
detectorData* popFinalDataQueue();
|
detectorData* popFinalDataQueue();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
resets the raw data queue
|
||||||
|
\sa dataQueue
|
||||||
|
*/
|
||||||
|
void resetDataQueue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
resets the postprocessed data queue
|
||||||
|
\sa finalDataQueue
|
||||||
|
*/
|
||||||
|
void resetFinalDataQueue();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
set/get timer value
|
set/get timer value
|
||||||
\param index timer index
|
\param index timer index
|
||||||
|
Loading…
x
Reference in New Issue
Block a user