source: drsdaq/DAQReadout.h@ 166

Last change on this file since 166 was 114, checked in by ogrimm, 15 years ago
Bug fix with overloaded variadic print function
File size: 4.1 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
36 pthread_t thread_DAQ;
37 pthread_t thread_DAQ_Silent;
38
39 unsigned int CmdNumber;
40 FILE *Logfile;
41 void PrintUsage();
42 bool CalibrationRead;
43
44 public:
45 RunHeader* RHeader;
46 EventHeader* EHeader;
47
48 DRS *drs;
49
50 short (*WaveForm)[kNumberOfChips][kNumberOfChannels][kNumberOfBins];
51 int (*TriggerCell)[kNumberOfChips];
52
53 pthread_mutex_t control_mutex;
54 int Rawfile;
55 class HVFeedback* HVFB;
56 class SlowData *SlowDataClass;
57
58 // Configuration data
59 char fLogFile[MAX_PATH];
60 char fSlowDataPath[MAX_PATH];
61 unsigned int fMaxLogLines;
62 char fRawDataPath[MAX_PATH];
63 int fMinDiskSpaceMB; // Minimum required disk space in MBytes
64 int fMaxFileSizeMB; // Maximum File size in Bytes
65 int fFirstSample;
66 unsigned int fSamples;
67 int fCCPort;
68 int fLastVMESlot;
69 int fFirstVMESlot;
70 char fHVFeedbackConfig[MAX_PATH];
71 double fDefaultFrequency;
72
73 // Status variables
74 int NParam; // Number of command parameters
75 const char *Param[MAX_NUM_TOKEN]; // Pointers to parameters
76 bool CmdFromSocket; // Current command issued via socket
77 int NumBoards;
78 int FirstBoard;
79 int LastBoard;
80 float *DRSFreq; // DRS sampling frequency [GHz]
81 BoardStructure *BStruct;
82 state_enum daq_state;
83 runtype_enum daq_runtype;
84 int Socket; // -1 if not connected
85 pthread_t *SocketThread; // exit function sends signal to this thread
86 bool Exit;
87 bool Stop; // Set to true to stop run
88 unsigned int NumEvents; // Number of event taken
89 unsigned int NumEventsRequested; // Number of events requested
90 unsigned int RunNumber, FileNumber;
91 char FileName[MAX_PATH];
92 char Prompt[MAX_COM_SIZE];
93 bool ConfigOK;
94
95 // Public functions
96 DAQReadout(const char*);
97 ~DAQReadout();
98
99 void cmd_exit(); void cmd_help();
100 void cmd_board(); void cmd_status();
101 void cmd_led(); void cmd_freq();
102 void cmd_calib(); void cmd_serial();
103 void cmd_trigger(); void cmd_delayed();
104 void cmd_wmode(); void cmd_rmode();
105 void cmd_mode(); void cmd_read();
106 void cmd_stop(); void cmd_test();
107 void cmd_regtest(); void cmd_ramtest();
108 void cmd_start(); void cmd_take();
109 void cmd_config(); void cmd_events();
110 void cmd_disk(); void cmd_uptime();
111
112 void cmd_fmode(); void cmd_faverage();
113 void cmd_ftarget(); void cmd_fgain();
114 void cmd_fresponse(); void cmd_fconfig();
115
116 void CommandControl(char*);
117 void StartDRS();
118 void StopDRS();
119 void StopRun();
120 bool IsDRSBusy();
121 bool IsDRSFreqSet();
122 void SetDRSFrequency(double, bool);
123 void SetDOMINOMode(int);
124 void SetDOMINOReadMode(int);
125 void SetDOMINOWaveMode(int);
126 void SetDelayedStart(int);
127 void HWTrigger(int);
128 bool ReadCalibration();
129 void ReadCalibratedDRSData();
130 void PrintConfig(int);
131 void PrintMessage(int, const char*, ...);
132 void PrintMessage(const char*, ...);
133 void DoPrintMessage(const char*, va_list, int);
134 bool OpenRawFile();
135 bool WriteRunHeader();
136 bool UpdateRunHeader(unsigned int, bool);
137 bool WriteEvent();
138};
139
140void DAQ(DAQReadout *);
141void DAQ_Silent(DAQReadout *);
142
143bool Match(const char*, const char*);
144int ParseInput(char*, const char *Param[]);
145int CheckDisk(char*);
146bool ReadCard(const char *, void *, char, FILE *, unsigned int=1);
147
148#endif
Note: See TracBrowser for help on using the repository browser.