source: drsdaq/DAQReadout.h@ 67

Last change on this file since 67 was 63, checked in by ogrimm, 15 years ago
Trigger cells stored in event data, data rotation no in memory but at disk transfer
File size: 4.0 KB
Line 
1#ifndef DAQREADOUT_H_SEEN
2#define DAQREADOUT_H_SEEN
3
4#include <stdlib.h>
5#include <stdarg.h>
6#include <ctype.h>
7#include <time.h>
8#include <errno.h>
9#include <sys/socket.h>
10#include <pthread.h>
11#include <fcntl.h>
12#include <dirent.h>
13#include <sys/vfs.h>
14#include <signal.h>
15
16#include "RawDataCTX.h"
17#include "DRS.h"
18#include "HVFeedback.h"
19
20#define RUN_NUM_FILE "/ct3data/LastRunNumber"
21#define MAX_PATH 256 // also used for filename length
22#define MAX_COM_SIZE 10000
23#define MAX_NUM_TOKEN 10
24
25#define MsgToConsole 1
26#define MsgToLog 2
27#define MsgToSocket 4
28
29enum state_enum {active, stopped};
30enum runtype_enum {data, pedestal, test};
31
32class DAQReadout {
33 time_t StartTime;
34 DRS *drs;
35 pthread_t thread_DAQ;
36 unsigned int CmdNumber;
37 FILE *Logfile;
38 void PrintUsage();
39 bool CalibrationRead;
40
41 public:
42 RunHeader* RHeader;
43 EventHeader* EHeader;
44
45 short (*WaveForm)[kNumberOfChips][kNumberOfChannels][kNumberOfBins];
46 int (*TriggerCell)[kNumberOfChips];
47
48 pthread_mutex_t control_mutex;
49 int Rawfile;
50 class HVFeedback* HVFB;
51 class SlowData *SlowDataClass;
52
53 // Configuration data
54 char fLogFile[MAX_PATH];
55 unsigned int fMaxLogLines;
56 char fRawDataPath[MAX_PATH];
57 int fMinDiskSpaceMB; // Minimum required disk space in MBytes
58 int fMaxFileSizeMB; // Maximum File size in Bytes
59 int fFirstSample;
60 unsigned int fSamples;
61 int fCCPort;
62 int fLastVMESlot;
63 int fFirstVMESlot;
64 char fHVFeedbackConfig[MAX_PATH];
65
66 // Status variables
67 int NParam; // Number of command parameters
68 const char *Param[MAX_NUM_TOKEN]; // Pointers to parameters
69 bool CmdFromSocket; // Current command issued via socket
70 int NumBoards;
71 int FirstBoard;
72 int LastBoard;
73 float *DRSFreq; // DRS sampling frequency [GHz]
74 BoardStructure *BStruct;
75 state_enum daq_state;
76 runtype_enum daq_runtype;
77 int Socket; // -1 if not connected
78 pthread_t *SocketThread; // exit function sends signal to this thread
79 bool Exit;
80 bool Stop; // Set to true to stop run
81 unsigned int NumEvents; // Number of event taken
82 unsigned int NumEventsRequested; // Number of events requested
83 unsigned int RunNumber, FileNumber;
84 char FileName[MAX_PATH];
85 char Prompt[MAX_COM_SIZE];
86
87 // Public functions
88 DAQReadout(const char*);
89 ~DAQReadout();
90
91 void cmd_exit(); void cmd_help();
92 void cmd_board(); void cmd_status();
93 void cmd_led(); void cmd_freq();
94 void cmd_calib(); void cmd_serial();
95 void cmd_trigger(); void cmd_delayed();
96 void cmd_wmode(); void cmd_rmode();
97 void cmd_mode(); void cmd_read();
98 void cmd_stop(); void cmd_test();
99 void cmd_regtest(); void cmd_ramtest();
100 void cmd_start(); void cmd_take();
101 void cmd_config(); void cmd_events();
102 void cmd_disk(); void cmd_uptime();
103
104 void cmd_fmode(); void cmd_faverage();
105 void cmd_ftarget(); void cmd_fgain();
106 void cmd_fresponse(); void cmd_fconfig();
107
108 void CommandControl(char*);
109 void StartDRS();
110 void StopDRS();
111 void StopRun();
112 bool IsDRSBusy();
113 bool IsDRSFreqSet();
114 void SetDRSFrequency(double, bool);
115 void CalibrateDRS(char*, double, double);
116 void SetDOMINOMode(int);
117 void SetDOMINOReadMode(int);
118 void SetDOMINOWaveMode(int);
119 void SetDelayedStart(int);
120 void HWTrigger(int);
121 bool ReadCalibration();
122 bool IsCalibrationRead();
123 void ReadCalibratedDRSData();
124 void PrintMessage(int, const char*, ...);
125 void PrintMessage(const char*, ...);
126 void PrintMessage(int, const char*, va_list);
127 bool OpenRawFile();
128 bool WriteRunHeader();
129 bool UpdateRunHeader(unsigned int, bool);
130 bool WriteEventHeader();
131 bool WriteEventData();
132};
133
134void DAQ(DAQReadout *);
135bool Match(const char*, const char*);
136int ParseInput(char*, const char *Param[]);
137int CheckDisk(char*);
138bool ReadCard(const char *, void *, char, FILE *, unsigned int=1);
139
140#endif
Note: See TracBrowser for help on using the repository browser.