source: drsdaq/DAQReadout.h@ 209

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