source: drsdaq/DAQReadout.h@ 22

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