source: fact/drsdaq/DAQReadout.h@ 10759

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