-
Notifications
You must be signed in to change notification settings - Fork 14
/
V1724.hh
100 lines (81 loc) · 2.94 KB
/
V1724.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
90
91
92
93
94
95
96
97
98
99
100
#ifndef _V1724_HH_
#define _V1724_HH_
#include <cstdint>
#include <vector>
#include <map>
#include <chrono>
#include <memory>
#include <atomic>
#include <tuple>
class MongoLog;
class Options;
class data_packet;
class V1724{
public:
V1724(std::shared_ptr<MongoLog>&, std::shared_ptr<Options>&, int, int, int, unsigned=0);
virtual ~V1724();
virtual int Read(std::unique_ptr<data_packet>&);
virtual int WriteRegister(unsigned int reg, unsigned int value);
virtual unsigned int ReadRegister(unsigned int reg);
virtual int End();
int bid() {return fBID;}
uint16_t SampleWidth() {return fSampleWidth;}
int GetClockWidth() {return fClockCycle;}
int16_t GetADChannel() {return fArtificialDeadtimeChannel;}
virtual int LoadDAC(std::vector<uint16_t>&);
void ClampDACValues(std::vector<uint16_t>&, std::map<std::string, std::vector<double>>&);
unsigned GetNumChannels() {return fNChannels;}
int SetThresholds(std::vector<uint16_t> vals);
virtual std::tuple<int, int, bool, uint32_t> UnpackEventHeader(std::u32string_view);
virtual std::tuple<int64_t, int, uint16_t, std::u32string_view> UnpackChannelHeader(std::u32string_view, long, uint32_t, uint32_t, int, int);
bool CheckFail(bool val=false) {bool ret = fError; fError = val; return ret;}
// Acquisition Control
virtual int SINStart();
virtual int SoftwareStart();
virtual int AcquisitionStop(bool=false);
virtual int SWTrigger();
virtual int Reset();
virtual bool EnsureReady(int ntries, int sleep);
virtual bool EnsureStarted(int ntries, int sleep);
virtual bool EnsureStopped(int ntries, int sleep);
virtual int CheckErrors();
virtual uint32_t GetAcquisitionStatus();
virtual int ResetClocks();
protected:
// Some values for base classes to override
unsigned int fAqCtrlRegister;
unsigned int fAqStatusRegister;
unsigned int fSwTrigRegister;
unsigned int fResetRegister;
unsigned int fClearRegister;
unsigned int fChStatusRegister;
unsigned int fChDACRegister;
unsigned int fChTrigRegister;
unsigned int fNChannels;
unsigned int fSNRegisterMSB;
unsigned int fSNRegisterLSB;
unsigned int fBoardFailStatRegister;
unsigned int fReadoutStatusRegister;
unsigned int fVMEAlignmentRegister;
unsigned int fBoardErrRegister;
int BLT_SIZE;
std::map<int, long> fBLTCounter;
virtual int Init(int, int, std::shared_ptr<Options>&);
bool MonitorRegister(uint32_t reg, uint32_t mask, int ntries, int sleep, uint32_t val=1);
virtual std::tuple<uint32_t, long> GetClockInfo(std::u32string_view);
virtual int GetClockCounter(uint32_t);
int fBoardHandle;
int fBID;
unsigned int fBaseAddress;
// Stuff for clock reset tracking
int fRolloverCounter;
uint32_t fLastClock;
std::chrono::high_resolution_clock::time_point fLastClockTime;
std::chrono::nanoseconds fClockPeriod;
std::shared_ptr<MongoLog> fLog;
std::atomic_bool fError;
float fBLTSafety, fBufferSafety;
int fSampleWidth, fClockCycle;
int16_t fArtificialDeadtimeChannel;
};
#endif