Commit 626eaac1 authored by Yuelong Yu's avatar Yuelong Yu
Browse files

bug fix on file creation

parent 3ec2d6b5
......@@ -1720,6 +1720,7 @@ void AGIPD::start_acq()
// Add your own code
//m_objSys->StartImaging();
if(isMaster == 0)
{
omni_mutex_lock l(m_mtxAcq);
......@@ -1729,7 +1730,7 @@ void AGIPD::start_acq()
}
else
{
SetState(Tango::MOVING);
SetState(Tango::MOVING);
m_objSys->StartImaging();
}
......@@ -1754,19 +1755,19 @@ void AGIPD::stop_acq()
// Add your own code
// m_objSys->StopImaging();
if(isMaster == 0)
{
omni_mutex_lock l(m_mtxAcq);
omni_mutex_lock l1(m_mtxSimu);
m_bStopAcq = true;
//m_bStartAcq = false;
}
{
omni_mutex_lock l(m_mtxAcq);
omni_mutex_lock l1(m_mtxSimu);
m_bStopAcq = true;
//m_bStartAcq = false;
}
else
{
m_objSys->StopImaging();
SetState(Tango::ON);
SetState(Tango::ON);
}
/*----- PROTECTED REGION END -----*/ // AGIPD::stop_acq
......
......@@ -53,13 +53,12 @@ namespace AGIPD_ns
private:
void AcquisitionStart()
{
m_objAGIPD->SetState(Tango::MOVING);
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;
}
......@@ -67,10 +66,13 @@ namespace AGIPD_ns
m_objAGIPD->m_bAcquiringData = true;
m_objAGIPD->m_bStartAcq = false;
m_objDet->StartImaging();
}
void AcquisitionStop()
{
if(m_bSaveAllImages)
{
if(m_lAcquiredImgs != 0)
......@@ -89,7 +91,8 @@ namespace AGIPD_ns
}
void AcquiringData()
{
{
//cout<<"Acquisition data..."<<endl;
if(m_objDet->GetQueuedImageNumbers(0))
{
m_ptrShData = m_objDet->GetImageData(m_lCurrentFrameNo,m_shFrameErrorCode);
......@@ -112,6 +115,7 @@ namespace AGIPD_ns
*/
bool CreateFile()
{
int nRet = 0;
nRet = m_objNXFileWriter->FileConfig(m_strFileName
,m_bOverwrite
......@@ -161,6 +165,24 @@ namespace AGIPD_ns
DisplayError(string("group collection create"),nRet);
if(nRet != 0)
return false;
if(m_nDataType == 1)
nRet = m_objNXFileWriter->Create2DField<short>(string("/entry/instrument/detector/"),string("data"));
DisplayError(string("field data create"),nRet);
if(nRet != 0)
return false;
nRet = m_objNXFileWriter->CreateField<int>(string("/entry/instrument/detector/"),string("sequence_number"));
DisplayError(string("field sequence_number create"),nRet);
if(nRet != 0)
return false;
nRet = m_objNXFileWriter->CreateField<int>(string("/entry/instrument/detector/collection/"),string("error_code"));
DisplayError(string("field error_code create"),nRet);
if(nRet != 0)
return false;
return DumpSettings();
}
......@@ -180,10 +202,10 @@ namespace AGIPD_ns
m_nY = m_objAGIPD->m_nSizeY;
m_nDepth = m_objAGIPD->m_shDepth;
if(m_nDepth == 12)
m_nDataType = 1; //short
else if(m_nDepth == 24)
m_nDataType = 2; //int
//if(m_nDepth == 12)
m_nDataType = 1; //short
//else if(m_nDepth == 24)
// m_nDataType = 2; //int
m_bCompressionEnabled = *(m_objAGIPD->attr_CompressionEnabled_read);
m_bCompressionShuffleEnabled = *(m_objAGIPD->attr_CompressorShuffle_read);
......@@ -218,6 +240,8 @@ namespace AGIPD_ns
{
int nRet;
vector<T> vData(tData,tData+m_nX*m_nY);
nRet = m_objNXFileWriter->WriteData<T>(string("/entry/instrument/detector/data"),
vData,
string("/entry/instrument/detector/sequence_number"),
......@@ -300,6 +324,7 @@ namespace AGIPD_ns
bool DumpSettings()
{
int nRet;
//ADCLatency
......@@ -387,7 +412,7 @@ namespace AGIPD_ns
return false;
//FileSplitEnabled
nRet = m_objNXFileWriter->DumpAllAttributesFromTango(string("/entry/instrument/detector/collection/"),"file_split_enabled",*(m_objAGIPD->attr_FileSplitEnabled_read));
nRet = m_objNXFileWriter->DumpAllAttributesFromTango(string("/entry/instrument/detector/collection/"),"file_split_enabled",false);
DisplayError(string("write file_split_enabled"),nRet);
if(nRet != 0)
return false;
......@@ -409,6 +434,8 @@ namespace AGIPD_ns
DisplayError(string("write total_loss_frames"),nRet);
if(nRet != 0)
return false;
return true;
}
void DisplayError(string strMsg,int nRet)
......
......@@ -1695,12 +1695,22 @@ void AGIPDMaster::start_acq()
// Add your own code
//for(auto objDP : m_vobjDP)
for(int i=0;i<m_vobjDP.size();i++)
// for(int i=0;i<m_vobjDP.size();i++)
// {
// Tango::DeviceProxy* objDP = m_vobjDP[i];
// objDP->command_inout("StartAcq");
// }
for(int i=m_vobjDP.size()-1;i>=0;i--)
{
Tango::DeviceProxy* objDP = m_vobjDP[i];
Tango::DeviceProxy* objDP = m_vobjDP[i];
usleep(100);
objDP->command_inout("StartAcq");
}
/*----- PROTECTED REGION END -----*/ // AGIPDMaster::start_acq
}
......@@ -1724,14 +1734,17 @@ void AGIPDMaster::stop_acq()
// for(auto objDP : m_vobjDP)
// {
for(int i=0;i<m_vobjDP.size();i++)
//for(int i=0;i<m_vobjDP.size();i++)
for(int i=m_vobjDP.size()-1;i>=0;i--)
{
Tango::DeviceProxy* objDP = m_vobjDP[i];
//before send stop acquisition command, check server status
//if submodule is already on ON state, don't send stopacq command
int n = objDP->state();
if(n!=Tango::ON)
objDP->command_inout("StopAcq");
//if(n!=Tango::ON)
usleep(100);
objDP->command_inout("StopAcq");
}
/*----- PROTECTED REGION END -----*/ // AGIPDMaster::stop_acq
......@@ -1817,7 +1830,7 @@ void AGIPDMaster:: WriteAttr(string strAttr,bool bVal)
void AGIPDMaster::WriteAttr(string strAttr,string strVal)
{
int nIdx = 1;
int nIdx = 0;
//cout<<strAttr<<":Write";
......
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