mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 13:27:14 +02:00
Merge branch 'developer' of git.psi.ch:sls_detectors_software/sls_detector_software into developer
This commit is contained in:
@ -2725,6 +2725,8 @@ int slsDetector::setChannel(sls_detector_channel chan){
|
|||||||
int ichip=chan.chip;
|
int ichip=chan.chip;
|
||||||
int imod=chan.module;
|
int imod=chan.module;
|
||||||
|
|
||||||
|
cout << "Set chan " << ichan << " chip " <<ichip << " mod " << imod << " reg " << hex << chan.reg << endl;
|
||||||
|
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
if (connectControl() == OK){
|
if (connectControl() == OK){
|
||||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
@ -8062,14 +8064,22 @@ string slsDetector::setFileName(string s) {
|
|||||||
|
|
||||||
if(ret==FORCE_UPDATE)
|
if(ret==FORCE_UPDATE)
|
||||||
updateReceiver();
|
updateReceiver();
|
||||||
}
|
return sretval;
|
||||||
|
|
||||||
/*pthread_mutex_lock(&ms);
|
} else {
|
||||||
|
if(!s.empty()){
|
||||||
|
pthread_mutex_lock(&ms);
|
||||||
|
fileIO::setFileName(s);
|
||||||
|
pthread_mutex_unlock(&ms);
|
||||||
|
}
|
||||||
|
pthread_mutex_lock(&ms);
|
||||||
s = fileIO::getFileName();
|
s = fileIO::getFileName();
|
||||||
pthread_mutex_unlock(&ms);
|
pthread_mutex_unlock(&ms);
|
||||||
|
|
||||||
return s;*/
|
return s;
|
||||||
return sretval;
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -275,6 +275,7 @@ int slsDetectorUtils::acquire(int delflag){
|
|||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
//send receiver file name
|
//send receiver file name
|
||||||
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
|
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
|
||||||
|
|
||||||
setFileName(fileIO::getFileName());
|
setFileName(fileIO::getFileName());
|
||||||
|
|
||||||
//start receiver
|
//start receiver
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
/* generates file name without extension*/
|
/* generates file name without extension*/
|
||||||
|
|
||||||
string fileIO::createFileName() {
|
string fileIO::createFileName() {
|
||||||
|
|
||||||
|
pthread_mutex_lock(&mf);
|
||||||
currentFileName=fileIOStatic::createFileName(filePath, \
|
currentFileName=fileIOStatic::createFileName(filePath, \
|
||||||
fileName, \
|
fileName, \
|
||||||
getActionMask(), \
|
getActionMask(), \
|
||||||
@ -26,6 +28,7 @@ string fileIO::createFileName() {
|
|||||||
// nBytes=2*getTotalNumberOfChannels();
|
// nBytes=2*getTotalNumberOfChannels();
|
||||||
//} else
|
//} else
|
||||||
nBytes=getDataBytes();
|
nBytes=getDataBytes();
|
||||||
|
pthread_mutex_unlock(&mf);
|
||||||
return currentFileName;
|
return currentFileName;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -35,6 +38,7 @@ string fileIO::createFileName() {
|
|||||||
/* generates file prefix for receivers */
|
/* generates file prefix for receivers */
|
||||||
|
|
||||||
string fileIO::createReceiverFilePrefix() {
|
string fileIO::createReceiverFilePrefix() {
|
||||||
|
pthread_mutex_lock(&mf);
|
||||||
currentReceiverFilePrefix=fileIOStatic::createReceiverFilePrefix(fileName, \
|
currentReceiverFilePrefix=fileIOStatic::createReceiverFilePrefix(fileName, \
|
||||||
getActionMask(), \
|
getActionMask(), \
|
||||||
getCurrentScanVariable(0), \
|
getCurrentScanVariable(0), \
|
||||||
@ -45,6 +49,7 @@ string fileIO::createReceiverFilePrefix() {
|
|||||||
getNumberOfPositions(), \
|
getNumberOfPositions(), \
|
||||||
detIndex \
|
detIndex \
|
||||||
);
|
);
|
||||||
|
pthread_mutex_unlock(&mf);
|
||||||
return currentReceiverFilePrefix;
|
return currentReceiverFilePrefix;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <semaphore.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
/**
|
/**
|
||||||
@ -30,7 +31,17 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
|||||||
|
|
||||||
|
|
||||||
/** default constructor */
|
/** default constructor */
|
||||||
fileIO(): fileIOStatic(){currentFrameIndex=-1;frameIndex=-1;detIndex=-1; framesPerFile=&nframes; nframes=1; filefd = NULL;};
|
fileIO(): fileIOStatic(){
|
||||||
|
currentFrameIndex=-1;
|
||||||
|
frameIndex=-1;
|
||||||
|
detIndex=-1;
|
||||||
|
framesPerFile=&nframes;
|
||||||
|
nframes=1;
|
||||||
|
filefd = NULL;
|
||||||
|
pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
mf=mp1;
|
||||||
|
pthread_mutex_init(&mf, NULL);
|
||||||
|
};
|
||||||
|
|
||||||
/** virtual destructor */
|
/** virtual destructor */
|
||||||
virtual ~fileIO(){};
|
virtual ~fileIO(){};
|
||||||
@ -39,51 +50,110 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
|||||||
using fileIOStatic::writeDataFile;
|
using fileIOStatic::writeDataFile;
|
||||||
using fileIOStatic::createFileName;
|
using fileIOStatic::createFileName;
|
||||||
|
|
||||||
int getFileIndexFromFileName(string fname){return fileIOStatic::getFileIndexFromFileName(fname);};
|
int getFileIndexFromFileName(string fname){
|
||||||
int getIndicesFromFileName(string fname, int &index){return fileIOStatic::getIndicesFromFileName(fname,index);};
|
int ret;
|
||||||
int getVariablesFromFileName(string fname, int &index, int &p_index, double &sv0, double &sv1){return fileIOStatic::getVariablesFromFileName(fname, index, p_index, sv0, sv1);};
|
pthread_mutex_lock(&mf);
|
||||||
int getVariablesFromFileName(string fname, int &index, int &f_index, int &p_index, double &sv0, double &sv1, int &detindex){return fileIOStatic::getVariablesFromFileName(fname, f_index, index, p_index, sv0, sv1, detindex);};
|
ret=fileIOStatic::getFileIndexFromFileName(fname);
|
||||||
|
pthread_mutex_unlock(&mf);
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
int getIndicesFromFileName(string fname, int &index){
|
||||||
|
int ret;
|
||||||
|
pthread_mutex_lock(&mf);
|
||||||
|
ret=fileIOStatic::getIndicesFromFileName(fname,index);
|
||||||
|
pthread_mutex_unlock(&mf);
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int getVariablesFromFileName(string fname, int &index, int &p_index, double &sv0, double &sv1){
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
pthread_mutex_lock(&mf);
|
||||||
|
ret=fileIOStatic::getVariablesFromFileName(fname, index, p_index, sv0, sv1);
|
||||||
|
pthread_mutex_unlock(&mf);
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
int getVariablesFromFileName(string fname, int &index, int &f_index, int &p_index, double &sv0, double &sv1, int &detindex){
|
||||||
|
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
pthread_mutex_lock(&mf);
|
||||||
|
ret=fileIOStatic::getVariablesFromFileName(fname, f_index, index, p_index, sv0, sv1, detindex);
|
||||||
|
pthread_mutex_unlock(&mf);
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
sets the default output files path
|
sets the default output files path
|
||||||
\param s file path
|
\param s file path
|
||||||
\return actual file path
|
\return actual file path
|
||||||
*/
|
*/
|
||||||
virtual string setFilePath(string s) {sprintf(filePath, s.c_str()); return string(filePath);};
|
virtual string setFilePath(string s) {
|
||||||
|
pthread_mutex_lock(&mf);
|
||||||
|
sprintf(filePath, s.c_str());
|
||||||
|
pthread_mutex_unlock(&mf);
|
||||||
|
return string(filePath);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
sets the default output files root name
|
sets the default output files root name
|
||||||
\param s file name to be set
|
\param s file name to be set
|
||||||
\returns actual file name
|
\returns actual file name
|
||||||
*/
|
*/
|
||||||
virtual string setFileName(string s) {sprintf(fileName, s.c_str()); return string(fileName);};
|
virtual string setFileName(string s) {
|
||||||
|
pthread_mutex_lock(&mf);
|
||||||
|
sprintf(fileName, s.c_str());
|
||||||
|
pthread_mutex_unlock(&mf);
|
||||||
|
return string(fileName);};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
sets the default output file index
|
sets the default output file index
|
||||||
\param i start file index to be set
|
\param i start file index to be set
|
||||||
\returns actual file index
|
\returns actual file index
|
||||||
*/
|
*/
|
||||||
virtual int setFileIndex(int i) {*fileIndex=i; return *fileIndex;};
|
virtual int setFileIndex(int i) {
|
||||||
|
pthread_mutex_lock(&mf);
|
||||||
|
*fileIndex=i;
|
||||||
|
pthread_mutex_unlock(&mf);
|
||||||
|
return *fileIndex;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
sets the default output file frame index
|
sets the default output file frame index
|
||||||
\param i file frame index to be set
|
\param i file frame index to be set
|
||||||
\returns actual file frame index
|
\returns actual file frame index
|
||||||
*/
|
*/
|
||||||
virtual int setFrameIndex(int i) {frameIndex=i; return frameIndex;};
|
virtual int setFrameIndex(int i) {
|
||||||
|
pthread_mutex_lock(&mf);
|
||||||
|
frameIndex=i;
|
||||||
|
pthread_mutex_unlock(&mf);
|
||||||
|
return frameIndex;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
sets the default output current frame index
|
sets the default output current frame index
|
||||||
\param i current frame index to be set
|
\param i current frame index to be set
|
||||||
\returns actual current frame index
|
\returns actual current frame index
|
||||||
*/
|
*/
|
||||||
virtual int setCurrentFrameIndex(int i) {currentFrameIndex=i; return currentFrameIndex;};
|
virtual int setCurrentFrameIndex(int i) {
|
||||||
|
pthread_mutex_lock(&mf);
|
||||||
|
currentFrameIndex=i;
|
||||||
|
pthread_mutex_unlock(&mf);
|
||||||
|
return currentFrameIndex;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
sets the default output file index
|
sets the default output file index
|
||||||
\param i frame index to be set
|
\param i frame index to be set
|
||||||
\returns actual frame index
|
\returns actual frame index
|
||||||
*/
|
*/
|
||||||
virtual int setFramesPerFile(int i) {if (i>0) *framesPerFile=i; return *framesPerFile;};
|
virtual int setFramesPerFile(int i) {
|
||||||
|
pthread_mutex_lock(&mf);
|
||||||
|
if (i>0) *framesPerFile=i;
|
||||||
|
pthread_mutex_unlock(&mf);
|
||||||
|
return *framesPerFile;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
sets the default output file index
|
sets the default output file index
|
||||||
@ -335,6 +405,8 @@ yes */
|
|||||||
|
|
||||||
int nBytes;
|
int nBytes;
|
||||||
|
|
||||||
|
/** mutex to synchronize read/write fname */
|
||||||
|
pthread_mutex_t mf;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user