forked from coderdj/redax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DAQController.hh
64 lines (53 loc) · 1.56 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
#ifndef _DAQCONTROLLER_HH_
#define _DAQCONTROLLER_HH_
#include <thread>
#include <atomic>
#include <string>
#include <map>
#include <vector>
#include <cstdint>
#include <mutex>
#include <list>
#include <mongocxx/collection.hpp>
class StraxFormatter;
class MongoLog;
class Options;
class V1724;
class DAQController{
/*
Main control interface for the DAQ. Control scripts and
user-facing interfaces can call this directly.
*/
public:
DAQController(std::shared_ptr<MongoLog>&, std::string hostname="DEFAULT");
virtual ~DAQController();
virtual int Arm(std::shared_ptr<Options>&);
virtual int Start();
virtual int Stop();
virtual void StatusUpdate(mongocxx::collection*);
int status() {return fStatus;}
protected:
std::string fHostname;
std::shared_ptr<MongoLog> fLog;
std::shared_ptr<Options> fOptions;
int fStatus;
private:
void ReadData(int link);
int OpenThreads();
void CloseThreads();
void InitLink(std::vector<std::shared_ptr<V1724>>&, std::map<int, std::vector<uint16_t>>&, int&);
int FitBaselines(std::vector<std::shared_ptr<V1724>>&, std::map<int, std::vector<uint16_t>>&);
std::vector<std::unique_ptr<StraxFormatter>> fFormatters;
std::vector<std::thread> fProcessingThreads;
std::vector<std::thread> fReadoutThreads;
std::map<int, std::vector<std::shared_ptr<V1724>>> fDigitizers;
std::mutex fMutex;
std::atomic_bool fReadLoop;
std::map<int, std::atomic_bool> fRunning;
int fNProcessingThreads;
// For reporting to frontend
std::atomic_int fDataRate;
std::atomic_long fCounter;
std::atomic_int fPLL;
};
#endif