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 arg[5][50];
|
||||||
char cword[50]="", *pcword;
|
char cword[50]="", *pcword;
|
||||||
string sword;
|
string sword;
|
||||||
int shortframe=1;
|
int retval=-1;
|
||||||
int retval=-100;
|
|
||||||
|
|
||||||
if(((adc>=-1)&&(adc<=4))||(adc==-100));
|
if(((adc>=-1)&&(adc<=4))||(adc==-100));
|
||||||
else{
|
else{
|
||||||
@ -4811,11 +4810,10 @@ int slsDetector::configureMAC(int adc){
|
|||||||
//connect to receiver
|
//connect to receiver
|
||||||
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||||
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||||
if(retval==-1) shortframe=0;
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "Sending shortframe to receiver " << shortframe << std::endl;
|
std::cout << "Sending adc val to receiver " << retval << std::endl;
|
||||||
#endif
|
#endif
|
||||||
ret=thisReceiver->sendInt(fnum,retval,shortframe);
|
ret=thisReceiver->sendInt(fnum,retval,retval);
|
||||||
if(ret==FAIL)
|
if(ret==FAIL)
|
||||||
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
||||||
}
|
}
|
||||||
|
@ -393,11 +393,13 @@ void* postProcessing::processData(int delflag) {
|
|||||||
}
|
}
|
||||||
//receiver
|
//receiver
|
||||||
else{
|
else{
|
||||||
|
/*
|
||||||
while(1){
|
while(1){
|
||||||
if (checkJoinThread()) break;
|
if (checkJoinThread()) break;
|
||||||
usleep(200000);
|
usleep(200000);
|
||||||
}
|
}
|
||||||
/*
|
*/
|
||||||
|
|
||||||
pthread_mutex_lock(&mg);
|
pthread_mutex_lock(&mg);
|
||||||
int prevCaught=getReceiverCurrentFrameIndex();
|
int prevCaught=getReceiverCurrentFrameIndex();
|
||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
@ -446,7 +448,7 @@ void* postProcessing::processData(int delflag) {
|
|||||||
cout<<"****Detector returned mismatched indeices***"<<endl;
|
cout<<"****Detector returned mismatched indeices***"<<endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#define PACKETS_PER_FRAME 2
|
#define PACKETS_PER_FRAME 2
|
||||||
|
|
||||||
#define SHORT_BUFFER_SIZE 518
|
#define SHORT_BUFFER_SIZE 518
|
||||||
|
#define SHORT_DATABYTES 512
|
||||||
#define SHORT_MAX_FRAMES 100000
|
#define SHORT_MAX_FRAMES 100000
|
||||||
#define SHORT_PACKETS_PER_FRAME 1
|
#define SHORT_PACKETS_PER_FRAME 1
|
||||||
|
|
||||||
|
@ -41,11 +41,11 @@ slsReceiverFunctionList::slsReceiverFunctionList(bool shortfname):
|
|||||||
framesInFile(0),
|
framesInFile(0),
|
||||||
prevframenum(0),
|
prevframenum(0),
|
||||||
status(IDLE),
|
status(IDLE),
|
||||||
latestData(NULL),
|
latestData(NULL),/**?*/
|
||||||
udpSocket(NULL),
|
udpSocket(NULL),
|
||||||
server_port(DEFAULT_UDP_PORTNO),
|
server_port(DEFAULT_UDP_PORTNO),
|
||||||
fifo(NULL),
|
fifo(NULL),
|
||||||
shortFrame(0),
|
shortFrame(-1),
|
||||||
bufferSize(BUFFER_SIZE),
|
bufferSize(BUFFER_SIZE),
|
||||||
packetsPerFrame(2)
|
packetsPerFrame(2)
|
||||||
{
|
{
|
||||||
@ -76,7 +76,7 @@ void slsReceiverFunctionList::setEthernetInterface(char* c){
|
|||||||
int slsReceiverFunctionList::getFrameIndex(){
|
int slsReceiverFunctionList::getFrameIndex(){
|
||||||
if(startFrameIndex==-1)
|
if(startFrameIndex==-1)
|
||||||
frameIndex=0;
|
frameIndex=0;
|
||||||
else
|
else if(framesCaught)
|
||||||
frameIndex=((int)(*((int*)latestData)) - startFrameIndex)/packetsPerFrame;
|
frameIndex=((int)(*((int*)latestData)) - startFrameIndex)/packetsPerFrame;
|
||||||
return frameIndex;
|
return frameIndex;
|
||||||
}
|
}
|
||||||
@ -86,8 +86,9 @@ int slsReceiverFunctionList::getFrameIndex(){
|
|||||||
int slsReceiverFunctionList::getAcquisitionIndex(){
|
int slsReceiverFunctionList::getAcquisitionIndex(){
|
||||||
if(startAcquisitionIndex==-1)
|
if(startAcquisitionIndex==-1)
|
||||||
acquisitionIndex=0;
|
acquisitionIndex=0;
|
||||||
else
|
else if(framesCaught)
|
||||||
acquisitionIndex=((int)(*((int*)latestData)) - startAcquisitionIndex)/packetsPerFrame;
|
acquisitionIndex=((int)(*((int*)latestData)) - startAcquisitionIndex)/packetsPerFrame;
|
||||||
|
|
||||||
return acquisitionIndex;
|
return acquisitionIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,9 +186,9 @@ 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){
|
||||||
cout << "Stopping new acquisition threadddd ...." << endl;
|
cout << "Stopping new acquisition threadddd ...." << endl;
|
||||||
@ -200,6 +201,7 @@ int slsReceiverFunctionList::stopReceiver(){
|
|||||||
//stop writing thread
|
//stop writing thread
|
||||||
pthread_join(writing_thread,NULL);
|
pthread_join(writing_thread,NULL);
|
||||||
if(fifo) delete fifo;
|
if(fifo) delete fifo;
|
||||||
|
//if(latestData) delete latestData;/**new*/
|
||||||
}
|
}
|
||||||
cout << "Status:" << status << endl;
|
cout << "Status:" << status << endl;
|
||||||
|
|
||||||
@ -280,7 +282,7 @@ int slsReceiverFunctionList::startListening(){
|
|||||||
//start of acquisition
|
//start of acquisition
|
||||||
if(startAcquisitionIndex==-1){
|
if(startAcquisitionIndex==-1){
|
||||||
startAcquisitionIndex=startFrameIndex;
|
startAcquisitionIndex=startFrameIndex;
|
||||||
//cout<<"startAcquisitionIndex:"<<startAcquisitionIndex<<endl;
|
cout<<"startAcquisitionIndex:"<<startAcquisitionIndex<<endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -291,7 +293,7 @@ int slsReceiverFunctionList::startListening(){
|
|||||||
if(fifo->isFull())
|
if(fifo->isFull())
|
||||||
;//cout<<"**********************FIFO FULLLLLLLL************************"<<endl;
|
;//cout<<"**********************FIFO FULLLLLLLL************************"<<endl;
|
||||||
else{
|
else{
|
||||||
//cout<<"read index:"<<(int)(*(int*)buffer)<<endl;
|
//cout<<"read index:"<<dec<<(int)(*(int*)buffer)<<endl;
|
||||||
dataReadFrame = new dataStruct;
|
dataReadFrame = new dataStruct;
|
||||||
dataReadFrame->buffer=buffer;
|
dataReadFrame->buffer=buffer;
|
||||||
dataReadFrame->rc=rc;
|
dataReadFrame->rc=rc;
|
||||||
@ -404,7 +406,7 @@ int slsReceiverFunctionList::startWriting(){
|
|||||||
framesCaught++;
|
framesCaught++;
|
||||||
totalFramesCaught++;
|
totalFramesCaught++;
|
||||||
memcpy(latestData,dataWriteFrame->buffer,bufferSize);
|
memcpy(latestData,dataWriteFrame->buffer,bufferSize);
|
||||||
//cout<<"list write \t index:"<<(int)(*(int*)latestData)<<endl;
|
//cout<<"write index:"<<(int)(*(int*)latestData)<<endl;
|
||||||
if(enableFileWrite)
|
if(enableFileWrite)
|
||||||
fwrite(dataWriteFrame->buffer, 1, dataWriteFrame->rc, sfilefd);
|
fwrite(dataWriteFrame->buffer, 1, dataWriteFrame->rc, sfilefd);
|
||||||
framesInFile++;
|
framesInFile++;
|
||||||
@ -444,7 +446,7 @@ char* slsReceiverFunctionList::readFrame(char* c){
|
|||||||
int slsReceiverFunctionList::setShortFrame(int i){
|
int slsReceiverFunctionList::setShortFrame(int i){
|
||||||
shortFrame=i;
|
shortFrame=i;
|
||||||
|
|
||||||
if(shortFrame){
|
if(shortFrame!=-1){
|
||||||
bufferSize = SHORT_BUFFER_SIZE;
|
bufferSize = SHORT_BUFFER_SIZE;
|
||||||
maxFramesPerFile = SHORT_MAX_FRAMES;
|
maxFramesPerFile = SHORT_MAX_FRAMES;
|
||||||
packetsPerFrame = 1;
|
packetsPerFrame = 1;
|
||||||
|
@ -283,10 +283,6 @@ public:
|
|||||||
/** if the listening thread is running*/
|
/** if the listening thread is running*/
|
||||||
static int listening_thread_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
|
#endif
|
||||||
|
@ -23,7 +23,8 @@ slsReceiverFuncs::slsReceiverFuncs(MySocketTCP *&mySocket,string const fname,int
|
|||||||
socket(mySocket),
|
socket(mySocket),
|
||||||
ret(OK),
|
ret(OK),
|
||||||
lockStatus(0),
|
lockStatus(0),
|
||||||
shortFrame(0){
|
shortFrame(-1),
|
||||||
|
packetsPerFrame(2){
|
||||||
|
|
||||||
int port_no = DEFAULT_PORTNO+2;
|
int port_no = DEFAULT_PORTNO+2;
|
||||||
ifstream infile;
|
ifstream infile;
|
||||||
@ -171,7 +172,7 @@ int slsReceiverFuncs::decode_function(){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "calling function fnum = "<< fnum << hex << flist[fnum] << endl;
|
cout << "calling function fnum = "<< fnum << hex << ":"<< flist[fnum] << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fnum<0 || fnum>numberOfFunctions-1)
|
if (fnum<0 || fnum>numberOfFunctions-1)
|
||||||
@ -649,26 +650,28 @@ int slsReceiverFuncs::reset_frames_caught(){
|
|||||||
int slsReceiverFuncs::read_frame(){
|
int slsReceiverFuncs::read_frame(){
|
||||||
ret=OK;
|
ret=OK;
|
||||||
char fName[MAX_STR_LENGTH];
|
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 bufferSize = BUFFER_SIZE;
|
||||||
int databytes = DATA_BYTES;
|
if(shortFrame!=-1)
|
||||||
int packetsPerFrame = PACKETS_PER_FRAME;
|
bufferSize=SHORT_BUFFER_SIZE;
|
||||||
|
|
||||||
if(shortFrame){
|
|
||||||
bufferSize = SHORT_BUFFER_SIZE;
|
|
||||||
databytes = SHORT_BUFFER_SIZE;
|
|
||||||
packetsPerFrame = SHORT_PACKETS_PER_FRAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
int nel = bufferSize/(sizeof(int));
|
int nel = bufferSize/(sizeof(int));
|
||||||
int onebuffersize = bufferSize/packetsPerFrame;
|
|
||||||
int onedatasize = databytes/packetsPerFrame;
|
|
||||||
|
|
||||||
|
|
||||||
char* raw = new char[bufferSize];
|
char* raw = new char[bufferSize];
|
||||||
int* origVal = new int[nel];
|
int* origVal = new int[rnel];
|
||||||
int* retval = new int[nel];
|
|
||||||
|
//int* emptys = new int[rnel]();
|
||||||
|
|
||||||
int index=-1,index2=-1;
|
int index=-1,index2=-1;
|
||||||
int startIndex=-1;
|
int startIndex=-1;
|
||||||
@ -695,6 +698,18 @@ int slsReceiverFuncs::read_frame(){
|
|||||||
|
|
||||||
//got atleast first frame, read buffer
|
//got atleast first frame, read buffer
|
||||||
if(ret==OK){
|
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){
|
while(count<20){
|
||||||
//get frame
|
//get frame
|
||||||
raw=slsReceiverList->readFrame(fName);
|
raw=slsReceiverList->readFrame(fName);
|
||||||
@ -734,14 +749,16 @@ int slsReceiverFuncs::read_frame(){
|
|||||||
memcpy(retval,((char*) origVal)+4, onedatasize);
|
memcpy(retval,((char*) origVal)+4, onedatasize);
|
||||||
memcpy((((char*)retval)+onedatasize), ((char*) origVal)+10+onedatasize, onedatasize);
|
memcpy((((char*)retval)+onedatasize), ((char*) origVal)+10+onedatasize, onedatasize);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
arg=((index - startIndex)/2)-1;
|
arg=((index - startIndex)/packetsPerFrame)-1;
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "\nstartIndex:" << startIndex << endl;
|
cout << "\nstartIndex:" << startIndex << endl;
|
||||||
cout << "fName:" << fName << endl;
|
cout << "fName:" << fName << endl;
|
||||||
cout << "index:" << arg << endl;
|
cout << "index:" << arg << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}else cout<<"failed to start"<<endl;
|
}else cout<<"failed to start"<<endl;
|
||||||
|
|
||||||
|
|
||||||
@ -876,6 +893,10 @@ int slsReceiverFuncs::set_short_frame() {
|
|||||||
else{
|
else{
|
||||||
retval=slsReceiverList->setShortFrame(index);
|
retval=slsReceiverList->setShortFrame(index);
|
||||||
shortFrame = retval;
|
shortFrame = retval;
|
||||||
|
if(shortFrame==-1)
|
||||||
|
packetsPerFrame=PACKETS_PER_FRAME;
|
||||||
|
else
|
||||||
|
packetsPerFrame=SHORT_PACKETS_PER_FRAME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -136,6 +136,9 @@ private:
|
|||||||
/** Short frame */
|
/** Short frame */
|
||||||
int shortFrame;
|
int shortFrame;
|
||||||
|
|
||||||
|
/** Packets per frame */
|
||||||
|
int packetsPerFrame;
|
||||||
|
|
||||||
static int file_des;
|
static int file_des;
|
||||||
static int socketDescriptor;
|
static int socketDescriptor;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user