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

bug fix

parent 73ee6963
......@@ -20,14 +20,14 @@ namespace FSDataRecvNS
DataReceiver::~DataReceiver()
{
LOG_TRACE(__FUNCTION__);
if(m_status != ON)
Stop();
if(m_status != ON)
Stop();
m_receiver_task->Exit();
m_filesaving_task->Exit();
m_threadpool.reset();
m_threadpool.reset();
}
void DataReceiver::InitDataReceiver(int32 x,
......@@ -135,8 +135,8 @@ namespace FSDataRecvNS
void DataReceiver::SetFileStructureWithXML(string file_structure)
{
LOG_TRACE(__FUNCTION__);
if(m_save_file)
m_filesaving_task->SetFileStructureWithXML(file_structure);
//if(m_save_file)
m_filesaving_task->SetFileStructureWithXML(file_structure);
}
Enum_detector_state DataReceiver::GetStatus()
......@@ -214,7 +214,7 @@ namespace FSDataRecvNS
DataReceiver::DataReceiver()
:m_x(1000),m_y(1000),m_img_size(m_x*m_y),
m_frame_number(0),m_requested_frames(0),m_max_frame_numbers(0),m_frames_per_file(100),
m_frame_number(0),m_requested_frames(0),m_max_frame_numbers(0),m_frames_per_file(1000),
m_buffer_length(10),
m_pixel_depth(2),m_error_code(0),
m_start_acq(false),m_stop_acq(false),m_save_file(false),
......
......@@ -42,6 +42,7 @@ namespace FSDataRecvNS
m_file_name("test"),
m_xml_structure(""),
m_file_split(false),
m_fileopen(false),
m_img_data(m_x*m_y,0)
{
LOG_TRACE(__FUNCTION__);
......@@ -54,7 +55,7 @@ namespace FSDataRecvNS
{
LOG_TRACE(__FUNCTION__);
CloseFile();
//CloseFile();
nx_writer.reset();
}
......@@ -104,25 +105,38 @@ namespace FSDataRecvNS
boost::unique_lock<boost::mutex> lock(m_bstSync);
if(!m_fStart)
{
m_bstCond.wait(lock);
UpdateParameters();
if(!CreateFile())
{
Stop();
continue;
}
}
if(m_fExit)
break;
{
if(m_fileopen)
CloseFile();
m_bstCond.wait(lock);
if(m_fExit)
break;
UpdateParameters();
if(!CreateFile())
{
Stop();
continue;
}
else
//open related fields for data written
nx_writer->PreAcq(string("/:NXentry/:NXinstrument/:NXdetector/data"),
string("/:NXentry/:NXinstrument/:NXdetector/sequence_number"),
string("/:NXentry/:NXinstrument/:NXdetector/:NXcollection/error_code"));
}
lock.unlock();
if(m_saved_images >= m_requested_frames)
{
Stop();
CloseFile();
continue;
}
......@@ -184,28 +198,30 @@ namespace FSDataRecvNS
sprintf (chNum, "part%05d",m_file_index);
m_file_name = m_file_name + "_" + chNum;
}
if(!(nx_writer->FileConfig(m_file_name,
true,
1,
m_y,
m_x,
16,
1,
false,
false,
false,
2,
false,
0)))
if(nx_writer->FileConfig(m_file_name,
true,
1,
m_y,
m_x,
16,
1,
false,
false,
false,
2,
false,
0) !=0 )
return false;
if(!(nx_writer->CreateFile()))
if(nx_writer->CreateFile() !=0 )
return false;
if(!(nx_writer->CreateStructureFromXMLString(m_xml_structure)))
if(nx_writer->CreateStructureFromXMLString(m_xml_structure) !=0 )
return false;
cout<<m_xml_structure<<endl;
m_fileopen = true;
return true;
}
......@@ -213,9 +229,11 @@ namespace FSDataRecvNS
{
LOG_TRACE(__FUNCTION__);
if(!(nx_writer->CloseFile()))
if(nx_writer->CloseFile() !=0 )
return false;
m_fileopen=false;
return true;
}
}
......@@ -115,7 +115,7 @@ namespace FSDataRecvNS
string m_file_name,m_xml_structure;
bool m_file_split;
bool m_file_split,m_fileopen;
vector<int16> m_img_data;
};
......
......@@ -228,7 +228,7 @@ namespace NexusNS
m_strFileName = strFileName + "." + strFilePostfix;
return 0;
return NO_ERROR;
}
void PreAcq(string strDataFieldPath,string strFrameFieldPath,string strErrField)
......
......@@ -91,17 +91,18 @@ namespace FSDataRecvNS
{
m_udpconn->ClearDataInSocket();
m_bstCond.wait(lock);
if(m_fExit)
break;
m_received_imgs = 0;
m_packets_collected = 0;
}
if(m_fExit)
break;
lock.unlock();
if(m_mempool16bit->GetTotalReceivedFrames() >= m_requested_frames)
if(m_mempool16bit->GetTotalReceivedFrames() == m_requested_frames)
{
Stop();
continue;
......@@ -128,6 +129,8 @@ namespace FSDataRecvNS
m_current_frame_number = m_received_imgs;
int16* data = reinterpret_cast<int16*>(&m_img_data[0]);
m_mempool16bit->SetImage(data,m_received_imgs,0);
m_packets_collected = 0;
LOG_INFOS("Get one image : "+to_string(m_received_imgs));
}
}
......
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