source: fact/FADctrl/FADBoard.h@ 10257

Last change on this file since 10257 was 10226, checked in by ogrimm, 14 years ago
Bug fix in amplitude calibration loop
File size: 2.0 KB
Line 
1#ifndef FADBoard_H_SEEN
2#define FADBoard_H_SEEN
3
4#include <ctype.h>
5#include <time.h>
6#include <math.h>
7#include <errno.h>
8#include <unistd.h>
9#include <dirent.h>
10#include <sys/time.h>
11
12#include <stdlib.h>
13#include <string.h>
14#include <iostream>
15#include <algorithm>
16#include <sys/socket.h>
17#include <netdb.h>
18
19#include "FAD.h"
20#include "FADFormat.h"
21
22const unsigned int READ_BUFFER_SIZE = 1000000;
23
24class FADBoard: public DimThread {
25
26 class FAD *m;
27 int Socket;
28 pthread_mutex_t Mutex;
29 DimService *DIM_Name, *DIM_ID, *DIM_Temp, *DIM_ROI, *DIM_DAC;
30
31 void ReadLoop();
32 static void LaunchThread(class FADBoard *);
33 void threadHandler();
34
35 public:
36 FADBoard(std::string, unsigned short, class FAD *, unsigned int);
37 ~FADBoard();
38
39 struct BoardStatus {
40 uint16_t BoardID;
41 uint64_t DNA;
42 uint16_t FirmwareRevision;
43 uint32_t BoardTime;
44 uint32_t EventCounter;
45 struct timeval Update;
46
47 uint32_t TriggerID;
48 uint16_t TriggerType;
49 uint16_t TriggerCRC;
50 uint16_t TriggerCell[NChips];
51
52 float Frequency;
53 bool Lock[NChips];
54 int8_t PhaseShift;
55
56 bool denable;
57 bool dwrite;
58 bool DCM_lock;
59 bool DCM_ready;
60 bool spi_clk;
61
62 uint16_t ROI[NChips][NChannels];
63 uint16_t DAC[NDAC];
64 float Temp[NTemp];
65 } Status;
66
67 short Data[NChips][NChannels][NBins];
68 long int Sum[NChips][NChannels][NBins];
69
70 struct CalibData {
71 uint64_t DNA;
72 short Baseline[NChips][NChannels][NBins];
73 double Gain[NChips][NChannels][NBins];
74 double Secondary[NChips][NChannels][NBins];
75 float Temp;
76 float Frequency;
77 time_t Time;
78 } ACalib;
79
80 void Send(const void *, size_t);
81 void Send(unsigned short);
82 struct BoardStatus GetStatus();
83 void AmplitudeCalibration();
84 void Lock();
85 void Unlock();
86
87 unsigned short Port;
88 char *Name;
89 bool CommOK;
90 bool Active;
91 bool Continue;
92 pthread_t Thread;
93 pthread_cond_t CondVar;
94
95 // Amplitude calibration
96 int Count;
97
98 private:
99 enum StateType {standbye, baseline, gain, secondary, cleanup, wait};
100 struct BoardStatus InitialStatus;
101 StateType State;
102};
103
104#endif
Note: See TracBrowser for help on using the repository browser.