Commit c656ac87 authored by ahoms's avatar ahoms
Browse files

SP+AH:

* added SPS live image display support in the Control layer 
  as a processlib SinkTask; available in PyFrelonDS through set/getMode
* included SPS in third-party
* fixed Frelon::Interface::reset to also stop the camera
* reading exp. time in Frelon::Camera::Sync to check if it's in ExtGate 


git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@212 45c4679d-1946-429d-baad-37912b19538b
parent b72a8af1
......@@ -191,7 +191,9 @@ class TacoCcdAcq(TacoServer):
'getChanges', 'DevCcdGetChanges'],
}
AutoSave = 8
LiveDisplay = 1
StripeConcat = 4
AutoSave = 8
DEB_CLASS(DebModApplication, 'TacoCcdAcq')
......@@ -364,6 +366,7 @@ class TacoCcdAcq(TacoServer):
@DEB_MEMBER_FUNCT
def setMode(self, mode):
deb.Param('Setting mode: %s (0x%x)' % (mode, mode))
live_display = (mode & self.LiveDisplay) != 0
auto_save = (mode & self.AutoSave) != 0
@DEB_MEMBER_FUNCT
......
......@@ -247,13 +247,18 @@ class FrelonTacoAcq(TacoCcdAcq):
@DEB_MEMBER_FUNCT
def setMode(self, mode):
deb.Param('Setting mode: %s (0x%x)' % (mode, mode))
live_display = (mode & self.LiveDisplay) != 0
self.setLiveDisplay(live_display)
auto_save = (mode & self.AutoSave) != 0
self.setAutosave(auto_save)
@DEB_MEMBER_FUNCT
def getMode(self):
auto_save = self.getAutosave()
mode = (auto_save and self.AutoSave) or 0
mode = 0
if self.getLiveDisplay():
mode |= self.LiveDisplay
if self.getAutosave():
mode |= self.AutoSave
deb.Return('Getting mode: %s (0x%x)' % (mode, mode))
return mode
......@@ -394,7 +399,21 @@ class FrelonTacoAcq(TacoCcdAcq):
autosave_act = (ct_saving.getSavingMode() == CtSaving.AutoFrame)
deb.Return('Getting autosave active: %s' % autosave_act)
return autosave_act
@DEB_MEMBER_FUNCT
def setLiveDisplay(self, livedisplay_act):
deb.Param('Setting live display active: %s' % livedisplay_act)
ct_display = self.m_acq.getDisplayControl()
ct_display.setNames('_ccd_ds_', 'frelon_live')
ct_display.setActive(livedisplay_act)
@DEB_MEMBER_FUNCT
def getLiveDisplay(self):
ct_display = self.m_acq.getDisplayControl()
livedisplay_act = ct_display.isActive()
deb.Return('Getting live display active: %s' % livedisplay_act)
return livedisplay_act
@DEB_MEMBER_FUNCT
def getCurrent(self):
ct = self.m_acq.getGlobalControl()
......
......@@ -21,7 +21,8 @@ class FrelonAcq:
self.m_ct_saving = self.m_ct.saving()
self.m_ct_image = self.m_ct.image()
self.m_ct_buffer = self.m_ct.buffer()
self.m_ct_display = self.m_ct.display()
@DEB_MEMBER_FUNCT
def __del__(self):
......@@ -72,4 +73,5 @@ class FrelonAcq:
def getBufferControl(self):
return self.m_ct_buffer
def getDisplayControl(self):
return self.m_ct_display
......@@ -36,7 +36,10 @@ void Camera::sync()
int ser_nb;
getSerialNb(ser_nb);
m_trig_mode = IntTrig;
double exp_time;
getExpTime(exp_time);
m_trig_mode = (exp_time == 0) ? ExtGate : IntTrig;
readRegister(NbFrames, m_nb_frames);
m_roi_offset = 0;
......
......@@ -490,7 +490,7 @@ void Interface::reset(ResetLevel reset_level)
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(reset_level);
m_acq.stop();
stopAcq();
if (reset_level == HardReset) {
DEB_TRACE() << "Performing camera hard reset";
......
......@@ -17,6 +17,7 @@ CXXFLAGS = -I../include -I../../common/espia/include \
-I../../../control/software_operation/include/ \
-I../../../third-party/Processlib/core/include \
-I../../../third-party/Processlib/tasks/include \
-I../../../third-party/Sps/Include \
-I$(ESPIA_DRV_INCL) -Wall -pthread -g
test-progs = testfrelon testfreloninterface testfrelonspectroscopy \
......@@ -27,7 +28,7 @@ all: $(test-progs)
testfrelon: testfrelon.o $(frelon-objs)
$(CXX) $(LDFLAGS) -o $@ $+ $(LDLIBS)
testfreloninterface: testfreloninterface.o $(frelon-objs)
testfreloninterface: testfreloninterface.o $(frelon-objs) $(ct-objs)
$(CXX) $(LDFLAGS) -o $@ $+ $(LDLIBS)
testfrelonspectroscopy: testfrelonspectroscopy.o $(frelon-objs)
......
......@@ -3,6 +3,7 @@
#include "CtAcquisition.h"
#include "CtImage.h"
#include "CtSaving.h"
#include "CtSpsImage.h"
#include "AcqState.h"
using namespace lima;
......@@ -10,6 +11,10 @@ using namespace std;
DEB_GLOBAL(DebModTest);
//*********************************************************************
//* ImageStatusCallback
//*********************************************************************
class ImageStatusCallback : public CtControl::ImageStatusCallback
{
DEB_CLASS(DebModTest, "ImageStatusCallback");
......@@ -66,6 +71,11 @@ void ImageStatusCallback::imageStatusChanged(
}
}
//*********************************************************************
//* FrelonAcq
//*********************************************************************
class FrelonAcq
{
DEB_CLASS(DebModTest, "FrelonAcq");
......@@ -104,6 +114,7 @@ private:
CtSaving *m_ct_saving;
CtImage *m_ct_image;
CtBuffer *m_ct_buffer;
CtSpsImage *m_ct_display;
ImageStatusCallback *m_img_status_cb;
};
......@@ -122,10 +133,11 @@ FrelonAcq::FrelonAcq(int espia_dev_nb)
AutoPtr<CtControl> ct = new CtControl(&m_hw_inter);
m_ct_acq = ct->acquisition();
m_ct_saving = ct->saving();
m_ct_image = ct->image();
m_ct_buffer = ct->buffer();
m_ct_acq = ct->acquisition();
m_ct_saving = ct->saving();
m_ct_image = ct->image();
m_ct_buffer = ct->buffer();
m_ct_display = ct->display();
printDefaults();
......@@ -133,6 +145,9 @@ FrelonAcq::FrelonAcq(int espia_dev_nb)
img_status_cb = new ImageStatusCallback(*ct, m_acq_state);
ct->registerImageStatusCallback(*img_status_cb);
m_ct_display->setNames("_ccd_ds_", "frelon_live");
m_ct_display->setActive(true);
DEB_TRACE() << "All is OK!";
m_ct = ct.forget();
m_img_status_cb = img_status_cb.forget();
......@@ -221,7 +236,6 @@ void FrelonAcq::initSaving(string dir, string prefix, string suffix, int idx,
m_ct_saving->setFormat(fmt);
m_ct_saving->setSavingMode(mode);
m_ct_saving->setFramesPerFile(frames_per_file);
}
void FrelonAcq::setExpTime(double exp_time)
......@@ -257,6 +271,10 @@ void FrelonAcq::setRoi(Roi& roi)
}
//*********************************************************************
//* test_frelon_control
//*********************************************************************
void test_frelon_control(bool enable_debug = false)
{
DEB_GLOBAL_FUNCT();
......@@ -313,6 +331,11 @@ void test_frelon_control(bool enable_debug = false)
}
//*********************************************************************
//* main
//*********************************************************************
int main(int argc, char *argv[])
{
DEB_GLOBAL_FUNCT();
......
......@@ -75,6 +75,7 @@ class FrelonAcq:
self.m_ct_saving = self.m_ct.saving()
self.m_ct_image = self.m_ct.image()
self.m_ct_buffer = self.m_ct.buffer()
self.m_ct_display = self.m_ct.display()
self.m_use_events = use_events
self.m_print_time = print_time
......@@ -86,6 +87,10 @@ class FrelonAcq:
else:
self.m_poll_time = 0.1
self.m_ct_display.setNames('_ccd_ds_', 'frelon_live')
self.m_ct_display.setActive(True)
@DEB_MEMBER_FUNCT
def __del__(self):
if self.m_use_events:
......
......@@ -5,6 +5,7 @@
#include "TaskMgr.h"
#include "TaskEventCallback.h"
#include "SoftRoi.h"
#include "CtSpsImage.h"
#include "AcqState.h"
#include <iostream>
......@@ -25,8 +26,8 @@ class SoftRoiCallback : public TaskEventCallback
DEB_CLASS(DebModTest, "SoftRoiCallback");
public:
SoftRoiCallback(Frelon::Interface& hw_inter, BufferSave& buffer_save,
AcqState& acq_state);
SoftRoiCallback(Frelon::Interface& hw_inter, CtSpsImage& m_sps_image,
BufferSave& buffer_save, AcqState& acq_state);
~SoftRoiCallback();
virtual void finished(Data& data);
......@@ -35,15 +36,17 @@ private:
FrameDim& fdim);
Frelon::Interface& m_hw_inter;
CtSpsImage& m_sps_image;
BufferSave& m_buffer_save;
AcqState& m_acq_state;
};
SoftRoiCallback::SoftRoiCallback(Frelon::Interface& hw_inter,
CtSpsImage& sps_image,
BufferSave& buffer_save,
AcqState& acq_state)
: m_hw_inter(hw_inter), m_buffer_save(buffer_save),
m_acq_state(acq_state)
: m_hw_inter(hw_inter), m_sps_image(sps_image),
m_buffer_save(buffer_save), m_acq_state(acq_state)
{
DEB_CONSTRUCTOR();
}
......@@ -89,6 +92,8 @@ void SoftRoiCallback::finished(Data& data)
{
DEB_MEMBER_FUNCT();
m_sps_image.frameReady(data);
HwFrameInfoType finfo;
FrameDim fdim;
data2FrameInfo(data, finfo, fdim);
......@@ -114,7 +119,8 @@ class TestFrameCallback : public HwFrameCallback
public:
TestFrameCallback(Frelon::Interface& hw_inter, Roi& soft_roi,
BufferSave& buffer_save, AcqState& acq_state);
CtSpsImage& sps_image, BufferSave& buffer_save,
AcqState& acq_state);
~TestFrameCallback();
protected:
......@@ -130,12 +136,14 @@ private:
};
TestFrameCallback::TestFrameCallback(Frelon::Interface& hw_inter,
Roi& soft_roi, BufferSave& buffer_save,
Roi& soft_roi, CtSpsImage& sps_image,
BufferSave& buffer_save,
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_state);
m_roi_cb = new SoftRoiCallback(hw_inter, sps_image, buffer_save,
acq_state);
m_roi_task = new SoftRoi();
}
......@@ -283,6 +291,36 @@ void set_hw_roi(HwRoiCtrlObj *hw_roi, const Roi& set_roi, Roi& real_roi,
}
//*********************************************************************
// check_sps_image_frame_dim
//*********************************************************************
void check_sps_image_frame_dim(HwInterface& hw_inter,
Bin& bin, Roi& set_roi, CtSpsImage& sps_image)
{
DEB_GLOBAL_FUNCT();
Size size;
if (set_roi.isEmpty()) {
HwDetInfoCtrlObj *hw_det_info;
hw_inter.getHwCtrlObj(hw_det_info);
hw_det_info->getMaxImageSize(size);
size /= bin;
} else {
size = set_roi.getSize();
}
HwBufferCtrlObj *hw_buffer;
hw_inter.getHwCtrlObj(hw_buffer);
FrameDim frame_dim;
hw_buffer->getFrameDim(frame_dim);
frame_dim.setSize(size);
DEB_TRACE() << DEB_VAR1(frame_dim);
sps_image.prepare(frame_dim);
}
//*********************************************************************
// print_deb_flags
//*********************************************************************
......@@ -334,11 +372,15 @@ void test_frelon_hw_inter(bool do_reset)
BufferSave buffer_save(BufferSave::EDF, "img", 0, ".edf", true, 1);
CtSpsImage sps_image;
sps_image.setNames("_ccd_ds_", "frelon_live");
MaxImageSizeCallback mis_cb;
Roi soft_roi;
AcqState acq_state;
TestFrameCallback cb(hw_inter, soft_roi, buffer_save, acq_state);
TestFrameCallback cb(hw_inter, soft_roi, sps_image, buffer_save,
acq_state);
HwDetInfoCtrlObj *hw_det_info;
hw_inter.getHwCtrlObj(hw_det_info);
......@@ -383,6 +425,7 @@ void test_frelon_hw_inter(bool do_reset)
hw_buffer->setFrameDim(effect_frame_dim);
hw_buffer->setNbBuffers(10);
hw_buffer->registerFrameCallback(cb);
check_sps_image_frame_dim(hw_inter, bin, set_roi, sps_image);
print_status(hw_inter);
acq_state.set(AcqState::Acquiring);
......@@ -435,6 +478,7 @@ void test_frelon_hw_inter(bool do_reset)
effect_frame_dim = frame_dim / bin;
hw_buffer->setFrameDim(effect_frame_dim);
hw_buffer->setNbBuffers(10);
check_sps_image_frame_dim(hw_inter, bin, set_roi, sps_image);
print_status(hw_inter);
acq_state.set(AcqState::Acquiring);
......@@ -450,6 +494,7 @@ void test_frelon_hw_inter(bool do_reset)
effect_frame_dim.setSize(real_roi.getSize());
hw_buffer->setFrameDim(effect_frame_dim);
hw_buffer->setNbBuffers(10);
check_sps_image_frame_dim(hw_inter, bin, set_roi, sps_image);
print_status(hw_inter);
acq_state.set(AcqState::Acquiring);
......@@ -468,6 +513,7 @@ void test_frelon_hw_inter(bool do_reset)
effect_frame_dim.setSize(real_roi.getSize());
hw_buffer->setFrameDim(effect_frame_dim);
hw_buffer->setNbBuffers(10);
check_sps_image_frame_dim(hw_inter, bin, set_roi, sps_image);
print_status(hw_inter);
acq_state.set(AcqState::Acquiring);
......@@ -481,6 +527,7 @@ void test_frelon_hw_inter(bool do_reset)
hw_buffer->setFrameDim(effect_frame_dim);
hw_buffer->setNbAccFrames(5);
hw_buffer->setNbBuffers(10);
check_sps_image_frame_dim(hw_inter, bin, set_roi, sps_image);
hw_sync->setNbFrames(3);
......
......@@ -18,6 +18,7 @@ namespace lima
class CtBuffer;
class CtBufferFrameCB;
class CtSaving;
class CtSpsImage;
class SoftOpInternalMgr;
class SoftOpExternalMgr;
......@@ -94,6 +95,7 @@ namespace lima
CtAcquisition* acquisition() { return m_ct_acq; }
CtSaving* saving() { return m_ct_saving; }
CtSpsImage* display() { return m_ct_sps_image; }
CtImage* image() { return m_ct_image; }
CtBuffer* buffer() { return m_ct_buffer; }
......@@ -141,6 +143,7 @@ namespace lima
mutable Status m_status;
CtSaving *m_ct_saving;
CtSpsImage *m_ct_sps_image;
CtAcquisition *m_ct_acq;
CtImage *m_ct_image;
CtBuffer *m_ct_buffer;
......@@ -157,6 +160,7 @@ namespace lima
ApplyPolicy m_policy;
bool m_ready;
bool m_autosave;
bool m_display_active_flag;
ImageStatusCallback *m_img_status_cb;
......
#ifndef CTSPSIMAGE_H
#define CTSPSIMAGE_H
#include <string>
#include "ThreadUtils.h"
#include "Debug.h"
#include "SizeUtils.h"
#include <Data.h>
namespace lima
{
class _SpsCBK;
class _SpsImage;
class CtSpsImage
{
DEB_CLASS_NAMESPC(DebModControl,"CtSpsImage","Control");
public:
CtSpsImage();
~CtSpsImage();
void setNames(const std::string& spec_name,
const std::string& array_name);
void prepare(const FrameDim &frame_dim);
void frameReady(Data&);
void reset();
void setActive(bool aFlag);
bool isActive() const;
private:
friend class _SpsCBK;
void _update_finnished(Data&);
void _check_data_size(Data&);
void _post_sps_task(Data&);
Cond m_cond;
bool m_ready_flag;
bool m_active_flag;
_SpsCBK *m_sps_cbk;
_SpsImage *m_sps_cnt;
Data m_next_data;
};
inline void CtSpsImage::setActive(bool aFlag)
{
m_active_flag = aFlag;
}
inline bool CtSpsImage::isActive() const
{
return m_active_flag;
}
} // namespace lima
#endif // CTSPSIMAGE_H
......@@ -72,9 +72,10 @@ using namespace lima;
CtAcquisition* acquisition();
CtSaving* saving();
CtSpsImage* display();
CtImage* image();
CtBuffer* buffer();
void setApplyPolicy(ApplyPolicy policy);
void getApplyPolicy(ApplyPolicy &policy /Out/) const;
......
class CtSpsImage
{
%TypeHeaderCode
#include <CtSpsImage.h>
using namespace lima;
%End
public:
CtSpsImage();
~CtSpsImage();
void setNames(const std::string& spec_name,
const std::string& array_name);
void prepare(const FrameDim &frame_dim);
void frameReady(Data&);
void reset();
void setActive(bool aFlag);
bool isActive() const;
};
......@@ -3,6 +3,7 @@
#include "CtControl.h"
#include "CtSaving.h"
#include "CtSpsImage.h"
#include "CtAcquisition.h"
#include "CtImage.h"
#include "CtBuffer.h"
......@@ -95,6 +96,8 @@ CtControl::CtControl(HwInterface *hw) :
m_ct_saving->setEndCallback(aSaveCbkPt);
aSaveCbkPt->unref();
//Sps image
m_ct_sps_image = new CtSpsImage();
m_op_int = new SoftOpInternalMgr();
m_op_ext = new SoftOpExternalMgr();
}
......@@ -111,6 +114,7 @@ CtControl::~CtControl()
unregisterImageStatusCallback(*m_img_status_cb);
delete m_ct_saving;
delete m_ct_sps_image;
delete m_ct_acq;
delete m_ct_image;
delete m_ct_buffer;
......@@ -189,6 +193,17 @@ void CtControl::prepareAcq()
else
DEB_TRACE() << "No auto save activated";
m_ready= true;
m_display_active_flag = m_ct_sps_image->isActive();
if(m_display_active_flag)
{
FrameDim dim;
m_ct_image->getImageDim(dim);
m_ct_sps_image->prepare(dim);
}
}
void CtControl::startAcq()
......@@ -326,6 +341,9 @@ void CtControl::reset()
DEB_TRACE() << "Reseting acquisition";
m_ct_acq->reset();
DEB_TRACE() << "Reseting display";
m_ct_sps_image->reset();
}
bool CtControl::newFrameReady(Data& fdata)
......@@ -404,6 +422,9 @@ void CtControl::newBaseImageReady(Data &aData)
newFrameToSave(aData);
}
if(m_display_active_flag)
m_ct_sps_image->frameReady(aData);
aLock.unlock();
if (img_status_changed && m_img_status_cb)
m_img_status_cb->imageStatusChanged(m_status.ImageCounters);
......
#include "SinkTask.h"
#include "TaskMgr.h"
#include "CtSpsImage.h"
#include <sps.h>
using namespace lima;
//*********************************************************************
//* SPSImage
//*********************************************************************
class lima::_SpsImage
{
DEB_CLASS_NAMESPC(DebModControl, "_SpsImage","Control");
public:
_SpsImage();
~_SpsImage();
void setNames(const std::string& spec_name,
const std::string& array_name);
void setFrameDim(const FrameDim& frame_dim);
void update(Data& data);
FrameDim m_frame_dim;
private:
void createSPS(const FrameDim& frame_dim);
void deleteSPS();
std::string m_spec_name;
std::string m_array_name;
void *m_shared_mem;
};
class lima::_SpsCBK: public TaskEventCallback
{
public:
_SpsCBK(CtSpsImage &aCtSpsImage) : m_ct_sps(aCtSpsImage) {}
virtual void finished(Data &aData)