source: fact/FADctrl/FADBoard.h@ 10482

Last change on this file since 10482 was 10290, checked in by ogrimm, 14 years ago
FADctrl publishes event rate per board
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 uint16_t TriggerType;
55 uint16_t TriggerCRC;
56 uint16_t TriggerCell[NChips];
57
58 float Frequency;
59 bool Lock[NChips];
60 int8_t PhaseShift;
61
62 bool denable;
63 bool dwrite;
64 bool DCM_lock;
65 bool DCM_ready;
66 bool spi_clk;
67
68 uint16_t ROI[NChips][NChannels];
69 uint16_t DAC[NDAC];
70 float Temp[NTemp];
71 } Status;
72
73 short Data[NChips][NChannels][NBins];
74 long int Sum[NChips][NChannels][NBins];
75
76 struct CalibData {
77 uint64_t DNA;
78 short Baseline[NChips][NChannels][NBins];
79 double Gain[NChips][NChannels][NBins];
80 double Secondary[NChips][NChannels][NBins];
81 float Temp;
82 float Frequency;
83 time_t Time;
84 } ACalib;
85
86 void Send(const void *, size_t);
87 void Send(unsigned short);
88 struct BoardStatus GetStatus();
89 void AmplitudeCalibration();
90 void Lock();
91 void Unlock();
92
93 unsigned short Port;
94 char *Name;
95 bool CommOK;
96 bool Active;
97 bool Continue;
98 pthread_t Thread;
99 pthread_cond_t CondVar;
100
101 // Amplitude calibration
102 int Count;
103
104 private:
105 enum StateType {standbye, baseline, gain, secondary, cleanup, wait};
106 struct BoardStatus InitialStatus;
107 StateType State;
108};
109
110#endif
Note: See TracBrowser for help on using the repository browser.