Anna's modifications

This commit is contained in:
2017-08-11 15:55:07 +02:00
67 changed files with 1879 additions and 763 deletions

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURLLIB "git@git.psi.ch:sls_detectors_software/sls_detector_software.git"
//#define SVNREPPATH ""
#define SVNREPUUIDLIB "a5b59b47430913bb461b50da05b553874b33f39a"
//#define SVNREV 0x1418
#define SVNREPUUIDLIB "2dfbd9016b501eca6ee2c00a08e49a3f7e7990d8"
//#define SVNREV 0x1457
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTHLIB "Dhanya_Maliakal"
#define SVNREVLIB 0x1418
#define SVNDATELIB 0x20170622
#define SVNREVLIB 0x1457
#define SVNDATELIB 0x20170809
//

View File

@ -26,9 +26,9 @@ int slsDetector::initSharedMemory(detectorType type, int id) {
#ifdef VERBOSE
cout << "init shm"<< endl;
#endif
switch(type) {
switch(type) {
case MYTHEN:
nch=128; // complete mythen system
nch=128; // complete mythen system
nm=24;
nc=10;
nd=6; // dacs+adcs
@ -777,6 +777,7 @@ int slsDetector::initializeDetectorSize(detectorType type) {
thisDetector->acquiringFlag = false;
thisDetector->flippedData[0] = 0;
thisDetector->flippedData[1] = 0;
thisDetector->zmqport = 0;
for (int ia=0; ia<MAX_ACTIONS; ia++) {
strcpy(thisDetector->actionScript[ia],"none");
@ -1674,7 +1675,7 @@ int slsDetector::setDetectorType(detectorType const type){
//receiver
if((retType != GENERIC) && (thisDetector->receiverOnlineFlag==ONLINE_FLAG)) {
if((retType != GENERIC) && (thisDetector->receiverOnlineFlag==ONLINE_FLAG) && (arg != GENERIC)) {
retval = FAIL;
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE
@ -2981,7 +2982,7 @@ int slsDetector::setModule(int reg, int imod){
};
int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval, int* offsetval){
int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval, int* offsetval, int tb){
int fnum=F_SET_MODULE;
int retval;
@ -2998,6 +2999,11 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
//to exclude trimbits
if(!tb) {
module.nchan=0;
module.nchip=0;
}
sendModule(&module);
//not included in module
@ -3031,23 +3037,29 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int
if (ret!=FAIL) {
if (detectorModules) {
if (imod>=0 && imod<thisDetector->nMod[X]*thisDetector->nMod[Y]) {
(detectorModules+imod)->nchan=module.nchan;
(detectorModules+imod)->nchip=module.nchip;
if(tb) {
(detectorModules+imod)->nchan=module.nchan;
(detectorModules+imod)->nchip=module.nchip;
}
(detectorModules+imod)->ndac=module.ndac;
(detectorModules+imod)->nadc=module.nadc;
thisDetector->nChips=module.nchip;
thisDetector->nChans=module.nchan/module.nchip;
if(tb) {
thisDetector->nChips=module.nchip;
thisDetector->nChans=module.nchan/module.nchip;
}
thisDetector->nDacs=module.ndac;
thisDetector->nAdcs=module.nadc;
if(thisDetector->myDetectorType != JUNGFRAU){
for (int ichip=0; ichip<thisDetector->nChips; ichip++) {
if (chipregs)
chipregs[ichip+thisDetector->nChips*imod]=module.chipregs[ichip];
if(tb) {
for (int ichip=0; ichip<thisDetector->nChips; ichip++) {
if (chipregs)
chipregs[ichip+thisDetector->nChips*imod]=module.chipregs[ichip];
if (chanregs) {
for (int i=0; i<thisDetector->nChans; i++) {
chanregs[i+ichip*thisDetector->nChans+thisDetector->nChips*thisDetector->nChans*imod]=module.chanregs[ichip*thisDetector->nChans+i];
if (chanregs) {
for (int i=0; i<thisDetector->nChans; i++) {
chanregs[i+ichip*thisDetector->nChans+thisDetector->nChips*thisDetector->nChans*imod]=module.chanregs[ichip*thisDetector->nChans+i];
}
}
}
}
@ -3278,11 +3290,11 @@ int slsDetector::getThresholdEnergy(int imod){
return thisDetector->currentThresholdEV;
};
int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isettings){
int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isettings, int tb){
//currently only for eiger
if (thisDetector->myDetectorType == EIGER) {
setThresholdEnergyAndSettings(e_eV,isettings);
setThresholdEnergyAndSettings(e_eV,isettings,tb);
return thisDetector->currentThresholdEV;
}
@ -3323,7 +3335,7 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti
int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings) {
int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, int tb) {
//if settings provided, use that, else use the shared memory variable
detectorSettings is = ((isettings != GET_SETTINGS) ? isettings: thisDetector->currentSettings);
@ -3389,7 +3401,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
#endif
//read the files
myMod=createModule();
if (NULL == readSettingsFile(settingsfname,thisDetector->myDetectorType, iodelay, tau, myMod)) {
if (NULL == readSettingsFile(settingsfname,thisDetector->myDetectorType, iodelay, tau, myMod, tb)) {
if(myMod)deleteModule(myMod);
return FAIL;
}
@ -3424,13 +3436,13 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
int tau1 = -1; //not included in the module
int iodelay2 = -1; //not included in the module
int tau2 = -1; //not included in the module
if (NULL == readSettingsFile(settingsfname1,thisDetector->myDetectorType, iodelay1, tau1, myMod1)) {
if (NULL == readSettingsFile(settingsfname1,thisDetector->myDetectorType, iodelay1, tau1, myMod1, tb)) {
setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN));
deleteModule(myMod1);
deleteModule(myMod2);
return FAIL;
}
if (NULL == readSettingsFile(settingsfname2,thisDetector->myDetectorType, iodelay2, tau2, myMod2)) {
if (NULL == readSettingsFile(settingsfname2,thisDetector->myDetectorType, iodelay2, tau2, myMod2, tb)) {
setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN));
deleteModule(myMod1);
deleteModule(myMod2);
@ -3446,14 +3458,14 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
iodelay = iodelay1;
//interpolate module
myMod = interpolateTrim(thisDetector->myDetectorType, myMod1, myMod2, e_eV, trim1, trim2);
myMod = interpolateTrim(thisDetector->myDetectorType, myMod1, myMod2, e_eV, trim1, trim2, tb);
if (myMod == NULL) {
printf("Could not interpolate, different dac values in files\n");
setErrorMask((getErrorMask())|(SETTINGS_NOT_SET));
}
//interpolate tau
tau = linearInterpolation(e_eV, trim1, trim2, tau1, tau2);
printf("new tau:%d\n",tau);
//printf("new tau:%d\n",tau);
deleteModule(myMod1);
deleteModule(myMod2);
@ -3462,7 +3474,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
myMod->module=0;
myMod->reg=thisDetector->currentSettings;
setModule(*myMod, iodelay, tau, e_eV, 0, 0);
setModule(*myMod, iodelay, tau, e_eV, 0, 0, tb);
deleteModule(myMod);
if (getSettings(-1) != is){
std::cout << "Could not set settings in detector" << endl;
@ -3965,6 +3977,62 @@ int slsDetector::updateDetector() {
// Acquisition functions
/* change these funcs accepting also ok/fail */
int slsDetector::prepareAcquisition() {
int fnum = F_PREPARE_ACQUISITION;
int ret=FAIL;
char mess[MAX_STR_LENGTH]="";
if (thisDetector->onlineFlag==ONLINE_FLAG) {
#ifdef VERBOSE
std::cout << "Preparing Detector for Acquisition" << std::endl;
#endif
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL){
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(PREPARE_ACQUISITION));
}
disconnectControl();
if (ret==FORCE_UPDATE)
updateDetector();
}
}else
std::cout << "cannot connect to detector" << endl;
return ret;
}
int slsDetector::cleanupAcquisition() {
int fnum = F_CLEANUP_ACQUISITION;
int ret=FAIL;
char mess[MAX_STR_LENGTH]="";
if (thisDetector->onlineFlag==ONLINE_FLAG) {
#ifdef VERBOSE
std::cout << "Cleaning up Detector after Acquisition " << std::endl;
#endif
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL){
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(CLEANUP_ACQUISITION));
}
disconnectControl();
if (ret==FORCE_UPDATE)
updateDetector();
}
}else
std::cout << "cannot connect to detector" << endl;
return ret;
}
int slsDetector::startAcquisition(){
@ -4247,6 +4315,10 @@ int* slsDetector::startAndReadAll(){
int i=0;
#endif
//#endif
if(thisDetector->myDetectorType == EIGER) {
if (prepareAcquisition() == FAIL)
return NULL;
}
startAndReadAllNoWait();
//#ifdef VERBOSE
// std::cout<< "started" << std::endl;
@ -4439,7 +4511,8 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
//send acquisiton period/frame number to receiver
if((index==FRAME_NUMBER)||(index==FRAME_PERIOD)||(index==CYCLES_NUMBER)||(index==ACQUISITION_TIME)){
if((index==FRAME_NUMBER)||(index==FRAME_PERIOD)||(index==CYCLES_NUMBER)||(index==ACQUISITION_TIME) || (index==SUBFRAME_ACQUISITION_TIME)){
string timername = getTimerType(index);
if(ret != FAIL){
int64_t args[2];
retval = -1;
@ -4448,25 +4521,21 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
//set #frames, #cycles
//set #frames * #cycles
if((index==FRAME_NUMBER)||(index==CYCLES_NUMBER)){
timername.assign("(Number of Frames) * (Number of cycles)");
#ifdef VERBOSE
std::cout << "Setting/Getting number of frames*cycles " << index <<" to/from receiver " << args[1] << std::endl;
std::cout << "Setting/Getting " << timername << " " << index <<" to/from receiver " << args[1] << std::endl;
#endif
if(thisDetector->timerValue[CYCLES_NUMBER]==0)
args[1] = thisDetector->timerValue[FRAME_NUMBER];
else
args[1] = thisDetector->timerValue[FRAME_NUMBER]*thisDetector->timerValue[CYCLES_NUMBER];
}
//set period/exptime
else{
#ifdef VERBOSE
if(index==ACQUISITION_TIME)
std::cout << "Setting/Getting acquisition time " << index << " to/from receiver " << args[1] << std::endl;
else
std::cout << "Setting/Getting acquisition period " << index << " to/from receiver " << args[1] << std::endl;
// set period/exptime/subexptime
else std::cout << "Setting/Getting " << timername << " " << index << " to/from receiver " << args[1] << std::endl;
#endif
}
char mess[MAX_STR_LENGTH]="";
if (connectData() == OK){
@ -4475,18 +4544,23 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
}
if((args[1] != retval)|| (ret==FAIL)){
ret = FAIL;
if(index==ACQUISITION_TIME){
if(strstr(mess,"receiver not idle")==NULL)
cout << "ERROR:Acquisition Time in receiver set incorrectly to " << retval << " instead of " << args[1] << endl;
setErrorMask((getErrorMask())|(RECEIVER_ACQ_TIME_NOT_SET));
}else if(index==FRAME_PERIOD){
if(strstr(mess,"receiver not idle")==NULL)
cout << "ERROR:Acquisition Period in receiver set incorrectly to " << retval << " instead of " << args[1] << endl;
setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET));
}else{
if(strstr(mess,"receiver not idle")==NULL)
cout << "ERROR:Number of Frames (* Number of cycles) in receiver set incorrectly to " << retval << " instead of " << args[1] << endl;
setErrorMask((getErrorMask())|(RECEIVER_FRAME_NUM_NOT_SET));
cout << "ERROR: " << timername << " in receiver set incorrectly to " << retval << " instead of " << args[1] << endl;
if(strstr(mess,"receiver is not idle")==NULL) {
switch(index) {
case ACQUISITION_TIME:
setErrorMask((getErrorMask())|(RECEIVER_ACQ_TIME_NOT_SET));
break;
case FRAME_PERIOD:
setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET));
break;
case SUBFRAME_ACQUISITION_TIME:
setErrorMask((getErrorMask())|(RECEIVER_SUBF_TIME_NOT_SET));
break;
default:
setErrorMask((getErrorMask())|(RECEIVER_FRAME_NUM_NOT_SET));
break;
}
}
}
if(ret==FORCE_UPDATE)
@ -5827,7 +5901,6 @@ int slsDetector::exitServer(){
string slsDetector::setNetworkParameter(networkParameter index, string value) {
int i;
switch (index) {
case DETECTOR_MAC:
return setDetectorMAC(value);
@ -5845,19 +5918,22 @@ string slsDetector::setNetworkParameter(networkParameter index, string value) {
return getReceiverUDPPort();
case RECEIVER_UDP_PORT2:
sscanf(value.c_str(),"%d",&i);
if(thisDetector->myDetectorType == EIGER)
if(thisDetector->myDetectorType == EIGER) {
setReceiverUDPPort2(i);
else
setReceiverUDPPort(i);
if(thisDetector->myDetectorType == EIGER)
return getReceiverUDPPort2();
return getReceiverUDPPort();
} else {
setReceiverUDPPort(i);
return getReceiverUDPPort();
}
case DETECTOR_TXN_DELAY_LEFT:
case DETECTOR_TXN_DELAY_RIGHT:
case DETECTOR_TXN_DELAY_FRAME:
case FLOW_CONTROL_10G:
sscanf(value.c_str(),"%d",&i);
return setDetectorNetworkParameter(index, i);
case RECEIVER_STREAMING_PORT:
setReceiverStreamingPort(value);
return getReceiverStreamingPort();
default:
return (char*)("unknown network parameter");
}
@ -5867,34 +5943,29 @@ string slsDetector::setNetworkParameter(networkParameter index, string value) {
string slsDetector::getNetworkParameter(networkParameter index) {
ostringstream ss;string s;
switch (index) {
case DETECTOR_MAC:
return getDetectorMAC();
break;
case DETECTOR_IP:
return getDetectorIP();
break;
case RECEIVER_HOSTNAME:
return getReceiver();
break;
case RECEIVER_UDP_IP:
return getReceiverUDPIP();
break;
case RECEIVER_UDP_MAC:
return getReceiverUDPMAC();
break;
case RECEIVER_UDP_PORT:
return getReceiverUDPPort();
break;
case RECEIVER_UDP_PORT2:
return getReceiverUDPPort2();
break;
case DETECTOR_TXN_DELAY_LEFT:
case DETECTOR_TXN_DELAY_RIGHT:
case DETECTOR_TXN_DELAY_FRAME:
case FLOW_CONTROL_10G:
return setDetectorNetworkParameter(index, -1);
case RECEIVER_STREAMING_PORT:
return getReceiverStreamingPort();
default:
return (char*)("unknown network parameter");
}
@ -5974,6 +6045,7 @@ string slsDetector::setReceiver(string receiverIP){
std::cout << "file path:" << fileIO::getFilePath() << endl;
std::cout << "file name:" << fileIO::getFileName() << endl;
std::cout << "file index:" << fileIO::getFileIndex() << endl;
std::cout << "file format:" << fileIO::getFileFormat() << endl;
pthread_mutex_lock(&ms);
std::cout << "write enable:" << parentDet->enableWriteToFileMask() << endl;
std::cout << "overwrite enable:" << parentDet->enableOverwriteMask() << endl;
@ -5981,8 +6053,12 @@ string slsDetector::setReceiver(string receiverIP){
std::cout << "frame index needed:" << ((thisDetector->timerValue[FRAME_NUMBER]*thisDetector->timerValue[CYCLES_NUMBER])>1) << endl;
std::cout << "frame period:" << thisDetector->timerValue[FRAME_PERIOD] << endl;
std::cout << "frame number:" << thisDetector->timerValue[FRAME_NUMBER] << endl;
std::cout << "sub exp time:" << thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME] << endl;
std::cout << "dynamic range:" << thisDetector->dynamicRange << endl << endl;
std::cout << "flippeddatax:" << thisDetector->flippedData[d] << endl;
std::cout << "10GbE:" << thisDetector->tenGigaEnable << endl << endl;
std::cout << "streaming port:" << thisDetector->zmqport << endl;
//std::cout << "dataStreaming:" << enableDataStreamingFromReceiver(-1) << endl << endl;
/** enable compresison, */
#endif
@ -5991,6 +6067,8 @@ string slsDetector::setReceiver(string receiverIP){
sendMultiDetectorSize();
setDetectorId();
setDetectorHostname();
setUDPConnection();
setFilePath(fileIO::getFilePath());
setFileName(fileIO::getFileName());
setFileIndex(fileIO::getFileIndex());
@ -6003,6 +6081,7 @@ string slsDetector::setReceiver(string receiverIP){
imask = parentDet->enableOverwriteMask();
pthread_mutex_unlock(&ms);
overwriteFile(imask);
if ((thisDetector->timerValue[FRAME_NUMBER]*thisDetector->timerValue[CYCLES_NUMBER])>1)
setFrameIndex(0);
else
@ -6011,19 +6090,30 @@ string slsDetector::setReceiver(string receiverIP){
setTimer(FRAME_PERIOD,thisDetector->timerValue[FRAME_PERIOD]);
setTimer(FRAME_NUMBER,thisDetector->timerValue[FRAME_NUMBER]);
setTimer(ACQUISITION_TIME,thisDetector->timerValue[ACQUISITION_TIME]);
setTimer(SUBFRAME_ACQUISITION_TIME,thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME]);
setDynamicRange(thisDetector->dynamicRange);
if(thisDetector->myDetectorType == EIGER){
setFlippedData(X,-1);
activate(-1);
}
//std::cout << "***********************************dataStreaming:" << parentDet->enableDataStreamingFromReceiver(-1) << endl << endl;
//parentDet->enableDataStreamingFromReceiver(parentDet->enableDataStreamingFromReceiver(-1));
//set scan tag
setUDPConnection();
if(thisDetector->myDetectorType == EIGER)
enableTenGigabitEthernet(thisDetector->tenGigaEnable);
//datastreamenable
//fifodepth
// data streaming
setReceiverStreamingPort(getReceiverStreamingPort());
int clientSockets = parentDet->getStreamingSocketsCreatedInClient();
int recSockets = enableDataStreamingFromReceiver(-1);
if(clientSockets != recSockets) {
pthread_mutex_lock(&ms);
if(clientSockets)
printf("Enabling Data Streaming\n");
else
printf("Disabling Data Streaming\n");
// push client state to receiver
parentDet->enableDataStreamingFromReceiver(clientSockets);
pthread_mutex_unlock(&ms);
}
}
}
@ -6122,6 +6212,42 @@ int slsDetector::setReceiverUDPPort2(int udpport){
}
int slsDetector::setReceiverStreamingPort(string port) {
int defaultport = 0;
int numsockets = (thisDetector->myDetectorType == EIGER) ? 2:1;
int arg = 0;
//multi command, calculate individual ports
size_t found = port.find("multi");
if(found != string::npos) {
port.erase(found,5);
sscanf(port.c_str(),"%d",&defaultport);
arg = defaultport + (posId * numsockets);
}
else
sscanf(port.c_str(),"%d",&arg);
// send to receiver
int fnum=F_SET_RECEIVER_STREAMING_PORT;
int ret = FAIL;
int retval=-1;
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE
std::cout << "Sending receiver streaming port to receiver " << arg << std::endl;
#endif
if (connectData() == OK){
ret=thisReceiver->sendInt(fnum,retval,arg);
disconnectData();
}
if(ret!=FAIL)
thisDetector->zmqport = retval;
if(ret==FORCE_UPDATE)
updateReceiver();
}
return thisDetector->zmqport;
}
string slsDetector::setDetectorNetworkParameter(networkParameter index, int delay){
int fnum = F_SET_NETWORK_PARAMETER;
int ret = FAIL;
@ -7794,6 +7920,7 @@ int slsDetector::startReceiver(){
}
}
//let detector prepare anyway even if receiver didnt work (for those not using the receiver)
if((thisDetector->myDetectorType != JUNGFRAU) ) {
int ret1 = detectorSendToReceiver(true);
@ -7813,7 +7940,7 @@ int slsDetector::stopReceiver(){
char mess[MAX_STR_LENGTH] = "";
if(thisDetector->myDetectorType != EIGER && thisDetector->myDetectorType != JUNGFRAU)
detectorSendToReceiver(false);
cleanupAcquisition(); // reset (send data to receiver) for these detectors, so back to CPU (dont care about ok/fail at this point)
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
#ifdef VERBOSE
@ -7859,37 +7986,6 @@ slsDetectorDefs::runStatus slsDetector::startReceiverReadout(){
}
int slsDetector::detectorSendToReceiver(bool set){
int fnum;
if(set) fnum=F_PREPARE_ACQUISITION;
else fnum=F_CLEANUP_ACQUISITION;
int ret = FAIL;
char mess[MAX_STR_LENGTH]="";
if (thisDetector->onlineFlag==ONLINE_FLAG) {
#ifdef VERBOSE
std::cout << "Setting detector to send packets via client to: " << set << std::endl;
#endif
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL){
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
}
disconnectControl();
if (ret==FORCE_UPDATE)
updateDetector();
}
}else
std::cout << "cannot connect to detector" << endl;
return ret;
}
@ -8098,21 +8194,46 @@ int slsDetector::updateReceiverNoWait() {
cout << "Updating receiver last modified by " << lastClientIP << std::endl;
#endif
n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
pthread_mutex_lock(&ms);
fileIO::setFileIndex(ind);
pthread_mutex_unlock(&ms);
// filepath
n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH);
pthread_mutex_lock(&ms);
fileIO::setFilePath(path);
pthread_mutex_unlock(&ms);
// filename
n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH);
pthread_mutex_lock(&ms);
fileIO::setFileName(path);
pthread_mutex_unlock(&ms);
// index
n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
pthread_mutex_lock(&ms);
fileIO::setFileIndex(ind);
pthread_mutex_unlock(&ms);
//file format
n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
pthread_mutex_lock(&ms);
fileIO::setFileFormat(ind);
pthread_mutex_unlock(&ms);
// file write enable
n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
pthread_mutex_lock(&ms);
parentDet->enableWriteToFileMask(ind);
pthread_mutex_unlock(&ms);
// file overwrite enable
n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
pthread_mutex_lock(&ms);
parentDet->enableOverwriteMask(ind);
pthread_mutex_unlock(&ms);
// streaming port
n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
thisDetector->zmqport = ind;
if (!n) printf("n: %d\n", n);
return OK;
@ -8132,12 +8253,14 @@ int slsDetector::updateReceiver() {
if (connectData() == OK){
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret!=FAIL)
updateReceiverNoWait();
else{
if (ret == FAIL) {
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Receiver returned error: " << mess << std::endl;
}
else
updateReceiverNoWait();
//if ret is force update, do not update now as client is updating receiver currently
disconnectData();
}
}

View File

@ -269,7 +269,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
bool acquiringFlag;
/** flipped data across x or y axis */
int flippedData[2];
/** tcp port between receiver and gui (only data) */
int zmqport;
} sharedSlsDetector;
@ -886,7 +887,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
set dacs value
\param index ADC index
\param imod module number
\returns current ADC value
\returns current ADC value (temperature for eiger and jungfrau in millidegrees)
*/
dacs_t getADC(dacIndex index, int imod=0);
@ -965,10 +966,11 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
\param e_eV threashold in eV (detector specific)
\param gainval pointer to extra gain values
\param offsetval pointer to extra offset values
\param tb 1 to include trimbits, 0 to exclude (used for eiger)
\returns current register value
\sa ::sls_detector_module
*/
int setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval=0, int* offsetval=0);
int setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval=0, int* offsetval=0, int tb=1);
//virtual int setModule(sls_detector_module module);
/**
@ -999,17 +1001,19 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
\param e_eV threshold in eV
\param imod module number (-1 all)
\param isettings ev. change settings
\param tb 1 to include trimbits, 0 to exclude
\returns current threshold value for imod in ev (-1 failed)
*/
int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS);
int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS, int tb=1);
/**
set threshold energy
\param e_eV threshold in eV
\param isettings ev. change settings
\param tb 1 to include trimbits, 0 to exclude
\returns OK if successful, else FAIL
*/
int setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings);
int setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, int tb=1);
/**
get detector settings
@ -1059,6 +1063,17 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
// Acquisition functions
/**
prepares detector for acquisition
\returns OK/FAIL
*/
int prepareAcquisition();
/**
prepares detector for acquisition
\returns OK/FAIL
*/
int cleanupAcquisition();
/**
start detector acquisition
@ -1610,10 +1625,6 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/
runStatus startReceiverReadout();
/** Sets(false) or Resets(true) the CPU bit in detector
\returns OK or FAIL
*/
int detectorSendToReceiver(bool set);
/** gets the status of the listening mode of receiver
\returns status
@ -1717,6 +1728,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
string getReceiverUDPPort() {ostringstream ss; ss << thisDetector->receiverUDPPort; string s = ss.str(); return s;};
/** returns the receiver UDP2 for Eiger IP address \sa sharedSlsDetector */
string getReceiverUDPPort2() {ostringstream ss; ss << thisDetector->receiverUDPPort2; string s = ss.str(); return s;};
/** returns the zmq port \sa sharedSlsDetector */
string getReceiverStreamingPort() {ostringstream ss; ss << thisDetector->zmqport; string s = ss.str(); return s;};
/** validates the format of detector MAC address and sets it \sa sharedSlsDetector */
string setDetectorMAC(string detectorMAC);
@ -1732,6 +1745,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
int setReceiverUDPPort(int udpport);
/** sets the receiver udp port2 for Eiger \sa sharedSlsDetector */
int setReceiverUDPPort2(int udpport);
/** sets the zmq port in client and receiver (includes "multi" at the end if it should calculate individual ports \sa sharedSlsDetector */
int setReceiverStreamingPort(string port);
/** sets the transmission delay for left or right port or for an entire frame*/
string setDetectorNetworkParameter(networkParameter index, int delay);

View File

@ -207,7 +207,7 @@ class slsDetectorActions : public virtual slsDetectorBase
/* *\/ */
/* virtual detectorType getDetectorsType(int pos=-1)=0; */
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS, int tb=1)=0;
virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0;

View File

@ -429,7 +429,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
virtual externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE)=0;
int setTimingMode(int i=-1){return slsDetectorUsers::getTimingMode( externalCommunicationType( setExternalCommunicationMode(externalCommunicationType( slsDetectorUsers::getTimingMode(i) ) ) ) );};
virtual int setThresholdEnergy(int e_eV, int imod, detectorSettings isettings=GET_SETTINGS)=0;
virtual int setThresholdEnergy(int e_eV, int imod, detectorSettings isettings=GET_SETTINGS, int tb=1)=0;
int setThresholdEnergy(int e_eV){return setThresholdEnergy(e_eV,-1);};
@ -751,6 +751,30 @@ virtual void readFrameFromReceiver()=0;
default: return string("unknown"); \
}};
/** returns string from timer index
\param s can be FRAME_NUMBER,ACQUISITION_TIME,FRAME_PERIOD, DELAY_AFTER_TRIGGER,GATES_NUMBER,PROBES_NUMBER, CYCLES_NUMBER, ACTUAL_TIME,MEASUREMENT_TIME, PROGRESS,MEASUREMENTS_NUMBER,FRAMES_FROM_START,FRAMES_FROM_START_PG,SAMPLES_JCTB,SUBFRAME_ACQUISITION_TIME
\returns string frame_number,acquisition_time,frame_period, delay_after_trigger,gates_number,probes_number, cycles_number, actual_time,measurement_time, progress,measurements_number,frames_from_start,frames_from_start_pg,samples_jctb,subframe_acquisition_time
*/
static string getTimerType(timerIndex t){ \
switch (t) { \
case FRAME_NUMBER: return string("frame_number"); \
case ACQUISITION_TIME: return string("acquisition_time"); \
case FRAME_PERIOD: return string("frame_period"); \
case DELAY_AFTER_TRIGGER: return string("delay_after_trigger"); \
case GATES_NUMBER: return string("gates_number"); \
case PROBES_NUMBER: return string("probes_number"); \
case CYCLES_NUMBER: return string("cycles_number"); \
case ACTUAL_TIME: return string("actual_time"); \
case MEASUREMENT_TIME: return string("measurement_time"); \
case PROGRESS: return string("progress"); \
case MEASUREMENTS_NUMBER: return string("measurements_number"); \
case FRAMES_FROM_START: return string("frames_from_start"); \
case FRAMES_FROM_START_PG: return string("frames_from_start_pg"); \
case SAMPLES_JCTB: return string("samples_jctb"); \
case SUBFRAME_ACQUISITION_TIME: return string("subframe_acquisition_time"); \
default: return string("unknown"); \
}};
};

View File

@ -37,6 +37,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdStatus;
i++;
descrToFuncMap[i].m_pFuncName="busy"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdStatus;
i++;
descrToFuncMap[i].m_pFuncName="datastream"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDataStream;
i++;
@ -386,6 +390,11 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
i++;
descrToFuncMap[i].m_pFuncName="zmqport"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
i++;
descrToFuncMap[i].m_pFuncName="configuremac"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdConfigureMac;
i++;
@ -564,6 +573,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
i++;
descrToFuncMap[i].m_pFuncName="thresholdnotb"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
i++;
descrToFuncMap[i].m_pFuncName="trimbits"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
i++;
@ -1320,7 +1333,7 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action) {
myDet->setOnline(ONLINE_FLAG);
if (myDet->setReceiverOnline(ONLINE_FLAG) == ONLINE_FLAG) {
//if it was not off
// command line: must be off, if receiver on or there was -1, then
if (myDet->enableDataStreamingFromReceiver(-1) != 0){
//switch it off, if error
if (myDet->enableDataStreamingFromReceiver(0) != 0) {
@ -1431,20 +1444,33 @@ string slsDetectorCommand::cmdStatus(int narg, char *args[], int action) {
#ifdef VERBOSE
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
#endif
myDet->setOnline(ONLINE_FLAG);
if (action==PUT_ACTION) {
//myDet->setThreadedProcessing(0);
if (string(args[1])=="start")
myDet->startAcquisition();
else if (string(args[1])=="stop")
myDet->stopAcquisition();
else
return string("unknown action");
} else if (action==HELP_ACTION) {
return helpStatus(narg,args,HELP_ACTION);
if (action==HELP_ACTION)
return helpStatus(narg,args,action);
if (cmd=="status") {
myDet->setOnline(ONLINE_FLAG);
if (action==PUT_ACTION) {
//myDet->setThreadedProcessing(0);
if (string(args[1])=="start")
myDet->startAcquisition();
else if (string(args[1])=="stop")
myDet->stopAcquisition();
else
return string("unknown action");
}
runStatus s=myDet->getRunStatus();
return myDet->runStatusType(s);
}
runStatus s=myDet->getRunStatus();
return myDet->runStatusType(s);
else if (cmd=="busy") {
if (action==PUT_ACTION) {
return string ("cannot put");
}
char answer[100];
sprintf(answer,"%d", myDet->getAcquiringFlag());
return string(answer);
}
else return string("cannot scan command ")+string(cmd);
}
@ -1453,8 +1479,10 @@ string slsDetectorCommand::cmdStatus(int narg, char *args[], int action) {
string slsDetectorCommand::helpStatus(int narg, char *args[], int action) {
ostringstream os;
if (action==GET_ACTION || action==HELP_ACTION)
if (action==GET_ACTION || action==HELP_ACTION) {
os << string("status \t gets the detector status - can be: running, error, transmitting, finished, waiting or idle\n");
os << string("busy \t gets the status of acquire- can be: 0 or 1. 0 for idle, 1 for running\n");
}
if (action==PUT_ACTION || action==HELP_ACTION)
os << string("status \t controls the detector acquisition - can be start or stop \n");
return os.str();
@ -2932,6 +2960,12 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio
if (!(sscanf(args[1],"%d",&i)))
return ("cannot parse argument") + string(args[1]);
}
}else if (cmd=="zmqport") {
t=RECEIVER_STREAMING_PORT;
if (action==PUT_ACTION){
if (!(sscanf(args[1],"%d",&i)))
return ("cannot parse argument") + string(args[1]);
}
}else return ("unknown network parameter")+cmd;
if (action==PUT_ACTION)
@ -2957,6 +2991,7 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti
os << "txndelay_right port \n sets detector transmission delay of the right port"<< std::endl;
os << "txndelay_frame port \n sets detector transmission delay of the entire frame"<< std::endl;
os << "flowcontrol_10g port \n sets flow control for 10g for eiger"<< std::endl;
os << "zmqport port \n sets zmq port (data from receiver to client); setting via multidetector command calculates port for individual detectors"<< std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION) {
os << "detectormac \n gets detector mac "<< std::endl;
@ -2969,6 +3004,7 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti
os << "txndelay_right \n gets detector transmission delay of the right port"<< std::endl;
os << "txndelay_frame \n gets detector transmission delay of the entire frame"<< std::endl;
os << "flowcontrol_10g \n gets flow control for 10g for eiger"<< std::endl;
os << "zmqport \n gets zmq port (data from receiver to client)"<< std::endl;
}
return os.str();
@ -3326,9 +3362,9 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) {
return string("unknown detector size ")+cmd;
if (cmd=="roimask")
sprintf(ans,"%x",ret);
sprintf(ans,"0x%x",ret);
else
sprintf(ans,"%d",ret);
sprintf(ans,"0x%d",ret);
return string(ans);
@ -3390,10 +3426,10 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
return myDet->getDetectorSettings(myDet->getSettings());
} else if (cmd=="threshold") {
if (action==PUT_ACTION) {
detectorType type = myDet->getDetectorsType();
if (!sscanf(args[1],"%d",&val)) {
return string("invalid threshold value");
}
detectorType type = myDet->getDetectorsType();
if (type != EIGER || (type == EIGER && narg<=2)) {
myDet->setThresholdEnergy(val);
} else {
@ -3405,6 +3441,25 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
}
sprintf(ans,"%d",myDet->getThresholdEnergy());
return string(ans);
} else if (cmd=="thresholdnotb") {
if (action==PUT_ACTION) {
if (!sscanf(args[1],"%d",&val)) {
return string("invalid threshold value");
}
detectorType type = myDet->getDetectorsType();
if (type != EIGER)
return string("not implemented for this detector");
if (narg<=2) {
myDet->setThresholdEnergy(val, -1, GET_SETTINGS, 0);
} else {
detectorSettings sett= myDet->getDetectorSettings(string(args[2]));
if(sett == -1)
return string("invalid settings value");
myDet->setThresholdEnergy(val, -1, sett, 0);
}
}
sprintf(ans,"%d",myDet->getThresholdEnergy());
return string(ans);
} else if (cmd=="trimbits") {
if (narg>=2) {
string sval=string(args[1]);
@ -3487,7 +3542,8 @@ string slsDetectorCommand::helpSettings(int narg, char *args[], int action) {
if (action==PUT_ACTION || action==HELP_ACTION) {
os << "settings s \n sets the settings of the detector - can be standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain"
"lownoise, dynamichg0,fixgain1,fixgain2,forceswitchg1, forceswitchg2"<< std::endl;
os << "threshold eV\n sets the detector threshold in eV"<< std::endl;
os << "threshold eV [sett]\n sets the detector threshold in eV. If sett is provided for eiger, uses settings sett"<< std::endl;
os << "thresholdnotb eV [sett]\n sets the detector threshold in eV without loading trimbits. If sett is provided for eiger, uses settings sett"<< std::endl;
os << "trimbits fname\n loads the trimfile fname to the detector. If no extension is specified, the serial number of each module will be attached."<< std::endl;
os << "trim:mode fname\n trims the detector according to mode (can be noise, beam, improve, fix) and saves the resulting trimbits to file fname."<< std::endl;
os << "trimval i \n sets all the trimbits to i" << std::endl;
@ -3497,6 +3553,7 @@ string slsDetectorCommand::helpSettings(int narg, char *args[], int action) {
if (action==GET_ACTION || action==HELP_ACTION) {
os << "settings \n gets the settings of the detector"<< std::endl;
os << "threshold V\n gets the detector threshold"<< std::endl;
os << "thresholdnotb V\n gets the detector threshold"<< std::endl;
os << "trimbits [fname]\n returns the trimfile loaded on the detector. If fname is specified the trimbits are saved to file. If no extension is specified, the serial number of each module will be attached."<< std::endl;
os << "trimval \n returns the value all trimbits are set to. If they are different, returns -1." << std::endl;
}
@ -3532,7 +3589,7 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) {
if (retval < 0)
sprintf(answer, "%d", -1);
else
sprintf(answer,"%lx", retval);
sprintf(answer,"0x%lx", retval);
return string(answer);
}
@ -3546,7 +3603,7 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) {
if (retval < 0)
sprintf(answer, "%d", -1);
else
sprintf(answer,"%lx", retval);
sprintf(answer,"0x%lx", retval);
return string(answer);
} else
return string("undefined module number");
@ -3556,7 +3613,7 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) {
if (retval < 0)
sprintf(answer, "%d", -1);
else
sprintf(answer,"%lx", retval);
sprintf(answer,"0x%lx", retval);
return string(answer);
}
if (cmd.find("modulenumber")!=string::npos) {
@ -3566,7 +3623,7 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) {
if (retval < 0)
sprintf(answer, "%d", -1);
else
sprintf(answer,"%lx", retval);
sprintf(answer,"0x%lx", retval);
return string(answer);
} else
return string("undefined module number");
@ -3577,7 +3634,7 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) {
if (retval < 0)
sprintf(answer, "%d", -1);
else
sprintf(answer,"%lx", retval);
sprintf(answer,"0x%lx", retval);
return string(answer);
}
@ -3586,7 +3643,7 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) {
if (retval < 0)
sprintf(answer, "%d", -1);
else
sprintf(answer,"%lx", retval);
sprintf(answer,"0x%lx", retval);
return string(answer);
}
@ -3596,7 +3653,7 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) {
if (retval < 0)
sprintf(answer, "%d", -1);
else
sprintf(answer,"%lx", retval);
sprintf(answer,"0x%lx", retval);
return string(answer);
}
return string("unknown id mode ")+cmd;
@ -3635,7 +3692,7 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action) {
if (cmd=="bustest"){
if (action==PUT_ACTION)
return string("cannot set ")+cmd;
sprintf(answer,"%x",myDet->digitalTest(DETECTOR_BUS_TEST));
sprintf(answer,"0x%x",myDet->digitalTest(DETECTOR_BUS_TEST));
return string(answer);
}
@ -3644,7 +3701,7 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action) {
return string("cannot set ")+cmd;
int ival=-1;
if (sscanf(args[0],"digitest:%d",&ival)) {
sprintf(answer,"%x",myDet->digitalTest(CHIP_TEST, ival));
sprintf(answer,"0x%x",myDet->digitalTest(CHIP_TEST, ival));
return string(answer);
} else
return string("undefined module number");
@ -3656,7 +3713,7 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action) {
int ival=-1;
if (sscanf(args[1],"%d",&ival)) {
if((ival==0)||(ival==1)){
sprintf(answer,"%x",myDet->digitalTest(DIGITAL_BIT_TEST,ival));
sprintf(answer,"0x%x",myDet->digitalTest(DIGITAL_BIT_TEST,ival));
return string(answer);
}
else
@ -3729,13 +3786,13 @@ string slsDetectorCommand::cmdRegister(int narg, char *args[], int action) {
;
else
return string("Could not scan value (hexadecimal fomat) ")+string(args[2]);
sprintf(answer,"%x",myDet->writeRegister(addr,val));
sprintf(answer,"0x%x",myDet->writeRegister(addr,val));
} else if (cmd=="adcreg") {
if (sscanf(args[2],"%x",&val))
;
else
return string("Could not scan value (hexadecimal fomat) ")+string(args[2]);
sprintf(answer,"%x",myDet->writeAdcRegister(addr,val));
sprintf(answer,"0x%x",myDet->writeAdcRegister(addr,val));
} else {
if (sscanf(args[2],"%d",&n))
@ -3747,9 +3804,9 @@ string slsDetectorCommand::cmdRegister(int narg, char *args[], int action) {
return string("Bit number out of range")+string(args[2]);
if (cmd=="setbit")
sprintf(answer,"%x",myDet->writeRegister(addr,myDet->readRegister(addr)| 1<<n));
sprintf(answer,"0x%x",myDet->writeRegister(addr,myDet->readRegister(addr)| 1<<n));
if (cmd=="clearbit")
sprintf(answer,"%x",myDet->writeRegister(addr,myDet->readRegister(addr) & ~(1<<n)));
sprintf(answer,"0x%x",myDet->writeRegister(addr,myDet->readRegister(addr) & ~(1<<n)));
}
@ -3770,7 +3827,7 @@ string slsDetectorCommand::cmdRegister(int narg, char *args[], int action) {
return string("Could not scan address (hexadecimal fomat) ")+string(args[1]);
sprintf(answer,"%x",myDet->readRegister(addr));
sprintf(answer,"0x%x",myDet->readRegister(addr));
}
@ -3807,7 +3864,7 @@ string slsDetectorCommand::helpRegister(int narg, char *args[], int action) {
ostringstream os;
if (action==PUT_ACTION || action==HELP_ACTION) {
os << "reg addr val \n writes the register addr with the value val"<< std::endl;
os << "reg addr val \n writes the register addr with the value val (hexadecimal format)"<< std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION) {
os << "reg addr \n reads the register addr"<< std::endl;
@ -4179,7 +4236,7 @@ string slsDetectorCommand::cmdADC(int narg, char *args[], int action) {
myDet->setOnline(ONLINE_FLAG);
#ifdef DACS_INT
if (myDet->getDetectorsType() == EIGER)
if (myDet->getDetectorsType() == EIGER || myDet->getDetectorsType() == JUNGFRAU)
sprintf(answer,"%.2f",(double)myDet->getADC(adc)/1000.00);
else sprintf(answer,"%d",myDet->getADC(adc));
#else
@ -4305,7 +4362,7 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {
myDet->setReceiverOnline(ONLINE_FLAG);
ret=myDet->setTimer(index,t);
if (index==ACQUISITION_TIME || index==SUBFRAME_ACQUISITION_TIME || index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER)
if ((ret!=-1) && (index==ACQUISITION_TIME || index==SUBFRAME_ACQUISITION_TIME || index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER))
rval=(double)ret*1E-9;
else rval=ret;
@ -4318,8 +4375,10 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {
myDet->setFrameIndex(-1);
}
sprintf(answer,"%0.9f",rval);
if (index==FRAME_NUMBER || index==GATES_NUMBER || index==PROBES_NUMBER || index==CYCLES_NUMBER || index==MEASUREMENTS_NUMBER)
sprintf(answer,"%d",(int)rval);
else
sprintf(answer,"%0.9f",rval);
return string(answer);

View File

@ -42,11 +42,7 @@ slsDetectorUtils::slsDetectorUtils() {
int slsDetectorUtils::acquire(int delflag){
struct timespec begin,end;
clock_gettime(CLOCK_REALTIME, &begin);
//ensure acquire isnt started multiple times by same client
//ensure acquire isnt started multiple times by same client
if(getAcquiringFlag() == false)
setAcquiringFlag(true);
else{
@ -54,6 +50,9 @@ int slsDetectorUtils::acquire(int delflag){
return FAIL;
}
struct timespec begin,end;
clock_gettime(CLOCK_REALTIME, &begin);
//not in the loop for real time acqusition yet,
//in the real time acquisition loop, processing thread will wait for a post each time
sem_init(&sem_newRTAcquisition,1,0);
@ -509,8 +508,9 @@ int slsDetectorUtils::acquire(int delflag){
sem_destroy(&sem_newRTAcquisition);
clock_gettime(CLOCK_REALTIME, &end);
#ifdef VERBOSE
cout << "Elapsed time for acquisition:" << (( end.tv_sec - begin.tv_sec ) + ( end.tv_nsec - begin.tv_nsec ) / 1000000000.0) << " seconds" << endl;
#endif
return OK;
}

View File

@ -421,7 +421,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
// double* convertAngles(){return convertAngles(currentPosition);};
// virtual double* convertAngles(double pos)=0;
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS, int tb=1)=0;
virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0;
virtual double getRateCorrectionTau()=0;
@ -555,7 +555,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\param imod module number
\returns current ADC value
*/
virtual dacs_t getADC(dacIndex index, int imod=0)=0;
virtual dacs_t getADC(dacIndex index, int imod=-1)=0;
/**
get the maximum size of the detector