forked from AxFoundation/redax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
V1724.hh
113 lines (95 loc) · 3.38 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
101
102
103
104
105
106
107
108
109
110
111
112
113
#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, unsigned=0);
virtual ~V1724();
virtual int Init(int, int);
virtual int Read(std::unique_ptr<data_packet>&);
virtual int WriteRegister(unsigned int, uint32_t);
virtual unsigned int ReadRegister(unsigned int);
virtual int End();
inline int bid() {return fBID;}
inline uint16_t SampleWidth() {return fSampleWidth;}
inline int GetClockWidth() {return fClockCycle;}
int16_t GetADChannel() {return fArtificialDeadtimeChannel;}
virtual int LoadDAC(std::vector<uint16_t>&);
inline 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, short);
inline bool CheckFail(bool val=false) {bool ret = fError; fError = val; return ret;}
void SetFlags(int flags) {fRegisterFlags = flags;}
void ResetFlags() {fRegisterFlags = 1;}
int BaselineStep(std::vector<uint16_t>&, std::vector<int>&, std::vector<double>&, int);
// Acquisition Control
virtual int SINStart();
virtual int SoftwareStart();
virtual int AcquisitionStop(bool=false);
virtual int SWTrigger();
virtual int Reset();
virtual bool EnsureReady(int=1000, int=1000);
virtual bool EnsureStarted(int=1000, int=1000);
virtual bool EnsureStopped(int=1000, int=1000);
virtual int CheckErrors();
virtual uint32_t GetAcquisitionStatus();
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;
unsigned int fInputDelayRegister;
unsigned int fInputDelayChRegister;
unsigned int fPreTrigRegister;
unsigned int fPreTrigChRegister;
int fBufferSize;
std::vector<int> fBLTalloc;
std::map<int, int> fBLTCounter;
std::vector<int> fDelayPerCh;
std::vector<int> fPreTrigPerCh;
std::vector<uint8_t> fROBuffer;
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;
int fDefaultDelay;
int fDefaultPreTrig;
int fRegisterFlags;
// 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::shared_ptr<Options> fOptions;
std::atomic_bool fError;
float fBLTSafety;
int fSampleWidth, fClockCycle;
int16_t fArtificialDeadtimeChannel;
std::chrono::nanoseconds fTotReadTime;
};
#endif