CtBuffer.h 2.97 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//###########################################################################
// 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/>.
//###########################################################################
papillon's avatar
 
papillon committed
22
23
24
25
#ifndef CTBUFFER_H
#define CTBUFFER_H

#include "Constants.h"
papillon's avatar
   
papillon committed
26
#include "SizeUtils.h"
papillon's avatar
   
papillon committed
27
#include "CtAcquisition.h"
papillon's avatar
   
papillon committed
28
#include "CtImage.h"
papillon's avatar
   
papillon committed
29
#include "HwInterface.h"
papillon's avatar
   
papillon committed
30
31
32
#include "HwFrameCallback.h"

#include "Data.h"
papillon's avatar
 
papillon committed
33
34
35

namespace lima {

36
  class LIMACORE_API CtBufferFrameCB : public HwFrameCallback
seb's avatar
seb committed
37
38
  {
    DEB_CLASS_NAMESPC(DebModControl,"BufferFrameCB","Control");
39
    friend class CtBuffer;
seb's avatar
seb committed
40
  public:
41
    CtBufferFrameCB(CtControl *ct): m_ct(ct),m_ct_accumulation(NULL) {}
seb's avatar
seb committed
42
43
44
  protected:
    bool newFrameReady(const HwFrameInfoType& frame_info);
  private:
45
46
    CtControl* 		m_ct;
    CtAccumulation* 	m_ct_accumulation;
seb's avatar
seb committed
47
48
  };

49
  class LIMACORE_API CtBuffer 
seb's avatar
seb committed
50
51
52
53
  {
    DEB_CLASS_NAMESPC(DebModControl,"Buffer","Control");

  public:
54
    struct LIMACORE_API Parameters 
seb's avatar
seb committed
55
56
    {
      DEB_CLASS_NAMESPC(DebModControl,"Buffer::Parameters","Control");
papillon's avatar
   
papillon committed
57
    public:
seb's avatar
seb committed
58
59
60
61
62
63
      Parameters();
      void reset();
      BufferMode mode;
      long	nbBuffers;
      short	maxMemory;
    };
papillon's avatar
   
papillon committed
64

seb's avatar
seb committed
65
66
    CtBuffer(HwInterface *hw);
    ~CtBuffer();
papillon's avatar
 
papillon committed
67

seb's avatar
seb committed
68
69
    void setPars(Parameters pars);
    void getPars(Parameters& pars) const;
papillon's avatar
 
papillon committed
70

seb's avatar
seb committed
71
72
    void setMode(BufferMode mode);
    void getMode(BufferMode& mode) const;
papillon's avatar
   
papillon committed
73

seb's avatar
seb committed
74
75
    void setNumber(long nb_buffers);
    void getNumber(long& nb_buffers) const;
papillon's avatar
 
papillon committed
76

seb's avatar
seb committed
77
78
    void setMaxMemory(short max_memory);
    void getMaxMemory(short& max_memory) const;
papillon's avatar
 
papillon committed
79

seb's avatar
seb committed
80
81
    void registerFrameCallback(CtControl *ct);
    void unregisterFrameCallback();
82
	
seb's avatar
seb committed
83
84
    void getFrame(Data&,int frameNumber);

85
    void reset();
seb's avatar
seb committed
86
    void setup(CtControl *ct);
papillon's avatar
   
papillon committed
87

seb's avatar
seb committed
88
89
    static void getDataFromHwFrameInfo(Data&,const HwFrameInfoType&);
  private:
papillon's avatar
   
papillon committed
90

91
92
93
94
    HwBufferCtrlObj* 	m_hw_buffer;
    CtBufferFrameCB* 	m_frame_cb;
    Parameters		m_pars;
    CtAccumulation* 	m_ct_accumulation;
seb's avatar
seb committed
95
  };
papillon's avatar
 
papillon committed
96

seb's avatar
seb committed
97
98
99
100
101
102
103
104
105
106
  inline std::ostream& operator<<(std::ostream &os,
				  const CtBuffer::Parameters &params)
  {
    os << "<"
       << "mode=" << params.mode << ", "
       << "nbBuffers=" << params.nbBuffers << ", "
       << "maxMemory=" << params.maxMemory << ", "
       << ">";
    return os;
  }
papillon's avatar
 
papillon committed
107
108
109
} // namespace lima

#endif // CTBUFFER_H