source: drsdaq/DAQReadout.h@ 108

Last change on this file since 108 was 99, checked in by ogrimm, 16 years ago
Streamlined DRS2 reponse calibration interface, updated HV feedback socket communication
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 char fSlowDataPath[MAX_PATH];
57 unsigned int fMaxLogLines;
58 char fRawDataPath[MAX_PATH];
59 int fMinDiskSpaceMB; // Minimum required disk space in MBytes
60 int fMaxFileSizeMB; // Maximum File size in Bytes
61 int fFirstSample;
62 unsigned int fSamples;
63 int fCCPort;
64 int fLastVMESlot;
65 int fFirstVMESlot;
66 char fHVFeedbackConfig[MAX_PATH];
67 double fDefaultFrequency;
68
69 // Status variables
70 int NParam; // Number of command parameters
71 const char *Param[MAX_NUM_TOKEN]; // Pointers to parameters
72 bool CmdFromSocket; // Current command issued via socket
73 int NumBoards;
74 int FirstBoard;
75 int LastBoard;
76 float *DRSFreq; // DRS sampling frequency [GHz]
77 BoardStructure *BStruct;
78 state_enum daq_state;
79 runtype_enum daq_runtype;
80 int Socket; // -1 if not connected
81 pthread_t *SocketThread; // exit function sends signal to this thread
82 bool Exit;
83 bool Stop; // Set to true to stop run
84 unsigned int NumEvents; // Number of event taken
85 unsigned int NumEventsRequested; // Number of events requested
86 unsigned int RunNumber, FileNumber;
87 char FileName[MAX_PATH];
88 char Prompt[MAX_COM_SIZE];
89 bool ConfigOK;
90
91 // Public functions
92 DAQReadout(const char*);
93 ~DAQReadout();
94
95 void cmd_exit(); void cmd_help();
96 void cmd_board(); void cmd_status();
97 void cmd_led(); void cmd_freq();
98 void cmd_calib(); void cmd_serial();
99 void cmd_trigger(); void cmd_delayed();
100 void cmd_wmode(); void cmd_rmode();
101 void cmd_mode(); void cmd_read();
102 void cmd_stop(); void cmd_test();
103 void cmd_regtest(); void cmd_ramtest();
104 void cmd_start(); void cmd_take();
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 CommandControl(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 PrintMessage(int, const char*, va_list);
130 bool OpenRawFile();
131 bool WriteRunHeader();
132 bool UpdateRunHeader(unsigned int, bool);
133 bool WriteEvent();
134};
135
136void DAQ(DAQReadout *);
137
138bool Match(const char*, const char*);
139int ParseInput(char*, const char *Param[]);
140int CheckDisk(char*);
141bool ReadCard(const char *, void *, char, FILE *, unsigned int=1);
142
143#endif
Note: See TracBrowser for help on using the repository browser.