Commit b68d5dae authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by operator for beamline
Browse files

Add StreamInfo, latched on each first stream frame; export LastStreamInfo

parent b12c5ca2
...@@ -89,6 +89,7 @@ add_library(eiger SHARED ...@@ -89,6 +89,7 @@ add_library(eiger SHARED
src/EigerDecompress.cpp src/EigerDecompress.cpp
src/EigerSavingCtrlObj.cpp src/EigerSavingCtrlObj.cpp
src/EigerStream.cpp src/EigerStream.cpp
src/EigerStreamInfo.cpp
sdk/linux/EigerAPI/src/CurlLoop.cpp sdk/linux/EigerAPI/src/CurlLoop.cpp
sdk/linux/EigerAPI/src/Requests.cpp sdk/linux/EigerAPI/src/Requests.cpp
${EIGER_INCS} ${EIGER_INCS}
......
...@@ -38,7 +38,9 @@ namespace lima ...@@ -38,7 +38,9 @@ namespace lima
class SavingCtrlObj; class SavingCtrlObj;
class Camera; class Camera;
class Stream; class Stream;
class StreamInfo;
class Decompress; class Decompress;
/******************************************************************* /*******************************************************************
* \class Interface * \class Interface
* \brief Eiger hardware interface * \brief Eiger hardware interface
...@@ -63,6 +65,8 @@ namespace lima ...@@ -63,6 +65,8 @@ namespace lima
//! get the camera object to access it directly from client //! get the camera object to access it directly from client
Camera& getCamera() { return m_cam;} Camera& getCamera() { return m_cam;}
void getLastStreamInfo(StreamInfo& info);
private: private:
Camera& m_cam; Camera& m_cam;
CapList m_cap_list; CapList m_cap_list;
......
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2015
// 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 EIGERSTREAMINFO_H
#define EIGERSTREAMINFO_H
#include <iostream>
#include "lima/SizeUtils.h"
namespace lima
{
namespace Eiger
{
struct StreamInfo {
std::string encoding;
FrameDim frame_dim;
int packed_size;
};
std::ostream& operator <<(std::ostream& os, const StreamInfo& i);
}
}
#endif // EIGERSTREAMINFO_H
...@@ -47,5 +47,7 @@ namespace Eiger ...@@ -47,5 +47,7 @@ namespace Eiger
//! get the camera object to access it directly from client //! get the camera object to access it directly from client
Eiger::Camera& getCamera(); Eiger::Camera& getCamera();
void getLastStreamInfo(Eiger::StreamInfo& last_info /Out/);
}; };
}; };
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2014
// 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/>.
//###########################################################################
namespace Eiger
{
struct StreamInfo {
%TypeHeaderCode
#include <EigerStreamInfo.h>
%End
std::string encoding;
FrameDim frame_dim;
int packed_size;
};
};
\ No newline at end of file
...@@ -194,3 +194,9 @@ int Interface::getNbHwAcquiredFrames() ...@@ -194,3 +194,9 @@ int Interface::getNbHwAcquiredFrames()
return acq_frames; return acq_frames;
} }
void Interface::getLastStreamInfo(StreamInfo& last_info)
{
DEB_MEMBER_FUNCT();
m_stream->getLastStreamInfo(last_info);
}
...@@ -393,9 +393,11 @@ void Stream::_run() ...@@ -393,9 +393,11 @@ void Stream::_run()
DEB_TRACE() << DEB_VAR1(anImageDim); DEB_TRACE() << DEB_VAR1(anImageDim);
if (frameid == 0) { if (frameid == 0) {
std::string encoding = data_header.get("encoding", "").asString(); m_last_info.encoding = data_header.get("encoding", "").asString();
m_last_info.frame_dim = anImageDim;
m_last_info.packed_size = data_header.get("size", "-1").asInt();
Camera::CompressionType comp_type; Camera::CompressionType comp_type;
_checkEncoding(encoding, image_type, comp_type); _checkCompression(m_last_info, comp_type);
} }
HwFrameInfoType frame_info; HwFrameInfoType frame_info;
...@@ -439,12 +441,13 @@ void Stream::_run() ...@@ -439,12 +441,13 @@ void Stream::_run()
m_running = false; m_running = false;
} }
void Stream::_checkEncoding(const std::string& encoding, void Stream::_checkCompression(const StreamInfo& info,
ImageType image_type,
Camera::CompressionType& comp_type) Camera::CompressionType& comp_type)
{ {
DEB_MEMBER_FUNCT(); DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR3(encoding, image_type, m_endianess); DEB_PARAM() << DEB_VAR2(info, m_endianess);
const std::string& encoding = info.encoding;
char endianess = *encoding.rbegin(); char endianess = *encoding.rbegin();
if (endianess != m_endianess) if (endianess != m_endianess)
...@@ -460,7 +463,7 @@ void Stream::_checkEncoding(const std::string& encoding, ...@@ -460,7 +463,7 @@ void Stream::_checkEncoding(const std::string& encoding,
comp_type = Camera::LZ4; comp_type = Camera::LZ4;
} else { } else {
const char *bs; const char *bs;
switch (image_type) { switch (info.frame_dim.getImageType()) {
case Bpp32S: case Bpp32: bs = "bs32-"; break; case Bpp32S: case Bpp32: bs = "bs32-"; break;
case Bpp16S: case Bpp16: bs = "bs16-"; break; case Bpp16S: case Bpp16: bs = "bs16-"; break;
case Bpp8S: case Bpp8: bs = "bs8-"; break; case Bpp8S: case Bpp8: bs = "bs8-"; break;
...@@ -480,6 +483,13 @@ void Stream::_checkEncoding(const std::string& encoding, ...@@ -480,6 +483,13 @@ void Stream::_checkEncoding(const std::string& encoding,
DEB_RETURN() << DEB_VAR1(comp_type); DEB_RETURN() << DEB_VAR1(comp_type);
} }
void Stream::getLastStreamInfo(StreamInfo& last_info)
{
DEB_MEMBER_FUNCT();
last_info = m_last_info;
DEB_RETURN() << DEB_VAR1(last_info);
}
bool Stream::get_msg(void* aDataBuffer,void*& msg_data,size_t& msg_size,int& depth) bool Stream::get_msg(void* aDataBuffer,void*& msg_data,size_t& msg_size,int& depth)
{ {
DEB_MEMBER_FUNCT(); DEB_MEMBER_FUNCT();
...@@ -519,4 +529,3 @@ void Stream::release_all_msgs() ...@@ -519,4 +529,3 @@ void Stream::release_all_msgs()
AutoMutex lock(m_cond.mutex()); AutoMutex lock(m_cond.mutex());
m_data_2_msg.clear(); m_data_2_msg.clear();
} }
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "lima/Debug.h" #include "lima/Debug.h"
#include "EigerCamera.h" #include "EigerCamera.h"
#include "EigerStreamInfo.h"
#include "lima/HwBufferMgr.h" #include "lima/HwBufferMgr.h"
namespace lima namespace lima
...@@ -60,6 +61,8 @@ namespace lima ...@@ -60,6 +61,8 @@ namespace lima
void release_msg(void* aDataBuffer); void release_msg(void* aDataBuffer);
void release_all_msgs(); void release_all_msgs();
void getLastStreamInfo(StreamInfo& info);
private: private:
class _BufferCtrlObj; class _BufferCtrlObj;
friend class _BufferCtrlObj; friend class _BufferCtrlObj;
...@@ -71,8 +74,7 @@ namespace lima ...@@ -71,8 +74,7 @@ namespace lima
void _run(); void _run();
void _send_synchro(); void _send_synchro();
void _checkEncoding(const std::string& encoding, void _checkCompression(const StreamInfo& info,
ImageType image_type,
Camera::CompressionType& comp_type); Camera::CompressionType& comp_type);
Camera& m_cam; Camera& m_cam;
...@@ -90,6 +92,7 @@ namespace lima ...@@ -90,6 +92,7 @@ namespace lima
void* m_zmq_context; void* m_zmq_context;
int m_pipes[2]; int m_pipes[2];
Data2Message m_data_2_msg; Data2Message m_data_2_msg;
StreamInfo m_last_info;
_BufferCtrlObj* m_buffer_ctrl_obj; _BufferCtrlObj* m_buffer_ctrl_obj;
}; };
} }
......
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2015
// 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 "EigerStreamInfo.h"
std::ostream& lima::Eiger::operator <<(std::ostream& os, const StreamInfo& i)
{
return os << "<"
<< "encoding=" << i.encoding << ", "
<< "frame_dim=" << i.frame_dim << ", "
<< "packed_size=" << i.packed_size
<< ">";
}
...@@ -126,6 +126,19 @@ class Eiger(PyTango.Device_4Impl): ...@@ -126,6 +126,19 @@ class Eiger(PyTango.Device_4Impl):
def __getattr__(self,name) : def __getattr__(self,name) :
return AttrHelper.get_attr_4u(self,name,_EigerCamera) return AttrHelper.get_attr_4u(self,name,_EigerCamera)
#==================================================================
#
# stream_last_info
#
#==================================================================
@Core.DEB_MEMBER_FUNCT
def read_stream_last_info(self, attr):
last_info = _EigerInterface.getLastStreamInfo()
last_info_strarr = [str(last_info.encoding),
str(last_info.frame_dim),
str(last_info.packed_size)]
attr.set_value(last_info_strarr)
#================================================================== #==================================================================
# #
# Eiger command methods # Eiger command methods
...@@ -220,6 +233,10 @@ class EigerClass(PyTango.DeviceClass): ...@@ -220,6 +233,10 @@ class EigerClass(PyTango.DeviceClass):
[[PyTango.DevLong, [[PyTango.DevLong,
PyTango.SCALAR, PyTango.SCALAR,
PyTango.READ]], PyTango.READ]],
'stream_last_info':
[[PyTango.DevString,
PyTango.SPECTRUM,
PyTango.READ, 16]],
} }
......
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