forked from coderdj/redax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDAQController.hh
84 lines (65 loc) · 1.85 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
#ifndef _DAQCONTROLLER_HH_
#define _DAQCONTROLLER_HH_
#include <thread>
#include "V1724.hh"
#include "DAXHelpers.hh"
#include "Options.hh"
#include "StraxInserter.hh"
struct processingThread{
std::thread *pthread;
//MongoInserter *inserter;
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,
std::map<int, std::vector<u_int16_t>>&written_dacs);
// Get data (return new buffer and size)
//double data_rate(){
// return 0;
//};
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
static void* ReadThreadWrapper(void* data, int link);
static 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();
private:
void AppendData(vector<data_packet> &d);
vector <processingThread> fProcessingThreads;
void OpenProcessingThreads();
void CloseProcessingThreads();
std::map<int, std::vector <V1724*>> fDigitizers;
std::mutex fBufferMutex;
MongoLog *fLog;
bool fReadLoop;
Options *fOptions;
DAXHelpers *fHelper;
std::vector<data_packet> *fRawDataBuffer;
int fStatus;
int fNProcessingThreads;
string fHostname;
// For reporting to frontend
u_int64_t fBufferLength;
u_int64_t fDatasize;
std::map<int, u_int64_t> fDataPerDigi;
};
#endif