| 1 |
|
|---|
| 2 | #ifndef PROCESSIO_H_SEEN
|
|---|
| 3 | #define PROCESSIO_H_SEEN
|
|---|
| 4 |
|
|---|
| 5 | #include <stdarg.h>
|
|---|
| 6 | #include <errno.h>
|
|---|
| 7 | #include <math.h>
|
|---|
| 8 | #include <signal.h>
|
|---|
| 9 |
|
|---|
| 10 | #define SERVER_NAME "Bias" // Name to use in DIM
|
|---|
| 11 | #include "Evidence.h"
|
|---|
| 12 |
|
|---|
| 13 | #include "HVCalib.h"
|
|---|
| 14 | #include "HV.h"
|
|---|
| 15 | #include "../pixelmap/PixelMap.h"
|
|---|
| 16 |
|
|---|
| 17 | #define MAX_COM_SIZE 5000
|
|---|
| 18 | #define NUM_CHAINS 4
|
|---|
| 19 | #define NUM_CHANNELS 32
|
|---|
| 20 | #define BUFFER_LENGTH 256
|
|---|
| 21 |
|
|---|
| 22 | #define MIN_TIMEOUT 0.01
|
|---|
| 23 | #define MAX_TIMEOUT 5.0
|
|---|
| 24 |
|
|---|
| 25 | #define MIN_RATE 0.01
|
|---|
| 26 | #define MAX_RATE 50.0
|
|---|
| 27 |
|
|---|
| 28 | #define MAX_NUM_TOKEN 10
|
|---|
| 29 |
|
|---|
| 30 | enum MsgTarget {Console=1, Log=2, All=7};
|
|---|
| 31 | typedef enum stateenum {active, stopped, na} state_enum;
|
|---|
| 32 |
|
|---|
| 33 | class ProcessIO: public DimCommand, public EvidenceServer {
|
|---|
| 34 |
|
|---|
| 35 | time_t StartTime;
|
|---|
| 36 | PixelMap *pm;
|
|---|
| 37 | float UpdateDelay;
|
|---|
| 38 |
|
|---|
| 39 | void commandHandler();
|
|---|
| 40 |
|
|---|
| 41 | public:
|
|---|
| 42 |
|
|---|
| 43 | HVCalib *calib;
|
|---|
| 44 | HVBoard **fHVBoard;
|
|---|
| 45 |
|
|---|
| 46 | pthread_mutex_t control_mutex;
|
|---|
| 47 |
|
|---|
| 48 | char Prompt[MAX_COM_SIZE];
|
|---|
| 49 | const char *Param[MAX_NUM_TOKEN]; // For parser
|
|---|
| 50 | int NParam;
|
|---|
| 51 |
|
|---|
| 52 | // Configuration data
|
|---|
| 53 | char *fPixMapTable;
|
|---|
| 54 | float fTimeOut;
|
|---|
| 55 | float fStatusRefreshRate;
|
|---|
| 56 | int DACMin;
|
|---|
| 57 | int DACMax;
|
|---|
| 58 | float fHVCalibOffset;
|
|---|
| 59 | float fHVCalibSlope;
|
|---|
| 60 | unsigned int fHVMaxDiff;
|
|---|
| 61 |
|
|---|
| 62 | // Status variables
|
|---|
| 63 | pthread_t HVMonitor; // exit function sends signal to these threads
|
|---|
| 64 |
|
|---|
| 65 | int NumHVBoards;
|
|---|
| 66 | int FirstBoard;
|
|---|
| 67 | int LastBoard;
|
|---|
| 68 | int FirstChain;
|
|---|
| 69 | int LastChain;
|
|---|
| 70 |
|
|---|
| 71 | state_enum state;
|
|---|
| 72 | bool Exit;
|
|---|
| 73 |
|
|---|
| 74 | // Methods
|
|---|
| 75 | ProcessIO();
|
|---|
| 76 | ~ProcessIO();
|
|---|
| 77 |
|
|---|
| 78 | void PrintMessage(MsgTarget, const char *, ...);
|
|---|
| 79 | void PrintMessage(const char *, ...);
|
|---|
| 80 | void DoPrintMessage(const char *, va_list, MsgTarget);
|
|---|
| 81 | void CommandControl(char*);
|
|---|
| 82 | bool RampVoltage(unsigned int, int, int, int);
|
|---|
| 83 | void Monitor();
|
|---|
| 84 | void ResetBoard(int);
|
|---|
| 85 | void PrintBoardStatus(int);
|
|---|
| 86 | int ParseInput(char*, const char *Param[]);
|
|---|
| 87 | };
|
|---|
| 88 |
|
|---|
| 89 | bool Match(const char *, const char *);
|
|---|
| 90 | bool ConvertToDouble(const char *, double *);
|
|---|
| 91 | bool ConvertToInt(const char *, int *);
|
|---|
| 92 |
|
|---|
| 93 | #endif
|
|---|