mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
removed salas code for the time being, implemented overwrite, fixed prob of communciating between detector and receiver for settimer
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@803 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <bitset>
|
||||
#include <cstdlib>
|
||||
#include <math.h>
|
||||
#include "svnInfoLib.h"
|
||||
|
||||
|
||||
@ -3482,7 +3483,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Setting timer "<< index << " to " << t << "ns" << std::endl;
|
||||
std::cout<< "Setting timer "<< index << " to " << t << "ns/value" << std::endl;
|
||||
#endif
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (connectControl() == OK){
|
||||
@ -3496,7 +3497,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
setErrorMask((getErrorMask())|(DETECTOR_TIMER_VALUE_NOT_SET));
|
||||
} else {
|
||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
thisDetector->timerValue[index]=retval;
|
||||
thisDetector->timerValue[index]=retval;
|
||||
}
|
||||
controlSocket->Disconnect();
|
||||
if (ret==FORCE_UPDATE) {
|
||||
@ -3534,7 +3535,6 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
|
||||
|
||||
|
||||
|
||||
//send acquisiton period/frame number to receiver
|
||||
if((index==FRAME_NUMBER)||(index==FRAME_PERIOD))
|
||||
{
|
||||
@ -3545,14 +3545,16 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
if(t == -1)
|
||||
args[1] = -1;
|
||||
|
||||
|
||||
if(index==FRAME_NUMBER){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Sending/Getting number of frames to/from receiver " << retval << std::endl;
|
||||
|
||||
std::cout << "Setting/Getting number of frames " << index <<" to/from receiver " << args[1] << std::endl;
|
||||
#endif
|
||||
args[0] = FRAME_NUMBER;
|
||||
}else{
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Sending/Getting acquisition period to/from receiver " << retval << std::endl;
|
||||
std::cout << "Setting/Getting acquisition period " << index << " to/from receiver " << args[1] << std::endl;
|
||||
#endif
|
||||
args[0] = FRAME_PERIOD;
|
||||
//if acquisition period is zero, then #frames/buffer depends on exposure time and not acq period
|
||||
@ -3560,22 +3562,26 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
args[1] = timerValue[ACQUISITION_TIME];
|
||||
}
|
||||
|
||||
|
||||
if (connectData() == OK)
|
||||
ret=thisReceiver->sendIntArray(fnum,ut,args);
|
||||
if((ut != retval)|| (ret==FAIL)){
|
||||
ret = FAIL;
|
||||
if(index==FRAME_PERIOD){
|
||||
cout << "ERROR:Acquisition Period in receiver set incorrectly to " << ut << " instead of " << retval << endl;
|
||||
setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET));
|
||||
//exptime sent if acq period = 0
|
||||
if(retval){
|
||||
cout << "ERROR:Acquisition Period in receiver set incorrectly to " << ut << " instead of " << retval << endl;
|
||||
setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET));
|
||||
}
|
||||
}else{
|
||||
cout << "ERROR:Number of Frames in receiver set incorrectly to " << ut << " instead of " << retval << endl;
|
||||
setErrorMask((getErrorMask())|(RECEIVER_FRAME_NUM_NOT_SET));
|
||||
}
|
||||
}
|
||||
|
||||
if(ret==FORCE_UPDATE)
|
||||
updateReceiver();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return thisDetector->timerValue[index];
|
||||
@ -4873,39 +4879,38 @@ char* slsDetector::setReceiver(string receiverIP){
|
||||
|
||||
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Setting up receiver with" << endl <<
|
||||
"file path:" << fileIO::getFilePath() << endl <<
|
||||
"file name:" << fileIO::getFileName() << endl <<
|
||||
"write enable:" << parentDet->enableWriteToFileMask();
|
||||
if(thisDetector->myDetectorType != EIGER){
|
||||
std::cout << "file index:" << fileIO::getFileIndex() << endl <<
|
||||
"frame index needed:" << ((setTimer(FRAME_NUMBER,-1)*setTimer(CYCLES_NUMBER,-1))>1) << endl <<
|
||||
"frame period:" << setTimer(FRAME_PERIOD,-1) ;
|
||||
}
|
||||
std::cout << endl;
|
||||
std::cout << "Setting up receiver with" << endl;
|
||||
std::cout << "file path:" << fileIO::getFilePath() << endl;
|
||||
std::cout << "file name:" << fileIO::getFileName() << endl;
|
||||
std::cout << "file index:" << fileIO::getFileIndex() << endl;
|
||||
std::cout << "write enable:" << parentDet->enableWriteToFileMask() << endl;
|
||||
std::cout << "overwrite enable:" << parentDet->enableOverwriteMask() << endl;
|
||||
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 << "dynamic range:" << thisDetector->dynamicRange << endl << endl;
|
||||
|
||||
#endif
|
||||
if(thisDetector->myDetectorType == EIGER)
|
||||
setDetectorHostname();
|
||||
setFilePath(fileIO::getFilePath());
|
||||
setFileName(fileIO::getFileName());
|
||||
setFileIndex(fileIO::getFileIndex());
|
||||
enableWriteToFile(parentDet->enableWriteToFileMask());
|
||||
overwriteFile(parentDet->enableOverwriteMask());
|
||||
|
||||
if ((thisDetector->timerValue[FRAME_NUMBER]*thisDetector->timerValue[CYCLES_NUMBER])>1)
|
||||
setFrameIndex(0);
|
||||
else
|
||||
setFrameIndex(-1);
|
||||
|
||||
setTimer(FRAME_PERIOD,thisDetector->timerValue[FRAME_PERIOD]);
|
||||
setTimer(FRAME_NUMBER,thisDetector->timerValue[FRAME_NUMBER]);
|
||||
setDynamicRange(thisDetector->dynamicRange);
|
||||
//set scan tag
|
||||
if(thisDetector->myDetectorType != EIGER){
|
||||
setFileIndex(fileIO::getFileIndex());
|
||||
if ((setTimer(FRAME_NUMBER,-1)*setTimer(CYCLES_NUMBER,-1))>1)
|
||||
setFrameIndex(0);
|
||||
else
|
||||
setFrameIndex(-1);
|
||||
|
||||
setTimer(FRAME_PERIOD,thisDetector->timerValue[FRAME_PERIOD]);
|
||||
setUDPConnection();
|
||||
}
|
||||
|
||||
else{
|
||||
setTimer(FRAME_NUMBER,thisDetector->timerValue[FRAME_NUMBER]);
|
||||
setDynamicRange(thisDetector->dynamicRange);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return thisDetector->receiver_hostname;
|
||||
@ -6448,6 +6453,35 @@ int slsDetector::enableWriteToFile(int enable){
|
||||
|
||||
|
||||
|
||||
int slsDetector::overwriteFile(int enable){
|
||||
int fnum=F_ENABLE_OVERWRITE;
|
||||
int ret = FAIL;
|
||||
int retval=-1;
|
||||
int arg = enable;
|
||||
|
||||
|
||||
if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){
|
||||
if(enable>=0)
|
||||
parentDet->enableOverwriteMask(enable);
|
||||
}
|
||||
|
||||
else if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Sending enable file write to receiver " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK)
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
if(ret!=FAIL)
|
||||
parentDet->enableOverwriteMask(retval);
|
||||
if(ret==FORCE_UPDATE)
|
||||
updateReceiver();
|
||||
}
|
||||
|
||||
return parentDet->enableOverwriteMask();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int slsDetector::setFrameIndex(int index){
|
||||
int fnum=F_SET_FRAME_INDEX;
|
||||
|
@ -1549,6 +1549,13 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
int enableWriteToFile(int enable=-1);
|
||||
|
||||
/**
|
||||
Sets/Gets file overwrite enable
|
||||
@param enable 1 or 0 to set/reset file overwrite enable
|
||||
/returns file overwrite enable
|
||||
*/
|
||||
int overwriteFile(int enable=-1);
|
||||
|
||||
|
||||
/**
|
||||
* set frame index to 0 or -1
|
||||
|
@ -208,6 +208,9 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdEnablefwrite;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="overwrite"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOverwrite;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="currentfname"; //OK
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdFileName;
|
||||
@ -1565,15 +1568,15 @@ string slsDetectorCommand::helpFileName(int narg, char *args[], int action){
|
||||
}
|
||||
|
||||
|
||||
//enable file write
|
||||
|
||||
string slsDetectorCommand::cmdEnablefwrite(int narg, char *args[], int action){
|
||||
|
||||
int i;
|
||||
char ans[100];
|
||||
|
||||
if (action==HELP_ACTION) {
|
||||
return helpFileName(narg, args, action);
|
||||
}
|
||||
return helpEnablefwrite(narg, args, action);
|
||||
}
|
||||
if (action==PUT_ACTION) {
|
||||
if (sscanf(args[1],"%d",&i))
|
||||
myDet->enableWriteToFile(i);
|
||||
@ -1597,6 +1600,40 @@ string slsDetectorCommand::helpEnablefwrite(int narg, char *args[], int action){
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
string slsDetectorCommand::cmdOverwrite(int narg, char *args[], int action){
|
||||
|
||||
int i;
|
||||
char ans[100];
|
||||
|
||||
if (action==HELP_ACTION) {
|
||||
return helpOverwrite(narg, args, action);
|
||||
}
|
||||
if (action==PUT_ACTION) {
|
||||
if (sscanf(args[1],"%d",&i))
|
||||
myDet->overwriteFile(i);
|
||||
else
|
||||
return string("could not decode overwrite");
|
||||
|
||||
|
||||
}
|
||||
sprintf(ans,"%d",myDet->overwriteFile());
|
||||
return string(ans);
|
||||
}
|
||||
|
||||
|
||||
|
||||
string slsDetectorCommand::helpOverwrite(int narg, char *args[], int action){
|
||||
ostringstream os;
|
||||
if (action==GET_ACTION || action==HELP_ACTION)
|
||||
os << string("When Enabled overwrites files\n");
|
||||
if (action==PUT_ACTION || action==HELP_ACTION)
|
||||
os << string(" i \t should be 1 or 0 or -1\n");
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
string slsDetectorCommand::cmdFileIndex(int narg, char *args[], int action){
|
||||
char ans[100];
|
||||
int i;
|
||||
@ -3304,7 +3341,7 @@ string slsDetectorCommand::helpDAC(int narg, char *args[], int action) {
|
||||
|
||||
ostringstream os;
|
||||
if (action==PUT_ACTION || action==HELP_ACTION) {
|
||||
os << "vthreshold dacu\t sets the detector threshold in dac units (0-1024). The energy is approx 800-15*keV" << std::endl;
|
||||
os << "vthreshold dacu\t sets the detector threshold in dac units (0-1024) or mV. The energy is approx 800-15*keV" << std::endl;
|
||||
os << std::endl;
|
||||
|
||||
os << "vcalibration " << "dacu\t sets the calibration pulse amplitude in dac units (0-1024)." << std::endl;
|
||||
|
@ -82,6 +82,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
static string helpCounter(int narg, char *args[], int action);
|
||||
static string helpADC(int narg, char *args[], int action);
|
||||
static string helpEnablefwrite(int narg, char *args[], int action);
|
||||
static string helpOverwrite(int narg, char *args[], int action);
|
||||
static string helpReceiver(int narg, char *args[], int action);
|
||||
|
||||
|
||||
@ -152,6 +153,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
string cmdCounter(int narg, char *args[], int action);
|
||||
string cmdADC(int narg, char *args[], int action);
|
||||
string cmdEnablefwrite(int narg, char *args[], int action);
|
||||
string cmdOverwrite(int narg, char *args[], int action);
|
||||
string cmdReceiver(int narg, char *args[], int action);
|
||||
|
||||
|
||||
|
@ -643,6 +643,14 @@ virtual int* readFrameFromReceiver(char* fName, int &fIndex)=0;
|
||||
*/
|
||||
virtual int exitReceiver()=0;
|
||||
|
||||
/**
|
||||
Sets/Gets file overwrite enable
|
||||
@param enable 1 or 0 to set/reset file overwrite enable
|
||||
/returns file overwrite enable
|
||||
*/
|
||||
virtual int overwriteFile(int enable=-1)=0;
|
||||
|
||||
|
||||
/**
|
||||
Sets/Gets receiver file write enable
|
||||
@param enable 1 or 0 to set/reset file write enable
|
||||
@ -650,7 +658,6 @@ virtual int exitReceiver()=0;
|
||||
*/
|
||||
virtual int enableWriteToFile(int enable=-1)=0;
|
||||
|
||||
|
||||
/** Starts acquisition, calibrates pedestal and writes to fpga
|
||||
/returns number of frames
|
||||
*/
|
||||
|
Reference in New Issue
Block a user