EigerInterface.cpp 5.47 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//###########################################################################
// 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/>.
//###########################################################################
#include "EigerInterface.h"
#include "EigerCamera.h"
#include "EigerDetInfoCtrlObj.h"
#include "EigerSyncCtrlObj.h"
26
#include "EigerSavingCtrlObj.h"
Sebastien Petitdemange's avatar
Sebastien Petitdemange committed
27
28
#include "EigerStream.h"
#include "EigerDecompress.h"
29
30
31
32
33
34
35
36
37
38
39

using namespace lima;
using namespace lima::Eiger;
using namespace std;


//-----------------------------------------------------
// @brief Ctor
//-----------------------------------------------------
Interface::Interface(Camera& cam) : m_cam(cam) 
{
40
41
42
43
44
45
46
47
48
49
  DEB_CONSTRUCTOR();
  m_det_info = new DetInfoCtrlObj(cam);
  m_cap_list.push_back(HwCap(m_det_info));

  m_sync     = new SyncCtrlObj(cam);
  m_cap_list.push_back(HwCap(m_sync));

  m_saving = new SavingCtrlObj(cam);
  m_cap_list.push_back(HwCap(m_saving));

Sebastien Petitdemange's avatar
Sebastien Petitdemange committed
50
51
52
  m_stream = new Stream(cam);
  
  HwBufferCtrlObj* buffer = m_stream->getBufferCtrlObj();
53
  m_cap_list.push_back(HwCap(buffer));	
Sebastien Petitdemange's avatar
Sebastien Petitdemange committed
54
55
56

  m_decompress = new Decompress(*m_stream);
  m_cap_list.push_back(HwCap(m_decompress));
57
58
59
60
61
62
63
64
}

//-----------------------------------------------------
// @brief Dtor
//-----------------------------------------------------
Interface::~Interface()
{
    DEB_DESTRUCTOR();
Sebastien Petitdemange's avatar
Sebastien Petitdemange committed
65
66
67
68
69
    delete m_det_info;
    delete m_sync;
    delete m_saving;
    delete m_stream;
    delete m_decompress;
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
}

//-----------------------------------------------------
// @brief return the capability list
//-----------------------------------------------------
void Interface::getCapList(HwInterface::CapList &cap_list) const
{
    DEB_MEMBER_FUNCT();
    cap_list = m_cap_list;
}

//-----------------------------------------------------
// @brief reset the interface, stop the acqisition
//-----------------------------------------------------
void Interface::reset(ResetLevel reset_level)
{
    DEB_MEMBER_FUNCT();
    DEB_PARAM() << DEB_VAR1(reset_level);

    stopAcq();
}

//-----------------------------------------------------
// @brief do nothing
//-----------------------------------------------------
void Interface::prepareAcq()
{
    DEB_MEMBER_FUNCT();
98
99
100
101
    bool use_filewriter = m_saving->isActive(); 
    m_stream->setActive(!use_filewriter);
    m_decompress->setActive(!use_filewriter);

102
103
    m_stream->release_all_msgs();

104
105
106
    m_cam.prepareAcq();
    int serie_id; m_cam.getSerieId(serie_id);
    m_saving->setSerieId(serie_id);
107
108
109
110
111
112
113
114
}

//-----------------------------------------------------
// @brief start the camera acquisition
//-----------------------------------------------------
void Interface::startAcq()
{
    DEB_MEMBER_FUNCT();
Sebastien Petitdemange's avatar
Sebastien Petitdemange committed
115
116
117
118
119
    // either we use eiger saving or the raw stream
    if(m_saving->isActive())
      m_saving->start();
    else
      m_stream->start();
120
121
122
123
124
125
126
127
128
129
    m_cam.startAcq();
}

//-----------------------------------------------------
// @brief stop the camera acquisition
//-----------------------------------------------------
void Interface::stopAcq()
{
  DEB_MEMBER_FUNCT();
  m_cam.stopAcq();
130
  m_saving->stop();
Sebastien Petitdemange's avatar
Sebastien Petitdemange committed
131
  m_stream->stop();
132
133
134
135
136
137
138
139
140
}

//-----------------------------------------------------
// @brief return the status of detector/acquisition
//-----------------------------------------------------
void Interface::getStatus(StatusType& status)
{
    DEB_MEMBER_FUNCT();
    
141
142
    Camera::Status Eiger_status;
      
143
144
145
    Eiger_status = m_cam.getStatus();
    switch (Eiger_status)
    {
146
      case Camera::Ready:
147
	{
148
149
150
	  if (m_stream->isRunning())
	    status.set(HwInterface::StatusType::Readout);
	  else
151
	    {
152
153
154
155
156
157
158
159
160
161
	      SavingCtrlObj::Status saving_status = m_saving->getStatus();
	      switch(saving_status)
		{
		case SavingCtrlObj::IDLE:
		  status.set(HwInterface::StatusType::Ready);break;
		case SavingCtrlObj::RUNNING:
		  status.set(HwInterface::StatusType::Readout);break;
		default:
		  status.set(HwInterface::StatusType::Fault);break;
		}
162
163
	    }
	}
164
165
166
167
168
169
170
171
172
173
174
175
176
177
        break;

      case Camera::Exposure:
        status.set(HwInterface::StatusType::Exposure);
        break;

      case Camera::Readout:
        status.set(HwInterface::StatusType::Readout);
        break;

      case Camera::Fault:
        status.set(HwInterface::StatusType::Fault);
        break;
        
178
179
180
      case Camera::Initialising:
	status.set(HwInterface::StatusType::Config);
	break;
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
    }
    
    DEB_RETURN() << DEB_VAR1(status);
}

//-----------------------------------------------------
// @brief return the hw number of acquired frames
//-----------------------------------------------------
int Interface::getNbHwAcquiredFrames()
{
     DEB_MEMBER_FUNCT();
     int acq_frames;
     m_cam.getNbHwAcquiredFrames(acq_frames);
     return acq_frames;
}

197
198
199
200
201
202
void Interface::getLastStreamInfo(StreamInfo& last_info)
{
     DEB_MEMBER_FUNCT();
     m_stream->getLastStreamInfo(last_info);
}