source: drsdaq/DAQReadout.h@ 272

Last change on this file since 272 was 269, checked in by ogrimm, 14 years ago
First commit of separated Feedback program
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 <math.h>
12#include <errno.h>
13#include <unistd.h>
14#include <sys/socket.h>
15#include <fcntl.h>
16#include <dirent.h>
17#include <sys/vfs.h>
18#include <sys/time.h>
19
20#include "RawDataCTX.h"
21#include "DRS.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 int Rawfile;
41
42 void PrintUsage();
43 void commandHandler();
44
45 // Configuration data
46 const char *fCalibDataPath;
47 const char *fRawDataPath;
48 int fMinDiskSpaceMB; // Minimum required disk space in MBytes
49 int fMaxFileSizeMB; // Maximum File size in Bytes
50 int fFirstSample;
51 unsigned int fSamples;
52 double fDefaultFrequency;
53
54 int fLedTrigBoard;
55 int fLedTrigChip;
56 int fLedTrigChannel;
57 int fLedTrigSample;
58 float fLedTrigThreshold;
59 int fLedSignalSample;
60 int fLedBaselineSample;
61 unsigned int fIntHalfWidth;
62
63 state_enum daq_state;
64 runtype_enum daq_runtype;
65 bool Stop; // Set to true to stop run
66 unsigned int NumEvents; // Number of event taken
67 unsigned int NumEventsRequested; // Number of events requested
68 int RunNumber;
69 unsigned int FileNumber;
70 char FileName[MAX_PATH];
71 char CalibInfoFilename[MAX_PATH];
72
73 public:
74 RunHeader* RHeader;
75 EventHeader* EHeader;
76 BoardStructure *BStruct;
77
78 short (*WaveForm)[kNumberOfChipsMax][kNumberOfChannelsMax][kNumberOfBins];
79 int (*TriggerCell)[kNumberOfChipsMax];
80 char *DIMEventData;
81
82 char Prompt[MAX_COM_SIZE];
83
84 int NParam; // Number of command parameters
85 const char *Param[MAX_NUM_TOKEN]; // Pointers to parameters
86 int NumBoards;
87 int FirstBoard;
88 int LastBoard;
89 float *DRSFreq; // DRS sampling frequency [GHz]
90 bool *ACalib;
91 double *ACalibTemp;
92 bool *TCalib;
93
94 DAQReadout();
95 ~DAQReadout();
96
97 void cmd_exit(); void cmd_help();
98 void cmd_board(); void cmd_status();
99 void cmd_led(); void cmd_freq();
100 void cmd_acalib(); void cmd_serial();
101 void cmd_trigger(); void cmd_centre();
102 void cmd_refclk();
103 void cmd_wmode(); void cmd_rmode();
104 void cmd_dmode(); void cmd_read();
105 void cmd_stop(); void cmd_chiptest();
106 void cmd_eepromtest(); void cmd_tcalib();
107 void cmd_regtest(); void cmd_ramtest();
108 void cmd_take(); void cmd_update();
109 void cmd_config(); void cmd_events();
110 void cmd_disk(); void cmd_uptime();
111
112 void Execute(char*);
113 void StartDRS();
114 void StopDRS();
115 void StopRun();
116 bool IsDRSBusy();
117 bool IsDRSFreqSet();
118 void SetDRSFrequency(double, bool);
119 void SetDOMINOMode(int);
120 void SetDOMINOReadMode(int);
121 void SetDOMINOWaveMode(int);
122 void SetDelayedStart(int);
123 void HWTrigger(int);
124 bool ReadCalibration();
125 void ReadCalibratedDRSData();
126 void PrintMessage(const char*, ...);
127 bool OpenRawFile();
128 bool WriteRunHeader();
129 bool UpdateRunHeader(unsigned int, bool);
130 bool WriteEvent();
131 void DAQ();
132
133 void Progress(int);
134};
135
136void DAQ(DAQReadout *);
137void Execute(char *);
138
139bool Match(const char*, const char*);
140int ParseInput(char*, const char *Param[]);
141int CheckDisk(const char*);
142
143#endif
Note: See TracBrowser for help on using the repository browser.