Commit 72a545b8 authored by ahoms's avatar ahoms

* added skeleton of testfreloncontrol

* fixed bug in CtBuffer not initializing m_frame_cb
* added applications/taco subdirectories
* created HwMaxImageSizeCallbackGen independent of HwDetInfoCtrlObj, the
  latter only acts as an entry point for [un]registering MaxImageSizeCallback
* Simulator/Espia::Focla DetInfoCtrlObj include dummy MaxImageSizeCallbackGen
* changed Frelon::Camera to be MaxImageSizeCallbackGen when changing FTM
* updated testfreloninterface[.py] to include MaxImageSize change detection
* implemented Frelon::SyncCtrlObj::getValidRanges



git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@191 45c4679d-1946-429d-baad-37912b19538b
parent 4eb84f38
......@@ -2,6 +2,7 @@
#define FRELONCAMERA_H
#include "FrelonSerialLine.h"
#include "HwMaxImageSizeCallback.h"
namespace lima
{
......@@ -9,7 +10,7 @@ namespace lima
namespace Frelon
{
class Camera
class Camera : public HwMaxImageSizeCallbackGen
{
DEB_CLASS_NAMESPC(DebModCamera, "Camera", "Frelon");
......@@ -74,6 +75,9 @@ class Camera
void start();
void stop();
protected:
virtual void setMaxImageSizeCallbackActive(bool cb_active);
private:
static const double HorzBinChangeTime;
static const double MaxReadoutTime;
......@@ -119,6 +123,7 @@ class Camera
Point m_roi_offset;
TrigMode m_trig_mode;
int m_nb_frames;
bool m_mis_cb_act;
};
inline bool Camera::isChanActive(InputChan chan)
......
......@@ -37,12 +37,13 @@ class DetInfoCtrlObj : public HwDetInfoCtrlObj
virtual void getDetectorType(std::string& det_type);
virtual void getDetectorModel(std::string& det_model);
protected:
virtual void setMaxImageSizeCallbackActive(bool cb_active);
virtual void registerMaxImageSizeCallback(
HwMaxImageSizeCallback& cb);
virtual void unregisterMaxImageSizeCallback(
HwMaxImageSizeCallback& cb);
private:
Camera& m_cam;
bool m_iscb_act;
};
......
......@@ -74,6 +74,9 @@ class Camera
void start();
void stop();
protected:
virtual void setMaxImageSizeCallbackActive(bool cb_active);
};
......
......@@ -29,9 +29,10 @@ class DetInfoCtrlObj : HwDetInfoCtrlObj
virtual void getDetectorType(std::string& det_type /Out/);
virtual void getDetectorModel(std::string& det_model /Out/);
protected:
virtual void setMaxImageSizeCallbackActive(bool cb_active);
virtual void registerMaxImageSizeCallback(
HwMaxImageSizeCallback& cb);
virtual void unregisterMaxImageSizeCallback(
HwMaxImageSizeCallback& cb);
};
......
......@@ -12,7 +12,7 @@ const double Camera::MaxReadoutTime = 0.7;
Camera::Camera(Espia::SerialLine& espia_ser_line)
: m_ser_line(espia_ser_line)
: m_ser_line(espia_ser_line), m_mis_cb_act(false)
{
DEB_CONSTRUCTOR();
......@@ -242,11 +242,26 @@ void Camera::setFrameTransferMode(FrameTransferMode ftm)
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(ftm);
FrameTransferMode prev_ftm;
getFrameTransferMode(prev_ftm);
if (ftm == prev_ftm) {
DEB_TRACE() << "Nothing to do";
return;
}
InputChan input_chan;
getInputChan(input_chan);
int chan_mode;
getInputChanMode(ftm, input_chan, chan_mode);
setChanMode(chan_mode);
if (!m_mis_cb_act)
return;
FrameDim frame_dim;
getFrameDim(frame_dim);
DEB_TRACE() << "MaxImageSizeChanged: " << DEB_VAR1(frame_dim);
maxImageSizeChanged(frame_dim.getSize(), frame_dim.getImageType());
}
void Camera::getFrameTransferMode(FrameTransferMode& ftm)
......@@ -849,3 +864,7 @@ void Camera::stop()
}
}
void Camera::setMaxImageSizeCallbackActive(bool cb_active)
{
m_mis_cb_act = cb_active;
}
......@@ -98,12 +98,18 @@ void DetInfoCtrlObj::getDetectorModel(std::string& det_model)
DEB_RETURN() << DEB_VAR1(det_model);
}
void DetInfoCtrlObj::setMaxImageSizeCallbackActive(bool cb_active)
void DetInfoCtrlObj::registerMaxImageSizeCallback(
HwMaxImageSizeCallback& cb)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(cb_active);
m_cam.registerMaxImageSizeCallback(cb);
}
DEB_ERROR() << "Not implemented yet!";
void DetInfoCtrlObj::unregisterMaxImageSizeCallback(
HwMaxImageSizeCallback& cb)
{
DEB_MEMBER_FUNCT();
m_cam.unregisterMaxImageSizeCallback(cb);
}
......@@ -294,7 +300,20 @@ void SyncCtrlObj::getValidRanges(ValidRangesType& valid_ranges)
{
DEB_MEMBER_FUNCT();
DEB_ERROR() << "Not implemented yet!";
const double MinTimeUnit = TimeUnitFactorMap[Microseconds];
const double MaxTimeUnit = TimeUnitFactorMap[Milliseconds];
const double LatTimeUnit = TimeUnitFactorMap[Milliseconds];
valid_ranges.min_exp_time = 1 * MinTimeUnit;
valid_ranges.max_exp_time = MaxRegVal * MaxTimeUnit;
valid_ranges.min_lat_time = 0 * LatTimeUnit;
valid_ranges.max_lat_time = MaxRegVal * LatTimeUnit;
DEB_RETURN() << DEB_VAR2(valid_ranges.min_exp_time,
valid_ranges.max_exp_time);
DEB_RETURN() << DEB_VAR2(valid_ranges.min_lat_time,
valid_ranges.max_lat_time);
}
......
frelon-objs = ../src/Frelon.o ../../common/espia/src/Espia.o \
../../../hardware/src/Hw.o ../../../common/src/Common.o
SRCS = testfrelon.cpp testfreloninterface.cpp testfrelonspectroscopy.cpp
ct-objs = ../../../control/src/Ct.o
SRCS = testfrelon.cpp testfreloninterface.cpp testfrelonspectroscopy.cpp \
testfreloncontrol.cpp
include ../../common/espia/include/espia.inc
......@@ -16,9 +19,12 @@ CXXFLAGS = -I../include -I../../common/espia/include \
-I../../../third-party/Processlib/tasks/include \
-I$(ESPIA_DRV_INCL) -Wall -pthread -g
all: testfrelon testfreloninterface testfrelonspectroscopy
test-progs = testfrelon testfreloninterface testfrelonspectroscopy \
testfreloncontrol
all: $(test-progs)
testfrelon: testfrelon.o $(frelon-objs)
testfrelon: testfrelon.o $(frelon-objs)
$(CXX) $(LDFLAGS) -o $@ $+ $(LDLIBS)
testfreloninterface: testfreloninterface.o $(frelon-objs)
......@@ -27,6 +33,9 @@ testfreloninterface: testfreloninterface.o $(frelon-objs)
testfrelonspectroscopy: testfrelonspectroscopy.o $(frelon-objs)
$(CXX) $(LDFLAGS) -o $@ $+ $(LDLIBS)
testfreloncontrol: testfreloncontrol.o $(frelon-objs) $(ct-objs)
$(CXX) $(LDFLAGS) -o $@ $+ $(LDLIBS)
clean:
rm -f *.o *.P testfrelon testfreloninterface testfrelonspectroscopy
......
#include "FrelonInterface.h"
#include "CtAcquisition.h"
using namespace lima;
DEB_GLOBAL(DebModTest);
void test_frelon_control()
{
DEB_GLOBAL_FUNCT();
// DebParams::disableModuleFlags(DebParams::AllFlags);
DebParams::enableModuleFlags(DebModTest);
Espia::Dev dev(0);
Espia::Acq acq(dev);
Espia::BufferMgr buffer_cb_mgr(acq);
Espia::SerialLine ser_line(dev);
Frelon::Camera cam(ser_line);
BufferCtrlMgr buffer_mgr(buffer_cb_mgr);
DEB_ALWAYS() << "Creating the Hw Interface ...";
Frelon::Interface hw_inter(acq, buffer_mgr, cam);
DEB_TRACE() << "Done!";
CtControl control(&hw_inter);
CtAcquisition* ct_acq = control.acquisition();
AcqMode acq_mode;
ct_acq->getAcqMode(acq_mode);
DEB_TRACE() << "Default " << DEB_VAR1(acq_mode);
double exp_time;
ct_acq->getAcqExpoTime(exp_time);
DEB_TRACE() << "Default " << DEB_VAR1(exp_time);
int nb_frame;
ct_acq->getAcqNbFrames(nb_frame);
DEB_TRACE() << "Default " << DEB_VAR1(nb_frame);
// ct_acq->setAcqMode(Single);
// ct_acq->setAcqExpoTime(exp_time);
// ct_acq->setAcqNbFrames(nframe);
}
int main(int argc, char *argv[])
{
DEB_GLOBAL_FUNCT();
try {
test_frelon_control();
} catch (Exception& e) {
DEB_ERROR() << "LIMA Exception: " << e;
}
return 0;
}
......@@ -15,6 +15,11 @@ using namespace Tasks;
DEB_GLOBAL(DebModTest);
//*********************************************************************
// SoftRoiCallback
//*********************************************************************
class SoftRoiCallback : public TaskEventCallback
{
DEB_CLASS(DebModTest, "SoftRoiCallback");
......@@ -99,6 +104,10 @@ void SoftRoiCallback::finished(Data& data)
}
//*********************************************************************
// TestFrameCallback
//*********************************************************************
class TestFrameCallback : public HwFrameCallback
{
DEB_CLASS(DebModTest, "TestFrameCallback");
......@@ -200,6 +209,46 @@ bool TestFrameCallback::newFrameReady(const HwFrameInfoType& frame_info)
return true;
}
//*********************************************************************
// MaxImageSizeCallback
//*********************************************************************
class MaxImageSizeCallback : public HwMaxImageSizeCallback
{
DEB_CLASS(DebModTest, "MaxImageSizeCallback");
public:
MaxImageSizeCallback();
virtual ~MaxImageSizeCallback();
protected:
virtual void maxImageSizeChanged(const Size& size,
ImageType image_type);
};
MaxImageSizeCallback::MaxImageSizeCallback()
{
DEB_CONSTRUCTOR();
}
MaxImageSizeCallback::~MaxImageSizeCallback()
{
DEB_DESTRUCTOR();
}
void MaxImageSizeCallback::maxImageSizeChanged(const Size& size,
ImageType image_type)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR2(size, image_type);
}
//*********************************************************************
// print_status
//*********************************************************************
void print_status(Frelon::Interface& hw_inter)
{
DEB_GLOBAL_FUNCT();
......@@ -210,6 +259,10 @@ void print_status(Frelon::Interface& hw_inter)
DEB_PARAM() << DEB_VAR1(status);
}
//*********************************************************************
// set_hw_roi
//*********************************************************************
void set_hw_roi(HwRoiCtrlObj *hw_roi, const Roi& set_roi, Roi& real_roi,
Roi& soft_roi)
{
......@@ -229,6 +282,11 @@ void set_hw_roi(HwRoiCtrlObj *hw_roi, const Roi& set_roi, Roi& real_roi,
DEB_TRACE() << DEB_VAR3(set_roi, real_roi, soft_roi);
}
//*********************************************************************
// print_deb_flags
//*********************************************************************
void print_deb_flags()
{
DEB_GLOBAL_FUNCT();
......@@ -249,6 +307,11 @@ void print_deb_flags()
DEB_PARAM() << DEB_VAR1(ModuleFlagsNameList);
}
//*********************************************************************
// test_frelon_hw_inter
//*********************************************************************
void test_frelon_hw_inter(bool do_reset)
{
DEB_GLOBAL_FUNCT();
......@@ -271,10 +334,12 @@ void test_frelon_hw_inter(bool do_reset)
BufferSave buffer_save(BufferSave::EDF, "img", 0, ".edf", true, 1);
MaxImageSizeCallback mis_cb;
Roi soft_roi;
AcqState acq_state;
TestFrameCallback cb(hw_inter, soft_roi, buffer_save, acq_state);
HwDetInfoCtrlObj *hw_det_info;
hw_inter.getHwCtrlObj(hw_det_info);
......@@ -301,7 +366,13 @@ void test_frelon_hw_inter(bool do_reset)
ImageType image_type;
hw_det_info->getCurrImageType(image_type);
FrameDim frame_dim(size, image_type);
hw_det_info->registerMaxImageSizeCallback(mis_cb);
DEB_TRACE() << "Setting FTM";
cam.setFrameTransferMode(Frelon::FTM);
DEB_TRACE() << "Setting FFM";
cam.setFrameTransferMode(Frelon::FFM);
Bin bin(1);
hw_bin->setBin(bin);
......@@ -431,6 +502,11 @@ void test_frelon_hw_inter(bool do_reset)
print_deb_flags();
}
//*********************************************************************
// main
//*********************************************************************
int main(int argc, char *argv[])
{
DEB_GLOBAL_FUNCT();
......
......@@ -107,6 +107,16 @@ class TestFrameCallback( lima.HwFrameCallback ):
return data
class MaxImageSizeCallback( lima.HwMaxImageSizeCallback ):
def maxImageSizeChanged(self, size, image_type):
fdim = lima.FrameDim(size, image_type)
msg = "size=%sx%s, image_type=%s, depth=%d" % \
(size.getWidth(), size.getHeight(), image_type, \
fdim.getDepth())
print "MaxImageSizeChanged:", msg
def main(argv):
print "Creating Espia.Dev"
edev = lima.Espia.Dev(0)
......@@ -127,7 +137,7 @@ def main(argv):
eser_line = lima.Espia.SerialLine(edev)
print "Creating Frelon.Camera"
cam = lima.Frelon.Camera(eser_line);
cam = lima.Frelon.Camera(eser_line)
print "Creating the Hw Interface ... "
hw_inter = lima.Frelon.Interface(acq, buffer_mgr, cam)
......@@ -151,6 +161,14 @@ def main(argv):
print "Getting HW RoI"
hw_roi = hw_inter.getHwCtrlObj(lima.HwCap.Roi)
mis_cb = MaxImageSizeCallback()
hw_det_info.registerMaxImageSizeCallback(mis_cb);
print "Setting FTM";
cam.setFrameTransferMode(lima.Frelon.FTM)
print "Setting FFM";
cam.setFrameTransferMode(lima.Frelon.FFM)
soft_roi = lima.Roi()
acq_state = lima.AcqState()
print "Creating a TestFrameCallback"
......
......@@ -3,8 +3,6 @@
#include "AcqState.h"
#include "PoolThreadMgr.h"
#include <iostream>
using namespace lima;
using namespace std;
......
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