source: fact/FADctrl/FADBoard.h@ 10531

Last change on this file since 10531 was 10504, checked in by neise, 14 years ago
supports new FAD event format: setting runnumber resetting internat trigger ID
File size: 2.2 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;
23const unsigned int STATUS_SIZE = 200;
24
25class FADBoard: public DimThread {
26
27 class FAD *m;
28 int Socket;
29 pthread_mutex_t Mutex;
30 DimService *DIM_Name, *DIM_Status, *DIM_ID, *DIM_Frequency;
31 DimService *DIM_Rate, *DIM_Temp, *DIM_ROI, *DIM_DAC;
32
33 void ReadLoop();
34 static void LaunchThread(class FADBoard *);
35 void threadHandler();
36 void SetStatus(const char *, ...);
37
38 public:
39 FADBoard(std::string, unsigned short, class FAD *, unsigned int);
40 ~FADBoard();
41
42 struct BoardStatus {
43 uint16_t BoardID;
44 uint64_t DNA;
45 uint16_t FirmwareRevision;
46 uint32_t BoardTime;
47 uint32_t EventCounter;
48
49 char Message[STATUS_SIZE];
50 struct timeval Update;
51 float Rate;
52
53 uint32_t TriggerID;
54 uint32_t Runnumber;
55 uint16_t TriggerType;
56 uint16_t TriggerCRC;
57 uint16_t TriggerCell[NChips];
58
59 float Frequency;
60 bool Lock[NChips];
61 int8_t PhaseShift;
62
63 bool denable;
64 bool dwrite;
65 bool DCM_lock;
66 bool DCM_ready;
67 bool spi_clk;
68
69 uint16_t ROI[NChips][NChannels];
70 uint16_t DAC[NDAC];
71 float Temp[NTemp];
72 } Status;
73
74 short Data[NChips][NChannels][NBins];
75 long int Sum[NChips][NChannels][NBins];
76
77 struct CalibData {
78 uint64_t DNA;
79 short Baseline[NChips][NChannels][NBins];
80 double Gain[NChips][NChannels][NBins];
81 double Secondary[NChips][NChannels][NBins];
82 float Temp;
83 float Frequency;
84 time_t Time;
85 } ACalib;
86
87 void Send(const void *, size_t);
88 void Send(unsigned short);
89 struct BoardStatus GetStatus();
90 void AmplitudeCalibration();
91 void Lock();
92 void Unlock();
93
94 unsigned short Port;
95 char *Name;
96 bool CommOK;
97 bool Active;
98 bool Continue;
99 pthread_t Thread;
100 pthread_cond_t CondVar;
101
102 // Amplitude calibration
103 int Count;
104
105 private:
106 enum StateType {standbye, baseline, gain, secondary, cleanup, wait};
107 struct BoardStatus InitialStatus;
108 StateType State;
109};
110
111#endif
Note: See TracBrowser for help on using the repository browser.