Commit f223f817 authored by ahoms's avatar ahoms

* moved HwInterface::Acq/DetStatus to the global lima namespace

* added ImageStatusCallback to CtControl
* fixed the CtBuffer to avoid multiple FrameCallback allocations



git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@194 45c4679d-1946-429d-baad-37912b19538b
parent 0cfc868c
......@@ -549,25 +549,26 @@ void Interface::getStatus(StatusType& status)
m_acq.getStatus(acq);
status.acq = acq.running ? AcqRunning : AcqReady;
static const DetStatus det_mask = (WaitForTrigger | Exposure |
ShutterClose | ChargeShift |
Readout | Latency);
static const DetStatus det_mask =
(DetWaitForTrigger | DetExposure | DetShutterClose |
DetChargeShift | DetReadout | DetLatency);
status.det_mask = det_mask;
status.det = DetIdle;
Frelon::Status cam;
m_cam.getStatus(cam);
if (cam & Frelon::Wait)
status.det |= WaitForTrigger;
status.det |= DetWaitForTrigger;
if (cam & Frelon::Exposure)
status.det |= Exposure;
status.det |= DetExposure;
if (cam & Frelon::Shutter)
status.det |= ShutterClose;
status.det |= DetShutterClose;
if (cam & Frelon::Transfer)
status.det |= ChargeShift;
status.det |= DetChargeShift;
if (cam & Frelon::Readout)
status.det |= Readout;
status.det |= DetReadout;
if (cam & Frelon::Latency)
status.det |= Latency;
status.det |= DetLatency;
DEB_RETURN() << DEB_VAR1(status);
}
......
......@@ -2,11 +2,62 @@
#include "CtControl.h"
#include "CtAcquisition.h"
#include "CtImage.h"
#include "CtSaving.h"
#include "AcqState.h"
using namespace lima;
DEB_GLOBAL(DebModTest);
class ImageStatusCallback : public CtControl::ImageStatusCallback
{
DEB_CLASS(DebModTest, "ImageStatusCallback");
public:
ImageStatusCallback(CtControl& ct, AcqState& acq_state);
virtual ~ImageStatusCallback();
protected:
virtual void imageStatusChanged(
const CtControl::ImageStatus& img_status);
private:
CtControl& m_ct;
AcqState& m_acq_state;
int m_nb_frames;
};
ImageStatusCallback::ImageStatusCallback(CtControl& ct, AcqState& acq_state)
: m_ct(ct), m_acq_state(acq_state)
{
DEB_CONSTRUCTOR();
}
ImageStatusCallback::~ImageStatusCallback()
{
DEB_DESTRUCTOR();
}
void ImageStatusCallback::imageStatusChanged(
const CtControl::ImageStatus& img_status)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(img_status);
int last_acq_frame_nb = img_status.LastImageAcquired;
int last_saved_frame_nb = img_status.LastImageSaved;
if (last_acq_frame_nb == 0) {
CtAcquisition *ct_acq = m_ct.acquisition();
ct_acq->getAcqNbFrames(m_nb_frames);
}
if (last_saved_frame_nb == m_nb_frames - 1) {
DEB_TRACE() << "Acquisition finished!";
m_acq_state.set(AcqState::Finished);
}
}
void test_frelon_control()
{
......@@ -26,11 +77,15 @@ void test_frelon_control()
Frelon::Interface hw_inter(acq, buffer_mgr, cam);
DEB_TRACE() << "Done!";
CtControl control(&hw_inter);
CtAcquisition *ct_acq = control.acquisition();
CtSaving *ct_saving = control.saving();
CtImage *ct_image = control.image();
CtBuffer *ct_buffer = control.buffer();
AutoPtr<CtControl> ct = new CtControl(&hw_inter);
CtAcquisition *ct_acq = ct->acquisition();
CtSaving *ct_save = ct->saving();
CtImage *ct_image = ct->image();
// CtBuffer *ct_buffer = ct->buffer();
AcqState acq_state;
ImageStatusCallback img_status_cb(*ct, acq_state);
ct->registerImageStatusCallback(img_status_cb);
AcqMode acq_mode;
ct_acq->getAcqMode(acq_mode);
......@@ -56,9 +111,41 @@ void test_frelon_control()
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);
int nb_frames;
ct_acq->getAcqNbFrames(nb_frames);
DEB_TRACE() << "Default " << DEB_VAR1(nb_frames);
ct_save->setDirectory(".");
ct_save->setPrefix("img");
ct_save->setSuffix(".edf");
ct_save->setNextNumber(0);
ct_save->setFormat(CtSaving::EDF);
ct_save->setSavingMode(CtSaving::AutoFrame);
ct_save->setFramesPerFile(1);
DEB_TRACE() << "Preparing acquisition";
ct->prepareAcq();
acq_state.set(AcqState::Running);
DEB_TRACE() << "Starting acquisition";
ct->startAcq();
acq_state.waitNot(AcqState::Running);
DEB_TRACE() << "Acquisition finished";
exp_time = 1e-6;
DEB_TRACE() << "Setting " << DEB_VAR1(exp_time);
ct_acq->setAcqExpoTime(exp_time);
nb_frames = 200;
DEB_TRACE() << "Setting " << DEB_VAR1(nb_frames);
ct_acq->setAcqNbFrames(nb_frames);
DEB_TRACE() << "Preparing acquisition";
ct->prepareAcq();
acq_state.set(AcqState::Running);
DEB_TRACE() << "Starting acquisition";
ct->startAcq();
acq_state.waitNot(AcqState::Running);
DEB_TRACE() << "Acquisition finished";
}
......
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