Commit 666ccebb authored by ahoms's avatar ahoms

* added AcqFinished helper class for test programs (testfreloninterface)

* implemented missing Cond acquire and release methods
* wrapped MutexAttr, Mutex and Cond classes (ThreadUtils.h) in sip
* updated testfreloninterface.py to work with callbacks (in progress)



git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@149 45c4679d-1946-429d-baad-37912b19538b
parent 395338b2
......@@ -5,6 +5,7 @@
#include "TaskMgr.h"
#include "TaskEventCallback.h"
#include "SoftRoi.h"
#include "AcqFinished.h"
#include <iostream>
......@@ -16,7 +17,7 @@ class SoftRoiCallback : public TaskEventCallback
{
public:
SoftRoiCallback(Frelon::Interface& hw_inter, BufferSave& buffer_save,
Cond& acq_finished)
AcqFinished& acq_finished)
: m_hw_inter(hw_inter), m_buffer_save(buffer_save),
m_acq_finished(acq_finished) {}
......@@ -27,7 +28,7 @@ private:
Frelon::Interface& m_hw_inter;
BufferSave& m_buffer_save;
Cond& m_acq_finished;
AcqFinished& m_acq_finished;
};
void SoftRoiCallback::data2FrameInfo(Data& data, HwFrameInfoType& finfo,
......@@ -72,7 +73,7 @@ void SoftRoiCallback::finished(Data& data)
int nb_frames;
hw_sync->getNbFrames(nb_frames);
if (data.frameNumber == nb_frames - 1)
m_acq_finished.signal();
m_acq_finished.signalFinished();
}
......@@ -81,7 +82,7 @@ class TestFrameCallback : public HwFrameCallback
{
public:
TestFrameCallback(Frelon::Interface& hw_inter, Roi& soft_roi,
BufferSave& buffer_save, Cond& acq_finished)
BufferSave& buffer_save, AcqFinished& acq_finished)
: m_hw_inter(hw_inter), m_soft_roi(soft_roi)
{
m_roi_cb = new SoftRoiCallback(hw_inter, buffer_save,
......@@ -212,7 +213,7 @@ void test_frelon_hw_inter(bool do_reset)
BufferSave buffer_save(BufferSave::EDF, "img", 0, ".edf", true, 1);
Roi soft_roi;
Cond acq_finished;
AcqFinished acq_finished;
TestFrameCallback cb(hw_inter, soft_roi, buffer_save, acq_finished);
HwDetInfoCtrlObj *hw_det_info;
......@@ -254,8 +255,9 @@ void test_frelon_hw_inter(bool do_reset)
hw_buffer->registerFrameCallback(cb);
print_status(hw_inter);
acq_finished.resetFinished();
hw_inter.startAcq();
acq_finished.wait();
acq_finished.waitFinished();
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
......@@ -264,8 +266,9 @@ void test_frelon_hw_inter(bool do_reset)
hw_sync->setExpTime(5);
print_status(hw_inter);
acq_finished.resetFinished();
hw_inter.startAcq();
acq_finished.wait();
acq_finished.waitFinished();
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
......@@ -275,8 +278,9 @@ void test_frelon_hw_inter(bool do_reset)
hw_sync->setNbFrames(3);
print_status(hw_inter);
acq_finished.resetFinished();
hw_inter.startAcq();
acq_finished.wait();
acq_finished.waitFinished();
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
......@@ -301,8 +305,9 @@ void test_frelon_hw_inter(bool do_reset)
hw_buffer->setNbBuffers(10);
print_status(hw_inter);
acq_finished.resetFinished();
hw_inter.startAcq();
acq_finished.wait();
acq_finished.waitFinished();
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
......@@ -315,8 +320,9 @@ void test_frelon_hw_inter(bool do_reset)
hw_buffer->setNbBuffers(10);
print_status(hw_inter);
acq_finished.resetFinished();
hw_inter.startAcq();
acq_finished.wait();
acq_finished.waitFinished();
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
......@@ -329,8 +335,9 @@ void test_frelon_hw_inter(bool do_reset)
hw_buffer->setNbBuffers(10);
print_status(hw_inter);
acq_finished.resetFinished();
hw_inter.startAcq();
acq_finished.wait();
acq_finished.waitFinished();
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
......@@ -343,8 +350,9 @@ void test_frelon_hw_inter(bool do_reset)
hw_sync->setNbFrames(3);
print_status(hw_inter);
acq_finished.resetFinished();
hw_inter.startAcq();
acq_finished.wait();
acq_finished.waitFinished();
PoolThreadMgr::get().wait();
print_status(hw_inter);
hw_inter.stopAcq();
......
......@@ -49,25 +49,31 @@ print "Getting HW RoI"
hw_roi = hw_inter.getHwCtrlObj(lima.HwCap.Roi)
print type(hw_roi)
class TestFrameCallback( lima.HwFrameCallback ):
def __init__(self, hw_inter, soft_roi, buffer_save, acq_finished):
lima.HwFrameCallback.__init__(self)
self.m_hw_inter = hw_inter
self.m_soft_roi = soft_roi
self.m_roi_task = lima.SoftRoi()
self.m_roi_cb = lima.SoftRoiCallback(hw_inter, buffer_save,
acq_finished)
self.m_acq_finished = acq_finished
# self.m_roi_task = lima.SoftRoi()
# self.m_roi_cb = lima.SoftRoiCallback(hw_inter, buffer_save,
# acq_finished)
def newFrameReady(self, frame_info):
print "newFrameReady!"
hw_sync = self.m_hw_inter.getHwCtrlObj(lima.HwCap.Sync)
nb_frames = hw_sync.getNbFrames()
if frame_info.acq_frame_nb == nb_frames - 1:
self.m_acq_finished.signalFinished()
return True
soft_roi = lima.Roi()
#acq_finished = lima.Cond() # Thread utils are not wrapped!
#print "Creating a TestFrameCallback"
#cb = TestFrameCallback(hw_inter, soft_roi, buffer_save, acq_finished)
acq_finished = lima.AcqFinished()
print "Creating a TestFrameCallback"
cb = TestFrameCallback(hw_inter, soft_roi, buffer_save, acq_finished)
s = raw_input('Reset the hardware? (y/n):')
if s[0] == 'y' or s[0] == 'Y':
do_reset = False
if do_reset:
print "Reseting hardware ..."
hw_inter.reset(lima.HwInterface.HardReset)
print " Done!"
......@@ -84,7 +90,8 @@ hw_bin.setBin(bin)
effect_frame_dim = lima.FrameDim(frame_dim) # was (frame_dim / bin)
hw_buffer.setFrameDim(effect_frame_dim)
hw_buffer.setNbBuffers(10)
#hw_buffer.registerFrameCallback(cb)
print "cb=", cb
hw_buffer.registerFrameCallback(cb)
hw_sync.setExpTime(2)
hw_sync.setNbFrames(3)
......@@ -92,10 +99,9 @@ hw_sync.setNbFrames(3)
print "Starting Acquisition"
hw_inter.startAcq()
#acq_finished.wait()
print "Waiting acq finished..."
acq_finished.waitFinished()
#PoolThreadMgr::get().wait();
print "Waiting 10 seconds..."
time.sleep(10)
print "Stopping Acquisition"
hw_inter.stopAcq()
......
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