Commit 36036f7f authored by Alejandro Homs Puron's avatar Alejandro Homs Puron
Browse files

Remove obsolete code:

* FrameMap, BadFrames and Eiger::BadRecvFrameCorr
* Jungfrau geometry helpers
parent c845b248
Pipeline #48629 failed with stages
in 12 minutes and 10 seconds
......@@ -100,7 +100,6 @@ file(GLOB_RECURSE SLSDETECTOR_INCS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
add_library(slsdetector SHARED
src/SlsDetectorDefs.cpp
src/SlsDetectorFrameMap.cpp
src/SlsDetectorCPUAffinity.cpp
src/SlsDetectorBebTools.cpp
src/SlsDetectorModel.cpp
......
......@@ -96,9 +96,6 @@ public:
void getFrameDim(FrameDim& frame_dim, bool raw = false)
{ m_model->getFrameDim(frame_dim, raw); }
FrameMap *getFrameMap()
{ return &m_frame_map; }
void putCmd(const std::string& s, int idx = -1);
std::string getCmd(const std::string& s, int idx = -1);
......@@ -137,11 +134,6 @@ public:
void setTolerateLostPackets(bool tol_lost_packets);
void getTolerateLostPackets(bool& tol_lost_packets);
int getNbBadFrames(int item_idx);
void getBadFrameList(int item_idx, int first_idx, int last_idx,
IntList& bad_frame_list);
void getBadFrameList(int item_idx, IntList& bad_frame_list);
void prepareAcq();
void startAcq();
void stopAcq();
......@@ -251,16 +243,10 @@ private:
void assemblePackets(DetFrameImagePackets det_frame_packets);
bool checkLostPackets();
FrameType getLastReceivedFrame();
void waitLastSkippedFrame();
void processLastSkippedFrame(int recv_idx);
void getSortedBadFrameList(IntList first_idx, IntList last_idx,
IntList& bad_frame_list );
void getSortedBadFrameList(IntList& bad_frame_list)
{ getSortedBadFrameList(IntList(), IntList(), bad_frame_list); }
std::string execCmd(const std::string& s, bool put, int idx = -1);
template <class T>
......@@ -289,7 +275,6 @@ private:
Cond m_cond;
AutoPtr<AppInputData> m_input_data;
AutoPtr<sls::Detector> m_det;
FrameMap m_frame_map;
RecvList m_recv_list;
TrigMode m_trig_mode;
FrameType m_lima_nb_frames;
......
......@@ -265,9 +265,6 @@ class Eiger : public Model
{ return m_reconstruction; }
protected:
virtual int getNbFrameMapItems();
virtual void updateFrameMapItems(FrameMap *map);
virtual void updateImageSize();
virtual bool checkSettings(Settings settings);
......@@ -314,27 +311,6 @@ class Eiger : public Model
typedef std::vector<CorrBase *> CorrList;
class BadRecvFrameCorr : public CorrBase
{
DEB_CLASS_NAMESPC(DebModCamera, "Eiger::BadRecvFrameCorr",
"SlsDetector");
public:
BadRecvFrameCorr(Eiger *eiger);
virtual void prepareAcq();
virtual void correctFrame(FrameType frame, void *ptr);
protected:
struct BadFrameData {
int last_idx;
IntList bad_frame_list;
void reset();
};
Camera *m_cam;
BadFrameData m_bfd;
};
class InterModGapCorr : public CorrBase
{
DEB_CLASS_NAMESPC(DebModCamera, "Eiger::InterModGapCorr",
......@@ -481,7 +457,6 @@ class Eiger : public Model
int getNbRecvs();
CorrBase *createBadRecvFrameCorr();
CorrBase *createChipBorderCorr(ImageType image_type);
CorrBase *createInterModGapCorr();
......
//###########################################################################
// 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 __SLS_DETECTOR_FRAME_MAP_H
#define __SLS_DETECTOR_FRAME_MAP_H
#include "SlsDetectorDefs.h"
#include <algorithm>
namespace lima
{
namespace SlsDetector
{
class FrameMap
{
DEB_CLASS_NAMESPC(DebModCamera, "FrameMap", "SlsDetector");
public:
struct FinishInfo {
FrameType first_lost;
int nb_lost;
SortedIntList finished;
};
class Item
{
DEB_CLASS_NAMESPC(DebModCamera, "Item", "SlsDetector");
public:
Item(FrameMap *map, int idx);
FrameMap *getFrameMap()
{ return m_map; }
int getIndex()
{ return m_idx; }
void checkFinishedFrame(FrameType frame);
FinishInfo frameFinished(FrameType frame, bool no_check,
bool valid);
bool isBadFrame(FrameType frame);
int getNbBadFrames();
void getBadFrameList(int first_idx, int last_idx, IntList& bfl);
private:
friend class FrameMap;
void clear();
AutoMutex lock()
{ return m_mutex; }
Mutex m_mutex;
FrameMap *m_map;
int m_idx;
FrameType m_last_frame;
IntList m_bad_frame_list;
};
typedef std::vector<AutoPtr<Item> > ItemList;
FrameMap(Camera *cam);
void setNbItems(int nb_items);
int getNbItems()
{ return m_nb_items; }
void setBufferSize(int buffer_size);
void clear();
Item *getItem(int item)
{ return m_item_list[item]; }
FrameArray getItemFrameArray() const;
FrameType getLastItemFrame() const
{ return getLatestFrame(getItemFrameArray()); }
FrameType getLastFinishedFrame() const
{ return getOldestFrame(getItemFrameArray()); }
XYStat::LinRegress calcDelayStat()
{ return m_delay_stat.calcLinRegress(); }
private:
friend class Item;
struct AtomicCounter {
int count;
Mutex mutex;
Timestamp t0;
void set(int reset)
{
mutex.lock();
count = reset;
mutex.unlock();
}
bool dec_test_and_reset(int reset, double& delay)
{
mutex.lock();
Timestamp t = Timestamp::now();
if (count == reset)
t0 = t;
bool zero = (--count == 0);
if (zero) {
count = reset;
delay = t - t0;
}
mutex.unlock();
return zero;
}
};
typedef std::vector<AtomicCounter> CounterList;
Camera *m_cam;
int m_nb_items;
int m_buffer_size;
CounterList m_frame_item_count_list;
ItemList m_item_list;
XYStat m_delay_stat;
};
inline bool FrameMap::Item::isBadFrame(FrameType frame)
{
AutoMutex l = lock();
IntList::iterator end = m_bad_frame_list.end();
return (std::find(m_bad_frame_list.begin(), end, frame) != end);
}
inline int FrameMap::Item::getNbBadFrames()
{
AutoMutex l = lock();
return m_bad_frame_list.size();
}
inline void FrameMap::Item::getBadFrameList(int first_idx, int last_idx,
IntList& bfl)
{
AutoMutex l = lock();
IntList::const_iterator b = m_bad_frame_list.begin();
bfl.assign(b + first_idx, b + last_idx);
}
std::ostream& operator <<(std::ostream& os, const FrameMap& m);
} // namespace SlsDetector
} // namespace lima
#endif // __SLS_DETECTOR_FRAME_MAP_H
......@@ -196,9 +196,6 @@ class Jungfrau : public Model
{ return m_reconstruction; }
protected:
virtual int getNbFrameMapItems();
virtual void updateFrameMapItems(FrameMap *map);
virtual void updateImageSize();
virtual bool checkSettings(Settings settings);
......@@ -532,12 +529,6 @@ class Jungfrau : public Model
int getNbJungfrauModules()
{ return getNbDetModules(); }
template <class DG>
Defs::xy getModulePosition(const DG& det_geom, int idx);
FrameDim getModuleFrameDim(int idx, bool raw);
int getModuleDataOffset(int idx, bool raw);
int getNbRecvs();
AutoPtr<GainPedImgProc> m_gain_ped_img_proc;
......
......@@ -78,9 +78,6 @@ class Model
virtual void getTimeRanges(TimeRanges& time_ranges) = 0;
virtual int getNbFrameMapItems() = 0;
virtual void updateFrameMapItems(FrameMap *map) = 0;
virtual bool isAcqActive();
virtual bool isXferActive() = 0;
......
......@@ -23,7 +23,6 @@
#ifndef __SLS_DETECTOR_RECEIVER_H
#define __SLS_DETECTOR_RECEIVER_H
#include "SlsDetectorFrameMap.h"
#include "SlsDetectorCPUAffinity.h"
#include "SlsDetectorArgs.h"
......
......@@ -55,8 +55,6 @@ public:
void getFrameDim(FrameDim& frame_dim /Out/, bool raw = false);
SlsDetector::FrameMap *getFrameMap();
void putCmd(const std::string& s, int idx = -1);
std::string getCmd(const std::string& s, int idx = -1);
......@@ -98,12 +96,6 @@ public:
void setTolerateLostPackets(bool tol_lost_packets);
void getTolerateLostPackets(bool& tol_lost_packets /Out/);
int getNbBadFrames(int recv_idx);
void getBadFrameList(int recv_idx, int first_idx, int last_idx,
std::vector<int>& bad_frame_list /Out/);
void getBadFrameList(int recv_idx,
std::vector<int>& bad_frame_list /Out/);
void prepareAcq();
void startAcq();
void stopAcq();
......
......@@ -96,9 +96,6 @@ class Eiger : public SlsDetector::Model
virtual Reconstruction *getReconstruction();
protected:
virtual int getNbFrameMapItems();
virtual void updateFrameMapItems(FrameMap *map);
virtual void updateImageSize();
virtual bool checkSettings(SlsDetector::Defs::Settings settings);
......
//###########################################################################
// 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/>.
//###########################################################################
namespace SlsDetector
{
%TypeHeaderCode
#include "SlsDetectorFrameMap.h"
%End
class FrameMap
{
public:
void setNbItems(int nb_items);
void setBufferSize(int buffer_size);
void clear();
unsigned long getLastItemFrame() const;
unsigned long getLastFinishedFrame() const;
private:
FrameMap();
FrameMap(const FrameMap& o);
};
}; // namespace SlsDetector
......@@ -194,9 +194,6 @@ class Jungfrau : public SlsDetector::Model
virtual SlsDetector::Reconstruction *getReconstruction();
protected:
virtual int getNbFrameMapItems();
virtual void updateFrameMapItems(FrameMap *map);
virtual void updateImageSize();
virtual bool checkSettings(SlsDetector::Defs::Settings settings);
......
......@@ -62,9 +62,6 @@ public:
virtual void getTimeRanges(SlsDetector::TimeRanges&
time_ranges /Out/) = 0;
virtual int getNbFrameMapItems() = 0;
virtual void updateFrameMapItems(FrameMap *map) = 0;
virtual bool isXferActive() = 0;
virtual SlsDetector::Reconstruction *getReconstruction();
......
......@@ -244,21 +244,10 @@ void Camera::AcqThread::threadFunction()
AutoMutexUnlock u(l);
stopAcq();
IntList bfl;
m_cam->getSortedBadFrameList(bfl);
DEB_ALWAYS() << "bad_frames=" << bfl.size() << ": "
<< PrettyIntList(bfl);
Stats stats;
m_cam->getStats(stats);
DEB_ALWAYS() << DEB_VAR1(stats);
FrameMap& m = m_cam->m_frame_map;
if (m.getNbItems() > 1) {
XYStat::LinRegress delay_stat = m.calcDelayStat();
DEB_ALWAYS() << DEB_VAR1(delay_stat);
}
if (had_frames) {
affinity_mgr.recvFinished();
affinity_mgr.waitLimaFinished();
......@@ -390,7 +379,6 @@ void Camera::AcqThread::stopAcq()
Camera::Camera(string config_fname, int det_id)
: m_det_id(det_id),
m_model(NULL),
m_frame_map(this),
m_lima_nb_frames(1),
m_det_nb_frames(1),
m_skip_frame_freq(0),
......@@ -498,10 +486,6 @@ void Camera::setModel(Model *model)
<< " with " << getNbDetModules() << "x" << nb_udp_ifaces
<< " UDP interfaces";
int nb_items = m_model->getNbFrameMapItems();
m_frame_map.setNbItems(nb_items);
m_model->updateFrameMapItems(&m_frame_map);
setPixelDepth(m_pixel_depth);
}
......@@ -922,8 +906,6 @@ void Camera::prepareAcq()
{
AutoMutex l = lock();
m_frame_map.setBufferSize(nb_buffers);
m_frame_map.clear();
m_prev_ifa.clear();
RecvList::iterator it, end = m_recv_list.end();
for (it = m_recv_list.begin(); it != end; ++it)
......@@ -1037,14 +1019,6 @@ void Camera::assemblePackets(DetFrameImagePackets det_frame_packets)
}
}
FrameType Camera::getLastReceivedFrame()
{
DEB_MEMBER_FUNCT();
FrameType last_frame = m_frame_map.getLastItemFrame();
DEB_RETURN() << DEB_VAR1(last_frame);
return last_frame;
}
void Camera::waitLastSkippedFrame()
{
DEB_MEMBER_FUNCT();
......@@ -1210,73 +1184,6 @@ void Camera::getTolerateLostPackets(bool& tol_lost_packets)
DEB_RETURN() << DEB_VAR1(tol_lost_packets);
}
int Camera::getNbBadFrames(int item_idx)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(item_idx);
if ((item_idx < -1) || (item_idx >= m_model->getNbFrameMapItems()))
THROW_HW_ERROR(InvalidValue) << DEB_VAR1(item_idx);
int nb_bad_frames;
if (item_idx == -1) {
IntList bfl;
getBadFrameList(item_idx, bfl);
nb_bad_frames = bfl.size();
} else {
FrameMap::Item *item = m_frame_map.getItem(item_idx);
nb_bad_frames = item->getNbBadFrames();
}
DEB_RETURN() << DEB_VAR1(nb_bad_frames);
return nb_bad_frames;
}
void Camera::getSortedBadFrameList(IntList first_idx, IntList last_idx,
IntList& bad_frame_list)
{
bool all = first_idx.empty();
IntList bfl;
int nb_items = m_frame_map.getNbItems();
for (int i = 0; i < nb_items; ++i) {
FrameMap::Item *item = m_frame_map.getItem(i);
int first = all ? 0 : first_idx[i];
int last = all ? item->getNbBadFrames() : last_idx[i];
IntList l;
item->getBadFrameList(first, last, l);
bfl.insert(bfl.end(), l.begin(), l.end());
}
IntList::iterator first = bfl.begin();
IntList::iterator last = bfl.end();
sort(first, last);
bad_frame_list.resize(last - first);
IntList::iterator bfl_end, bfl_begin = bad_frame_list.begin();
bfl_end = unique_copy(first, last, bfl_begin);
bad_frame_list.resize(bfl_end - bfl_begin);
}
void Camera::getBadFrameList(int item_idx, int first_idx, int last_idx,
IntList& bad_frame_list)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR3(item_idx, first_idx, last_idx);
if ((item_idx < 0) || (item_idx >= m_model->getNbFrameMapItems()))
THROW_HW_ERROR(InvalidValue) << DEB_VAR1(item_idx);
FrameMap::Item *item = m_frame_map.getItem(item_idx);
item->getBadFrameList(first_idx, last_idx, bad_frame_list);
DEB_RETURN() << DEB_VAR1(PrettyIntList(bad_frame_list));
}
void Camera::getBadFrameList(int item_idx, IntList& bad_frame_list)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(item_idx);
if (item_idx == -1)
getSortedBadFrameList(bad_frame_list);
else
getBadFrameList(item_idx, 0, getNbBadFrames(item_idx),
bad_frame_list);
}
void Camera::registerTimeRangesChangedCallback(TimeRangesChangedCallback& cb)
{
DEB_MEMBER_FUNCT();
......
......@@ -79,55 +79,6 @@ void Eiger::CorrBase::prepareAcq()
m_inter_lines[m_nb_eiger_modules - 1] = 0;
}
void Eiger::BadRecvFrameCorr::BadFrameData::reset()
{
last_idx = 0;
bad_frame_list.clear();
}
Eiger::BadRecvFrameCorr::BadRecvFrameCorr(Eiger *eiger)
: CorrBase(eiger)
{
DEB_CONSTRUCTOR();
m_cam = m_eiger->getCamera();
}
void Eiger::BadRecvFrameCorr::prepareAcq()
{
DEB_MEMBER_FUNCT();
CorrBase::prepareAcq();
m_bfd.reset();
}
void Eiger::BadRecvFrameCorr::correctFrame(FrameType frame, void *ptr)
{
DEB_MEMBER_FUNCT();
char *bptr = (char *) ptr;
IntList& bfl = m_bfd.bad_frame_list;
int& last_idx = m_bfd.last_idx;
if (bfl.empty()) {
int bad_frames = m_cam->getNbBadFrames(0);
if (bad_frames == last_idx)
return;
m_cam->getBadFrameList(0, last_idx, bad_frames, bfl);
}
IntList::iterator end = bfl.end();
if (find(bfl.begin(), end, frame) != end) {
Eiger::Geometry *geom = m_eiger->getGeometry();
for (int i = 0; i < geom->getNbRecvs(); ++i) {
Eiger::Geometry::Recv *recv = geom->getRecv(i);
recv->fillBadFrame(frame, bptr);
}
}
if (*(end - 1) > int(frame))
return;
last_idx += bfl.size();
bfl.clear();
}
Eiger::InterModGapCorr::InterModGapCorr(Eiger *eiger)
: CorrBase(eiger)
{
......@@ -875,27 +826,12 @@ void Eiger::measureReadoutTime(double& /*readout_time*/)
*/
}