mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 08:10:02 +02:00
frame index now is set via the multi and sls and sent to receiver when frames/cycles is set, resetframescaught doesnt decide if frames needed, possible problem in acquire scans,gets #frames/cycles from detector,but needed
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@451 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
ed4aaa83ce
commit
7a55ed9a74
@ -128,7 +128,9 @@ enum {
|
|||||||
|
|
||||||
F_SETUP_UDP, /**< sets the receiver udp connection and returns receiver mac address */
|
F_SETUP_UDP, /**< sets the receiver udp connection and returns receiver mac address */
|
||||||
|
|
||||||
F_ENABLE_FILE_WRITE /**< sets the receiver file write */
|
F_ENABLE_FILE_WRITE, /**< sets the receiver file write */
|
||||||
|
|
||||||
|
F_SET_FRAME_INDEX /**< sets the receiver frame index */
|
||||||
|
|
||||||
/* Always append functions hereafter!!! */
|
/* Always append functions hereafter!!! */
|
||||||
|
|
||||||
|
@ -54,20 +54,17 @@ int init_detector(int b) {
|
|||||||
printf("This is a VIRTUAL detector\n");
|
printf("This is a VIRTUAL detector\n");
|
||||||
#else
|
#else
|
||||||
mapCSP0();
|
mapCSP0();
|
||||||
|
|
||||||
//only for control server
|
//only for control server
|
||||||
if(b){
|
if(b){
|
||||||
|
printf("\ninitializing detector\n");
|
||||||
printf("fifo reset\n");
|
|
||||||
fifoReset();
|
|
||||||
printf("fifo test\n");
|
|
||||||
fifoTest();
|
|
||||||
printf("\ninitializing detector\n");
|
|
||||||
//Aurora-Links
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||||
initializeDetector();
|
initializeDetector();
|
||||||
|
|
||||||
|
|
||||||
|
fifoReset();
|
||||||
|
fifoTest();
|
||||||
|
|
||||||
//testFpga();
|
//testFpga();
|
||||||
//testRAM();
|
//testRAM();
|
||||||
//setSettings(GET_SETTINGS,-1);
|
//setSettings(GET_SETTINGS,-1);
|
||||||
|
@ -122,7 +122,7 @@ int fifoReset(){
|
|||||||
u_int32_t mask = FIFOCNTRL_RESET_MASK;
|
u_int32_t mask = FIFOCNTRL_RESET_MASK;
|
||||||
|
|
||||||
fifo_control_reg |= mask;
|
fifo_control_reg |= mask;
|
||||||
printf("CTRL Register bits: 0x%08x\n",fifo_control_reg);
|
//printf("CTRL Register bits: 0x%08x\n",fifo_control_reg);
|
||||||
|
|
||||||
bus_w(FIFO_CNTRL_REG,fifo_control_reg);
|
bus_w(FIFO_CNTRL_REG,fifo_control_reg);
|
||||||
bus_w(FIFO_CNTRL_REG,fifo_control_reg);
|
bus_w(FIFO_CNTRL_REG,fifo_control_reg);
|
||||||
@ -132,6 +132,8 @@ int fifoReset(){
|
|||||||
fifo_control_reg &= (~mask);
|
fifo_control_reg &= (~mask);
|
||||||
bus_w(FIFO_CNTRL_REG,fifo_control_reg);
|
bus_w(FIFO_CNTRL_REG,fifo_control_reg);
|
||||||
|
|
||||||
|
printf("fifo has been reset\n\n");
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +144,7 @@ int fifoTest(void){
|
|||||||
|
|
||||||
int buffer_length = 256;
|
int buffer_length = 256;
|
||||||
int rec_buffer_length = 4096;
|
int rec_buffer_length = 4096;
|
||||||
char cmd[] = "fpgatfemp";
|
char cmd[] = "help";
|
||||||
unsigned int buffer[buffer_length];
|
unsigned int buffer[buffer_length];
|
||||||
unsigned int rec_buffer[rec_buffer_length];
|
unsigned int rec_buffer[rec_buffer_length];
|
||||||
unsigned int send_len;
|
unsigned int send_len;
|
||||||
|
@ -3725,11 +3725,11 @@ int multiSlsDetector::getReceiverCurrentFrameIndex() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int multiSlsDetector::resetFramesCaught(int index) {
|
int multiSlsDetector::resetFramesCaught() {
|
||||||
int ret=-100, ret1;
|
int ret=-100, ret1;
|
||||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++){
|
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++){
|
||||||
if (detectors[i]){
|
if (detectors[i]){
|
||||||
ret1=detectors[i]->resetFramesCaught(index);
|
ret1=detectors[i]->resetFramesCaught();
|
||||||
if (ret==-100)
|
if (ret==-100)
|
||||||
ret=ret1;
|
ret=ret1;
|
||||||
else if (ret!=ret1)
|
else if (ret!=ret1)
|
||||||
@ -3849,3 +3849,23 @@ int multiSlsDetector::enableWriteToFile(int enable){
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int multiSlsDetector::setFrameIndex(int index){
|
||||||
|
int ret=-100, ret1;
|
||||||
|
|
||||||
|
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
|
||||||
|
if (detectors[idet]) {
|
||||||
|
ret1=detectors[idet]->setFrameIndex(index);
|
||||||
|
if (ret==-100)
|
||||||
|
ret=ret1;
|
||||||
|
else if (ret!=ret1)
|
||||||
|
ret=-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1089,9 +1089,8 @@ class multiSlsDetector : public slsDetectorUtils {
|
|||||||
/**
|
/**
|
||||||
* resets framescaught
|
* resets framescaught
|
||||||
* @param index frames caught by receiver
|
* @param index frames caught by receiver
|
||||||
* @param index if frame index is needed
|
|
||||||
*/
|
*/
|
||||||
int resetFramesCaught(int index=-1);
|
int resetFramesCaught();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a frame from receiver
|
* Reads a frame from receiver
|
||||||
@ -1124,6 +1123,12 @@ class multiSlsDetector : public slsDetectorUtils {
|
|||||||
*/
|
*/
|
||||||
int enableWriteToFile(int enable=-1);
|
int enableWriteToFile(int enable=-1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set frame index to 0 or -1
|
||||||
|
* @param index is the frame index
|
||||||
|
*/
|
||||||
|
int setFrameIndex(int index=-1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -4557,6 +4557,10 @@ char* slsDetector::setReceiver(string receiverIP){
|
|||||||
setFilePath(fileIO::getFilePath());
|
setFilePath(fileIO::getFilePath());
|
||||||
setFileName(fileIO::getFileName());
|
setFileName(fileIO::getFileName());
|
||||||
setFileIndex(fileIO::getFileIndex());
|
setFileIndex(fileIO::getFileIndex());
|
||||||
|
if ((setTimer(FRAME_NUMBER,-1)*setTimer(CYCLES_NUMBER,-1))>1)
|
||||||
|
setFrameIndex(0);
|
||||||
|
else
|
||||||
|
setFrameIndex(-1);
|
||||||
enableWriteToFile(parentDet->enableWriteToFileMask());
|
enableWriteToFile(parentDet->enableWriteToFileMask());
|
||||||
setUDPConnection();
|
setUDPConnection();
|
||||||
}
|
}
|
||||||
@ -5837,17 +5841,15 @@ int slsDetector::getReceiverCurrentFrameIndex(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsDetector::resetFramesCaught(int index){
|
int slsDetector::resetFramesCaught(){
|
||||||
int fnum=F_RESET_FRAMES_CAUGHT;
|
int fnum=F_RESET_FRAMES_CAUGHT;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
int retval=-1;
|
|
||||||
int arg=index;
|
|
||||||
|
|
||||||
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "Reset Frames Caught by Receiver:" << arg << std::endl;
|
std::cout << "Reset Frames Caught by Receiver" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
ret=thisReceiver->executeFunction(fnum);
|
||||||
if(ret==FORCE_UPDATE)
|
if(ret==FORCE_UPDATE)
|
||||||
ret=updateReceiver();
|
ret=updateReceiver();
|
||||||
}
|
}
|
||||||
@ -6058,3 +6060,34 @@ int slsDetector::enableWriteToFile(int enable){
|
|||||||
|
|
||||||
return parentDet->enableWriteToFileMask();
|
return parentDet->enableWriteToFileMask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int slsDetector::setFrameIndex(int index){
|
||||||
|
int fnum=F_SET_FRAME_INDEX;
|
||||||
|
int ret = FAIL;
|
||||||
|
int retval=-1;
|
||||||
|
int arg = index;
|
||||||
|
|
||||||
|
if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){
|
||||||
|
fileIO::setFrameIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||||
|
#ifdef VERBOSE
|
||||||
|
std::cout << "Sending frame index to receiver " << arg << std::endl;
|
||||||
|
#endif
|
||||||
|
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||||
|
if(ret!=FAIL)
|
||||||
|
fileIO::setFrameIndex(retval);
|
||||||
|
if(ret==FORCE_UPDATE)
|
||||||
|
updateReceiver();
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileIO::getFrameIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1465,9 +1465,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
|||||||
/**
|
/**
|
||||||
* resets framescaught
|
* resets framescaught
|
||||||
* @param index frames caught by receiver
|
* @param index frames caught by receiver
|
||||||
* @param index if frame index is needed
|
|
||||||
*/
|
*/
|
||||||
int resetFramesCaught(int index=-1);
|
int resetFramesCaught();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a frame from receiver
|
* Reads a frame from receiver
|
||||||
@ -1513,6 +1512,14 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
|||||||
int enableWriteToFile(int enable=-1);
|
int enableWriteToFile(int enable=-1);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set frame index to 0 or -1
|
||||||
|
* @param index is the frame index
|
||||||
|
*/
|
||||||
|
int setFrameIndex(int index=-1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int fillModuleMask(int *mM);
|
int fillModuleMask(int *mM);
|
||||||
|
|
||||||
|
|
||||||
|
@ -3187,6 +3187,15 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {
|
|||||||
else rval=ret;
|
else rval=ret;
|
||||||
|
|
||||||
|
|
||||||
|
//set frame index
|
||||||
|
if (index==FRAME_NUMBER || index==CYCLES_NUMBER ){
|
||||||
|
if ((myDet->setTimer(FRAME_NUMBER,-1)*myDet->setTimer(CYCLES_NUMBER,-1))>1)
|
||||||
|
myDet->setFrameIndex(0);
|
||||||
|
else
|
||||||
|
myDet->setFrameIndex(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sprintf(answer,"%0.9f",rval);
|
sprintf(answer,"%0.9f",rval);
|
||||||
return string(answer);
|
return string(answer);
|
||||||
|
|
||||||
|
@ -121,10 +121,8 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
|
|
||||||
|
|
||||||
//resets frames caught in receiver
|
//resets frames caught in receiver
|
||||||
if ((timerValue[FRAME_NUMBER]*timerValue[CYCLES_NUMBER])>1)
|
resetFramesCaught();
|
||||||
resetFramesCaught(1);
|
|
||||||
else
|
|
||||||
resetFramesCaught(0);
|
|
||||||
|
|
||||||
if(setReceiverOnline()==OFFLINE_FLAG)
|
if(setReceiverOnline()==OFFLINE_FLAG)
|
||||||
*stoppedFlag=1;
|
*stoppedFlag=1;
|
||||||
@ -234,7 +232,8 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
}
|
}
|
||||||
|
|
||||||
setCurrentFrameIndex(0);
|
setCurrentFrameIndex(0);
|
||||||
if ((timerValue[FRAME_NUMBER]*timerValue[CYCLES_NUMBER])>1) {
|
//if ((timerValue[FRAME_NUMBER]*timerValue[CYCLES_NUMBER])>1) {
|
||||||
|
if ((setTimer(FRAME_NUMBER,-1)*setTimer(CYCLES_NUMBER,-1))>1){
|
||||||
setFrameIndex(0);
|
setFrameIndex(0);
|
||||||
} else {
|
} else {
|
||||||
setFrameIndex(-1);
|
setFrameIndex(-1);
|
||||||
|
@ -625,9 +625,8 @@ virtual int getReceiverCurrentFrameIndex()=0;
|
|||||||
/**
|
/**
|
||||||
* resets framescaught
|
* resets framescaught
|
||||||
* @param index frames caught by receiver
|
* @param index frames caught by receiver
|
||||||
* @param index if frame index is needed
|
|
||||||
*/
|
*/
|
||||||
virtual int resetFramesCaught(int index=-1)=0;
|
virtual int resetFramesCaught()=0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a frame from receiver
|
* Reads a frame from receiver
|
||||||
|
@ -31,7 +31,7 @@ slsReceiverFunctionList::slsReceiverFunctionList(bool shortfname):
|
|||||||
shortFileName(shortfname),
|
shortFileName(shortfname),
|
||||||
shortFileNameIndex(0),
|
shortFileNameIndex(0),
|
||||||
fileIndex(0),
|
fileIndex(0),
|
||||||
frameIndexNeeded(true),
|
frameIndexNeeded(0),
|
||||||
framesCaught(0),
|
framesCaught(0),
|
||||||
startFrameIndex(-1),
|
startFrameIndex(-1),
|
||||||
frameIndex(0),
|
frameIndex(0),
|
||||||
@ -152,12 +152,10 @@ int slsReceiverFunctionList::setFileIndex(int i){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool slsReceiverFunctionList::resetTotalFramesCaught(bool i){
|
void slsReceiverFunctionList::resetTotalFramesCaught(){
|
||||||
frameIndexNeeded = i;
|
|
||||||
startAcquisitionIndex = -1;
|
startAcquisitionIndex = -1;
|
||||||
totalFramesCaught = 0;
|
totalFramesCaught = 0;
|
||||||
|
|
||||||
return frameIndexNeeded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -170,7 +168,9 @@ int slsReceiverFunctionList::startReceiver(){
|
|||||||
|
|
||||||
int err = 0;
|
int err = 0;
|
||||||
if(!listening_thread_running){
|
if(!listening_thread_running){
|
||||||
|
#ifdef VERBOSE
|
||||||
cout << "Starting new acquisition threadddd ...." << endl;
|
cout << "Starting new acquisition threadddd ...." << endl;
|
||||||
|
#endif
|
||||||
listening_thread_running=1;
|
listening_thread_running=1;
|
||||||
|
|
||||||
|
|
||||||
@ -183,8 +183,9 @@ int slsReceiverFunctionList::startReceiver(){
|
|||||||
cout << "Cant create writing thread. Status:" << status << endl << endl;
|
cout << "Cant create writing thread. Status:" << status << endl << endl;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
cout << "Writing thread created successfully." << endl;
|
cout << "Writing thread created successfully." << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
//error creating listenign thread
|
//error creating listenign thread
|
||||||
err = 0;
|
err = 0;
|
||||||
@ -200,9 +201,14 @@ int slsReceiverFunctionList::startReceiver(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
while(status!=RUNNING);
|
while(status!=RUNNING);
|
||||||
|
#ifdef VERBOSE
|
||||||
cout << "Listening thread created successfully." << endl;
|
cout << "Listening thread created successfully." << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cout << "Threads created successfully." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,12 +217,14 @@ int slsReceiverFunctionList::startReceiver(){
|
|||||||
|
|
||||||
|
|
||||||
int slsReceiverFunctionList::stopReceiver(){
|
int slsReceiverFunctionList::stopReceiver(){
|
||||||
//#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Stopping Receiver" << endl;
|
cout << "Stopping Receiver" << endl;
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
if(listening_thread_running){
|
if(listening_thread_running){
|
||||||
|
#ifdef VERBOSE
|
||||||
cout << "Stopping new acquisition threadddd ...." << endl;
|
cout << "Stopping new acquisition threadddd ...." << endl;
|
||||||
|
#endif
|
||||||
//stop listening thread
|
//stop listening thread
|
||||||
listening_thread_running=0;
|
listening_thread_running=0;
|
||||||
udpSocket->ShutDownSocket();
|
udpSocket->ShutDownSocket();
|
||||||
@ -228,7 +236,7 @@ int slsReceiverFunctionList::stopReceiver(){
|
|||||||
// if(fifo) delete fifo;
|
// if(fifo) delete fifo;
|
||||||
//if(latestData) delete latestData;/**new*/
|
//if(latestData) delete latestData;/**new*/
|
||||||
}
|
}
|
||||||
cout << "Status:" << status << endl;
|
cout << "Receiver Stoppped.\nStatus:" << status << endl;
|
||||||
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@ -374,18 +382,17 @@ int slsReceiverFunctionList::startWriting(){
|
|||||||
framesInFile=0;
|
framesInFile=0;
|
||||||
framesCaught=0;
|
framesCaught=0;
|
||||||
frameIndex=0;
|
frameIndex=0;
|
||||||
|
|
||||||
if(sfilefd) sfilefd=0;
|
if(sfilefd) sfilefd=0;
|
||||||
|
|
||||||
strcpy(savefilename,"");
|
strcpy(savefilename,"");
|
||||||
strcpy(actualfilename,"");
|
strcpy(actualfilename,"");
|
||||||
|
|
||||||
cout << "Max Frames Per File:" << maxFramesPerFile << endl;
|
cout << "Max Frames Per File:" << maxFramesPerFile << endl;
|
||||||
cout << "Ready!" << endl;
|
cout << "Ready!" << endl;
|
||||||
|
|
||||||
|
|
||||||
if(enableFileWrite){
|
if(enableFileWrite){
|
||||||
//create file name
|
//create file name
|
||||||
if(!frameIndexNeeded) sprintf(savefilename, "%s/%s_%d.raw", filePath,fileName,fileIndex);
|
if(frameIndexNeeded==-1) sprintf(savefilename, "%s/%s_%d.raw", filePath,fileName,fileIndex);
|
||||||
else sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,framesCaught,fileIndex);
|
else sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,framesCaught,fileIndex);
|
||||||
|
|
||||||
//for sebastian
|
//for sebastian
|
||||||
@ -398,6 +405,7 @@ int slsReceiverFunctionList::startWriting(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while(listening_thread_running){
|
while(listening_thread_running){
|
||||||
|
|
||||||
//when it reaches maxFramesPerFile,start writing new file
|
//when it reaches maxFramesPerFile,start writing new file
|
||||||
@ -406,7 +414,7 @@ int slsReceiverFunctionList::startWriting(){
|
|||||||
if(enableFileWrite){
|
if(enableFileWrite){
|
||||||
fclose(sfilefd);
|
fclose(sfilefd);
|
||||||
//create file name
|
//create file name
|
||||||
if(!frameIndexNeeded) sprintf(savefilename, "%s/%s_%d.raw", filePath,fileName,fileIndex);
|
if(frameIndexNeeded==-1) sprintf(savefilename, "%s/%s_%d.raw", filePath,fileName,fileIndex);
|
||||||
else sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,framesCaught,fileIndex);
|
else sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,framesCaught,fileIndex);
|
||||||
//for sebastian
|
//for sebastian
|
||||||
if(!shortFileName) strcpy(actualfilename,savefilename);
|
if(!shortFileName) strcpy(actualfilename,savefilename);
|
||||||
@ -426,6 +434,8 @@ int slsReceiverFunctionList::startWriting(){
|
|||||||
framesInFile = 0;
|
framesInFile = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//actual writing from fifo
|
//actual writing from fifo
|
||||||
if(!fifo->isEmpty()){
|
if(!fifo->isEmpty()){
|
||||||
// dataWriteFrame = new dataStruct;
|
// dataWriteFrame = new dataStruct;
|
||||||
@ -487,14 +497,14 @@ char* slsReceiverFunctionList::readFrame(char* c){
|
|||||||
guiRequiresData=0;
|
guiRequiresData=0;
|
||||||
|
|
||||||
//if no more data //if(guiRequiresData) // retun NULL;
|
//if no more data //if(guiRequiresData) // retun NULL;
|
||||||
|
|
||||||
//cout<<"latestdata:"<<(int)(*(int*)latestData)<<endl;
|
//cout<<"latestdata:"<<(int)(*(int*)latestData)<<endl;
|
||||||
strcpy(c,savefilename);
|
strcpy(c,savefilename);
|
||||||
return latestData;
|
return latestData;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsReceiverFunctionList::setShortFrame(int i){
|
int slsReceiverFunctionList::setShortFrame(int i){
|
||||||
shortFrame=i;
|
shortFrame=i;
|
||||||
|
|
||||||
|
@ -105,6 +105,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
int setFileIndex(int i);
|
int setFileIndex(int i);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Frame Index Needed
|
||||||
|
* @param i frame index needed
|
||||||
|
*/
|
||||||
|
int setFrameIndexNeeded(int i){frameIndexNeeded = i;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set enable file write
|
* Set enable file write
|
||||||
* @param i file write enable
|
* @param i file write enable
|
||||||
@ -115,10 +121,9 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Resets the Total Frames Caught
|
* Resets the Total Frames Caught
|
||||||
* This is how the receiver differentiates between entire acquisitions
|
* This is how the receiver differentiates between entire acquisitions
|
||||||
* @param i true if frame index in file name is required, else false
|
* Returns 0
|
||||||
* Returns frames needed in file name
|
|
||||||
*/
|
*/
|
||||||
bool resetTotalFramesCaught(bool i);
|
void resetTotalFramesCaught();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close File
|
* Close File
|
||||||
@ -208,7 +213,7 @@ private:
|
|||||||
int fileIndex;
|
int fileIndex;
|
||||||
|
|
||||||
/** if frame index required in file name */
|
/** if frame index required in file name */
|
||||||
bool frameIndexNeeded;
|
int frameIndexNeeded;
|
||||||
|
|
||||||
/** Frames Caught for each real time acquisition (eg. for each scan) */
|
/** Frames Caught for each real time acquisition (eg. for each scan) */
|
||||||
int framesCaught;
|
int framesCaught;
|
||||||
|
@ -120,6 +120,7 @@ int slsReceiverFuncs::function_table(){
|
|||||||
flist[F_SET_FILE_NAME] = &slsReceiverFuncs::set_file_name;
|
flist[F_SET_FILE_NAME] = &slsReceiverFuncs::set_file_name;
|
||||||
flist[F_SET_FILE_PATH] = &slsReceiverFuncs::set_file_dir;
|
flist[F_SET_FILE_PATH] = &slsReceiverFuncs::set_file_dir;
|
||||||
flist[F_SET_FILE_INDEX] = &slsReceiverFuncs::set_file_index;
|
flist[F_SET_FILE_INDEX] = &slsReceiverFuncs::set_file_index;
|
||||||
|
flist[F_SET_FRAME_INDEX] = &slsReceiverFuncs::set_frame_index;
|
||||||
flist[F_SETUP_UDP] = &slsReceiverFuncs::setup_udp;
|
flist[F_SETUP_UDP] = &slsReceiverFuncs::setup_udp;
|
||||||
flist[F_START_RECEIVER] = &slsReceiverFuncs::start_receiver;
|
flist[F_START_RECEIVER] = &slsReceiverFuncs::start_receiver;
|
||||||
flist[F_STOP_RECEIVER] = &slsReceiverFuncs::stop_receiver;
|
flist[F_STOP_RECEIVER] = &slsReceiverFuncs::stop_receiver;
|
||||||
@ -387,6 +388,60 @@ int slsReceiverFuncs::set_file_index() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int slsReceiverFuncs::set_frame_index() {
|
||||||
|
ret=OK;
|
||||||
|
int retval=-1;
|
||||||
|
int index;
|
||||||
|
strcpy(mess,"Could not set frame index\n");
|
||||||
|
|
||||||
|
|
||||||
|
// receive arguments
|
||||||
|
if(socket->ReceiveDataOnly(&index,sizeof(index)) < 0 ){
|
||||||
|
strcpy(mess,"Error reading from socket\n");
|
||||||
|
ret = FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// execute action if the arguments correctly arrived
|
||||||
|
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||||
|
if (ret==OK) {
|
||||||
|
if (lockStatus==1 && socket->differentClients==1){//necessary???
|
||||||
|
sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP);
|
||||||
|
ret=FAIL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
retval=slsReceiverList->setFrameIndexNeeded(index);
|
||||||
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
|
if(ret!=FAIL)
|
||||||
|
cout << "frame index:" << retval << endl;
|
||||||
|
else
|
||||||
|
cout << mess << endl;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(ret==OK && socket->differentClients){
|
||||||
|
cout << "Force update" << endl;
|
||||||
|
ret=FORCE_UPDATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// send answer
|
||||||
|
socket->SendDataOnly(&ret,sizeof(ret));
|
||||||
|
if(ret==FAIL)
|
||||||
|
socket->SendDataOnly(mess,sizeof(mess));
|
||||||
|
socket->SendDataOnly(&retval,sizeof(retval));
|
||||||
|
|
||||||
|
//return ok/fail
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsReceiverFuncs::setup_udp(){
|
int slsReceiverFuncs::setup_udp(){
|
||||||
ret=OK;
|
ret=OK;
|
||||||
strcpy(mess,"could not set up udp connection");
|
strcpy(mess,"could not set up udp connection");
|
||||||
@ -606,18 +661,11 @@ int slsReceiverFuncs::get_frame_index(){
|
|||||||
|
|
||||||
int slsReceiverFuncs::reset_frames_caught(){
|
int slsReceiverFuncs::reset_frames_caught(){
|
||||||
ret=OK;
|
ret=OK;
|
||||||
int retval=-1;
|
|
||||||
int index=-1;
|
int index=-1;
|
||||||
|
|
||||||
strcpy(mess,"Could not reset frames caught\n");
|
strcpy(mess,"Could not reset frames caught\n");
|
||||||
|
|
||||||
|
|
||||||
// receive arguments
|
|
||||||
if(socket->ReceiveDataOnly(&index,sizeof(index)) < 0) {;
|
|
||||||
sprintf(mess,"Error reading from socket\n");
|
|
||||||
ret=FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// execute action if the arguments correctly arrived
|
// execute action if the arguments correctly arrived
|
||||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||||
if (ret==OK) {
|
if (ret==OK) {
|
||||||
@ -626,7 +674,7 @@ int slsReceiverFuncs::reset_frames_caught(){
|
|||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
retval=slsReceiverList->resetTotalFramesCaught(index);
|
slsReceiverList->resetTotalFramesCaught();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -639,7 +687,7 @@ int slsReceiverFuncs::reset_frames_caught(){
|
|||||||
socket->SendDataOnly(&ret,sizeof(ret));
|
socket->SendDataOnly(&ret,sizeof(ret));
|
||||||
if(ret==FAIL)
|
if(ret==FAIL)
|
||||||
socket->SendDataOnly(mess,sizeof(mess));
|
socket->SendDataOnly(mess,sizeof(mess));
|
||||||
socket->SendDataOnly(&retval,sizeof(retval));
|
|
||||||
//return ok/fail
|
//return ok/fail
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -56,6 +56,9 @@ public:
|
|||||||
/** Set File index */
|
/** Set File index */
|
||||||
int set_file_index();
|
int set_file_index();
|
||||||
|
|
||||||
|
/** Set Frame index */
|
||||||
|
int set_frame_index();
|
||||||
|
|
||||||
/** Start Receiver - starts listening to udp packets from detector */
|
/** Start Receiver - starts listening to udp packets from detector */
|
||||||
int start_receiver();
|
int start_receiver();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user