Commit bb0ddd79 authored by ahoms's avatar ahoms
Browse files

* formalized stripe concatenation in HwBufferMgr

* implemented frame accumulation (callbacks) in BufferCtrlMgr
* added HwRoiCtrlObj, implemented Frelon Rois
* using SoftRoi processlib task in testfreloninterface
* moved checkBin to Frelon::Camera
* added Roi-of-Roi (subRoi) management
* fixed and added new sip files; first full lima module in Python
* implemented some missing functions (HwShutterCtrlObj, BufferSave)
* added LimaConvertor.h with HwCap to CtrlObj conversion
* added global build directory with liblima.so; compiling code with -fPIC
* added HwFrameInfo::isValid method



git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@110 45c4679d-1946-429d-baad-37912b19538b
parent 28679283
......@@ -41,6 +41,7 @@ class Camera
void setFlip(const Point& flip);
void getFlip(Point& flip);
void checkBin(Bin& bin);
void setBin(const Bin& bin);
void getBin(Bin& bin);
......
......@@ -134,6 +134,26 @@ class BinCtrlObj : public HwBinCtrlObj
};
/*******************************************************************
* \class RoiCtrlObj
* \brief Control object providing Frelon Roi interface
*******************************************************************/
class RoiCtrlObj : public HwRoiCtrlObj
{
public:
RoiCtrlObj(Camera& cam);
virtual ~RoiCtrlObj();
virtual void checkRoi(const Roi& set_roi, Roi& hw_roi);
virtual void setRoi(const Roi& set_roi);
virtual void getRoi(Roi& hw_roi);
private:
Camera& m_cam;
};
/*******************************************************************
* \class Interface
* \brief Frelon hardware interface
......@@ -164,6 +184,7 @@ class Interface : public HwInterface
BufferCtrlObj m_buffer;
SyncCtrlObj m_sync;
BinCtrlObj m_bin;
RoiCtrlObj m_roi;
};
......
......@@ -208,6 +208,13 @@ void Camera::getFlip(Point& flip)
flip.y = (flip_mode >> 0) & 1;
}
void Camera::checkBin(Bin& bin)
{
int bin_x = min(bin.getX(), int(MaxBinX));
int bin_y = min(bin.getY(), int(MaxBinY));
bin = Bin(bin_x, bin_y);
}
void Camera::setBin(const Bin& bin)
{
if ((bin.getX() > 8) || (bin.getY() > 1024))
......
......@@ -261,9 +261,36 @@ void BinCtrlObj::getBin(Bin& bin)
void BinCtrlObj::checkBin(Bin& bin)
{
int bin_x = min(bin.getX(), int(MaxBinX));
int bin_y = min(bin.getY(), int(MaxBinY));
bin = Bin(bin_x, bin_y);
m_cam.checkBin(bin);
}
/*******************************************************************
* \brief RoiCtrlObj constructor
*******************************************************************/
RoiCtrlObj::RoiCtrlObj(Camera& cam)
: m_cam(cam)
{
}
RoiCtrlObj::~RoiCtrlObj()
{
}
void RoiCtrlObj::checkRoi(const Roi& set_roi, Roi& hw_roi)
{
m_cam.checkRoi(set_roi, hw_roi);
}
void RoiCtrlObj::setRoi(const Roi& roi)
{
m_cam.setRoi(roi);
}
void RoiCtrlObj::getRoi(Roi& roi)
{
m_cam.getRoi(roi);
}
......@@ -274,7 +301,8 @@ void BinCtrlObj::checkBin(Bin& bin)
Interface::Interface(Acq& acq, BufferCtrlMgr& buffer_mgr,
Camera& cam)
: m_acq(acq), m_buffer_mgr(buffer_mgr), m_cam(cam),
m_det_info(cam), m_buffer(buffer_mgr), m_sync(acq, cam), m_bin(cam)
m_det_info(cam), m_buffer(buffer_mgr), m_sync(acq, cam),
m_bin(cam), m_roi(cam)
{
HwDetInfoCtrlObj *det_info = &m_det_info;
m_cap_list.push_back(HwCap(det_info));
......@@ -288,6 +316,9 @@ Interface::Interface(Acq& acq, BufferCtrlMgr& buffer_mgr,
HwBinCtrlObj *bin = &m_bin;
m_cap_list.push_back(HwCap(bin));
HwRoiCtrlObj *roi = &m_roi;
m_cap_list.push_back(HwCap(roi));
reset(SoftReset);
}
......@@ -315,6 +346,7 @@ void Interface::reset(ResetLevel reset_level)
m_sync.setTrigMode(IntTrig);
m_bin.setBin(Bin(1));
m_roi.setRoi(Roi());
Size image_size;
m_det_info.getMaxImageSize(image_size);
......
......@@ -5,7 +5,7 @@ frelon-objs = FrelonBase.o FrelonSerialLine.o FrelonCamera.o FrelonInterface.o
CXXFLAGS = -I../include -I../../common/espia/include \
-I../../../hardware/include -I../../../common/include \
-I$(ESPIA_DRV_INCL) -Wall -pthread
-I$(ESPIA_DRV_INCL) -Wall -pthread -fPIC
all: clean Frelon.o
......
......@@ -11,6 +11,7 @@ CXXFLAGS = -I../include -I../../common/espia/include \
-I../../../hardware/include -I../../../common/include \
-I../../../control/include/ \
-I../../../third-party/Processlib/core/include \
-I../../../third-party/Processlib/tasks/include \
-I$(ESPIA_DRV_INCL) -Wall -pthread
all: clean testfrelon testfreloninterface
......
......@@ -2,27 +2,74 @@
#include "PoolThreadMgr.h"
#include "CtSaving.h"
#include "Data.h"
#include "TaskMgr.h"
#include "TaskEventCallback.h"
#include "SoftRoi.h"
#include <iostream>
using namespace lima;
using namespace std;
using namespace Tasks;
class TestFrameCallback : public HwFrameCallback
class SoftRoiCallback : public TaskEventCallback
{
public:
TestFrameCallback(Frelon::Interface& hw_inter, CtSaving& buffer_save,
Cond& acq_finished)
SoftRoiCallback(Frelon::Interface& hw_inter, CtSaving& buffer_save,
Cond& acq_finished)
: m_hw_inter(hw_inter), m_buffer_save(buffer_save),
m_acq_finished(acq_finished) {}
protected:
virtual bool newFrameReady(const HwFrameInfoType& frame_info);
virtual void finnished(Data& data);
private:
Frelon::Interface& m_hw_inter;
CtSaving& m_buffer_save;
Cond& m_acq_finished;
};
void SoftRoiCallback::finnished(Data& data)
{
m_buffer_save.frameReady(data);
HwSyncCtrlObj *hw_sync;
m_hw_inter.getHwCtrlObj(hw_sync);
int nb_frames;
hw_sync->getNbFrames(nb_frames);
if (data.frameNumber == nb_frames - 1) {
m_acq_finished.signal();
m_buffer_save.resetLastFrameNb();
}
}
class TestFrameCallback : public HwFrameCallback
{
public:
TestFrameCallback(Frelon::Interface& hw_inter, Roi& soft_roi,
CtSaving& buffer_save, Cond& acq_finished)
: m_hw_inter(hw_inter), m_soft_roi(soft_roi)
{
m_roi_cb = new SoftRoiCallback(hw_inter, buffer_save,
acq_finished);
m_roi_task = new SoftRoi();
}
~TestFrameCallback()
{
m_roi_task->unref();
m_roi_cb->unref();
}
protected:
virtual bool newFrameReady(const HwFrameInfoType& frame_info);
private:
Frelon::Interface& m_hw_inter;
Roi& m_soft_roi;
SoftRoi *m_roi_task;
SoftRoiCallback *m_roi_cb;
};
bool TestFrameCallback::newFrameReady(const HwFrameInfoType& frame_info)
{
int nb_acq_frames = m_hw_inter.getNbAcquiredFrames();
......@@ -34,27 +81,35 @@ bool TestFrameCallback::newFrameReady(const HwFrameInfoType& frame_info)
<< " nb_acq_frames=" << nb_acq_frames << endl
<< " status=" << status << endl;
Data aNewData = Data();
aNewData.frameNumber = frame_info.acq_frame_nb;
Data data = Data();
data.frameNumber = frame_info.acq_frame_nb;
const Size &aSize = frame_info.frame_dim->getSize();
aNewData.width = aSize.getWidth();
aNewData.height = aSize.getHeight();
aNewData.type = Data::UINT16;
data.width = aSize.getWidth();
data.height = aSize.getHeight();
data.type = Data::UINT16;
Buffer *aNewBuffer = new Buffer();
aNewBuffer->owner = Buffer::MAPPED;
aNewBuffer->data = (void*)frame_info.frame_ptr;
aNewData.setBuffer(aNewBuffer);
aNewBuffer->unref();
m_buffer_save.frameReady(aNewData);
HwSyncCtrlObj *hw_sync;
m_hw_inter.getHwCtrlObj(hw_sync);
int nb_frames;
hw_sync->getNbFrames(nb_frames);
if (frame_info.acq_frame_nb == nb_frames - 1)
m_acq_finished.signal();
Buffer *buffer = new Buffer();
buffer->owner = Buffer::MAPPED;
buffer->data = (void*)frame_info.frame_ptr;
data.setBuffer(buffer);
buffer->unref();
if (m_soft_roi.isActive()) {
Point tl = m_soft_roi.getTopLeft();
Point br = m_soft_roi.getBottomRight();
m_roi_task->setRoi(tl.x, br.x, tl.y, br.y);
m_roi_task->setEventCallback(m_roi_cb);
TaskMgr *task_mgr = new TaskMgr();
task_mgr->setLinkTask(0, m_roi_task);
task_mgr->setInputData(data);
cout << " adding SoftRoi task!" << endl;
PoolThreadMgr::get().addProcess(task_mgr);
} else {
m_roi_cb->finnished(data);
}
return true;
}
......@@ -67,6 +122,24 @@ void print_status(Frelon::Interface& hw_inter)
cout << "status=" << status << endl;
}
void set_hw_roi(HwRoiCtrlObj *hw_roi, const Roi& set_roi, Roi& real_roi,
Roi& soft_roi)
{
hw_roi->setRoi(set_roi);
hw_roi->getRoi(real_roi);
if (real_roi == set_roi) {
soft_roi.reset();
} else if (real_roi.isActive() && !set_roi.isActive()) {
soft_roi = real_roi;
} else {
soft_roi = real_roi.subRoiAbs2Rel(set_roi);
}
cout << "set_roi=" << set_roi << ", real_roi=" << real_roi << ", "
<< "soft_roi=" << soft_roi << endl;
}
void test_frelon_hw_inter(bool do_reset)
{
Espia::Dev dev(0);
......@@ -87,13 +160,15 @@ void test_frelon_hw_inter(bool do_reset)
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);
Roi soft_roi;
Cond acq_finished;
TestFrameCallback cb(hw_inter, buffer_save, acq_finished);
TestFrameCallback cb(hw_inter, soft_roi, buffer_save, acq_finished);
HwDetInfoCtrlObj *hw_det_info;
hw_inter.getHwCtrlObj(hw_det_info);
......@@ -107,6 +182,9 @@ void test_frelon_hw_inter(bool do_reset)
HwBinCtrlObj *hw_bin;
hw_inter.getHwCtrlObj(hw_bin);
HwRoiCtrlObj *hw_roi;
hw_inter.getHwCtrlObj(hw_roi);
if (do_reset) {
cout << "Reseting the hardware ... " << endl;
hw_inter.reset(HwInterface::HardReset);
......@@ -122,6 +200,9 @@ void test_frelon_hw_inter(bool do_reset)
Bin bin(1);
hw_bin->setBin(bin);
Roi set_roi, real_roi;
set_hw_roi(hw_roi, set_roi, real_roi, soft_roi);
FrameDim effect_frame_dim = frame_dim / bin;
hw_buffer->setFrameDim(effect_frame_dim);
hw_buffer->setNbBuffers(10);
......@@ -130,6 +211,7 @@ void test_frelon_hw_inter(bool do_reset)
print_status(hw_inter);
hw_inter.startAcq();
acq_finished.wait();
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
print_status(hw_inter);
......@@ -139,6 +221,7 @@ void test_frelon_hw_inter(bool do_reset)
print_status(hw_inter);
hw_inter.startAcq();
acq_finished.wait();
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
print_status(hw_inter);
......@@ -149,6 +232,7 @@ void test_frelon_hw_inter(bool do_reset)
print_status(hw_inter);
hw_inter.startAcq();
acq_finished.wait();
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
print_status(hw_inter);
......@@ -178,6 +262,34 @@ void test_frelon_hw_inter(bool do_reset)
print_status(hw_inter);
hw_inter.stopAcq();
print_status(hw_inter);
set_roi = Roi(Point(256, 256), Size(512, 512));
set_hw_roi(hw_roi, set_roi, real_roi, soft_roi);
effect_frame_dim.setSize(real_roi.getSize());
hw_buffer->setFrameDim(effect_frame_dim);
hw_buffer->setNbBuffers(10);
print_status(hw_inter);
hw_inter.startAcq();
acq_finished.wait();
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
print_status(hw_inter);
set_roi = Roi(Point(267, 267), Size(501, 501));
set_hw_roi(hw_roi, set_roi, real_roi, soft_roi);
effect_frame_dim.setSize(real_roi.getSize());
hw_buffer->setFrameDim(effect_frame_dim);
hw_buffer->setNbBuffers(10);
print_status(hw_inter);
hw_inter.startAcq();
acq_finished.wait();
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
print_status(hw_inter);
}
int main(int argc, char *argv[])
......
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