source: drsdaq/DAQReadout.h@ 177

Last change on this file since 177 was 176, checked in by ogrimm, 15 years ago
Migrated to DRS4. DRS class does not run with DRS2 FPGA firmware anymore.
File size: 4.2 KB
Line 
1#ifndef DAQREADOUT_H_SEEN
2#define DAQREADOUT_H_SEEN
3
4#include <stdlib.h>
5#include <stdarg.h>
6#include <ctype.h>
7#include <time.h>
8#include <errno.h>
9#include <unistd.h>
10#include <sys/socket.h>
11#include <pthread.h>
12#include <fcntl.h>
13#include <dirent.h>
14#include <sys/vfs.h>
15#include <signal.h>
16
17#include "RawDataCTX.h"
18#include "DRS.h"
19#include "HVFeedback.h"
20
21#define RUN_NUM_FILE "/home/ogrimm/Data/LastRunNumber"
22
23#define MAX_PATH 256 // also used for filename length
24#define MAX_COM_SIZE 10000
25#define MAX_NUM_TOKEN 10
26
27#define MsgToConsole 1
28#define MsgToLog 2
29#define MsgToSocket 4
30
31enum state_enum {active, stopped};
32enum runtype_enum {data, pedestal, reserved, test};
33
34class DAQReadout : public DRS, public DRSCallback {
35 time_t StartTime;
36
37 pthread_t thread_DAQ;
38 pthread_t thread_DAQ_Silent;
39
40 unsigned int CmdNumber;
41 FILE *Logfile;
42 void PrintUsage();
43
44 public:
45 RunHeader* RHeader;
46 EventHeader* EHeader;
47
48 short (*WaveForm)[kNumberOfChipsMax][kNumberOfChannelsMax][kNumberOfBins];
49 int (*TriggerCell)[kNumberOfChipsMax];
50
51 pthread_mutex_t control_mutex;
52 int Rawfile;
53 class HVFeedback* HVFB;
54 class SlowData *SlowDataClass;
55
56 // Configuration data
57 char fLogFile[MAX_PATH];
58 char fSlowDataPath[MAX_PATH];
59 char fCalibDataPath[MAX_PATH];
60 unsigned int fMaxLogLines;
61 char fRawDataPath[MAX_PATH];
62 int fMinDiskSpaceMB; // Minimum required disk space in MBytes
63 int fMaxFileSizeMB; // Maximum File size in Bytes
64 int fFirstSample;
65 unsigned int fSamples;
66 int fCCPort;
67 char fHVFeedbackConfig[MAX_PATH];
68 double fDefaultFrequency;
69
70 // Status variables
71 int NParam; // Number of command parameters
72 const char *Param[MAX_NUM_TOKEN]; // Pointers to parameters
73 bool CmdFromSocket; // Current command issued via socket
74 int NumBoards;
75 int FirstBoard;
76 int LastBoard;
77 float *DRSFreq; // DRS sampling frequency [GHz]
78 bool *ACalib;
79 double *ACalibTemp;
80 bool *TCalib;
81
82 BoardStructure *BStruct;
83 state_enum daq_state;
84 runtype_enum daq_runtype;
85 int Socket; // -1 if not connected
86 pthread_t *SocketThread; // exit function sends signal to this thread
87 bool Exit;
88 bool Stop; // Set to true to stop run
89 unsigned int NumEvents; // Number of event taken
90 unsigned int NumEventsRequested; // Number of events requested
91 unsigned int RunNumber, FileNumber;
92 char FileName[MAX_PATH];
93 char Prompt[MAX_COM_SIZE];
94 bool ConfigOK;
95
96 // Public functions
97 DAQReadout(const char*);
98 ~DAQReadout();
99
100 void cmd_exit(); void cmd_help();
101 void cmd_board(); void cmd_status();
102 void cmd_led(); void cmd_freq();
103 void cmd_acalib(); void cmd_serial();
104 void cmd_trigger(); void cmd_centre();
105 void cmd_refclk();
106 void cmd_wmode(); void cmd_rmode();
107 void cmd_dmode(); void cmd_read();
108 void cmd_stop(); void cmd_chiptest();
109 void cmd_eepromtest(); void cmd_tcalib();
110 void cmd_regtest(); void cmd_ramtest();
111 void cmd_start(); void cmd_take();
112 void cmd_config(); void cmd_events();
113 void cmd_disk(); void cmd_uptime();
114
115 void cmd_fmode(); void cmd_faverage();
116 void cmd_ftarget(); void cmd_fgain();
117 void cmd_fresponse(); void cmd_fconfig();
118
119 void CommandControl(char*);
120 void StartDRS();
121 void StopDRS();
122 void StopRun();
123 bool IsDRSBusy();
124 bool IsDRSFreqSet();
125 void SetDRSFrequency(double, bool);
126 void SetDOMINOMode(int);
127 void SetDOMINOReadMode(int);
128 void SetDOMINOWaveMode(int);
129 void SetDelayedStart(int);
130 void HWTrigger(int);
131 bool ReadCalibration();
132 void ReadCalibratedDRSData();
133 void PrintConfig(int);
134 void PrintMessage(int, const char*, ...);
135 void PrintMessage(const char*, ...);
136 void DoPrintMessage(const char*, va_list, int);
137 bool OpenRawFile();
138 bool WriteRunHeader();
139 bool UpdateRunHeader(unsigned int, bool);
140 bool WriteEvent();
141
142 void Progress(int);
143};
144
145void DAQ(DAQReadout *);
146void DAQ_Silent(DAQReadout *);
147
148bool Match(const char*, const char*);
149int ParseInput(char*, const char *Param[]);
150int CheckDisk(char*);
151bool ReadCard(const char *, void *, char, FILE *, unsigned int=1);
152
153#endif
Note: See TracBrowser for help on using the repository browser.