mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 18:10:40 +02:00
fixed gui expecting more databytes from receiver, cuz of probes changing databytes
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@359 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
5236aa7cce
commit
d0d7eac553
@ -189,7 +189,7 @@ protocol(p), is_a_server(0), socketDescriptor(-1),file_des(-1), packet_size(DEFA
|
|||||||
|
|
||||||
|
|
||||||
if(bind(socketDescriptor,(struct sockaddr *) &serverAddress,sizeof(serverAddress))<0){
|
if(bind(socketDescriptor,(struct sockaddr *) &serverAddress,sizeof(serverAddress))<0){
|
||||||
cerr << "Can not bind socket "<<endl;
|
cerr << "Can not bind socket "<< endl;
|
||||||
socketDescriptor=-1;
|
socketDescriptor=-1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -349,7 +349,6 @@ protocol(p), is_a_server(0), socketDescriptor(-1),file_des(-1), packet_size(DEFA
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return file_des;
|
return file_des;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,6 +356,9 @@ protocol(p), is_a_server(0), socketDescriptor(-1),file_des(-1), packet_size(DEFA
|
|||||||
return ntohs(serverAddress.sin_port);
|
return ntohs(serverAddress.sin_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getFileDes(){return file_des;};
|
||||||
|
|
||||||
|
int getsocketDescriptor(){return socketDescriptor;};
|
||||||
|
|
||||||
/** @short free connection */
|
/** @short free connection */
|
||||||
void Disconnect(){
|
void Disconnect(){
|
||||||
|
@ -520,11 +520,13 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
|||||||
thisDetector->timerValue[MEASUREMENTS_NUMBER]=1;
|
thisDetector->timerValue[MEASUREMENTS_NUMBER]=1;
|
||||||
thisDetector->timerValue[CYCLES_NUMBER]=1;
|
thisDetector->timerValue[CYCLES_NUMBER]=1;
|
||||||
|
|
||||||
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*thisDetector->dynamicRange/8;
|
||||||
|
|
||||||
|
if(thisDetector->myDetectorType==MYTHEN){
|
||||||
|
if (thisDetector->dynamicRange==24 || thisDetector->timerValue[PROBES_NUMBER]>0)
|
||||||
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
|
||||||
|
}
|
||||||
|
|
||||||
if (thisDetector->dynamicRange==24 || thisDetector->timerValue[PROBES_NUMBER]>0)
|
|
||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
|
|
||||||
else
|
|
||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*thisDetector->dynamicRange/8;
|
|
||||||
/** set trimDsdir, calDir to default to home directory*/
|
/** set trimDsdir, calDir to default to home directory*/
|
||||||
strcpy(thisDetector->settingsDir,getenv("HOME"));
|
strcpy(thisDetector->settingsDir,getenv("HOME"));
|
||||||
strcpy(thisDetector->calDir,getenv("HOME"));
|
strcpy(thisDetector->calDir,getenv("HOME"));
|
||||||
@ -1338,11 +1340,13 @@ int slsDetector::setNumberOfModules(int n, dimension d){
|
|||||||
if (dr==24)
|
if (dr==24)
|
||||||
dr=32;
|
dr=32;
|
||||||
|
|
||||||
if (thisDetector->timerValue[PROBES_NUMBER]==0) {
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*dr/8;
|
||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*dr/8;
|
|
||||||
} else {
|
if(thisDetector->myDetectorType==MYTHEN){
|
||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
|
if (thisDetector->timerValue[PROBES_NUMBER]!=0)
|
||||||
}
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "Data size is " << thisDetector->dataBytes << std::endl;
|
std::cout<< "Data size is " << thisDetector->dataBytes << std::endl;
|
||||||
@ -3824,12 +3828,15 @@ int slsDetector::setDynamicRange(int n){
|
|||||||
|
|
||||||
if (ret!=FAIL && retval>0) {
|
if (ret!=FAIL && retval>0) {
|
||||||
/* checking the number of probes to chose the data size */
|
/* checking the number of probes to chose the data size */
|
||||||
if (thisDetector->timerValue[PROBES_NUMBER]==0) {
|
|
||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*retval/8;
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*retval/8;
|
||||||
} else {
|
|
||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
|
if(thisDetector->myDetectorType==MYTHEN){
|
||||||
}
|
if (thisDetector->timerValue[PROBES_NUMBER]!=0)
|
||||||
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (retval==32)
|
if (retval==32)
|
||||||
thisDetector->dynamicRange=24;
|
thisDetector->dynamicRange=24;
|
||||||
else
|
else
|
||||||
@ -5654,7 +5661,6 @@ int slsDetector::resetFramesCaught(int index){
|
|||||||
|
|
||||||
|
|
||||||
int* slsDetector::readFrameFromReceiver(char* fName, int &fIndex){
|
int* slsDetector::readFrameFromReceiver(char* fName, int &fIndex){
|
||||||
//cout<<"databytes:"<<thisDetector->dataBytes<<" headerlength:"<<HEADERLENGTH<<endl;
|
|
||||||
int fnum=F_READ_FRAME;
|
int fnum=F_READ_FRAME;
|
||||||
int nel=(thisDetector->dataBytes+HEADERLENGTH)/sizeof(int);//2572/
|
int nel=(thisDetector->dataBytes+HEADERLENGTH)/sizeof(int);//2572/
|
||||||
int* retval=new int[nel];
|
int* retval=new int[nel];
|
||||||
|
@ -5,15 +5,24 @@
|
|||||||
#include "MySocketTCP.h"
|
#include "MySocketTCP.h"
|
||||||
#include "slsReceiver_funcs.h"
|
#include "slsReceiver_funcs.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <signal.h> //SIGINT
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
//static MySocketTCP *mysocket = NULL;
|
||||||
|
|
||||||
|
void closeFile(int p){cout<<"in closefile in receiver"<<endl;
|
||||||
|
slsReceiverFuncs::closeFile(p);
|
||||||
|
//mysocket->Disconnect();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ret = slsDetectorDefs::OK;
|
int ret = slsDetectorDefs::OK;
|
||||||
MySocketTCP *socket = NULL;
|
MySocketTCP *mysocket = NULL;
|
||||||
string fname = "";
|
string fname = "";
|
||||||
bool shortfname = false;
|
bool shortfname = false;
|
||||||
|
|
||||||
@ -33,11 +42,15 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
|
|
||||||
//reads config file, creates socket, assigns function table
|
//reads config file, creates socket, assigns function table
|
||||||
slsReceiverFuncs *receiver = new slsReceiverFuncs(socket,fname,ret, shortfname);
|
slsReceiverFuncs *receiver = new slsReceiverFuncs(mysocket,fname,ret, shortfname);
|
||||||
if(ret==slsDetectorDefs::FAIL)
|
if(ret==slsDetectorDefs::FAIL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
|
//Catch signal SIGINT to close files properly
|
||||||
|
signal(SIGINT,closeFile);
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Function table assigned." << endl;
|
cout << "Function table assigned." << endl;
|
||||||
#endif
|
#endif
|
||||||
@ -51,7 +64,7 @@ int main(int argc, char *argv[])
|
|||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
cout << "Waiting for client call" << endl;
|
cout << "Waiting for client call" << endl;
|
||||||
#endif
|
#endif
|
||||||
if(socket->Connect()>=0){
|
if(mysocket->Connect()>=0){
|
||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
cout << "Conenction accepted" << endl;
|
cout << "Conenction accepted" << endl;
|
||||||
#endif
|
#endif
|
||||||
@ -59,14 +72,14 @@ int main(int argc, char *argv[])
|
|||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
cout << "function executed" << endl;
|
cout << "function executed" << endl;
|
||||||
#endif
|
#endif
|
||||||
socket->Disconnect();
|
mysocket->Disconnect();
|
||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
cout << "connection closed" << endl;
|
cout << "connection closed" << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete socket;
|
delete mysocket;
|
||||||
cout << "Goodbye!" << endl;
|
cout << "Goodbye!" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -106,18 +106,6 @@ bool slsReceiverFunctionList::resetTotalFramesCaught(bool i){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void slsReceiverFunctionList::closeFile(int p){
|
|
||||||
if(listening_thread_running){
|
|
||||||
cout << "Closing file and Exiting." << endl;
|
|
||||||
fclose(sfilefd);
|
|
||||||
}
|
|
||||||
//exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsReceiverFunctionList::startReceiver(){
|
int slsReceiverFunctionList::startReceiver(){
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Starting Receiver" << endl;
|
cout << "Starting Receiver" << endl;
|
||||||
@ -188,9 +176,6 @@ int slsReceiverFunctionList::startListening(){
|
|||||||
frameIndex=0;
|
frameIndex=0;
|
||||||
shortFileNameIndex=1;
|
shortFileNameIndex=1;
|
||||||
|
|
||||||
//Catch signal SIGINT to close files properly
|
|
||||||
signal(SIGINT,closeFile);
|
|
||||||
|
|
||||||
|
|
||||||
//create file name
|
//create file name
|
||||||
if(!frameIndexNeeded)
|
if(!frameIndexNeeded)
|
||||||
@ -280,6 +265,7 @@ int slsReceiverFunctionList::startListening(){
|
|||||||
//close file
|
//close file
|
||||||
fclose(sfilefd);
|
fclose(sfilefd);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
|
cout << "listening_thread_running:" << listening_thread_running << endl;
|
||||||
cout << "sfield:" << (int)sfilefd << endl;
|
cout << "sfield:" << (int)sfilefd << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Close File
|
* Close File
|
||||||
*/
|
*/
|
||||||
static void closeFile(int p);
|
//static void closeFile(int p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts Receiver - starts to listen for packets
|
* Starts Receiver - starts to listen for packets
|
||||||
@ -186,7 +186,7 @@ private:
|
|||||||
int framesInFile;
|
int framesInFile;
|
||||||
|
|
||||||
/** if the listening thread is running*/
|
/** if the listening thread is running*/
|
||||||
static int listening_thread_running;
|
//static int listening_thread_running;
|
||||||
|
|
||||||
/** thread listening to packets */
|
/** thread listening to packets */
|
||||||
pthread_t listening_thread;
|
pthread_t listening_thread;
|
||||||
@ -195,7 +195,7 @@ private:
|
|||||||
runStatus status;
|
runStatus status;
|
||||||
|
|
||||||
/** File Descriptor */
|
/** File Descriptor */
|
||||||
static FILE *sfilefd;
|
//static FILE *sfilefd;
|
||||||
|
|
||||||
/** Receiver buffer */
|
/** Receiver buffer */
|
||||||
char buffer[BUFFER_SIZE];
|
char buffer[BUFFER_SIZE];
|
||||||
@ -206,6 +206,12 @@ private:
|
|||||||
/** Server UDP Port*/
|
/** Server UDP Port*/
|
||||||
int server_port;
|
int server_port;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/** File Descriptor */
|
||||||
|
static FILE *sfilefd;
|
||||||
|
|
||||||
|
/** if the listening thread is running*/
|
||||||
|
static int listening_thread_running;
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include "slsReceiver_funcs.h"
|
#include "slsReceiver_funcs.h"
|
||||||
#include "slsReceiverFunctionList.h"
|
#include "slsReceiverFunctionList.h"
|
||||||
|
|
||||||
//#include <signal.h> //SIGINT
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -17,7 +16,8 @@ using namespace std;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int slsReceiverFuncs::file_des(-1);
|
||||||
|
int slsReceiverFuncs::socketDescriptor(-1);
|
||||||
|
|
||||||
slsReceiverFuncs::slsReceiverFuncs(MySocketTCP *&mySocket,string const fname,int &success, bool shortfname):
|
slsReceiverFuncs::slsReceiverFuncs(MySocketTCP *&mySocket,string const fname,int &success, bool shortfname):
|
||||||
socket(mySocket),
|
socket(mySocket),
|
||||||
@ -97,8 +97,9 @@ slsReceiverFuncs::slsReceiverFuncs(MySocketTCP *&mySocket,string const fname,int
|
|||||||
function_table();
|
function_table();
|
||||||
slsReceiverList = new slsReceiverFunctionList(shortfname);
|
slsReceiverList = new slsReceiverFunctionList(shortfname);
|
||||||
|
|
||||||
//Catch signal SIGINT to close files properly
|
|
||||||
//signal(SIGINT,closeFile);
|
file_des=socket->getFileDes();
|
||||||
|
socketDescriptor=socket->getsocketDescriptor();
|
||||||
|
|
||||||
success = OK;
|
success = OK;
|
||||||
}
|
}
|
||||||
@ -174,7 +175,6 @@ int slsReceiverFuncs::decode_function(){
|
|||||||
if (ret==FAIL)
|
if (ret==FAIL)
|
||||||
cout << "Error executing the function = " << fnum << endl;
|
cout << "Error executing the function = " << fnum << endl;
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,12 +198,22 @@ int slsReceiverFuncs::M_nofunc(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
void slsReceiverFuncs::closeFile(int p){
|
void slsReceiverFuncs::closeFile(int p){
|
||||||
//if(socket)
|
char *buf;
|
||||||
slsReceiverFunctionList::closeFile();
|
char buffer[1];
|
||||||
|
|
||||||
|
|
||||||
|
if(slsReceiverFunctionList::listening_thread_running)
|
||||||
|
fclose(slsReceiverFunctionList::sfilefd);
|
||||||
|
|
||||||
|
|
||||||
|
close(file_des);
|
||||||
|
shutdown(socketDescriptor,SHUT_RDWR);
|
||||||
|
close(socketDescriptor);
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsReceiverFuncs::set_file_name() {
|
int slsReceiverFuncs::set_file_name() {
|
||||||
@ -588,9 +598,9 @@ int slsReceiverFuncs::read_frame(){
|
|||||||
int count=0;
|
int count=0;
|
||||||
do{
|
do{
|
||||||
if(count>0){
|
if(count>0){
|
||||||
cout << endl << "unmatching: index:" << index <<" index2:" << index2 << endl;
|
cout << endl << "unmatching/wrong order: index:" << index <<" index2:" << index2 << endl;
|
||||||
if(count>10){
|
if(count>10){
|
||||||
strcpy(mess,"unmatching index. could not read frame.\n");
|
strcpy(mess,"unmatching index/wrong order. could not read frame.\n");
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -601,7 +611,7 @@ int slsReceiverFuncs::read_frame(){
|
|||||||
index2= (int)(*((int*)retval2));
|
index2= (int)(*((int*)retval2));
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
}while((index%2)==(index2%2));
|
}while(((index%2)==(index2%2))||(index+1!=index2));
|
||||||
|
|
||||||
fIndex=((int)(*((int*)retval)) - startIndex)/2;
|
fIndex=((int)(*((int*)retval)) - startIndex)/2;
|
||||||
arg[0]=fIndex-1;
|
arg[0]=fIndex-1;
|
||||||
@ -750,6 +760,7 @@ int slsReceiverFuncs::set_port() {
|
|||||||
socket->Disconnect();
|
socket->Disconnect();
|
||||||
delete socket;
|
delete socket;
|
||||||
socket = mySocket;
|
socket = mySocket;
|
||||||
|
file_des=socket->getFileDes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
int M_nofunc();
|
int M_nofunc();
|
||||||
|
|
||||||
/** Close File */
|
/** Close File */
|
||||||
//static void closeFile(int p);
|
static void closeFile(int p);
|
||||||
|
|
||||||
/** Set File name without frame index, file index and extension */
|
/** Set File name without frame index, file index and extension */
|
||||||
int set_file_name();
|
int set_file_name();
|
||||||
@ -96,11 +96,11 @@ public:
|
|||||||
/** Execute command */
|
/** Execute command */
|
||||||
int exec_command();
|
int exec_command();
|
||||||
|
|
||||||
private:
|
//private:
|
||||||
|
|
||||||
/** Socket */
|
/** Socket */
|
||||||
MySocketTCP*& socket;
|
MySocketTCP*& socket;
|
||||||
|
private:
|
||||||
/** slsReceiverFunctionList object */
|
/** slsReceiverFunctionList object */
|
||||||
slsReceiverFunctionList *slsReceiverList;
|
slsReceiverFunctionList *slsReceiverList;
|
||||||
|
|
||||||
@ -119,6 +119,9 @@ private:
|
|||||||
/** Lock Status if server locked to a client */
|
/** Lock Status if server locked to a client */
|
||||||
int lockStatus;
|
int lockStatus;
|
||||||
|
|
||||||
|
static int file_des;
|
||||||
|
static int socketDescriptor;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user