source: drsdaq/DAQReadout.h@ 73

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