mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 14:38:14 +02:00
shortframes work with gui enabled
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@445 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
22bd638f64
commit
341e026f4e
@ -4681,8 +4681,7 @@ int slsDetector::configureMAC(int adc){
|
||||
char arg[5][50];
|
||||
char cword[50]="", *pcword;
|
||||
string sword;
|
||||
int shortframe=1;
|
||||
int retval=-100;
|
||||
int retval=-1;
|
||||
|
||||
if(((adc>=-1)&&(adc<=4))||(adc==-100));
|
||||
else{
|
||||
@ -4811,11 +4810,10 @@ int slsDetector::configureMAC(int adc){
|
||||
//connect to receiver
|
||||
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||
if(retval==-1) shortframe=0;
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Sending shortframe to receiver " << shortframe << std::endl;
|
||||
std::cout << "Sending adc val to receiver " << retval << std::endl;
|
||||
#endif
|
||||
ret=thisReceiver->sendInt(fnum,retval,shortframe);
|
||||
ret=thisReceiver->sendInt(fnum,retval,retval);
|
||||
if(ret==FAIL)
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
||||
}
|
||||
|
@ -393,11 +393,13 @@ void* postProcessing::processData(int delflag) {
|
||||
}
|
||||
//receiver
|
||||
else{
|
||||
/*
|
||||
while(1){
|
||||
if (checkJoinThread()) break;
|
||||
usleep(200000);
|
||||
}
|
||||
/*
|
||||
*/
|
||||
|
||||
pthread_mutex_lock(&mg);
|
||||
int prevCaught=getReceiverCurrentFrameIndex();
|
||||
pthread_mutex_unlock(&mg);
|
||||
@ -446,7 +448,7 @@ void* postProcessing::processData(int delflag) {
|
||||
cout<<"****Detector returned mismatched indeices***"<<endl;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#define PACKETS_PER_FRAME 2
|
||||
|
||||
#define SHORT_BUFFER_SIZE 518
|
||||
#define SHORT_DATABYTES 512
|
||||
#define SHORT_MAX_FRAMES 100000
|
||||
#define SHORT_PACKETS_PER_FRAME 1
|
||||
|
||||
|
@ -41,11 +41,11 @@ slsReceiverFunctionList::slsReceiverFunctionList(bool shortfname):
|
||||
framesInFile(0),
|
||||
prevframenum(0),
|
||||
status(IDLE),
|
||||
latestData(NULL),
|
||||
latestData(NULL),/**?*/
|
||||
udpSocket(NULL),
|
||||
server_port(DEFAULT_UDP_PORTNO),
|
||||
fifo(NULL),
|
||||
shortFrame(0),
|
||||
shortFrame(-1),
|
||||
bufferSize(BUFFER_SIZE),
|
||||
packetsPerFrame(2)
|
||||
{
|
||||
@ -76,7 +76,7 @@ void slsReceiverFunctionList::setEthernetInterface(char* c){
|
||||
int slsReceiverFunctionList::getFrameIndex(){
|
||||
if(startFrameIndex==-1)
|
||||
frameIndex=0;
|
||||
else
|
||||
else if(framesCaught)
|
||||
frameIndex=((int)(*((int*)latestData)) - startFrameIndex)/packetsPerFrame;
|
||||
return frameIndex;
|
||||
}
|
||||
@ -86,8 +86,9 @@ int slsReceiverFunctionList::getFrameIndex(){
|
||||
int slsReceiverFunctionList::getAcquisitionIndex(){
|
||||
if(startAcquisitionIndex==-1)
|
||||
acquisitionIndex=0;
|
||||
else
|
||||
else if(framesCaught)
|
||||
acquisitionIndex=((int)(*((int*)latestData)) - startAcquisitionIndex)/packetsPerFrame;
|
||||
|
||||
return acquisitionIndex;
|
||||
}
|
||||
|
||||
@ -185,9 +186,9 @@ int slsReceiverFunctionList::startReceiver(){
|
||||
|
||||
|
||||
int slsReceiverFunctionList::stopReceiver(){
|
||||
#ifdef VERBOSE
|
||||
//#ifdef VERBOSE
|
||||
cout << "Stopping Receiver" << endl;
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
if(listening_thread_running){
|
||||
cout << "Stopping new acquisition threadddd ...." << endl;
|
||||
@ -200,6 +201,7 @@ int slsReceiverFunctionList::stopReceiver(){
|
||||
//stop writing thread
|
||||
pthread_join(writing_thread,NULL);
|
||||
if(fifo) delete fifo;
|
||||
//if(latestData) delete latestData;/**new*/
|
||||
}
|
||||
cout << "Status:" << status << endl;
|
||||
|
||||
@ -280,7 +282,7 @@ int slsReceiverFunctionList::startListening(){
|
||||
//start of acquisition
|
||||
if(startAcquisitionIndex==-1){
|
||||
startAcquisitionIndex=startFrameIndex;
|
||||
//cout<<"startAcquisitionIndex:"<<startAcquisitionIndex<<endl;
|
||||
cout<<"startAcquisitionIndex:"<<startAcquisitionIndex<<endl;
|
||||
}
|
||||
|
||||
|
||||
@ -291,7 +293,7 @@ int slsReceiverFunctionList::startListening(){
|
||||
if(fifo->isFull())
|
||||
;//cout<<"**********************FIFO FULLLLLLLL************************"<<endl;
|
||||
else{
|
||||
//cout<<"read index:"<<(int)(*(int*)buffer)<<endl;
|
||||
//cout<<"read index:"<<dec<<(int)(*(int*)buffer)<<endl;
|
||||
dataReadFrame = new dataStruct;
|
||||
dataReadFrame->buffer=buffer;
|
||||
dataReadFrame->rc=rc;
|
||||
@ -404,7 +406,7 @@ int slsReceiverFunctionList::startWriting(){
|
||||
framesCaught++;
|
||||
totalFramesCaught++;
|
||||
memcpy(latestData,dataWriteFrame->buffer,bufferSize);
|
||||
//cout<<"list write \t index:"<<(int)(*(int*)latestData)<<endl;
|
||||
//cout<<"write index:"<<(int)(*(int*)latestData)<<endl;
|
||||
if(enableFileWrite)
|
||||
fwrite(dataWriteFrame->buffer, 1, dataWriteFrame->rc, sfilefd);
|
||||
framesInFile++;
|
||||
@ -444,7 +446,7 @@ char* slsReceiverFunctionList::readFrame(char* c){
|
||||
int slsReceiverFunctionList::setShortFrame(int i){
|
||||
shortFrame=i;
|
||||
|
||||
if(shortFrame){
|
||||
if(shortFrame!=-1){
|
||||
bufferSize = SHORT_BUFFER_SIZE;
|
||||
maxFramesPerFile = SHORT_MAX_FRAMES;
|
||||
packetsPerFrame = 1;
|
||||
|
@ -283,10 +283,6 @@ public:
|
||||
/** if the listening thread is running*/
|
||||
static int listening_thread_running;
|
||||
};
|
||||
/*
|
||||
|
||||
//int setUDPPortNumber(int p=-1); //sets/gets port number to listen to for data from the detector
|
||||
//int setTCPPortNumber(int p=-1); //sets/get port number for communication to client
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
@ -23,7 +23,8 @@ slsReceiverFuncs::slsReceiverFuncs(MySocketTCP *&mySocket,string const fname,int
|
||||
socket(mySocket),
|
||||
ret(OK),
|
||||
lockStatus(0),
|
||||
shortFrame(0){
|
||||
shortFrame(-1),
|
||||
packetsPerFrame(2){
|
||||
|
||||
int port_no = DEFAULT_PORTNO+2;
|
||||
ifstream infile;
|
||||
@ -171,7 +172,7 @@ int slsReceiverFuncs::decode_function(){
|
||||
#endif
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "calling function fnum = "<< fnum << hex << flist[fnum] << endl;
|
||||
cout << "calling function fnum = "<< fnum << hex << ":"<< flist[fnum] << endl;
|
||||
#endif
|
||||
|
||||
if (fnum<0 || fnum>numberOfFunctions-1)
|
||||
@ -649,26 +650,28 @@ int slsReceiverFuncs::reset_frames_caught(){
|
||||
int slsReceiverFuncs::read_frame(){
|
||||
ret=OK;
|
||||
char fName[MAX_STR_LENGTH];
|
||||
int arg = -1;
|
||||
int arg = -1,i;
|
||||
|
||||
//retval is a full frame
|
||||
int rnel = BUFFER_SIZE/(sizeof(int));
|
||||
int* retval = new int[rnel];
|
||||
//all initialized to 0
|
||||
for(i=0;i<rnel;i++) retval[i]=0;
|
||||
|
||||
//only for full frames
|
||||
int onebuffersize = BUFFER_SIZE/PACKETS_PER_FRAME;
|
||||
int onedatasize = DATA_BYTES/PACKETS_PER_FRAME;
|
||||
|
||||
|
||||
//depending on shortframe or not
|
||||
int bufferSize = BUFFER_SIZE;
|
||||
int databytes = DATA_BYTES;
|
||||
int packetsPerFrame = PACKETS_PER_FRAME;
|
||||
|
||||
if(shortFrame){
|
||||
if(shortFrame!=-1)
|
||||
bufferSize=SHORT_BUFFER_SIZE;
|
||||
databytes = SHORT_BUFFER_SIZE;
|
||||
packetsPerFrame = SHORT_PACKETS_PER_FRAME;
|
||||
}
|
||||
|
||||
int nel = bufferSize/(sizeof(int));
|
||||
int onebuffersize = bufferSize/packetsPerFrame;
|
||||
int onedatasize = databytes/packetsPerFrame;
|
||||
|
||||
|
||||
char* raw = new char[bufferSize];
|
||||
int* origVal = new int[nel];
|
||||
int* retval = new int[nel];
|
||||
int* origVal = new int[rnel];
|
||||
|
||||
//int* emptys = new int[rnel]();
|
||||
|
||||
int index=-1,index2=-1;
|
||||
int startIndex=-1;
|
||||
@ -695,6 +698,18 @@ int slsReceiverFuncs::read_frame(){
|
||||
|
||||
//got atleast first frame, read buffer
|
||||
if(ret==OK){
|
||||
if(shortFrame!=-1){;
|
||||
//get frame
|
||||
raw=slsReceiverList->readFrame(fName);
|
||||
index=(int)(*(int*)raw);
|
||||
memcpy(origVal,raw,bufferSize);
|
||||
raw=NULL;
|
||||
|
||||
//copy only the adc part
|
||||
memcpy((((char*)retval)+(SHORT_DATABYTES*shortFrame)),((char*) origVal)+4, SHORT_DATABYTES);
|
||||
|
||||
}else{
|
||||
//for full frames
|
||||
while(count<20){
|
||||
//get frame
|
||||
raw=slsReceiverList->readFrame(fName);
|
||||
@ -734,14 +749,16 @@ int slsReceiverFuncs::read_frame(){
|
||||
memcpy(retval,((char*) origVal)+4, onedatasize);
|
||||
memcpy((((char*)retval)+onedatasize), ((char*) origVal)+10+onedatasize, onedatasize);
|
||||
}
|
||||
}
|
||||
|
||||
arg=((index - startIndex)/2)-1;
|
||||
arg=((index - startIndex)/packetsPerFrame)-1;
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "\nstartIndex:" << startIndex << endl;
|
||||
cout << "fName:" << fName << endl;
|
||||
cout << "index:" << arg << endl;
|
||||
#endif
|
||||
|
||||
}else cout<<"failed to start"<<endl;
|
||||
|
||||
|
||||
@ -876,6 +893,10 @@ int slsReceiverFuncs::set_short_frame() {
|
||||
else{
|
||||
retval=slsReceiverList->setShortFrame(index);
|
||||
shortFrame = retval;
|
||||
if(shortFrame==-1)
|
||||
packetsPerFrame=PACKETS_PER_FRAME;
|
||||
else
|
||||
packetsPerFrame=SHORT_PACKETS_PER_FRAME;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -136,6 +136,9 @@ private:
|
||||
/** Short frame */
|
||||
int shortFrame;
|
||||
|
||||
/** Packets per frame */
|
||||
int packetsPerFrame;
|
||||
|
||||
static int file_des;
|
||||
static int socketDescriptor;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user