Commit aa913d78 authored by Yuelong Yu's avatar Yuelong Yu
Browse files

multi module file saving problem

parent 626eaac1
......@@ -271,8 +271,8 @@ void AGIPD::init_device()
,uDPSrcIP,uDPSrcMAC);
m_objSys->GetImageFormat(m_nSizeX,m_nSizeY,m_shDepth);
if(isMaster==0)
m_thAcq = new AcquisitionThread(this,m_objSys,m_mtxAcq);
if(isMaster==0)
m_thAcq = new AcquisitionThread(this,m_objSys,m_mtxAcq);
//RefreshDetector();
set_state(Tango::OFF);
}
......@@ -1729,7 +1729,7 @@ void AGIPD::start_acq()
//m_bStopAcq = false;
}
else
{
{
SetState(Tango::MOVING);
m_objSys->StartImaging();
}
......@@ -1754,6 +1754,8 @@ void AGIPD::stop_acq()
// Add your own code
// m_objSys->StopImaging();
//cout<<"stop acq called.IsMasterModule:"<<isMaster<<endl;
if(isMaster == 0)
{
omni_mutex_lock l(m_mtxAcq);
......@@ -1874,7 +1876,9 @@ void AGIPD::UpdateFileName()
}
m_objSys->SetFrameNumbers(*attr_FrameNumbers_read);
cout<<m_nOpMode<<"|"<<*attr_FrameNumbers_read<<"|"<<m_nTotalFrames<<endl;
cout<<"operation mode:"<<m_nOpMode
<<"|frame numbers:"<<*attr_FrameNumbers_read
<<"|total frame numbers:"<<m_nTotalFrames<<endl;
}// //--------------------------------------------------------
// /**
......
......@@ -53,12 +53,15 @@ namespace AGIPD_ns
private:
void AcquisitionStart()
{
cout<<"xxxxxxxxxxxxxxxxxxxxxx\nacquisition start"<<endl;
m_objAGIPD->SetState(Tango::MOVING);
UpdateParameters();
if(m_bSaveAllImages)
if(!CreateFile())//check if file is created successfully
{
{
m_objAGIPD->m_bAcquiringData = false;
m_objAGIPD->m_bStopAcq = true;
}
......@@ -66,24 +69,28 @@ namespace AGIPD_ns
m_objAGIPD->m_bAcquiringData = true;
m_objAGIPD->m_bStartAcq = false;
m_objDet->StartImaging();
}
void AcquisitionStop()
{
cout<<"Acquisition stop"<<endl;
if(m_bSaveAllImages)
{
if(m_lAcquiredImgs != 0)
{
{
(*(m_objAGIPD->attr_FileStartNum_read))++;
m_objAGIPD->UpdateFileName();
}
int nRet = m_objNXFileWriter->CloseFile();
DisplayError(string("Close file"),nRet);
}
m_lAcquiredImgs = 0;
m_objDet->StopImaging();
m_objAGIPD->m_bStopAcq = false;
m_objAGIPD->m_bAcquiringData = false;
......@@ -220,6 +227,7 @@ namespace AGIPD_ns
m_strFilePostfix = string("nxs");
m_lRequestFrameNo = *(m_objAGIPD->attr_FrameNumbers_read);
m_bSaveAllImages = *(m_objAGIPD->attr_SaveAllImages_read);
m_bLiveMode = *(m_objAGIPD->attr_LiveMode_read);
m_lAcquiredImgs = 0;
......@@ -325,6 +333,7 @@ namespace AGIPD_ns
bool DumpSettings()
{
int nRet;
//ADCLatency
......
This diff is collapsed.
......@@ -60,7 +60,15 @@ class AGIPDMaster : public Tango::Device_4Impl
Tango::DevState m_stateDetLatest;
vector<Tango::DeviceProxy*> m_vobjDP;
omni_thread* m_thAcq;
omni_mutex m_mtxAcq;
public:
bool m_bSysExit;
bool m_bStartAcq;
long m_lLatestImgNo;
/*----- PROTECTED REGION END -----*/ // AGIPDMaster::Data Members
......
#ifndef __ACQUISITION_THREAD__
#define __ACQUISITION_THREAD__
#include <tango.h>
#include "AGIPDMaster.h"
namespace AGIPDMaster_ns
{
class AcquisitionThread:public omni_thread,public Tango::LogAdapter
{
public:
AcquisitionThread(AGIPDMaster* _objAGIPDMaster,omni_mutex& _mutexAcq)
:omni_thread(),Tango::LogAdapter(_objAGIPDMaster),m_objAGIPDMaster(_objAGIPDMaster),m_mutexAcq(_mutexAcq)
{
start_undetached();
}
~AcquisitionThread()
{
}
void *run_undetached(void*)
{
while(1)
{
usleep(10000);
{
omni_mutex_lock l(m_mutexAcq);
if(m_objAGIPDMaster->m_bSysExit)
break;
StopAcq();
}
}
omni_thread::exit();
}
private:
void StopAcq()
{
if(*(m_objAGIPDMaster->attr_LatestImageNumber_read)
==*(m_objAGIPDMaster->attr_FrameNumbers_read)
&&m_objAGIPDMaster->m_bStartAcq)
{
m_objAGIPDMaster->stop_acq();
// *(m_objAGIPDMaster->attr_LatestImageNumber_read) = 0;
}
}
private:
AGIPDMaster* m_objAGIPDMaster;
omni_mutex& m_mutexAcq;
};
}
#endif
......@@ -79,7 +79,7 @@ LFLAGS_USR= $(RELEASE_TYPE) -Wall $(LIB_DIR_USER) \
CXXFLAGS_USR =-O3 -std=c++0x $(RELEASE_TYPE) -D_REENTRANT $(INC_DIR_USER)
SVC_INC = $(PACKAGE_NAME).h $(PACKAGE_NAME)Class.h
SVC_INC = $(PACKAGE_NAME).h $(PACKAGE_NAME)Class.h AcquisitionThread.h
SVC_OBJS = $(OBJS_DIR)/main.o \
$(OBJS_DIR)/ClassFactory.o \
......@@ -105,4 +105,4 @@ mk_dir:
clean:
rm -f $(OBJS_DIR)/*.o \
$(BIN_DIR)/$(PACKAGE_NAME)
\ No newline at end of file
$(BIN_DIR)/$(PACKAGE_NAME)
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