source: drsdaq/DAQReadout.h@ 33

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