mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 00:07:13 +02:00
couldnt commit changes, tried to merge, probably messy
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@139 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -2,7 +2,6 @@
|
|||||||
#include "usersFunctions.h"
|
#include "usersFunctions.h"
|
||||||
#include "slsDetectorCommand.h"
|
#include "slsDetectorCommand.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/ipc.h>
|
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
@ -3005,56 +3004,60 @@ int* slsDetector::readFrame(){
|
|||||||
return retval;
|
return retval;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int* slsDetector::getDataFromDetector(){
|
int* slsDetector::getDataFromDetector(){
|
||||||
|
int nel=thisDetector->dataBytes/sizeof(int);
|
||||||
int nel=thisDetector->dataBytes/sizeof(int);
|
int n;
|
||||||
int n;
|
int* retval=new int[nel];
|
||||||
int* retval=new int[nel];
|
int ret=FAIL;
|
||||||
int ret=FAIL;
|
char mess[100]="Nothing";
|
||||||
char mess[100]="Nothing";
|
|
||||||
#ifdef VERY_VERBOSE
|
|
||||||
int i;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "getting data "<< thisDetector->dataBytes << " " << nel<< std::endl;
|
std::cout<< "getting data "<< thisDetector->dataBytes << " " << nel<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "ret=" << ret << endl;
|
cout << "ret=" << ret << endl;
|
||||||
#endif
|
#endif
|
||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
n= controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
n= controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||||
if (ret==FAIL) {
|
if (ret==FAIL) {
|
||||||
thisDetector->stoppedFlag=1;
|
thisDetector->stoppedFlag=1;
|
||||||
std::cout<< "Detector returned: " << mess << " " << n << std::endl;
|
std::cout<< "Detector returned: " << mess << " " << n << std::endl;
|
||||||
} else {
|
} else {
|
||||||
;
|
;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "Detector successfully returned: " << mess << " " << n << std::endl;
|
std::cout<< "Detector successfully returned: " << mess << " " << n << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
delete [] retval;
|
delete [] retval;
|
||||||
retval=NULL;
|
retval=NULL;
|
||||||
} else {
|
} else {
|
||||||
n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes);
|
n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes);
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "Received "<< n << " data bytes" << std::endl;
|
std::cout<< "Received "<< n << " data bytes" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (n!=thisDetector->dataBytes) {
|
if (n!=thisDetector->dataBytes) {
|
||||||
std::cout<< "wrong data size received: received " << n << " but expected " << thisDetector->dataBytes << std::endl;
|
std::cout<< "wrong data size received: received " << n << " but expected " << thisDetector->dataBytes << std::endl;
|
||||||
thisDetector->stoppedFlag=1;
|
thisDetector->stoppedFlag=1;
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
delete [] retval;
|
delete [] retval;
|
||||||
retval=NULL;
|
retval=NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retval;
|
|
||||||
|
return retval;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int* slsDetector::readAll(){
|
int* slsDetector::readAll(){
|
||||||
|
|
||||||
int fnum=F_READ_ALL;
|
int fnum=F_READ_ALL;
|
||||||
@ -3068,6 +3071,7 @@ int* slsDetector::readAll(){
|
|||||||
if (controlSocket) {
|
if (controlSocket) {
|
||||||
if (controlSocket->Connect()>=0) {
|
if (controlSocket->Connect()>=0) {
|
||||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
|
|
||||||
while ((retval=getDataFromDetector())){
|
while ((retval=getDataFromDetector())){
|
||||||
i++;
|
i++;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -3084,7 +3088,7 @@ int* slsDetector::readAll(){
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "received "<< i<< " frames" << std::endl;
|
std::cout<< "received "<< i<< " frames" << std::endl;
|
||||||
#else
|
#else
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return dataQueue.front(); // check what we return!
|
return dataQueue.front(); // check what we return!
|
||||||
|
|
||||||
@ -4579,51 +4583,33 @@ int slsDetector:: writeAngularConversion(ofstream &ofs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsDetector::loadImageToDetector(imageType index,string const fname){
|
int slsDetector::loadImageToDetector(imageType index,string const fname){
|
||||||
int retval;
|
|
||||||
int fnum=F_LOAD_IMAGE;
|
int ret=FAIL;
|
||||||
int ret=FAIL;
|
short int arg[thisDetector->nChans*thisDetector->nChips];
|
||||||
char mess[100];
|
|
||||||
short int arg[1280];
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< std::endl<< "Loading ";
|
std::cout<< std::endl<< "Loading ";
|
||||||
if(!index)
|
if(!index)
|
||||||
std::cout<<"Dark";
|
std::cout<<"Dark";
|
||||||
else
|
else
|
||||||
std::cout<<"Gain";
|
std::cout<<"Gain";
|
||||||
std::cout<<" image from file " << fname << std::endl;
|
std::cout<<" image from file " << fname << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(readDataFile(fname,arg)){
|
if(readDataFile(fname,arg)){
|
||||||
std::cout<< "Could not open file "<< fname << std::endl;
|
std::cout<< "Could not open file "<< fname << std::endl;
|
||||||
return -1;
|
return ret;
|
||||||
}
|
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
|
||||||
if (controlSocket) {
|
|
||||||
if (controlSocket->Connect()>=0) {
|
|
||||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
|
||||||
controlSocket->SendDataOnly(&index,sizeof(index));
|
|
||||||
controlSocket->SendDataOnly(arg,sizeof(arg));
|
|
||||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
|
||||||
if (ret!=FAIL)
|
|
||||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
|
||||||
else {
|
|
||||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
|
||||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
|
||||||
}
|
}
|
||||||
controlSocket->Disconnect();
|
ret = sendImageToDetector(index,arg);
|
||||||
if (ret==FORCE_UPDATE)
|
return ret;
|
||||||
updateDetector();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ret==FAIL) {
|
|
||||||
std::cout<< "failed " << std::endl;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4634,25 +4620,43 @@ int slsDetector::loadImageToDetector(imageType index,string const fname){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int slsDetector::sendImageToDetector(imageType index,short int arg[]){
|
||||||
|
|
||||||
|
int ret=FAIL;
|
||||||
|
int retval;
|
||||||
|
int fnum=F_LOAD_IMAGE;
|
||||||
|
char mess[100];
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
std::cout<< std::endl<< "Sending image to detector " << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
|
if (controlSocket) {
|
||||||
|
if (controlSocket->Connect()>=0) {
|
||||||
|
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
|
controlSocket->SendDataOnly(&index,sizeof(index));
|
||||||
|
controlSocket->SendDataOnly(arg,sizeof(arg));
|
||||||
|
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
|
if (ret!=FAIL)
|
||||||
|
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
|
else {
|
||||||
|
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||||
|
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||||
|
}
|
||||||
|
controlSocket->Disconnect();
|
||||||
|
if (ret==FORCE_UPDATE)
|
||||||
|
updateDetector();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ret==FAIL) {
|
||||||
|
std::cout<< "failed " << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -4822,10 +4826,10 @@ int slsDetector::writeConfigurationFile(ofstream &outfile){
|
|||||||
|
|
||||||
switch (thisDetector->myDetectorType) {
|
switch (thisDetector->myDetectorType) {
|
||||||
case GOTTHARD:
|
case GOTTHARD:
|
||||||
names[3]="outdir";
|
names[6]="outdir";
|
||||||
names[4]="clientip";
|
names[7]="clientip";
|
||||||
names[5]="clientmac";
|
names[8]="clientmac";
|
||||||
names[6]="servermac";
|
names[9]="servermac";
|
||||||
nvar=10;
|
nvar=10;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -5434,47 +5438,63 @@ int slsDetector::saveSettingsFile(string fname, int imod) {
|
|||||||
|
|
||||||
|
|
||||||
int slsDetector::testFunction(int times) {
|
int slsDetector::testFunction(int times) {
|
||||||
int val = 0,i,oldval=0;
|
int i,count=0;
|
||||||
runStatus s;
|
runStatus s;
|
||||||
|
short int dataVals[thisDetector->nChans*thisDetector->nChips];
|
||||||
|
|
||||||
for(i=0;i<times;i++){
|
|
||||||
std::cout<<std::endl<<dec<<i+1<<": \t";
|
|
||||||
usleep(2000000);
|
|
||||||
startAcquisition();
|
|
||||||
s = getRunStatus();
|
|
||||||
if(s==IDLE){
|
|
||||||
std::cout<<"NOTTT WORKED"<<std::endl;
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
else if (s==RUNNING){
|
|
||||||
while(s==RUNNING){
|
|
||||||
usleep(20);
|
|
||||||
val=readRegister(0x25);
|
|
||||||
if(val!=oldval)
|
|
||||||
std::cout<<hex<<val<<"\t";
|
|
||||||
if(val){
|
|
||||||
if((val&0x100)||(val&0x200)||(val&0x400))
|
|
||||||
s = getRunStatus();
|
|
||||||
else{
|
|
||||||
std::cout<<"\nStuck status.Exit\n";
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
oldval=val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
std::cout<<"\nWeird Status.Exit\n";
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::cout<<std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for(i=0;i<times;i++){
|
||||||
|
std::cout<<std::endl<<dec<<i+1<<": \t";
|
||||||
|
//usleep(2000000);
|
||||||
|
startAcquisition();
|
||||||
|
s = getRunStatus();
|
||||||
|
if(s==IDLE){
|
||||||
|
s = getRunStatus();
|
||||||
|
if(s==IDLE)
|
||||||
|
std::cout<<"IDLE"<<std::endl;
|
||||||
|
//exit(-1);
|
||||||
|
}
|
||||||
|
else if (s==RUNNING){
|
||||||
|
count=0;
|
||||||
|
while(s==RUNNING){
|
||||||
|
count++;
|
||||||
|
if(count==3){
|
||||||
|
std::cout<<"STUCK"<<std::endl;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
usleep(2);
|
||||||
|
//val=readRegister(0x25);
|
||||||
|
s = getRunStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
std::cout<<"\nWeird Status.Exit\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
system("rm ~/wORKSPACE/scratch/run* ");
|
||||||
|
//system("more ~/wORKSPACE/scratch/run* ");
|
||||||
|
usleep(1000000);
|
||||||
|
|
||||||
|
setFileIndex(0);
|
||||||
|
readAll();
|
||||||
|
processData(1);
|
||||||
|
|
||||||
|
|
||||||
|
if(readDataFile("/home/l_maliakal_d/wORKSPACE/scratch/run_1.raw",dataVals)){
|
||||||
|
std::cout<< "Could not open file "<< std::endl;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int j=1277;j< (thisDetector->nChans*thisDetector->nChips);j++)
|
||||||
|
cout<<"\t"<<j<<":"<<dataVals[j];
|
||||||
|
|
||||||
|
if(dataVals[1278]!=2558){
|
||||||
|
std::cout<< "DATA ERROR!! "<< std::endl;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cout<<std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -5505,6 +5525,27 @@ masterFlags slsDetector::setMaster(masterFlags flag) {
|
|||||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||||
} else {
|
} else {
|
||||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
|
system("rm ~/wORKSPACE/scratch/run* ");
|
||||||
|
//system("more ~/wORKSPACE/scratch/run* ");
|
||||||
|
usleep(1000000);
|
||||||
|
|
||||||
|
setFileIndex(0);
|
||||||
|
readAll();
|
||||||
|
processData(1);
|
||||||
|
|
||||||
|
|
||||||
|
if(readDataFile("/home/l_maliakal_d/wORKSPACE/scratch/run_1.raw",dataVals)){
|
||||||
|
std::cout<< "Could not open file "<< std::endl;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int j=1277;j< (thisDetector->nChans*thisDetector->nChips);j++)
|
||||||
|
cout<<"\t"<<j<<":"<<dataVals[j];
|
||||||
|
|
||||||
|
if(dataVals[1278]!=2558){
|
||||||
|
std::cout<< "DATA ERROR!! "<< std::endl;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
controlSocket->Disconnect();
|
controlSocket->Disconnect();
|
||||||
if (ret==FORCE_UPDATE)
|
if (ret==FORCE_UPDATE)
|
||||||
|
@ -1321,7 +1321,21 @@ typedef struct sharedSlsDetector {
|
|||||||
*/
|
*/
|
||||||
masterFlags setMaster(masterFlags flag);
|
masterFlags setMaster(masterFlags flag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Loads dark image or gain image from a file and sends it to the detector
|
||||||
|
\param index is 0 for dark image and 1 for gain image
|
||||||
|
\param fname file name to load data from
|
||||||
|
|
||||||
|
*/
|
||||||
|
int loadImageToDetector(imageType index,string const fname);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Called from loadImageToDetector to send the image to detector
|
||||||
|
\param index is 0 for dark image and 1 for gain image
|
||||||
|
\param arg image
|
||||||
|
|
||||||
|
*/
|
||||||
|
int sendImageToDetector(imageType index,short int arg[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets/gets the synchronization mode of the various detectors
|
Sets/gets the synchronization mode of the various detectors
|
||||||
@ -1330,9 +1344,6 @@ typedef struct sharedSlsDetector {
|
|||||||
*/
|
*/
|
||||||
synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE);
|
synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE);
|
||||||
|
|
||||||
int loadImageToDetector(imageType index,string const fname);
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user