source: drsdaq/DAQReadout.h@ 229

Last change on this file since 229 was 229, checked in by ogrimm, 14 years ago
Config requests non-blocking if not made from main thread, adapted all servers to GetConfig() returning std::string, workaround for erroneous SERVICE_LIST
File size: 3.9 KB
Line 
1#ifndef DAQREADOUT_H_SEEN
2#define DAQREADOUT_H_SEEN
3
4#define SERVER_NAME "drsdaq" // Name to use in DIM
5#include "Evidence.h"
6
7#include <stdlib.h>
8#include <stdarg.h>
9#include <ctype.h>
10#include <time.h>
11#include <errno.h>
12#include <unistd.h>
13#include <sys/socket.h>
14#include <pthread.h>
15#include <fcntl.h>
16#include <dirent.h>
17#include <sys/vfs.h>
18#include <signal.h>
19#include <sys/time.h>
20
21#include "RawDataCTX.h"
22#include "DRS.h"
23#include "HVFeedback.h"
24
25#define MAX_PATH 256 // also used for filename length
26#define MAX_COM_SIZE 10000
27#define MAX_NUM_TOKEN 10
28
29#define MsgToConsole 1
30#define MsgToLog 2
31
32enum state_enum {active, stopped};
33enum runtype_enum {data, pedestal, reserved, test};
34
35class DAQReadout : public DRS, public DRSCallback, public EvidenceServer {
36
37 time_t StartTime;
38 pid_t MainThread;
39 DimService *EventService;
40 int MinDelay;
41 unsigned int CmdNumber;
42 DimCommand *Command;
43 DimService *ConsoleOut;
44 char *ConsoleText;
45
46 void PrintUsage();
47 void commandHandler();
48
49 pthread_mutex_t Mutex;
50 int Rawfile;
51 class HVFeedback* HVFB;
52
53 // Configuration data
54 const char *fCalibDataPath;
55 const 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 double fDefaultFrequency;
61
62 state_enum daq_state;
63 runtype_enum daq_runtype;
64 bool Stop; // Set to true to stop run
65 unsigned int NumEvents; // Number of event taken
66 unsigned int NumEventsRequested; // Number of events requested
67 int RunNumber;
68 unsigned int FileNumber;
69 char FileName[MAX_PATH];
70 char CalibInfoFilename[MAX_PATH];
71
72 public:
73 RunHeader* RHeader;
74 EventHeader* EHeader;
75 BoardStructure *BStruct;
76
77 short (*WaveForm)[kNumberOfChipsMax][kNumberOfChannelsMax][kNumberOfBins];
78 int (*TriggerCell)[kNumberOfChipsMax];
79 char *DIMEventData;
80
81 char Prompt[MAX_COM_SIZE];
82
83 int NParam; // Number of command parameters
84 const char *Param[MAX_NUM_TOKEN]; // Pointers to parameters
85 int NumBoards;
86 int FirstBoard;
87 int LastBoard;
88 float *DRSFreq; // DRS sampling frequency [GHz]
89 bool *ACalib;
90 double *ACalibTemp;
91 bool *TCalib;
92
93 DAQReadout();
94 ~DAQReadout();
95
96 void cmd_exit(); void cmd_help();
97 void cmd_board(); void cmd_status();
98 void cmd_led(); void cmd_freq();
99 void cmd_acalib(); void cmd_serial();
100 void cmd_trigger(); void cmd_centre();
101 void cmd_refclk();
102 void cmd_wmode(); void cmd_rmode();
103 void cmd_dmode(); void cmd_read();
104 void cmd_stop(); void cmd_chiptest();
105 void cmd_eepromtest(); void cmd_tcalib();
106 void cmd_regtest(); void cmd_ramtest();
107 void cmd_take(); void cmd_update();
108 void cmd_config(); void cmd_events();
109 void cmd_disk(); void cmd_uptime();
110
111 void cmd_fmode(); void cmd_faverage();
112 void cmd_ftarget(); void cmd_fgain();
113 void cmd_fresponse(); void cmd_fconfig();
114
115 void Execute(char*);
116 void StartDRS();
117 void StopDRS();
118 void StopRun();
119 bool IsDRSBusy();
120 bool IsDRSFreqSet();
121 void SetDRSFrequency(double, bool);
122 void SetDOMINOMode(int);
123 void SetDOMINOReadMode(int);
124 void SetDOMINOWaveMode(int);
125 void SetDelayedStart(int);
126 void HWTrigger(int);
127 bool ReadCalibration();
128 void ReadCalibratedDRSData();
129 void PrintConfig(int);
130 void PrintMessage(int, const char*, ...);
131 void PrintMessage(const char*, ...);
132 void DoPrintMessage(const char*, va_list, int);
133 bool OpenRawFile();
134 bool WriteRunHeader();
135 bool UpdateRunHeader(unsigned int, bool);
136 bool WriteEvent();
137 void DAQ();
138
139 void Progress(int);
140};
141
142void DAQ(DAQReadout *);
143void Execute(char *);
144
145bool Match(const char*, const char*);
146int ParseInput(char*, const char *Param[]);
147int CheckDisk(const char*);
148
149#endif
Note: See TracBrowser for help on using the repository browser.