Commit 181c9dea authored by Sebastien Petitdemange's avatar Sebastien Petitdemange
Browse files

Pilatus code refactoring

parent ccaf48f1
Subproject commit 9a9f9d76d02690f9de3ac098634d7e8ae5062fcc Subproject commit ab45b47b45a9a4130ef7ad9ef9f83cc2e795499b
Subproject commit f299a6dec9a5662792011c7bcb76f59b662ce7d7 Subproject commit f62bc46bb4dbca5be759cc3901277e3521ca5bee
...@@ -33,12 +33,14 @@ namespace lima ...@@ -33,12 +33,14 @@ namespace lima
class HwFileEventCallbackHelper : public DirectoryEvent::Callback class HwFileEventCallbackHelper : public DirectoryEvent::Callback
{ {
public: public:
enum CallFrom {Acquisition,OnDemand};
class Callback class Callback
{ {
public: public:
virtual void prepare(const DirectoryEvent::Parameters&) {} virtual void prepare(const DirectoryEvent::Parameters&) {}
virtual bool getFrameInfo(int image_number,const char* full_path, virtual bool getFrameInfo(int image_number,const char* full_path,
HwFrameInfoType&) = 0; CallFrom,HwFrameInfoType&) = 0;
virtual bool newFrameReady(const HwFrameInfoType&) = 0; virtual bool newFrameReady(const HwFrameInfoType&) = 0;
}; };
...@@ -49,6 +51,7 @@ namespace lima ...@@ -49,6 +51,7 @@ namespace lima
int &next_file_number_expected) throw(); int &next_file_number_expected) throw();
virtual bool newFile(int file_number,const char *full_path) throw(); virtual bool newFile(int file_number,const char *full_path) throw();
int getNbOfFramePending() const {return m_pending_frame_infos.size();}
private: private:
typedef std::map<int,HwFrameInfoType> DatasPendingType; typedef std::map<int,HwFrameInfoType> DatasPendingType;
...@@ -63,7 +66,10 @@ namespace lima ...@@ -63,7 +66,10 @@ namespace lima
class Callback class Callback
{ {
public: public:
virtual void prepare(const DirectoryEvent::Parameters&) {}
virtual bool getFrameInfo(int image_number,const char* full_path, virtual bool getFrameInfo(int image_number,const char* full_path,
HwFileEventCallbackHelper::CallFrom,
HwFrameInfoType&) = 0; HwFrameInfoType&) = 0;
virtual void getFrameDim(FrameDim& frame_dim) = 0; virtual void getFrameDim(FrameDim& frame_dim) = 0;
}; };
...@@ -80,6 +86,8 @@ namespace lima ...@@ -80,6 +86,8 @@ namespace lima
bool isStopped() const; bool isStopped() const;
int getLastAcquiredFrame() const; int getLastAcquiredFrame() const;
int getNbOfFramePending() const {return m_directory_cbk.getNbOfFramePending();}
//methodes used by Lima core //methodes used by Lima core
virtual void setFrameDim(const FrameDim& frame_dim); virtual void setFrameDim(const FrameDim& frame_dim);
virtual void getFrameDim(FrameDim& frame_dim); virtual void getFrameDim(FrameDim& frame_dim);
...@@ -105,6 +113,7 @@ namespace lima ...@@ -105,6 +113,7 @@ namespace lima
friend class _CBK; friend class _CBK;
int _calcNbMaxImages(); int _calcNbMaxImages();
bool _getFrameInfo(int image_number,const char* full_path, bool _getFrameInfo(int image_number,const char* full_path,
HwFileEventCallbackHelper::CallFrom,
HwFrameInfoType &frame_info); HwFrameInfoType &frame_info);
std::string m_tmpfs_path; std::string m_tmpfs_path;
......
...@@ -47,8 +47,9 @@ bool HwFileEventCallbackHelper::nextFileExpected(int file_number, ...@@ -47,8 +47,9 @@ bool HwFileEventCallbackHelper::nextFileExpected(int file_number,
bool continueFlag = true; bool continueFlag = true;
try try
{ {
continueFlag = m_cbk.getFrameInfo(file_number,full_path,aNewFrameInfo); continueFlag = m_cbk.getFrameInfo(file_number,full_path,
bool continueAcq = !m_cbk.newFrameReady(aNewFrameInfo); Acquisition,aNewFrameInfo);
bool continueAcq = m_cbk.newFrameReady(aNewFrameInfo);
if(continueFlag) continueFlag = continueAcq; if(continueFlag) continueFlag = continueAcq;
DatasPendingType::iterator i = m_pending_frame_infos.begin(); DatasPendingType::iterator i = m_pending_frame_infos.begin();
while(i != m_pending_frame_infos.end() && continueFlag) while(i != m_pending_frame_infos.end() && continueFlag)
...@@ -82,7 +83,9 @@ bool HwFileEventCallbackHelper::newFile(int file_number,const char *full_path) t ...@@ -82,7 +83,9 @@ bool HwFileEventCallbackHelper::newFile(int file_number,const char *full_path) t
try try
{ {
HwFrameInfoType aNewFrameInfo; HwFrameInfoType aNewFrameInfo;
continueFlag = m_cbk.getFrameInfo(file_number,full_path,aNewFrameInfo); continueFlag = m_cbk.getFrameInfo(file_number,full_path,
Acquisition,
aNewFrameInfo);
m_pending_frame_infos[file_number] = aNewFrameInfo; m_pending_frame_infos[file_number] = aNewFrameInfo;
} }
catch(...) catch(...)
...@@ -119,12 +122,14 @@ public: ...@@ -119,12 +122,14 @@ public:
unlink(fullPath); unlink(fullPath);
} }
closedir(aWatchDir); closedir(aWatchDir);
} }
m_cnt.m_cbk.prepare(params);
} }
virtual bool getFrameInfo(int image_number,const char* full_path, virtual bool getFrameInfo(int image_number,const char* full_path,
HwFileEventCallbackHelper::CallFrom mode,
HwFrameInfoType &frame_info) HwFrameInfoType &frame_info)
{ {
return m_cnt._getFrameInfo(image_number,full_path,frame_info); return m_cnt._getFrameInfo(image_number,full_path,mode,frame_info);
} }
virtual bool newFrameReady(const HwFrameInfoType &frame_info) virtual bool newFrameReady(const HwFrameInfoType &frame_info)
{ {
...@@ -271,14 +276,16 @@ void HwTmpfsBufferMgr::getStartTimestamp(Timestamp& start_ts) ...@@ -271,14 +276,16 @@ void HwTmpfsBufferMgr::getStartTimestamp(Timestamp& start_ts)
void HwTmpfsBufferMgr::getFrameInfo(int acq_frame_nb, HwFrameInfoType& info) void HwTmpfsBufferMgr::getFrameInfo(int acq_frame_nb, HwFrameInfoType& info)
{ {
DEB_MEMBER_FUNCT(); DEB_MEMBER_FUNCT();
char filename[1024]; char filename[1024];
snprintf(filename,sizeof(filename), snprintf(filename,sizeof(filename),
m_file_pattern.c_str(),acq_frame_nb); m_file_pattern.c_str(),acq_frame_nb);
std::string fullPath = m_tmpfs_path + "/"; std::string fullPath = m_tmpfs_path + "/";
fullPath += filename; fullPath += filename;
m_cbk.getFrameInfo(acq_frame_nb,fullPath.c_str(),info); m_cbk.getFrameInfo(acq_frame_nb,fullPath.c_str(),
HwFileEventCallbackHelper::OnDemand,
info);
} }
void HwTmpfsBufferMgr::registerFrameCallback(HwFrameCallback& frame_cb) void HwTmpfsBufferMgr::registerFrameCallback(HwFrameCallback& frame_cb)
...@@ -309,7 +316,8 @@ int HwTmpfsBufferMgr::_calcNbMaxImages() ...@@ -309,7 +316,8 @@ int HwTmpfsBufferMgr::_calcNbMaxImages()
} }
bool HwTmpfsBufferMgr::_getFrameInfo(int image_number,const char* full_path, bool HwTmpfsBufferMgr::_getFrameInfo(int image_number,const char* full_path,
HwFileEventCallbackHelper::CallFrom mode,
HwFrameInfoType &frame_info) HwFrameInfoType &frame_info)
{ {
return m_cbk.getFrameInfo(image_number,full_path,frame_info); return m_cbk.getFrameInfo(image_number,full_path,mode,frame_info);
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment