source: drsdaq/DAQReadout.h@ 263

Last change on this file since 263 was 254, checked in by ogrimm, 14 years ago
Replaced mutex by Lock()/Unlock() from Evidence class, added feedback state service
File size: 3.7 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 <fcntl.h>
15#include <dirent.h>
16#include <sys/vfs.h>
17#include <sys/time.h>
18
19#include "RawDataCTX.h"
20#include "DRS.h"
21#include "HVFeedback.h"
22
23#define MAX_PATH 256 // also used for filename length
24#define MAX_COM_SIZE 10000
25#define MAX_NUM_TOKEN 10
26
27enum state_enum {active, stopped};
28enum runtype_enum {data, pedestal, reserved, test};
29
30class DAQReadout : public DRS, public DRSCallback, public EvidenceServer {
31
32 time_t StartTime;
33 pid_t MainThread;
34 DimService *EventService;
35 int MinDelay;
36 unsigned int CmdNumber;
37 DimCommand *Command;
38 DimService *ConsoleOut;
39 char *ConsoleText;
40
41 void PrintUsage();
42 void commandHandler();
43
44 int Rawfile;
45 class HVFeedback* HVFB;
46
47 // Configuration data
48 const char *fCalibDataPath;
49 const char *fRawDataPath;
50 int fMinDiskSpaceMB; // Minimum required disk space in MBytes
51 int fMaxFileSizeMB; // Maximum File size in Bytes
52 int fFirstSample;
53 unsigned int fSamples;
54 double fDefaultFrequency;
55
56 state_enum daq_state;
57 runtype_enum daq_runtype;
58 bool Stop; // Set to true to stop run
59 unsigned int NumEvents; // Number of event taken
60 unsigned int NumEventsRequested; // Number of events requested
61 int RunNumber;
62 unsigned int FileNumber;
63 char FileName[MAX_PATH];
64 char CalibInfoFilename[MAX_PATH];
65
66 public:
67 RunHeader* RHeader;
68 EventHeader* EHeader;
69 BoardStructure *BStruct;
70
71 short (*WaveForm)[kNumberOfChipsMax][kNumberOfChannelsMax][kNumberOfBins];
72 int (*TriggerCell)[kNumberOfChipsMax];
73 char *DIMEventData;
74
75 char Prompt[MAX_COM_SIZE];
76
77 int NParam; // Number of command parameters
78 const char *Param[MAX_NUM_TOKEN]; // Pointers to parameters
79 int NumBoards;
80 int FirstBoard;
81 int LastBoard;
82 float *DRSFreq; // DRS sampling frequency [GHz]
83 bool *ACalib;
84 double *ACalibTemp;
85 bool *TCalib;
86
87 DAQReadout();
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_acalib(); void cmd_serial();
94 void cmd_trigger(); void cmd_centre();
95 void cmd_refclk();
96 void cmd_wmode(); void cmd_rmode();
97 void cmd_dmode(); void cmd_read();
98 void cmd_stop(); void cmd_chiptest();
99 void cmd_eepromtest(); void cmd_tcalib();
100 void cmd_regtest(); void cmd_ramtest();
101 void cmd_take(); void cmd_update();
102 void cmd_config(); void cmd_events();
103 void cmd_disk(); void cmd_uptime();
104
105 void cmd_fmode(); void cmd_faverage();
106 void cmd_ftarget(); void cmd_fgain();
107 void cmd_fresponse(); void cmd_fconfig();
108
109 void Execute(char*);
110 void StartDRS();
111 void StopDRS();
112 void StopRun();
113 bool IsDRSBusy();
114 bool IsDRSFreqSet();
115 void SetDRSFrequency(double, bool);
116 void SetDOMINOMode(int);
117 void SetDOMINOReadMode(int);
118 void SetDOMINOWaveMode(int);
119 void SetDelayedStart(int);
120 void HWTrigger(int);
121 bool ReadCalibration();
122 void ReadCalibratedDRSData();
123 void PrintConfig();
124 void PrintMessage(const char*, ...);
125 bool OpenRawFile();
126 bool WriteRunHeader();
127 bool UpdateRunHeader(unsigned int, bool);
128 bool WriteEvent();
129 void DAQ();
130
131 void Progress(int);
132};
133
134void DAQ(DAQReadout *);
135void Execute(char *);
136
137bool Match(const char*, const char*);
138int ParseInput(char*, const char *Param[]);
139int CheckDisk(const char*);
140
141#endif
Note: See TracBrowser for help on using the repository browser.