Commit 25114925 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by Operator for ID00
Browse files

Add Lima plugin skeleton

parent 55b94df3
############################################################################
# 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/>.
############################################################################
src-dirs = src
test-dirs = test
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 SLSDETECTORINTERFACE_H
#define SLSDETECTORINTERFACE_H
#include "lima/HwInterface.h"
namespace lima
{
namespace Slsdetector
{
class Interface;
/*******************************************************************
* \class EventCallback
* \brief Bridge class transfering events from Acq -> HwEventCtrlObj
*******************************************************************/
class EventCallback : public lima::EventCallback
{
DEB_CLASS_NAMESPC(DebModCamera, "EventCallback", "Slsdetector");
public:
EventCallback(HwEventCtrlObj& ctrl_obj);
virtual ~EventCallback();
protected:
virtual void processEvent(Event *event);
private:
HwEventCtrlObj& m_ctrl_obj;
};
/*******************************************************************
* \class DetInfoCtrlObj
* \brief Control object providing Slsdetector detector info interface
*******************************************************************/
class DetInfoCtrlObj : public HwDetInfoCtrlObj
{
DEB_CLASS_NAMESPC(DebModCamera, "DetInfoCtrlObj", "Slsdetector");
public:
DetInfoCtrlObj();
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:
};
/*******************************************************************
* \class SyncCtrlObj
* \brief Control object providing Slsdetector synchronization interface
*******************************************************************/
class SyncCtrlObj : public HwSyncCtrlObj
{
DEB_CLASS_NAMESPC(DebModCamera, "SyncCtrlObj", "Slsdetector");
public:
SyncCtrlObj();
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 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:
};
/*******************************************************************
* \class EventCtrlObj
* \brief Control object providing Slsdetector event interface
*******************************************************************/
class EventCtrlObj : public HwEventCtrlObj
{
DEB_CLASS(DebModCamera, "EventCtrlObj");
public:
EventCtrlObj();
virtual ~EventCtrlObj();
};
/*******************************************************************
* \class Interface
* \brief Slsdetector hardware interface
*******************************************************************/
class Interface : public HwInterface
{
DEB_CLASS_NAMESPC(DebModCamera, "Interface", "Slsdetector");
public:
Interface();
virtual ~Interface();
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();
void resetDefaults();
private:
CapList m_cap_list;
DetInfoCtrlObj m_det_info;
SoftBufferCtrlObj m_buffer;
SyncCtrlObj m_sync;
EventCtrlObj m_event;
Slsdetector::EventCallback m_event_cb;
};
} // namespace Slsdetector
} // namespace lima
#endif // SLSDETECTORINTERFACE_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/>.
############################################################################
slsdetector-objs = SlsdetectorInterface.o
SRCS = $(slsdetector-objs:.o=.cpp)
CXXFLAGS = -I../include \
-I../../../hardware/include -I../../../common/include \
-I../../../third-party/Processlib/core/include \
-Wall -pthread -fPIC -g
all: Slsdetector.o
Slsdetector.o: $(slsdetector-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 "SlsdetectorInterface.h"
using namespace lima;
using namespace lima::Slsdetector;
using namespace std;
/*******************************************************************
* \brief EventCallback constructor
*******************************************************************/
Slsdetector::EventCallback::EventCallback(HwEventCtrlObj& ctrl_obj)
: m_ctrl_obj(ctrl_obj)
{
DEB_CONSTRUCTOR();
}
Slsdetector::EventCallback::~EventCallback()
{
DEB_DESTRUCTOR();
}
void Slsdetector::EventCallback::processEvent(Event *event)
{
DEB_MEMBER_FUNCT();
m_ctrl_obj.reportEvent(event);
}
/*******************************************************************
* \brief DetInfoCtrlObj constructor
*******************************************************************/
DetInfoCtrlObj::DetInfoCtrlObj()
{
DEB_CONSTRUCTOR();
}
DetInfoCtrlObj::~DetInfoCtrlObj()
{
DEB_DESTRUCTOR();
}
void DetInfoCtrlObj::getMaxImageSize(Size& max_image_size)
{
DEB_MEMBER_FUNCT();
FrameDim max_frame_dim(Size(1024, 1024), Bpp16);
max_image_size = max_frame_dim.getSize();
}
void DetInfoCtrlObj::getDetectorImageSize(Size& det_image_size)
{
DEB_MEMBER_FUNCT();
FrameDim max_frame_dim(Size(1024, 1024), Bpp16);
det_image_size = max_frame_dim.getSize();
}
void DetInfoCtrlObj::getDefImageType(ImageType& def_image_type)
{
DEB_MEMBER_FUNCT();
FrameDim max_frame_dim(Size(1024, 1024), Bpp16);
def_image_type = max_frame_dim.getImageType();
}
void DetInfoCtrlObj::getCurrImageType(ImageType& curr_image_type)
{
DEB_MEMBER_FUNCT();
FrameDim max_frame_dim(Size(1024, 1024), Bpp16);
curr_image_type = max_frame_dim.getImageType();
}
void DetInfoCtrlObj::setCurrImageType(ImageType curr_image_type)
{
DEB_MEMBER_FUNCT();
ImageType unique_image_type = Bpp16;
if (curr_image_type != unique_image_type)
THROW_HW_ERROR(InvalidValue)
<< "Only " << DEB_VAR1(unique_image_type) << "allowed";
}
void DetInfoCtrlObj::getPixelSize(double& x_size, double& y_size)
{
DEB_MEMBER_FUNCT();
x_size = y_size = 10e-6;
DEB_RETURN() << DEB_VAR2(x_size, y_size);
}
void DetInfoCtrlObj::getDetectorType(std::string& det_type)
{
DEB_MEMBER_FUNCT();
det_type = "Slsdetector";
DEB_RETURN() << DEB_VAR1(det_type);
}
void DetInfoCtrlObj::getDetectorModel(std::string& det_model)
{
DEB_MEMBER_FUNCT();
det_model = "Generic";
DEB_RETURN() << DEB_VAR1(det_model);
}
void DetInfoCtrlObj::registerMaxImageSizeCallback(
HwMaxImageSizeCallback& cb)
{
DEB_MEMBER_FUNCT();
}
void DetInfoCtrlObj::unregisterMaxImageSizeCallback(
HwMaxImageSizeCallback& cb)
{
DEB_MEMBER_FUNCT();
}
/*******************************************************************
* \brief SyncCtrlObj constructor
*******************************************************************/
SyncCtrlObj::SyncCtrlObj()
: HwSyncCtrlObj()
{
DEB_CONSTRUCTOR();
}
SyncCtrlObj::~SyncCtrlObj()
{
DEB_DESTRUCTOR();
}
bool SyncCtrlObj::checkTrigMode(TrigMode trig_mode)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(trig_mode);
bool valid_mode;
switch (trig_mode) {
case IntTrig:
valid_mode = true;
break;
default:
valid_mode = false;
}
DEB_RETURN() << DEB_VAR1(valid_mode);
return valid_mode;
}
void SyncCtrlObj::setTrigMode(TrigMode trig_mode)
{
DEB_MEMBER_FUNCT();
if (!checkTrigMode(trig_mode))
THROW_HW_ERROR(InvalidValue) << "Invalid "
<< DEB_VAR1(trig_mode);
}
void SyncCtrlObj::getTrigMode(TrigMode& trig_mode)
{
DEB_MEMBER_FUNCT();
trig_mode = IntTrig;
}
void SyncCtrlObj::setExpTime(double exp_time)
{
DEB_MEMBER_FUNCT();
}
void SyncCtrlObj::getExpTime(double& exp_time)
{
DEB_MEMBER_FUNCT();
exp_time = 1.0;
}
void SyncCtrlObj::setLatTime(double lat_time)
{
DEB_MEMBER_FUNCT();
}
void SyncCtrlObj::getLatTime(double& lat_time)
{
DEB_MEMBER_FUNCT();
lat_time = 0.0;
}
void SyncCtrlObj::setNbHwFrames(int nb_frames)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(nb_frames);
}
void SyncCtrlObj::getNbHwFrames(int& nb_frames)
{
DEB_MEMBER_FUNCT();
nb_frames = 1;
}
void SyncCtrlObj::getValidRanges(ValidRangesType& valid_ranges)
{
DEB_MEMBER_FUNCT();
valid_ranges.min_exp_time = 1e-6;
valid_ranges.max_exp_time = 1e6;
valid_ranges.min_lat_time = 1e-6;
valid_ranges.max_lat_time = 1e6;
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);
}
/*******************************************************************
* \brief EventCtrlObj constructor
*******************************************************************/
EventCtrlObj::EventCtrlObj()
{
DEB_CONSTRUCTOR();
}
EventCtrlObj::~EventCtrlObj()
{
DEB_DESTRUCTOR();
}
/*******************************************************************
* \brief Hw Interface constructor
*******************************************************************/
Interface::Interface()
: m_event_cb(m_event)
{
DEB_CONSTRUCTOR();
HwDetInfoCtrlObj *det_info = &m_det_info;
m_cap_list.push_back(HwCap(det_info));
HwBufferCtrlObj *buffer = &m_buffer;
m_cap_list.push_back(HwCap(buffer));
HwSyncCtrlObj *sync = &m_sync;
m_cap_list.push_back(HwCap(sync));
HwEventCtrlObj *event = &m_event;
m_cap_list.push_back(HwCap(event));
reset(SoftReset);
resetDefaults();
}
Interface::~Interface()
{
DEB_DESTRUCTOR();
}
void Interface::getCapList(HwInterface::CapList &cap_list) const
{
DEB_MEMBER_FUNCT();
cap_list = m_cap_list;
}
void Interface::reset(ResetLevel reset_level)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(reset_level);
stopAcq();
if (reset_level == HardReset) {
DEB_TRACE() << "Performing camera hard reset";
resetDefaults();
}
}
void Interface::resetDefaults()
{
DEB_MEMBER_FUNCT();
DEB_TRACE() << "Setting default configuration";
stopAcq();
}
void Interface::prepareAcq()
{
DEB_MEMBER_FUNCT();
}
void Interface::startAcq()
{
DEB_MEMBER_FUNCT();
}
void Interface::stopAcq()
{
DEB_MEMBER_FUNCT();
}
void Interface::getStatus(StatusType& status)
{
DEB_MEMBER_FUNCT();
status.acq = AcqReady;
status.det = DetIdle;
DEB_RETURN() << DEB_VAR1(status);
}
int Interface::getNbHwAcquiredFrames()
{
DEB_MEMBER_FUNCT();
int nb_hw_acq_frames = 0;
DEB_RETURN() << DEB_VAR1(nb_hw_acq_frames);
return nb_hw_acq_frames;
}
......@@ -38,6 +38,11 @@ LDFLAGS += -L../../../third-party/CBFLib/lib
LDLIBS += -lcbf
endif
ifneq ($(COMPILE_CONFIG), 0)
LDFLAGS += -L../../../third-party/libconfig/lib/.libs
LDLIBS += -lconfig++
endif
LIMA_INCL_FLAGS = -I../../../hardware/include -I../../../common/include \
-I../../../control/include/ \
-I../../../control/software_operation/include/ \
......
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