Commit 7518ccf8 authored by ahoms's avatar ahoms

* returning to BufferSave in testfreloninterface to avoid

  conflict with control layer
* fixed bug in testfreloninterface forcing Data::UINT16
* fixed bug in FrameDim::setImageType not updating the depth
* small change in ~HwFrameCallbackGen() with (probably) no effect
* fixed Frelon::Interface::getNbAcquiredFrames in frame acc. mode



git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@122 45c4679d-1946-429d-baad-37912b19538b
parent 7d6e419e
......@@ -414,7 +414,9 @@ int Interface::getNbAcquiredFrames()
{
Acq::Status acq_status;
m_acq.getStatus(acq_status);
return acq_status.last_frame_nb + 1;
int nb_acc_frames;
m_buffer.getNbAccFrames(nb_acc_frames);
return (acq_status.last_frame_nb + 1) / nb_acc_frames;
}
#include "FrelonInterface.h"
#include "PoolThreadMgr.h"
#include "CtSaving.h"
#include "BufferSave.h"
#include "Data.h"
#include "TaskMgr.h"
#include "TaskEventCallback.h"
......@@ -15,30 +15,64 @@ using namespace Tasks;
class SoftRoiCallback : public TaskEventCallback
{
public:
SoftRoiCallback(Frelon::Interface& hw_inter, CtSaving& buffer_save,
SoftRoiCallback(Frelon::Interface& hw_inter, BufferSave& buffer_save,
Cond& acq_finished)
: m_hw_inter(hw_inter), m_buffer_save(buffer_save),
m_acq_finished(acq_finished) {}
virtual void finished(Data& data);
private:
void data2FrameInfo(Data& data, HwFrameInfoType& finfo,
FrameDim& fdim);
Frelon::Interface& m_hw_inter;
CtSaving& m_buffer_save;
BufferSave& m_buffer_save;
Cond& m_acq_finished;
};
void SoftRoiCallback::data2FrameInfo(Data& data, HwFrameInfoType& finfo,
FrameDim& fdim)
{
ImageType image_type;
switch (data.type) {
case Data::INT8:
case Data::UINT8:
image_type = Bpp8; break;
case Data::INT16:
case Data::UINT16:
image_type = Bpp16; break;
case Data::INT32:
case Data::UINT32:
image_type = Bpp32; break;
default:
throw LIMA_HW_EXC(InvalidValue, "Unknown data type");
}
HwBufferCtrlObj *buffer_ctrl;
m_hw_inter.getHwCtrlObj(buffer_ctrl);
Timestamp start_ts;
buffer_ctrl->getStartTimestamp(start_ts);
fdim = FrameDim(data.width, data.height, image_type);
int valid_pixels = Point(fdim.getSize()).getArea();
finfo = HwFrameInfoType(data.frameNumber, data.data(), &fdim,
start_ts - Timestamp::now(), valid_pixels);
}
void SoftRoiCallback::finished(Data& data)
{
m_buffer_save.frameReady(data);
HwFrameInfoType finfo;
FrameDim fdim;
data2FrameInfo(data, finfo, fdim);
m_buffer_save.writeFrame(finfo);
HwSyncCtrlObj *hw_sync;
m_hw_inter.getHwCtrlObj(hw_sync);
int nb_frames;
hw_sync->getNbFrames(nb_frames);
if (data.frameNumber == nb_frames - 1) {
if (data.frameNumber == nb_frames - 1)
m_acq_finished.signal();
m_buffer_save.resetLastFrameNb();
}
}
......@@ -47,7 +81,7 @@ class TestFrameCallback : public HwFrameCallback
{
public:
TestFrameCallback(Frelon::Interface& hw_inter, Roi& soft_roi,
CtSaving& buffer_save, Cond& acq_finished)
BufferSave& buffer_save, Cond& acq_finished)
: m_hw_inter(hw_inter), m_soft_roi(soft_roi)
{
m_roi_cb = new SoftRoiCallback(hw_inter, buffer_save,
......@@ -63,36 +97,58 @@ public:
protected:
virtual bool newFrameReady(const HwFrameInfoType& frame_info);
private:
void frameInfo2Data(const HwFrameInfoType& frame_info, Data& data);
Frelon::Interface& m_hw_inter;
Roi& m_soft_roi;
SoftRoi *m_roi_task;
SoftRoiCallback *m_roi_cb;
};
bool TestFrameCallback::newFrameReady(const HwFrameInfoType& frame_info)
void TestFrameCallback::frameInfo2Data(const HwFrameInfoType& frame_info,
Data& data)
{
int nb_acq_frames = m_hw_inter.getNbAcquiredFrames();
HwInterface::Status status;
m_hw_inter.getStatus(status);
cout << "In callback:" << endl
<< " frame_info=" << frame_info << endl
<< " nb_acq_frames=" << nb_acq_frames << endl
<< " status=" << status << endl;
Data data = Data();
data.frameNumber = frame_info.acq_frame_nb;
const Size &aSize = frame_info.frame_dim->getSize();
data.width = aSize.getWidth();
data.height = aSize.getHeight();
data.type = Data::UINT16;
ImageType image_type = frame_info.frame_dim->getImageType();
switch (image_type) {
case Bpp8:
data.type = Data::UINT8; break;
case Bpp16:
data.type = Data::UINT16; break;
case Bpp32:
data.type = Data::UINT32; break;
default:
throw LIMA_HW_EXC(InvalidValue, "Invalid frame image type");
}
Buffer *buffer = new Buffer();
buffer->owner = Buffer::MAPPED;
buffer->data = (void*)frame_info.frame_ptr;
data.setBuffer(buffer);
buffer->unref();
}
bool TestFrameCallback::newFrameReady(const HwFrameInfoType& frame_info)
{
int nb_acq_frames = m_hw_inter.getNbAcquiredFrames();
HwInterface::Status status;
m_hw_inter.getStatus(status);
cout << "In callback:" << endl
<< " frame_info=" << frame_info << endl
<< " nb_acq_frames=" << nb_acq_frames << endl
<< " status=" << status << endl;
Data data;
frameInfo2Data(frame_info, data);
if (m_soft_roi.isActive()) {
Point tl = m_soft_roi.getTopLeft();
......@@ -153,18 +209,7 @@ void test_frelon_hw_inter(bool do_reset)
Frelon::Interface hw_inter(acq, buffer_mgr, cam);
cout << " Done!" << endl;
CtControl aControl(&hw_inter);
CtSaving buffer_save(aControl);
CtSaving::Parameters saving_par;
saving_par.directory = ".";
saving_par.prefix = "img";
saving_par.suffix = ".edf";
saving_par.nextNumber = 0;
saving_par.fileFormat = CtSaving::EDF;
saving_par.savingMode = CtSaving::AutoFrame;
saving_par.overwritePolicy = CtSaving::Overwrite;
saving_par.framesPerFile = 1;
buffer_save.setParameters(saving_par);
BufferSave buffer_save(BufferSave::EDF, "img", 0, ".edf", true, 1);
Roi soft_roi;
Cond acq_finished;
......
Markdown is supported
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