source: fact/BIASctrl/Crate.h@ 10100

Last change on this file since 10100 was 10096, checked in by ogrimm, 14 years ago
Small changes to limit error messages in case crate communication breaks
File size: 1.8 KB
Line 
1#ifndef HV_H_SEEN
2#define HV_H_SEEN
3
4#include <termios.h> // POSIX terminal control definitions
5#include <fcntl.h> // File control definitions => fcntl() in fcn OpenPort()
6#include <errno.h>
7#include <stdio.h>
8#include <unistd.h>
9#include <sys/ioctl.h>
10#include <string>
11#include <vector>
12#include <map>
13
14#include "dis.hxx"
15
16#define MAX_NUM_BOARDS 13 // Maximum number of boards per crate
17#define NUM_CHANNELS 32 // Channels per bias board
18#define BAUDRATE B115200
19const float RESISTOR = 1000; // Resistance in Ohm for voltage correction
20const int MAX_ERR_COUNT = 10; // Maximum number of errors before reporting stopped
21class User;
22
23class Crate {
24
25 class User *m;
26 int CrateNumber;
27 int fDescriptor;
28 FILE *File;
29 DimService *NameService;
30 DimService *BiasVolt;
31 DimService *BiasDAC;
32 DimService *BiasCurrent;
33
34 int DAC[MAX_NUM_BOARDS][NUM_CHANNELS]; // Voltage in DAC units
35 double Volt[MAX_NUM_BOARDS][NUM_CHANNELS]; // Voltage in Volt
36 float Current[MAX_NUM_BOARDS][NUM_CHANNELS];
37 float CurrentOffset[MAX_NUM_BOARDS][NUM_CHANNELS]; // Offset for current measurement
38
39 std::vector<unsigned char> Communicate(std::string);
40 void ClearVoltageArrays();
41
42 public:
43 Crate(std::string, int, class User *);
44 ~Crate();
45
46 char *Name;
47
48 bool OC[MAX_NUM_BOARDS][NUM_CHANNELS];
49 bool Present[MAX_NUM_BOARDS][NUM_CHANNELS];
50 bool ResetHit;
51 bool WrapOK;
52 int WrapCount;
53 int ErrorCount;
54
55 float RefCurrent[MAX_NUM_BOARDS][NUM_CHANNELS];
56 double RefVolt[MAX_NUM_BOARDS][NUM_CHANNELS];
57
58 bool InitOK;
59
60 int SetChannels(std::map<unsigned int, double>);
61 int ReadAll();
62 int SystemReset();
63 int GlobalSet(double);
64 bool Synch();
65 bool CurrentCalib(double);
66 double GetVoltage(unsigned int);
67 unsigned int GetDAC(unsigned int);
68 float GetCurrent(unsigned int);
69 void UpdateDIM();
70 void SetRefCurrent();
71 void AdaptVoltages();
72};
73
74#endif
Note: See TracBrowser for help on using the repository browser.