source: drsdaq/DAQReadout.h@ 189

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