1 | #ifndef DAQREADOUT_H_SEEN
|
---|
2 | #define DAQREADOUT_H_SEEN
|
---|
3 |
|
---|
4 | #define SERVER_NAME "drsdaq" // Name to use in DIM
|
---|
5 | #include "Evidence.h"
|
---|
6 |
|
---|
7 | #include <stdlib.h>
|
---|
8 | #include <stdarg.h>
|
---|
9 | #include <ctype.h>
|
---|
10 | #include <time.h>
|
---|
11 | #include <math.h>
|
---|
12 | #include <errno.h>
|
---|
13 | #include <unistd.h>
|
---|
14 | #include <sys/socket.h>
|
---|
15 | #include <fcntl.h>
|
---|
16 | #include <dirent.h>
|
---|
17 | #include <sys/vfs.h>
|
---|
18 | #include <sys/time.h>
|
---|
19 | #include <algorithm>
|
---|
20 |
|
---|
21 | #include "RawDataCTX.h"
|
---|
22 | #include "DRS.h"
|
---|
23 |
|
---|
24 | #define MAX_PATH 256 // also used for filename length
|
---|
25 | #define MAX_COM_SIZE 10000
|
---|
26 | #define MAX_NUM_TOKEN 10
|
---|
27 |
|
---|
28 | enum state_enum {active, stopped};
|
---|
29 | enum runtype_enum {data, pedestal, reserved, test};
|
---|
30 |
|
---|
31 | class DAQReadout : public DRS, public DRSCallback, public EvidenceServer {
|
---|
32 |
|
---|
33 | time_t StartTime;
|
---|
34 | pid_t MainThread;
|
---|
35 | DimService *EventService;
|
---|
36 | DimService *RunNumService;
|
---|
37 | int MinDelay;
|
---|
38 | unsigned int CmdNumber;
|
---|
39 | DimCommand *Command;
|
---|
40 | DimService *ConsoleOut;
|
---|
41 | char *ConsoleText;
|
---|
42 | int Rawfile;
|
---|
43 |
|
---|
44 | void PrintUsage();
|
---|
45 | void commandHandler();
|
---|
46 |
|
---|
47 | // Configuration data
|
---|
48 | const char *fCalibDataPath;
|
---|
49 | const char *fRawDataPath;
|
---|
50 | int fMinDiskSpaceMB; // Minimum required disk space in MBytes
|
---|
51 | int fMaxFileSizeMB; // Maximum File size in Bytes
|
---|
52 | int fFirstSample;
|
---|
53 | unsigned int fSamples;
|
---|
54 | double fDefaultFrequency;
|
---|
55 |
|
---|
56 | int fLedTrigBoard;
|
---|
57 | int fLedTrigChip;
|
---|
58 | int fLedTrigChannel;
|
---|
59 | int fLedTrigSample;
|
---|
60 | float fLedTrigThreshold;
|
---|
61 | int fLedSignalSample;
|
---|
62 | int fLedBaselineSample;
|
---|
63 | unsigned int fIntHalfWidth;
|
---|
64 |
|
---|
65 | state_enum daq_state;
|
---|
66 | runtype_enum daq_runtype;
|
---|
67 | bool Stop; // Set to true to stop run
|
---|
68 | int NumEvents; // Number of event taken
|
---|
69 | int NumEventsRequested; // Number of events requested
|
---|
70 | int RunNumber;
|
---|
71 | unsigned int FileNumber;
|
---|
72 | char FileName[MAX_PATH];
|
---|
73 | char CalibInfoFilename[MAX_PATH];
|
---|
74 |
|
---|
75 | public:
|
---|
76 | RunHeader* RHeader;
|
---|
77 | EventHeader* EHeader;
|
---|
78 | BoardStructure *BStruct;
|
---|
79 |
|
---|
80 | short (*WaveForm)[kNumberOfChipsMax][kNumberOfChannelsMax][kNumberOfBins];
|
---|
81 | int (*TriggerCell)[kNumberOfChipsMax];
|
---|
82 | char *DIMEventData;
|
---|
83 |
|
---|
84 | char Prompt[MAX_COM_SIZE];
|
---|
85 |
|
---|
86 | int NParam; // Number of command parameters
|
---|
87 | const char *Param[MAX_NUM_TOKEN]; // Pointers to parameters
|
---|
88 | int NumBoards;
|
---|
89 | int FirstBoard;
|
---|
90 | int LastBoard;
|
---|
91 | int ChipsToWrite;
|
---|
92 | int ChannelsToWrite;
|
---|
93 |
|
---|
94 | float *DRSFreq; // DRS sampling frequency [GHz]
|
---|
95 | bool *ACalib;
|
---|
96 | double *ACalibTemp;
|
---|
97 | bool *TCalib;
|
---|
98 |
|
---|
99 | DAQReadout();
|
---|
100 | ~DAQReadout();
|
---|
101 |
|
---|
102 | void cmd_exit(); void cmd_help();
|
---|
103 | void cmd_board(); void cmd_status();
|
---|
104 | void cmd_led(); void cmd_freq();
|
---|
105 | void cmd_acalib(); void cmd_serial();
|
---|
106 | void cmd_trigger(); void cmd_centre();
|
---|
107 | void cmd_refclk(); void cmd_write();
|
---|
108 | void cmd_wmode(); void cmd_rmode();
|
---|
109 | void cmd_dmode(); void cmd_read();
|
---|
110 | void cmd_stop(); void cmd_chiptest();
|
---|
111 | void cmd_eepromtest(); void cmd_tcalib();
|
---|
112 | void cmd_regtest(); void cmd_ramtest();
|
---|
113 | void cmd_take(); void cmd_update();
|
---|
114 | void cmd_config(); void cmd_events();
|
---|
115 | void cmd_disk(); void cmd_uptime();
|
---|
116 |
|
---|
117 | void Execute(char*);
|
---|
118 | void StartDRS();
|
---|
119 | void StopDRS();
|
---|
120 | void StopRun();
|
---|
121 | bool IsDRSBusy();
|
---|
122 | bool IsDRSFreqSet();
|
---|
123 | void SetDRSFrequency(double, bool);
|
---|
124 | void SetDOMINOMode(int);
|
---|
125 | void SetDOMINOReadMode(int);
|
---|
126 | void SetDOMINOWaveMode(int);
|
---|
127 | void SetDelayedStart(int);
|
---|
128 | void HWTrigger(int);
|
---|
129 | bool ReadCalibration();
|
---|
130 | void ReadCalibratedDRSData();
|
---|
131 | void PrintMessage(const char*, ...);
|
---|
132 | bool OpenRawFile();
|
---|
133 | bool WriteRunHeader();
|
---|
134 | bool UpdateRunHeader(unsigned int, bool);
|
---|
135 | bool WriteEvent();
|
---|
136 | void DAQ();
|
---|
137 |
|
---|
138 | void Progress(int);
|
---|
139 | };
|
---|
140 |
|
---|
141 | void DAQ(DAQReadout *);
|
---|
142 | void Execute(char *);
|
---|
143 |
|
---|
144 | bool Match(const char*, const char*);
|
---|
145 | int ParseInput(char*, const char *Param[]);
|
---|
146 | int CheckDisk(const char*);
|
---|
147 |
|
---|
148 | #endif
|
---|