SlsDetectorReceiver.h 2.96 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-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_RECEIVER_H
#define __SLS_DETECTOR_RECEIVER_H

26
#include "SlsDetectorFrameMap.h"
27
#include "SlsDetectorModel.h"
28
#include "SlsDetectorCPUAffinity.h"
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "slsReceiverUsers.h"

namespace lima 
{

namespace SlsDetector
{

class Camera;

class Receiver 
{
	DEB_CLASS_NAMESPC(DebModCamera, "Receiver", "SlsDetector");

public:
44
45
46
	typedef slsReceiverDefs::sls_detector_header sls_detector_header;
	typedef slsReceiverDefs::sls_receiver_header sls_receiver_header;

47
48
49
50
	Receiver(Camera *cam, int idx, int rx_port);
	~Receiver();

	void start();
51
52

	void setModelRecv(Model::Recv *model_recv);
53
54
55

	void prepareAcq();

56
57
	void setCPUAffinity(const RecvCPUAffinity& recv_affinity);

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
private:
	friend class Camera;

	class Port 
	{
		DEB_CLASS_NAMESPC(DebModCamera, "Receiver::Port", 
				  "SlsDetector");
	public:
		struct Stats {
			SlsDetector::Stats stats;
			Timestamp last_t0;
			Timestamp last_t1;
			void reset()
			{
				stats.reset();
				last_t0 = last_t1 = Timestamp();
			}
		};
	
		Port(Receiver& recv, int port);

		void prepareAcq();

		Stats& getStats()
		{ return m_stats; }

	private:
		friend class Receiver;

87
88
89
90
91
92
93
94
95
96
		void portCallback(FrameType det_frame, char *dptr, 
				  uint32_t dsize);

		Camera *m_cam;
		int m_port_idx;
		Model::Recv::Port *m_model_port;
		Stats m_stats;
	};
	typedef std::vector<AutoPtr<Port> > PortList;

97
98
99
	static int fileStartCallback(char *fpath, char *fname, 
				     FrameType fidx, uint32_t dsize, 
				     void *priv);
100
	static void portCallback(char *header, char *dptr, uint32_t dsize, 
101
102
103
104
105
				 void *priv);

	int fileStartCallback(char *fpath, char *fname, uint64_t fidx, 
			      uint32_t dsize);

106
107
108
109
110
	void getNodeMaskList(const CPUAffinityList& listener,
			     const CPUAffinityList& writer,
			     slsReceiverUsers::NodeMaskList& fifo_node_mask,
			     int& max_node);

111
112
113
114
115
	Camera *m_cam;
	int m_idx;
	int m_rx_port;
	Args m_args;
	AutoPtr<slsReceiverUsers> m_recv;
116
	Model::Recv *m_model_recv;
117
118
119
120
121
122
123
124
125
126
	PortList m_port_list;
}; 


} // namespace SlsDetector

} // namespace lima


#endif // __SLS_DETECTOR_RECEIVER_H