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:
l_maliakal_d
2012-03-15 09:57:20 +00:00
parent c2846e72e7
commit 14bc483310
2 changed files with 192 additions and 140 deletions

View File

@ -2,7 +2,6 @@
#include "usersFunctions.h"
#include "slsDetectorCommand.h"
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/socket.h>
#include <arpa/inet.h>
@ -3005,16 +3004,15 @@ int* slsDetector::readFrame(){
return retval;
};
int* slsDetector::getDataFromDetector(){
int* slsDetector::getDataFromDetector(){
int nel=thisDetector->dataBytes/sizeof(int);
int n;
int* retval=new int[nel];
int ret=FAIL;
char mess[100]="Nothing";
#ifdef VERY_VERBOSE
int i;
#endif
#ifdef VERBOSE
std::cout<< "getting data "<< thisDetector->dataBytes << " " << nel<< std::endl;
@ -3050,11 +3048,16 @@ int* slsDetector::getDataFromDetector(){
retval=NULL;
}
}
return retval;
};
int* slsDetector::readAll(){
int fnum=F_READ_ALL;
@ -3068,6 +3071,7 @@ int* slsDetector::readAll(){
if (controlSocket) {
if (controlSocket->Connect()>=0) {
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
while ((retval=getDataFromDetector())){
i++;
#ifdef VERBOSE
@ -4579,12 +4583,17 @@ int slsDetector:: writeAngularConversion(ofstream &ofs) {
}
int slsDetector::loadImageToDetector(imageType index,string const fname){
int retval;
int fnum=F_LOAD_IMAGE;
int ret=FAIL;
char mess[100];
short int arg[1280];
short int arg[thisDetector->nChans*thisDetector->nChips];
#ifdef VERBOSE
std::cout<< std::endl<< "Loading ";
@ -4597,8 +4606,31 @@ int slsDetector::loadImageToDetector(imageType index,string const fname){
if(readDataFile(fname,arg)){
std::cout<< "Could not open file "<< fname << std::endl;
return -1;
return ret;
}
ret = sendImageToDetector(index,arg);
return ret;
}
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) {
@ -4621,38 +4653,10 @@ int slsDetector::loadImageToDetector(imageType index,string const fname){
}
if (ret==FAIL) {
std::cout<< "failed " << std::endl;
return -1;
}
return 0;
}
return ret;
}
@ -4822,10 +4826,10 @@ int slsDetector::writeConfigurationFile(ofstream &outfile){
switch (thisDetector->myDetectorType) {
case GOTTHARD:
names[3]="outdir";
names[4]="clientip";
names[5]="clientmac";
names[6]="servermac";
names[6]="outdir";
names[7]="clientip";
names[8]="clientmac";
names[9]="servermac";
nvar=10;
break;
default:
@ -5434,42 +5438,59 @@ int slsDetector::saveSettingsFile(string fname, int imod) {
int slsDetector::testFunction(int times) {
int val = 0,i,oldval=0;
int i,count=0;
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);
//usleep(2000000);
startAcquisition();
s = getRunStatus();
if(s==IDLE){
std::cout<<"NOTTT WORKED"<<std::endl;
exit(-1);
s = getRunStatus();
if(s==IDLE)
std::cout<<"IDLE"<<std::endl;
//exit(-1);
}
else if (s==RUNNING){
count=0;
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";
count++;
if(count==3){
std::cout<<"STUCK"<<std::endl;
exit(-1);
}
}
else
break;
oldval=val;
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;
@ -5477,7 +5498,6 @@ int slsDetector::testFunction(int times) {
/* returns if the detector is Master, slave or nothing
\param flag can be GET_MASTER, NO_MASTER, IS_MASTER, IS_SLAVE
\returns master flag of the detector
@ -5505,6 +5525,27 @@ masterFlags slsDetector::setMaster(masterFlags flag) {
std::cout<< "Detector returned error: " << mess << std::endl;
} else {
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();
if (ret==FORCE_UPDATE)

View File

@ -1321,7 +1321,21 @@ typedef struct sharedSlsDetector {
*/
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
@ -1330,9 +1344,6 @@ typedef struct sharedSlsDetector {
*/
synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE);
int loadImageToDetector(imageType index,string const fname);
protected: