source: drsdaq/DAQReadout.h@ 37

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