forked from coderdj/redax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDAQController.hh
89 lines (70 loc) · 2.07 KB
/
DAQController.hh
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
87
88
89
#ifndef _DAQCONTROLLER_HH_
#define _DAQCONTROLLER_HH_
#include <thread>
#include <atomic>
#include <string>
#include <map>
#include <vector>
#include <cstdint>
#include <mutex>
class StraxInserter;
class MongoLog;
class Options;
class V1724;
class data_packet;
struct processingThread{
std::thread *pthread;
StraxInserter *inserter;
};
class DAQController{
/*
Main control interface for the DAQ. Control scripts and
user-facing interfaces can call this directly.
*/
public:
DAQController(MongoLog *log=NULL, std::string hostname="DEFAULT");
~DAQController();
int InitializeElectronics(Options *options, std::vector<int> &keys);
int status(){
return fStatus;
};
int buffer_length(){
return fBufferLength;
};
std::string run_mode();
int Start();
int Stop();
void ReadData(int link);
void End();
int GetData(std::vector <data_packet> *&retVec);
// Static wrapper so we can call ReadData in a std::thread
void ReadThreadWrapper(void* data, int link);
void ProcessingThreadWrapper(void* data);
u_int64_t GetDataSize(){ u_int64_t ds = fDatasize; fDatasize=0; return ds;};
std::map<int, u_int64_t> GetDataPerDigi();
bool CheckErrors();
int OpenProcessingThreads();
void CloseProcessingThreads();
std::map<std::string, int> GetDataFormat();
private:
void AppendData(std::vector<data_packet> &d);
void InitLink(std::vector<V1724*>&, std::map<int, std::map<std::string, std::vector<double>>>&, int&);
int FitBaselines(std::vector<V1724*>&, std::map<int, std::vector<u_int16_t>>&, int,
std::map<int, std::map<std::string, std::vector<double>>>&);
std::vector <processingThread> fProcessingThreads;
std::map<int, std::vector <V1724*>> fDigitizers;
std::mutex fBufferMutex;
std::mutex fMapMutex;
bool fReadLoop;
std::vector<data_packet> *fRawDataBuffer;
int fStatus;
int fNProcessingThreads;
std::string fHostname;
MongoLog *fLog;
Options *fOptions;
// For reporting to frontend
std::atomic_uint64_t fBufferLength;
u_int64_t fDatasize;
std::map<int, std::atomic_ulong> fDataPerDigi;
};
#endif