Commit 3ca65ca1 authored by seb's avatar seb
Browse files

add ReadImage and ReadBaseImage in CtControl


git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@132 45c4679d-1946-429d-baad-37912b19538b
parent 5af60f98
......@@ -50,10 +50,14 @@ class CtBuffer {
void registerFrameCallback(CtControl *ct);
void unregisterFrameCallback();
void getFrame(Data&,int frameNumber);
void setup(CtControl *ct);
static void getDataFromHwFrameInfo(Data&,const HwFrameInfoType&);
private:
HwBufferCtrlObj *m_hw_buffer;
CtBufferFrameCB *m_frame_cb;
Parameters m_pars;
......
......@@ -66,6 +66,9 @@ namespace lima {
void getAcqStatus(HwInterface::AcqStatus& status) const; // from HW
void getImageStatus(ImageStatus& status) const;
void ReadImage(Data&,long frameNumber = -1);
void ReadBaseImage(Data&,long frameNumber = -1);
void reset();
protected:
......
......@@ -22,4 +22,13 @@ using namespace lima;
void setMaxMemory(short max_memory);
void getMaxMemory(short& max_memory /Out/) const;
void registerFrameCallback(CtControl *ct);
void unregisterFrameCallback();
void getFrame(Data&,int frameNumber);
void setup(CtControl *ct);
static void getDataFromHwFrameInfo(Data&,const HwFrameInfoType&);
};
......@@ -43,6 +43,9 @@ using namespace lima;
void getAcqStatus(HwInterface::AcqStatus& status /Out/) const; // from HW
void getImageStatus(ImageStatus &imageStatus /Out/) const;
void ReadImage(Data&,long frameNumber = -1);
void ReadBaseImage(Data&,long frameNumber = -1);
void reset();
protected:
void newFrameReady(Data& data);
......
......@@ -4,36 +4,10 @@ using namespace lima;
bool CtBufferFrameCB::newFrameReady(const HwFrameInfoType& frame_info)
{
Data fdata;
ImageType ftype;
Size fsize;
ftype= frame_info.frame_dim->getImageType();
switch (ftype) {
case Bpp8:
fdata.type= Data::UINT8; break;
case Bpp10:
case Bpp12:
case Bpp14:
case Bpp16:
fdata.type= Data::UINT16; break;
case Bpp32:
fdata.type= Data::UINT32; break;
}
fsize= frame_info.frame_dim->getSize();
fdata.width= fsize.getWidth();
fdata.height= fsize.getHeight();
fdata.frameNumber= frame_info.acq_frame_nb;
Buffer *fbuf = new Buffer();
fbuf->owner = Buffer::MAPPED;
fbuf->data = frame_info.frame_ptr;
fdata.setBuffer(fbuf);
fbuf->unref();
m_ct->newFrameReady(fdata);
return true;
Data fdata;
CtBuffer::getDataFromHwFrameInfo(fdata,frame_info);
m_ct->newFrameReady(fdata);
return true;
}
CtBuffer::CtBuffer(HwInterface *hw)
......@@ -104,6 +78,12 @@ void CtBuffer::getMaxMemory(short& max_memory) const
max_memory= m_pars.maxMemory;
}
void CtBuffer::getFrame(Data &aReturnData,int frameNumber)
{
HwFrameInfo info;
m_hw_buffer->getFrameInfo(frameNumber,info);
getDataFromHwFrameInfo(aReturnData,info);
}
void CtBuffer::setup(CtControl *ct)
{
CtAcquisition *acq;
......@@ -141,6 +121,36 @@ void CtBuffer::setup(CtControl *ct)
registerFrameCallback(ct);
}
void CtBuffer::getDataFromHwFrameInfo(Data &fdata,
const HwFrameInfoType& frame_info)
{
ImageType ftype;
Size fsize;
ftype= frame_info.frame_dim->getImageType();
switch (ftype) {
case Bpp8:
fdata.type= Data::UINT8; break;
case Bpp10:
case Bpp12:
case Bpp14:
case Bpp16:
fdata.type= Data::UINT16; break;
case Bpp32:
fdata.type= Data::UINT32; break;
}
fsize= frame_info.frame_dim->getSize();
fdata.width= fsize.getWidth();
fdata.height= fsize.getHeight();
fdata.frameNumber= frame_info.acq_frame_nb;
Buffer *fbuf = new Buffer();
fbuf->owner = Buffer::MAPPED;
fbuf->data = frame_info.frame_ptr;
fdata.setBuffer(fbuf);
fbuf->unref();
}
// -----------------
// struct Parameters
// -----------------
......
......@@ -208,6 +208,22 @@ void CtControl::getImageStatus(ImageStatus& status) const
status= m_img_status;
}
void CtControl::ReadImage(Data &aReturnData,long frameNumber)
{
ReadBaseImage(aReturnData,frameNumber); // todo change when external op activated
}
void CtControl::ReadBaseImage(Data &aReturnData,long frameNumber)
{
AutoMutex aLock(m_cond.mutex());
if(frameNumber < 0)
frameNumber = m_img_status.LastBaseImageReady;
else if(frameNumber > m_img_status.LastBaseImageReady)
throw LIMA_CTL_EXC(Error, "Frame not available yet");
aLock.unlock();
m_ct_buffer->getFrame(aReturnData,frameNumber);
}
void CtControl::reset()
{
}
......
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