source: fact/FADctrl/FADBoard.h@ 10275

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