mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 10:00: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){
|
||||
cerr << "Can not bind socket "<<endl;
|
||||
cerr << "Can not bind socket "<< endl;
|
||||
socketDescriptor=-1;
|
||||
return;
|
||||
}
|
||||
@ -349,7 +349,6 @@ protocol(p), is_a_server(0), socketDescriptor(-1),file_des(-1), packet_size(DEFA
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
int getFileDes(){return file_des;};
|
||||
|
||||
int getsocketDescriptor(){return socketDescriptor;};
|
||||
|
||||
/** @short free connection */
|
||||
void Disconnect(){
|
||||
|
@ -520,11 +520,13 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
thisDetector->timerValue[MEASUREMENTS_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*/
|
||||
strcpy(thisDetector->settingsDir,getenv("HOME"));
|
||||
strcpy(thisDetector->calDir,getenv("HOME"));
|
||||
@ -1338,11 +1340,13 @@ int slsDetector::setNumberOfModules(int n, dimension d){
|
||||
if (dr==24)
|
||||
dr=32;
|
||||
|
||||
if (thisDetector->timerValue[PROBES_NUMBER]==0) {
|
||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*dr/8;
|
||||
} else {
|
||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
|
||||
}
|
||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*dr/8;
|
||||
|
||||
if(thisDetector->myDetectorType==MYTHEN){
|
||||
if (thisDetector->timerValue[PROBES_NUMBER]!=0)
|
||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
|
||||
}
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Data size is " << thisDetector->dataBytes << std::endl;
|
||||
@ -3824,12 +3828,15 @@ int slsDetector::setDynamicRange(int n){
|
||||
|
||||
if (ret!=FAIL && retval>0) {
|
||||
/* 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;
|
||||
} else {
|
||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
|
||||
}
|
||||
|
||||
|
||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*retval/8;
|
||||
|
||||
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)
|
||||
thisDetector->dynamicRange=24;
|
||||
else
|
||||
@ -5654,7 +5661,6 @@ int slsDetector::resetFramesCaught(int index){
|
||||
|
||||
|
||||
int* slsDetector::readFrameFromReceiver(char* fName, int &fIndex){
|
||||
//cout<<"databytes:"<<thisDetector->dataBytes<<" headerlength:"<<HEADERLENGTH<<endl;
|
||||
int fnum=F_READ_FRAME;
|
||||
int nel=(thisDetector->dataBytes+HEADERLENGTH)/sizeof(int);//2572/
|
||||
int* retval=new int[nel];
|
||||
|
@ -5,15 +5,24 @@
|
||||
#include "MySocketTCP.h"
|
||||
#include "slsReceiver_funcs.h"
|
||||
|
||||
|
||||
#include <signal.h> //SIGINT
|
||||
|
||||
#include <iostream>
|
||||
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 ret = slsDetectorDefs::OK;
|
||||
MySocketTCP *socket = NULL;
|
||||
MySocketTCP *mysocket = NULL;
|
||||
string fname = "";
|
||||
bool shortfname = false;
|
||||
|
||||
@ -33,11 +42,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
//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)
|
||||
return -1;
|
||||
|
||||
|
||||
//Catch signal SIGINT to close files properly
|
||||
signal(SIGINT,closeFile);
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "Function table assigned." << endl;
|
||||
#endif
|
||||
@ -51,7 +64,7 @@ int main(int argc, char *argv[])
|
||||
#ifdef VERY_VERBOSE
|
||||
cout << "Waiting for client call" << endl;
|
||||
#endif
|
||||
if(socket->Connect()>=0){
|
||||
if(mysocket->Connect()>=0){
|
||||
#ifdef VERY_VERBOSE
|
||||
cout << "Conenction accepted" << endl;
|
||||
#endif
|
||||
@ -59,14 +72,14 @@ int main(int argc, char *argv[])
|
||||
#ifdef VERY_VERBOSE
|
||||
cout << "function executed" << endl;
|
||||
#endif
|
||||
socket->Disconnect();
|
||||
mysocket->Disconnect();
|
||||
#ifdef VERY_VERBOSE
|
||||
cout << "connection closed" << endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
delete socket;
|
||||
delete mysocket;
|
||||
cout << "Goodbye!" << endl;
|
||||
|
||||
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(){
|
||||
#ifdef VERBOSE
|
||||
cout << "Starting Receiver" << endl;
|
||||
@ -188,9 +176,6 @@ int slsReceiverFunctionList::startListening(){
|
||||
frameIndex=0;
|
||||
shortFileNameIndex=1;
|
||||
|
||||
//Catch signal SIGINT to close files properly
|
||||
signal(SIGINT,closeFile);
|
||||
|
||||
|
||||
//create file name
|
||||
if(!frameIndexNeeded)
|
||||
@ -280,6 +265,7 @@ int slsReceiverFunctionList::startListening(){
|
||||
//close file
|
||||
fclose(sfilefd);
|
||||
#ifdef VERBOSE
|
||||
cout << "listening_thread_running:" << listening_thread_running << endl;
|
||||
cout << "sfield:" << (int)sfilefd << endl;
|
||||
#endif
|
||||
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
/**
|
||||
* Close File
|
||||
*/
|
||||
static void closeFile(int p);
|
||||
//static void closeFile(int p);
|
||||
|
||||
/**
|
||||
* Starts Receiver - starts to listen for packets
|
||||
@ -186,7 +186,7 @@ private:
|
||||
int framesInFile;
|
||||
|
||||
/** if the listening thread is running*/
|
||||
static int listening_thread_running;
|
||||
//static int listening_thread_running;
|
||||
|
||||
/** thread listening to packets */
|
||||
pthread_t listening_thread;
|
||||
@ -195,7 +195,7 @@ private:
|
||||
runStatus status;
|
||||
|
||||
/** File Descriptor */
|
||||
static FILE *sfilefd;
|
||||
//static FILE *sfilefd;
|
||||
|
||||
/** Receiver buffer */
|
||||
char buffer[BUFFER_SIZE];
|
||||
@ -206,6 +206,12 @@ private:
|
||||
/** Server UDP 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 "slsReceiverFunctionList.h"
|
||||
|
||||
//#include <signal.h> //SIGINT
|
||||
|
||||
#include <iostream>
|
||||
#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):
|
||||
socket(mySocket),
|
||||
@ -97,8 +97,9 @@ slsReceiverFuncs::slsReceiverFuncs(MySocketTCP *&mySocket,string const fname,int
|
||||
function_table();
|
||||
slsReceiverList = new slsReceiverFunctionList(shortfname);
|
||||
|
||||
//Catch signal SIGINT to close files properly
|
||||
//signal(SIGINT,closeFile);
|
||||
|
||||
file_des=socket->getFileDes();
|
||||
socketDescriptor=socket->getsocketDescriptor();
|
||||
|
||||
success = OK;
|
||||
}
|
||||
@ -174,7 +175,6 @@ int slsReceiverFuncs::decode_function(){
|
||||
if (ret==FAIL)
|
||||
cout << "Error executing the function = " << fnum << endl;
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -198,12 +198,22 @@ int slsReceiverFuncs::M_nofunc(){
|
||||
|
||||
|
||||
|
||||
/*
|
||||
void slsReceiverFuncs::closeFile(int p){
|
||||
//if(socket)
|
||||
slsReceiverFunctionList::closeFile();
|
||||
char *buf;
|
||||
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() {
|
||||
@ -588,9 +598,9 @@ int slsReceiverFuncs::read_frame(){
|
||||
int count=0;
|
||||
do{
|
||||
if(count>0){
|
||||
cout << endl << "unmatching: index:" << index <<" index2:" << index2 << endl;
|
||||
cout << endl << "unmatching/wrong order: index:" << index <<" index2:" << index2 << endl;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
@ -601,7 +611,7 @@ int slsReceiverFuncs::read_frame(){
|
||||
index2= (int)(*((int*)retval2));
|
||||
count++;
|
||||
|
||||
}while((index%2)==(index2%2));
|
||||
}while(((index%2)==(index2%2))||(index+1!=index2));
|
||||
|
||||
fIndex=((int)(*((int*)retval)) - startIndex)/2;
|
||||
arg[0]=fIndex-1;
|
||||
@ -750,6 +760,7 @@ int slsReceiverFuncs::set_port() {
|
||||
socket->Disconnect();
|
||||
delete socket;
|
||||
socket = mySocket;
|
||||
file_des=socket->getFileDes();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
int M_nofunc();
|
||||
|
||||
/** Close File */
|
||||
//static void closeFile(int p);
|
||||
static void closeFile(int p);
|
||||
|
||||
/** Set File name without frame index, file index and extension */
|
||||
int set_file_name();
|
||||
@ -96,11 +96,11 @@ public:
|
||||
/** Execute command */
|
||||
int exec_command();
|
||||
|
||||
private:
|
||||
//private:
|
||||
|
||||
/** Socket */
|
||||
MySocketTCP*& socket;
|
||||
|
||||
private:
|
||||
/** slsReceiverFunctionList object */
|
||||
slsReceiverFunctionList *slsReceiverList;
|
||||
|
||||
@ -119,6 +119,9 @@ private:
|
||||
/** Lock Status if server locked to a client */
|
||||
int lockStatus;
|
||||
|
||||
static int file_des;
|
||||
static int socketDescriptor;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user