source: drsdaq/DAQReadout.h@ 212

Last change on this file since 212 was 211, checked in by ogrimm, 15 years ago
Fix for exit signalling from DimCommand thread
File size: 3.8 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 DimCommand, public EvidenceServer {
36
37 time_t StartTime;
38 pid_t MainThread;
39 DimService *EventService;
40 int MinDelay;
41 unsigned int CmdNumber;
42
43 void PrintUsage();
44 void commandHandler();
45
46 pthread_mutex_t Mutex;
47 int Rawfile;
48 class HVFeedback* HVFB;
49
50 // Configuration data
51 char *fCalibDataPath;
52 char *fRawDataPath;
53 int fMinDiskSpaceMB; // Minimum required disk space in MBytes
54 int fMaxFileSizeMB; // Maximum File size in Bytes
55 int fFirstSample;
56 unsigned int fSamples;
57 double fDefaultFrequency;
58
59 state_enum daq_state;
60 runtype_enum daq_runtype;
61 bool Stop; // Set to true to stop run
62 unsigned int NumEvents; // Number of event taken
63 unsigned int NumEventsRequested; // Number of events requested
64 int RunNumber;
65 unsigned int FileNumber;
66 char FileName[MAX_PATH];
67 char CalibInfoFilename[MAX_PATH];
68
69 public:
70 RunHeader* RHeader;
71 EventHeader* EHeader;
72 BoardStructure *BStruct;
73
74 short (*WaveForm)[kNumberOfChipsMax][kNumberOfChannelsMax][kNumberOfBins];
75 int (*TriggerCell)[kNumberOfChipsMax];
76 char *DIMEventData;
77
78 char Prompt[MAX_COM_SIZE];
79
80 int NParam; // Number of command parameters
81 const char *Param[MAX_NUM_TOKEN]; // Pointers to parameters
82 int NumBoards;
83 int FirstBoard;
84 int LastBoard;
85 float *DRSFreq; // DRS sampling frequency [GHz]
86 bool *ACalib;
87 double *ACalibTemp;
88 bool *TCalib;
89
90 DAQReadout();
91 ~DAQReadout();
92
93 void cmd_exit(); void cmd_help();
94 void cmd_board(); void cmd_status();
95 void cmd_led(); void cmd_freq();
96 void cmd_acalib(); void cmd_serial();
97 void cmd_trigger(); void cmd_centre();
98 void cmd_refclk();
99 void cmd_wmode(); void cmd_rmode();
100 void cmd_dmode(); void cmd_read();
101 void cmd_stop(); void cmd_chiptest();
102 void cmd_eepromtest(); void cmd_tcalib();
103 void cmd_regtest(); void cmd_ramtest();
104 void cmd_take(); void cmd_update();
105 void cmd_config(); void cmd_events();
106 void cmd_disk(); void cmd_uptime();
107
108 void cmd_fmode(); void cmd_faverage();
109 void cmd_ftarget(); void cmd_fgain();
110 void cmd_fresponse(); void cmd_fconfig();
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 PrintConfig(int);
127 void PrintMessage(int, const char*, ...);
128 void PrintMessage(const char*, ...);
129 void DoPrintMessage(const char*, va_list, int);
130 bool OpenRawFile();
131 bool WriteRunHeader();
132 bool UpdateRunHeader(unsigned int, bool);
133 bool WriteEvent();
134 void DAQ();
135
136 void Progress(int);
137};
138
139void DAQ(DAQReadout *);
140void Execute(char *);
141
142bool Match(const char*, const char*);
143int ParseInput(char*, const char *Param[]);
144int CheckDisk(char*);
145
146#endif
Note: See TracBrowser for help on using the repository browser.