Meta camera implementation

Cosmetic changes.

Manage reconstruction in Meta camera
parent ddf9a833
......@@ -661,6 +661,29 @@ build_targets += $(call lib-full,$(aviex-name),$(aviex-ver))
endif
############################
# LIMA - META
############################
ifneq ($(COMPILE_META),0)
META_LDFLAGS := $(LDFLAGS)
META_LDLIBS := $(LDLIBS)
meta-name := meta
meta-objs := ../camera/common/meta/src/Meta.o
meta-ver := ../camera/common/meta/VERSION
meta-flags := $(META_LDFLAGS)
meta-deps := $(META_LDLIBS)
$(call lib-full,$(meta-name),$(meta-ver)): $(meta-objs)
$(call compile-lib,$(meta-name),$(meta-ver),\
$(meta-flags),$(meta-deps),$@,$+)
$(call create-links,$(meta-name),$(meta-ver))
build_targets += $(call lib-full,$(meta-name),$(meta-ver))
endif
src: $(build_targets)
test:
......
......@@ -31,4 +31,12 @@ ifneq ($(COMPILE_ESPIA),0)
sub-dirs += espia
endif
ifndef COMPILE_META
COMPILE_META = 0
endif
ifneq ($(COMPILE_META),0)
sub-dirs += meta
endif
include ../../global.inc
src-dirs = src
test-dirs =
include ../../../global.inc
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#ifndef METADETINFOCTRLOBJ_H
#define METADETINFOCTRLOBJ_H
#include "HwDetInfoCtrlObj.h"
#include "Debug.h"
namespace lima
{
class HwInterface;
namespace Meta
{
class Interface;
class DetInfoCtrlObj : public HwDetInfoCtrlObj, public HwMaxImageSizeCallbackGen
{
DEB_CLASS_NAMESPC(DebModCamera, "DetInfoCtrlObj","Meta");
class _MaxImageSizeCallback;
friend class _MaxImageSizeCallback;
friend class Interface;
public:
DetInfoCtrlObj(Interface&);
virtual ~DetInfoCtrlObj();
virtual void getMaxImageSize(Size& max_image_size);
virtual void getDetectorImageSize(Size& det_image_size);
virtual void getDefImageType(ImageType& def_image_type);
virtual void getCurrImageType(ImageType& curr_image_type);
virtual void setCurrImageType(ImageType curr_image_type);
virtual void getPixelSize(double& x_size,double &y_size);
virtual void getDetectorType(std::string& det_type);
virtual void getDetectorModel(std::string& det_model);
virtual void registerMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
virtual void unregisterMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
private:
Interface& m_interface;
std::list<_MaxImageSizeCallback*> m_cbk;
void _maxImageSizeChanged();
void _addInterface(HwInterface*);
};
} // namespace Meta
} // namespace lima
#endif // METADETINFOCTRLOBJ_H
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#ifndef METAINTERFACE_H
#define METAINTERFACE_H
#include <map>
#include "HwInterface.h"
#include "Data.h"
namespace lima
{
namespace Meta
{
class DetInfoCtrlObj;
class SyncCtrlObj;
class Interface : public HwInterface
{
DEB_CLASS_NAMESPC(DebModCamera, "MetaInterface", "Meta");
friend class DetInfoCtrlObj;
friend class SyncCtrlObj;
public:
enum Geometry {TILE};
Interface(Geometry = TILE);
virtual ~Interface();
void addInterface(int row,int column,HwInterface*);
//- From HwInterface
virtual void getCapList(CapList&) const;
virtual void reset(ResetLevel reset_level);
virtual void prepareAcq();
virtual void startAcq();
virtual void stopAcq();
virtual void getStatus(StatusType& status);
virtual int getNbHwAcquiredFrames();
private:
class _BufferFrameCBK;
friend class _BufferFrameCBK;
typedef std::pair<int,int> ColumnRow;
struct ltColumnRow
{
bool operator()(const ColumnRow& a,const ColumnRow& b)
{
return a.second == b.second ?
a.first < b.first : a.second < b.second;
}
};
typedef std::map<ColumnRow,HwInterface*,ltColumnRow> TileCnt;
typedef std::map<ColumnRow,int> TileOffset;
typedef std::map<int,int> PendingFrames;
typedef std::vector<_BufferFrameCBK*> BufferFrameCBKs;
bool _newFrameReady(int row,int column,const Data&);
TileCnt m_tiles;
Geometry m_geometry;
DetInfoCtrlObj* m_det_info;
SyncCtrlObj* m_sync;
SoftBufferCtrlObj m_buffer;
bool m_dirty_geom_flag;
int m_width_step;
ImageType m_curr_type;
TileOffset m_tiles_offset;
bool m_continue_acq;
Mutex m_lock;
PendingFrames m_pending_frames;
BufferFrameCBKs m_buffer_cbks;
};
}
}
#endif
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#ifndef METASYNCCTRLOBJ_H
#define METASYNCCTRLOBJ_H
#include "HwSyncCtrlObj.h"
#include "HwInterface.h"
namespace lima
{
namespace Meta
{
class Interface;
class SyncCtrlObj : public HwSyncCtrlObj
{
DEB_CLASS_NAMESPC(DebModCamera,"SyncCtrlObj","Meta");
public:
SyncCtrlObj(Interface&);
virtual ~SyncCtrlObj();
virtual bool checkTrigMode(TrigMode trig_mode);
virtual void setTrigMode(TrigMode trig_mode);
virtual void getTrigMode(TrigMode& trig_mode);
virtual void setExpTime(double exp_time);
virtual void getExpTime(double& exp_time);
virtual bool checkAutoExposureMode(AutoExposureMode mode) const;
virtual void setHwAutoExposureMode(AutoExposureMode mode);
virtual void setLatTime(double lat_time);
virtual void getLatTime(double& lat_time);
virtual void setNbHwFrames(int nb_frames);
virtual void getNbHwFrames(int& nb_frames);
virtual void getValidRanges(ValidRangesType& valid_ranges);
private:
Interface& m_interface;
};
} // namespace Meta
} // namespace lima
#endif // METASYNCCTRLOBJ_H
############################################################################
# This file is part of LImA, a Library for Image Acquisition
#
# Copyright (C) : 2009-2011
# European Synchrotron Radiation Facility
# BP 220, Grenoble 38043
# FRANCE
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
############################################################################
from Lima import module_helper
mod_path = __path__
depends_on = 'Core'
has_dependent = False
cleanup_data = module_helper.load_prepare(mod_path, depends_on, has_dependent)
from Lima import Core
cleanup_data = module_helper.load_dep_cleanup(cleanup_data)
from Lima.Meta.limameta import Meta as _B
globals().update(_B.__dict__)
module_helper.load_cleanup(cleanup_data)
del mod_path, depends_on, has_dependent, cleanup_data
del module_helper
namespace Meta
{
class Interface : HwInterface
{
%TypeHeaderCode
#include <MetaInterface.h>
%End
public:
enum Geometry {TILE};
Interface(Geometry = TILE);
virtual ~Interface();
void addInterface(int row,int column,HwInterface*);
//- From HwInterface
// virtual void getCapList(CapList& /Out/) const;
virtual void getCapList(std::vector<HwCap> &cap_list /Out/) const;
virtual void reset(ResetLevel reset_level);
virtual void prepareAcq();
virtual void startAcq();
virtual void stopAcq();
virtual void getStatus(StatusType& status /Out/);
virtual int getNbHwAcquiredFrames();
};
};
meta-objs = MetaInterface.o MetaDetInfoCtrlObj.o MetaSyncCtrlObj.o
SRCS = $(meta-objs:.o=.cpp)
CXXFLAGS += -I../include -I../../../../hardware/include -I../../../../common/include \
-I../../../../control/include -I../../../../control/software_operation/include \
-I../../../../third-party/Processlib/core/include -Wall -pthread -fPIC -g
all: Meta.o
Meta.o: $(meta-objs)
$(LD) -o $@ -r $+
clean:
rm -f *.o *.P
%.o : %.cpp
$(COMPILE.cpp) -MD $(CXXFLAGS) -o $@ $<
@cp $*.d $*.P; \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
rm -f $*.d
-include $(SRCS:.cpp=.P)
.PHONY: check-syntax
check-syntax:
$(CXX) -Wall -Wextra -fsyntax-only $(CXXFLAGS) $(CHK_SOURCES)
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#include <cstdlib>
#include "MetaDetInfoCtrlObj.h"
#include "MetaInterface.h"
using namespace lima;
using namespace lima::Meta;
#define GET_LOCAL_DET_INFO \
Interface::TileCnt::iterator i = m_interface.m_tiles.begin(); \
HwDetInfoCtrlObj* local_det_info; \
if(i == m_interface.m_tiles.end()) \
THROW_HW_ERROR(Error) << "Meta doesn't have any sub detector"; \
if(!i->second->getHwCtrlObj(local_det_info)) \
THROW_HW_ERROR(Error) << "Cannot get hardware det info";
class DetInfoCtrlObj::_MaxImageSizeCallback : public HwMaxImageSizeCallback
{
public:
_MaxImageSizeCallback(DetInfoCtrlObj &det) : m_det(det) {}
protected:
virtual void maxImageSizeChanged(const Size& size,ImageType image_type)
{
m_det._maxImageSizeChanged();
}
private:
DetInfoCtrlObj& m_det;
};
DetInfoCtrlObj::DetInfoCtrlObj(Interface& interface):
m_interface(interface)
{
}
DetInfoCtrlObj::~DetInfoCtrlObj()
{
for(std::list<_MaxImageSizeCallback*>::iterator i = m_cbk.begin();
i != m_cbk.end();++i)
delete *i;
}
void DetInfoCtrlObj::getMaxImageSize(Size& max_image_size)
{
DEB_MEMBER_FUNCT();
max_image_size = Size(0,0);
GET_LOCAL_DET_INFO;
Size local_max_image_size;
int prev_row = i->first.second;
local_det_info->getMaxImageSize(local_max_image_size);
int row_width = local_max_image_size.getWidth();
int row_height = local_max_image_size.getHeight();
for(++i;i != m_interface.m_tiles.end();++i)
{
if(!i->second->getHwCtrlObj(local_det_info))
THROW_HW_ERROR(Error) << "Cannot get hardware det info";
local_det_info->getMaxImageSize(local_max_image_size);
if(prev_row == i->first.second) // new column, same row
{
row_height = std::max(row_height,
local_max_image_size.getHeight());
row_width += local_max_image_size.getWidth();
}
else // new row
{
prev_row = i->first.second;
max_image_size = Size(std::max(max_image_size.getWidth(),row_width),
max_image_size.getHeight() + row_height);
row_height = local_max_image_size.getHeight();
row_width = local_max_image_size.getWidth();
}
}
max_image_size = Size(std::max(max_image_size.getWidth(),row_width),
max_image_size.getHeight() + row_height);
DEB_RETURN() << DEB_VAR1(max_image_size);
}
void DetInfoCtrlObj::getDetectorImageSize(Size& det_image_size)
{
DEB_MEMBER_FUNCT();
getMaxImageSize(det_image_size);
}
void DetInfoCtrlObj::getDefImageType(ImageType& def_image_type)
{
DEB_MEMBER_FUNCT();
GET_LOCAL_DET_INFO;
local_det_info->getDefImageType(def_image_type);
DEB_RETURN() << DEB_VAR1(def_image_type);
}
void DetInfoCtrlObj::getCurrImageType(ImageType& curr_image_type)
{
DEB_MEMBER_FUNCT();
getDefImageType(curr_image_type);
}
void DetInfoCtrlObj::setCurrImageType(ImageType curr_image_type)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(curr_image_type);
for(Interface::TileCnt::iterator i = m_interface.m_tiles.begin();
i != m_interface.m_tiles.end();++i)
{
HwDetInfoCtrlObj* local_det_info;
if(!i->second->getHwCtrlObj(local_det_info))
THROW_HW_ERROR(Error) << "Cannot get hardware det info";
local_det_info->setCurrImageType(curr_image_type);
}
}
/** @brief get pixel size of detector
assumed that all detector have the same resolution, it might be wrong in some cases.
*/
void DetInfoCtrlObj::getPixelSize(double& x_size,double& y_size)
{
DEB_MEMBER_FUNCT();
GET_LOCAL_DET_INFO;
local_det_info->getPixelSize(x_size,y_size);
DEB_RETURN() << DEB_VAR2(x_size,y_size);
}
void DetInfoCtrlObj::getDetectorType(std::string& det_type)
{
DEB_MEMBER_FUNCT();
GET_LOCAL_DET_INFO;
std::string local_det_type;
local_det_info->getDetectorType(local_det_type);
bool allMatch = true;
for(++i;allMatch && i != m_interface.m_tiles.end();++i)
{
std::string loop_det_type;
if(!i->second->getHwCtrlObj(local_det_info))
THROW_HW_ERROR(Error) << "Cannot get hardware det info";
local_det_info->getDetectorType(loop_det_type);
allMatch = loop_det_type == local_det_type;
}
if(allMatch)
det_type = "Meta_" + local_det_type;
else
det_type = "Meta_Hybrid";
DEB_RETURN() << DEB_VAR1(det_type);
}
void DetInfoCtrlObj::getDetectorModel(std::string& det_model)
{
DEB_MEMBER_FUNCT();
det_model = "";
for(Interface::TileCnt::iterator i = m_interface.m_tiles.begin();
i != m_interface.m_tiles.end();++i)
{
std::string local_det_model;
HwDetInfoCtrlObj* local_det_info;
if(!i->second->getHwCtrlObj(local_det_info))
THROW_HW_ERROR(Error) << "Cannot get hardware det info";
local_det_info->getDetectorModel(local_det_model);
if(!det_model.size())
det_model = local_det_model;
else
det_model += "\n" + local_det_model;
}
}
void DetInfoCtrlObj::registerMaxImageSizeCallback(HwMaxImageSizeCallback& cb)
{
this->HwMaxImageSizeCallbackGen::registerMaxImageSizeCallback(cb);
}
void DetInfoCtrlObj::unregisterMaxImageSizeCallback(HwMaxImageSizeCallback &cb)
{
this->HwMaxImageSizeCallbackGen::unregisterMaxImageSizeCallback(cb);
}
void DetInfoCtrlObj::_maxImageSizeChanged()
{
Size max_image_size;
getMaxImageSize(max_image_size);
ImageType def_image_type;
getCurrImageType(def_image_type);
maxImageSizeChanged(max_image_size,def_image_type);
m_interface.m_dirty_geom_flag = true;
}
void DetInfoCtrlObj::_addInterface(HwInterface* i)
{
DEB_MEMBER_FUNCT();
_MaxImageSizeCallback *cbk = new _MaxImageSizeCallback(*this);
HwDetInfoCtrlObj* local_det_info;
if(!i->getHwCtrlObj(local_det_info))
THROW_HW_ERROR(Error) << "Cannot get hardware det info";
local_det_info->registerMaxImageSizeCallback(*cbk);
m_cbk.push_back(cbk);
}
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the