mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
started the basics for sending every nth frame from receiver to gui.incomplete and will be implemented later
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@506 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -56,6 +56,7 @@ slsReceiverFunctionList::slsReceiverFunctionList():
|
||||
guiData(NULL),
|
||||
guiFileName(NULL),
|
||||
currframenum(0),
|
||||
nFrameToGui(0),
|
||||
writeReceiverData(0),
|
||||
pwriteReceiverDataArg(0),
|
||||
startAcquisitionCallBack(NULL),
|
||||
@ -410,6 +411,9 @@ int slsReceiverFunctionList::startWriting(){
|
||||
cout << "Max Frames Per File:" << maxFramesPerFile << endl;
|
||||
if (writeReceiverData)
|
||||
cout << "Note: Data Write has been defined exernally" << endl;
|
||||
if(nFrameToGui)
|
||||
cout << " Not implemented yet: Sending every " << nFrameToGui << "th frame to gui" << endl;
|
||||
|
||||
cout << "Ready!" << endl;
|
||||
|
||||
//by default, we read/write everything
|
||||
@ -485,12 +489,15 @@ int slsReceiverFunctionList::startWriting(){
|
||||
} else {
|
||||
if(sfilefd)
|
||||
fwrite(wbuf, 1, bufferSize, sfilefd);
|
||||
else
|
||||
else{
|
||||
cout << "You do not have permissions to overwrite: " << savefilename << endl;
|
||||
usleep(50000);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//copies gui data and sets/resets guiDataReady
|
||||
if(guiData){
|
||||
//if (cbAction>=2)
|
||||
@ -501,6 +508,7 @@ int slsReceiverFunctionList::startWriting(){
|
||||
guiDataReady=0;
|
||||
|
||||
|
||||
|
||||
framesInFile++;
|
||||
// delete [] dataWriteFrame->buffer;
|
||||
fifofree->push(wbuf);
|
||||
|
@ -13,10 +13,12 @@
|
||||
#include "genericSocket.h"
|
||||
#include "circularFifo.h"
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/**
|
||||
* @short does all the functions for a receiver, set/get parameters, start/stop etc.
|
||||
*/
|
||||
@ -185,6 +187,12 @@ public:
|
||||
*/
|
||||
int setShortFrame(int i);
|
||||
|
||||
/**
|
||||
* Set the variable to send every nth frame to gui
|
||||
* or if 0,send frame only upon gui request
|
||||
*/
|
||||
int setNFrameToGui(int i){if(i>=0) nFrameToGui = i; return nFrameToGui;};
|
||||
|
||||
/**
|
||||
* Register call back function to write receiver data
|
||||
*/
|
||||
@ -298,6 +306,11 @@ private:
|
||||
/** current frame number */
|
||||
int currframenum;
|
||||
|
||||
/** send every nth frame to gui or only upon gui request*/
|
||||
int nFrameToGui;
|
||||
|
||||
|
||||
|
||||
/** register for call back to get data */
|
||||
int (*writeReceiverData)(char*,int,FILE*,void*);
|
||||
void *pwriteReceiverDataArg;
|
||||
@ -343,6 +356,9 @@ private:
|
||||
* 2 we open, close, write file, callback does not do anything */
|
||||
int cbAction;
|
||||
|
||||
|
||||
|
||||
|
||||
public:
|
||||
/** File Descriptor */
|
||||
static FILE *sfilefd;
|
||||
@ -350,6 +366,7 @@ public:
|
||||
/** if the listening thread is running*/
|
||||
static int listening_thread_running;
|
||||
|
||||
|
||||
/**
|
||||
callback arguments are
|
||||
filepath
|
||||
@ -365,7 +382,6 @@ public:
|
||||
*/
|
||||
void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){startAcquisitionCallBack=func; pStartAcquisition=arg;};
|
||||
|
||||
|
||||
/**
|
||||
callback argument is
|
||||
toatal frames caught
|
||||
@ -373,8 +389,6 @@ public:
|
||||
*/
|
||||
void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){acquisitionFinishedCallBack=func; pAcquisitionFinished=arg;};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
args to raw data ready callback are
|
||||
framenum
|
||||
@ -383,10 +397,6 @@ public:
|
||||
guidatapointer (NULL, no data required)
|
||||
*/
|
||||
void registerCallBackRawDataReady(void (*func)(int, char*, FILE*, char*, void*),void *arg){rawDataReadyCallBack=func; pRawDataReady=arg;};
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -181,6 +181,8 @@ int slsReceiverFuncs::function_table(){
|
||||
flist[F_GET_FRAME_INDEX] = &slsReceiverFuncs::get_frame_index;
|
||||
flist[F_RESET_FRAMES_CAUGHT] = &slsReceiverFuncs::reset_frames_caught;
|
||||
flist[F_READ_FRAME] = &slsReceiverFuncs::read_frame;
|
||||
flist[F_READ_ALL] = &slsReceiverFuncs::read_all;
|
||||
flist[F_READ_RECEIVER_FREQUENCY]= &slsReceiverFuncs::set_read_frequency;
|
||||
flist[F_ENABLE_FILE_WRITE] = &slsReceiverFuncs::enable_file_write;
|
||||
flist[F_GET_ID] = &slsReceiverFuncs::get_version;
|
||||
flist[F_CONFIGURE_MAC] = &slsReceiverFuncs::set_short_frame;
|
||||
@ -860,8 +862,8 @@ int slsReceiverFuncs::read_frame(){
|
||||
count++;
|
||||
}
|
||||
|
||||
if ((count==20) || (count == -1)){
|
||||
if (count == -20)
|
||||
if ((count==10) || (count == -1)){
|
||||
if (count == -10)
|
||||
cout << "same type: index:" << index << "\tindex2:" << index2 << endl;
|
||||
else
|
||||
cout << "no data to read for gui" << endl;
|
||||
@ -914,6 +916,56 @@ int slsReceiverFuncs::read_frame(){
|
||||
|
||||
|
||||
|
||||
int slsReceiverFuncs::set_read_frequency(){
|
||||
ret=OK;
|
||||
int retval=-1;
|
||||
int index;
|
||||
strcpy(mess,"Could not set receiver read frequency\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->setNFrameToGui(index);
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**needs to be implemented */
|
||||
int slsReceiverFuncs::read_all(){
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -124,6 +124,12 @@ public:
|
||||
/** Reads Frame/ buffer */
|
||||
int read_frame();
|
||||
|
||||
/** Sets the receiver to send every nth frame to gui, or only upon gui request */
|
||||
int set_read_frequency();
|
||||
|
||||
/** Reads every nth frame, sends them to gui without closing socket */
|
||||
int read_all();
|
||||
|
||||
/** Enable File Write*/
|
||||
int enable_file_write();
|
||||
|
||||
|
Reference in New Issue
Block a user