Commit 01520263 authored by ahoms's avatar ahoms

* fixed spelling in HwBufferCtrlObj (and derivates) getFrameDim (was getFramedim)

* improved testfrelonspectroscopy to perform a real Fast Kinetic acquisition
* renamed AcqFinished to AcqState with Idle, Running, Finished and Aborted
* changed FrameDim multip/division operator to work with Point (instead of Bin)
* changed Roi-from-points constructor to work with any pair of corners
* fixed DEB_RETURN statements in several Acq methods



git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@188 45c4679d-1946-429d-baad-37912b19538b
parent e8fd54bb
......@@ -60,7 +60,7 @@ class BufferCtrlObj : public HwBufferCtrlObj
virtual ~BufferCtrlObj();
virtual void setFrameDim(const FrameDim& frame_dim);
virtual void getFramedim( FrameDim& frame_dim);
virtual void getFrameDim( FrameDim& frame_dim);
virtual void setNbBuffers(int nb_buffers);
virtual void getNbBuffers(int& nb_buffers);
......
......@@ -48,7 +48,7 @@ class BufferCtrlObj : HwBufferCtrlObj
virtual ~BufferCtrlObj();
virtual void setFrameDim(const FrameDim& frame_dim);
virtual void getFramedim( FrameDim& frame_dim /Out/);
virtual void getFrameDim( FrameDim& frame_dim /Out/);
virtual void setNbBuffers(int nb_buffers);
virtual void getNbBuffers(int& nb_buffers /Out/);
......
......@@ -483,8 +483,7 @@ void Camera::getImageRoi(const Roi& chan_roi, Roi& image_roi)
xformChanCoords(chan_tl, img_tl, c_tl);
xformChanCoords(chan_br, img_br, c_br);
Roi unbinned_roi;
unbinned_roi.setCorners(img_tl, img_br);
Roi unbinned_roi(img_tl, img_br);
DEB_TRACE() << DEB_VAR1(unbinned_roi);
Bin bin;
......
......@@ -128,7 +128,7 @@ void BufferCtrlObj::setFrameDim(const FrameDim& frame_dim)
m_buffer_mgr.setFrameDim(frame_dim);
}
void BufferCtrlObj::getFramedim(FrameDim& frame_dim)
void BufferCtrlObj::getFrameDim(FrameDim& frame_dim)
{
DEB_MEMBER_FUNCT();
m_buffer_mgr.getFrameDim(frame_dim);
......
......@@ -5,7 +5,7 @@
#include "TaskMgr.h"
#include "TaskEventCallback.h"
#include "SoftRoi.h"
#include "AcqFinished.h"
#include "AcqState.h"
#include <iostream>
......@@ -21,7 +21,7 @@ class SoftRoiCallback : public TaskEventCallback
public:
SoftRoiCallback(Frelon::Interface& hw_inter, BufferSave& buffer_save,
AcqFinished& acq_finished);
AcqState& acq_state);
~SoftRoiCallback();
virtual void finished(Data& data);
......@@ -31,14 +31,14 @@ private:
Frelon::Interface& m_hw_inter;
BufferSave& m_buffer_save;
AcqFinished& m_acq_finished;
AcqState& m_acq_state;
};
SoftRoiCallback::SoftRoiCallback(Frelon::Interface& hw_inter,
BufferSave& buffer_save,
AcqFinished& acq_finished)
AcqState& acq_state)
: m_hw_inter(hw_inter), m_buffer_save(buffer_save),
m_acq_finished(acq_finished)
m_acq_state(acq_state)
{
DEB_CONSTRUCTOR();
}
......@@ -94,7 +94,7 @@ void SoftRoiCallback::finished(Data& data)
int nb_frames;
hw_sync->getNbFrames(nb_frames);
if (data.frameNumber == nb_frames - 1)
m_acq_finished.signalFinished();
m_acq_state.set(AcqState::Finished);
}
......@@ -105,7 +105,7 @@ class TestFrameCallback : public HwFrameCallback
public:
TestFrameCallback(Frelon::Interface& hw_inter, Roi& soft_roi,
BufferSave& buffer_save, AcqFinished& acq_finished);
BufferSave& buffer_save, AcqState& acq_state);
~TestFrameCallback();
protected:
......@@ -122,11 +122,11 @@ private:
TestFrameCallback::TestFrameCallback(Frelon::Interface& hw_inter,
Roi& soft_roi, BufferSave& buffer_save,
AcqFinished& acq_finished)
AcqState& acq_state)
: m_hw_inter(hw_inter), m_soft_roi(soft_roi)
{
DEB_CONSTRUCTOR();
m_roi_cb = new SoftRoiCallback(hw_inter, buffer_save, acq_finished);
m_roi_cb = new SoftRoiCallback(hw_inter, buffer_save, acq_state);
m_roi_task = new SoftRoi();
}
......@@ -272,8 +272,8 @@ void test_frelon_hw_inter(bool do_reset)
BufferSave buffer_save(BufferSave::EDF, "img", 0, ".edf", true, 1);
Roi soft_roi;
AcqFinished acq_finished;
TestFrameCallback cb(hw_inter, soft_roi, buffer_save, acq_finished);
AcqState acq_state;
TestFrameCallback cb(hw_inter, soft_roi, buffer_save, acq_state);
HwDetInfoCtrlObj *hw_det_info;
hw_inter.getHwCtrlObj(hw_det_info);
......@@ -314,9 +314,9 @@ void test_frelon_hw_inter(bool do_reset)
hw_buffer->registerFrameCallback(cb);
print_status(hw_inter);
acq_finished.resetFinished();
acq_state.set(AcqState::Running);
hw_inter.startAcq();
acq_finished.waitFinished();
acq_state.waitNot(AcqState::Running);
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
......@@ -325,9 +325,9 @@ void test_frelon_hw_inter(bool do_reset)
hw_sync->setExpTime(5);
print_status(hw_inter);
acq_finished.resetFinished();
acq_state.set(AcqState::Running);
hw_inter.startAcq();
acq_finished.waitFinished();
acq_state.waitNot(AcqState::Running);
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
......@@ -337,9 +337,9 @@ void test_frelon_hw_inter(bool do_reset)
hw_sync->setNbFrames(3);
print_status(hw_inter);
acq_finished.resetFinished();
acq_state.set(AcqState::Running);
hw_inter.startAcq();
acq_finished.waitFinished();
acq_state.waitNot(AcqState::Running);
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
......@@ -366,9 +366,9 @@ void test_frelon_hw_inter(bool do_reset)
hw_buffer->setNbBuffers(10);
print_status(hw_inter);
acq_finished.resetFinished();
acq_state.set(AcqState::Running);
hw_inter.startAcq();
acq_finished.waitFinished();
acq_state.waitNot(AcqState::Running);
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
......@@ -381,9 +381,9 @@ void test_frelon_hw_inter(bool do_reset)
hw_buffer->setNbBuffers(10);
print_status(hw_inter);
acq_finished.resetFinished();
acq_state.set(AcqState::Running);
hw_inter.startAcq();
acq_finished.waitFinished();
acq_state.waitNot(AcqState::Running);
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
......@@ -399,9 +399,9 @@ void test_frelon_hw_inter(bool do_reset)
hw_buffer->setNbBuffers(10);
print_status(hw_inter);
acq_finished.resetFinished();
acq_state.set(AcqState::Running);
hw_inter.startAcq();
acq_finished.waitFinished();
acq_state.waitNot(AcqState::Running);
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
......@@ -417,9 +417,9 @@ void test_frelon_hw_inter(bool do_reset)
print_deb_flags();
print_status(hw_inter);
acq_finished.resetFinished();
acq_state.set(AcqState::Running);
hw_inter.startAcq();
acq_finished.waitFinished();
acq_state.waitNot(AcqState::Running);
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
......
......@@ -28,11 +28,11 @@ class SoftRoiCallback( processlib.TaskEventCallback ):
N.uint32: lima.Bpp32
}
def __init__(self, hw_inter, buffer_save, acq_finished):
def __init__(self, hw_inter, buffer_save, acq_state):
processlib.TaskEventCallback.__init__(self)
self.m_hw_inter = hw_inter
self.m_buffer_save = buffer_save
self.m_acq_finished = acq_finished
self.m_acq_state = acq_state
def finished(self, data):
finfo, fdim = self.data2FrameInfo(data)
......@@ -41,7 +41,7 @@ class SoftRoiCallback( processlib.TaskEventCallback ):
hw_sync = self.m_hw_inter.getHwCtrlObj(lima.HwCap.Sync)
nb_frames = hw_sync.getNbFrames()
if finfo.acq_frame_nb == nb_frames - 1:
self.m_acq_finished.signalFinished()
self.m_acq_state.set(lima.AcqState.Finished)
def data2FrameInfo(self, data):
arr = data.buffer
......@@ -70,14 +70,14 @@ class TestFrameCallback( lima.HwFrameCallback ):
lima.Bpp32: Data_UINT32
}
def __init__(self, hw_inter, soft_roi, buffer_save, acq_finished):
def __init__(self, hw_inter, soft_roi, buffer_save, acq_state):
lima.HwFrameCallback.__init__(self)
self.m_hw_inter = hw_inter
self.m_soft_roi = soft_roi
self.m_acq_finished = acq_finished
self.m_acq_state = acq_state
self.m_roi_task = processlib.Tasks.SoftRoi()
self.m_roi_cb = SoftRoiCallback(hw_inter, buffer_save,
acq_finished)
acq_state)
def newFrameReady(self, frame_info):
msg = 'acq_frame_nb=%d, ' % frame_info.acq_frame_nb
......@@ -152,9 +152,9 @@ def main(argv):
hw_roi = hw_inter.getHwCtrlObj(lima.HwCap.Roi)
soft_roi = lima.Roi()
acq_finished = lima.AcqFinished()
acq_state = lima.AcqState()
print "Creating a TestFrameCallback"
cb = TestFrameCallback(hw_inter, soft_roi, buffer_save, acq_finished)
cb = TestFrameCallback(hw_inter, soft_roi, buffer_save, acq_state)
do_reset = False
if do_reset:
......@@ -181,11 +181,11 @@ def main(argv):
hw_sync.setNbFrames(3)
print "Starting Acquisition"
acq_finished.resetFinished()
acq_state.set(lima.AcqState.Running)
hw_inter.startAcq()
print "Waiting acq finished..."
acq_finished.waitFinished()
acq_state.waitNot(lima.AcqState.Running)
print "Acq finished!!"
print "Stopping Acquisition"
......
#include "FrelonInterface.h"
#include "BufferSave.h"
#include "AcqState.h"
#include "PoolThreadMgr.h"
#include <iostream>
using namespace lima;
......@@ -6,11 +10,105 @@ using namespace std;
DEB_GLOBAL(DebModTest);
class TestFrameCallback : public HwFrameCallback
{
DEB_CLASS(DebModTest, "TestFrameCallback");
public:
TestFrameCallback(Frelon::Interface& hw_inter,
BufferSave& buffer_save, AcqState& acq_state);
~TestFrameCallback();
const HwFrameInfoType& getBufferInfo();
protected:
virtual bool newFrameReady(const HwFrameInfoType& frame_info);
private:
Frelon::Interface& m_hw_inter;
BufferSave& m_buffer_save;
AcqState& m_acq_state;
void *m_buffer_ptr;
int m_nb_frames;
int m_nb_stripes;
FrameDim m_buffer_dim;
HwFrameInfoType m_buffer_info;
};
TestFrameCallback::TestFrameCallback(Frelon::Interface& hw_inter,
BufferSave& buffer_save,
AcqState& acq_state)
: m_hw_inter(hw_inter), m_buffer_save(buffer_save),
m_acq_state(acq_state)
{
DEB_CONSTRUCTOR();
m_buffer_ptr = NULL;
m_nb_frames = 1;
m_nb_stripes = 1;
}
TestFrameCallback::~TestFrameCallback()
{
DEB_DESTRUCTOR();
}
bool TestFrameCallback::newFrameReady(const HwFrameInfoType& frame_info)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(frame_info);
if (!frame_info.isValid()) {
DEB_ERROR() << "Acquisition aborted";
m_acq_state.set(AcqState::Aborted);
return false;
}
int acq_frame_nb = frame_info.acq_frame_nb;
if (acq_frame_nb == 0) {
HwBufferCtrlObj *hw_buffer;
m_hw_inter.getHwCtrlObj(hw_buffer);
hw_buffer->getNbConcatFrames(m_nb_stripes);
HwSyncCtrlObj *hw_sync;
m_hw_inter.getHwCtrlObj(hw_sync);
hw_sync->getNbFrames(m_nb_frames);
}
if (acq_frame_nb % m_nb_stripes == 0)
m_buffer_ptr = frame_info.frame_ptr;
if (((acq_frame_nb + 1) % m_nb_stripes) == 0) {
Point factor(1, m_nb_stripes);
m_buffer_dim = *frame_info.frame_dim * factor;
m_buffer_info = frame_info;
m_buffer_info.frame_ptr = m_buffer_ptr;
m_buffer_info.frame_dim = &m_buffer_dim;
m_buffer_info.valid_pixels *= m_nb_stripes;
DEB_ALWAYS() << "Buffer ready: " << m_buffer_info;
}
if (acq_frame_nb == m_nb_frames - 1) {
DEB_ALWAYS() << "Acq finished!";
m_acq_state.set(AcqState::Finished);
}
return true;
}
const HwFrameInfoType& TestFrameCallback::getBufferInfo()
{
return m_buffer_info;
}
void test_frelon_spectroscopy()
{
DEB_GLOBAL_FUNCT();
// DebParams::disableModuleFlags(DebModEspiaSerial | DebModCameraCom);
DebParams::disableTypeFlags(DebParams::AllFlags);
Espia::Dev dev(0);
Espia::Acq acq(dev);
......@@ -19,10 +117,14 @@ void test_frelon_spectroscopy()
Frelon::Camera cam(ser_line);
BufferCtrlMgr buffer_mgr(buffer_cb_mgr);
DEB_TRACE() << "Creating the Hw Interface ...";
DEB_ALWAYS() << "Creating the Hw Interface ...";
Frelon::Interface hw_inter(acq, buffer_mgr, cam);
DEB_TRACE() << "Done!";
BufferSave buffer_save(BufferSave::EDF, "big_img", 0, ".edf", true, 1);
AcqState acq_state;
TestFrameCallback cb(hw_inter, buffer_save, acq_state);
HwDetInfoCtrlObj *hw_det_info;
hw_inter.getHwCtrlObj(hw_det_info);
......@@ -38,31 +140,73 @@ void test_frelon_spectroscopy()
HwRoiCtrlObj *hw_roi;
hw_inter.getHwCtrlObj(hw_roi);
DEB_TRACE() << "Setting Chans 3 & 4";
hw_buffer->registerFrameCallback(cb);
DEB_ALWAYS() << "Setting Chans 3 & 4";
cam.setInputChan(Frelon::Chan34);
Bin bin(1, 64);
DEB_TRACE() << "Setting binning to " << bin;
DEB_ALWAYS() << "Setting binning to " << bin;
hw_bin->setBin(bin);
Roi roi(Point(0, 30), Size(2048, 1));
DEB_TRACE() << "Checking " << DEB_VAR1(roi);
DEB_ALWAYS() << "Checking " << DEB_VAR1(roi);
Roi real_roi;
hw_roi->checkRoi(roi, real_roi);
DEB_TRACE() << "Got " << DEB_VAR1(real_roi);
DEB_TRACE() << "Setting " << DEB_VAR1(roi);
DEB_ALWAYS() << "Setting " << DEB_VAR1(roi);
hw_roi->setRoi(roi);
hw_roi->getRoi(real_roi);
DEB_TRACE() << "Got " << DEB_VAR1(real_roi);
DEB_TRACE() << "Setting Kinetic roi";
cam.setRoiMode(Frelon::Kinetic);
int nb_stripes = 10000;
int nb_buffers = 1;
DEB_ALWAYS() << "Setting stripe concatenation (big buffer)";
FrameDim fdim;
hw_buffer->getFrameDim(fdim);
fdim.setSize(real_roi.getSize());
hw_buffer->setFrameDim(fdim);
hw_buffer->setNbConcatFrames(nb_stripes);
hw_buffer->setNbBuffers(nb_buffers);
double exp_time = 1e-6;
int nb_frames = nb_buffers * nb_stripes;
hw_sync->setExpTime(exp_time);
hw_sync->setNbFrames(nb_frames);
Timestamp t0, t1;
DEB_ALWAYS() << "Starting acquisition";
t0 = Timestamp::now();
acq_state.set(AcqState::Running);
hw_inter.startAcq();
acq_state.waitNot(AcqState::Running);
t1 = Timestamp::now();
if (acq_state.get() == AcqState::Aborted) {
DEB_ERROR() << "Acquisition aborted!";
throw LIMA_HW_EXC(Error, "Acquisition aborted");
}
DEB_ALWAYS() << "Acquisition finished after " << (t1 - t0) << " sec";
DEB_ALWAYS() << "Saving buffer";
buffer_save.writeFrame(cb.getBufferInfo());
DEB_TRACE() << "Done!";
}
int main(int argc, char *argv[])
{
DEB_GLOBAL_FUNCT();
int nb_threads = 1;
DEB_TRACE() << "Setting Proccesslib NbPoolThreads to " << nb_threads;
PoolThreadMgr& pool_thread_mgr = PoolThreadMgr::get();
pool_thread_mgr.setNumberOfThread(nb_threads);
try {
test_frelon_spectroscopy();
} catch (Exception& e) {
......
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