| 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 | DimService *Textout;
|
|---|
| 38 | float UpdateDelay;
|
|---|
| 39 |
|
|---|
| 40 | void commandHandler();
|
|---|
| 41 |
|
|---|
| 42 | public:
|
|---|
| 43 |
|
|---|
| 44 | HVCalib *calib;
|
|---|
| 45 | HVBoard **fHVBoard;
|
|---|
| 46 |
|
|---|
| 47 | pthread_mutex_t control_mutex;
|
|---|
| 48 |
|
|---|
| 49 | char Prompt[MAX_COM_SIZE];
|
|---|
| 50 | const char *Param[MAX_NUM_TOKEN]; // For parser
|
|---|
| 51 | int NParam;
|
|---|
| 52 |
|
|---|
| 53 | // Configuration data
|
|---|
| 54 | char *fPixMapTable;
|
|---|
| 55 | float fTimeOut;
|
|---|
| 56 | float fStatusRefreshRate;
|
|---|
| 57 | int DACMin;
|
|---|
| 58 | int DACMax;
|
|---|
| 59 | float fHVCalibOffset;
|
|---|
| 60 | float fHVCalibSlope;
|
|---|
| 61 | unsigned int fHVMaxDiff;
|
|---|
| 62 |
|
|---|
| 63 | // Status variables
|
|---|
| 64 | pthread_t HVMonitor; // exit function sends signal to these threads
|
|---|
| 65 |
|
|---|
| 66 | int NumHVBoards;
|
|---|
| 67 | int FirstBoard;
|
|---|
| 68 | int LastBoard;
|
|---|
| 69 | int FirstChain;
|
|---|
| 70 | int LastChain;
|
|---|
| 71 |
|
|---|
| 72 | state_enum state;
|
|---|
| 73 | bool Exit;
|
|---|
| 74 |
|
|---|
| 75 | // Methods
|
|---|
| 76 | ProcessIO();
|
|---|
| 77 | ~ProcessIO();
|
|---|
| 78 |
|
|---|
| 79 | void PrintMessage(MsgTarget, const char *, ...);
|
|---|
| 80 | void PrintMessage(const char *, ...);
|
|---|
| 81 | void DoPrintMessage(const char *, va_list, MsgTarget);
|
|---|
| 82 | void CommandControl(char*);
|
|---|
| 83 | bool RampVoltage(unsigned int, int, int, int);
|
|---|
| 84 | void Monitor();
|
|---|
| 85 | void ResetBoard(int);
|
|---|
| 86 | void PrintBoardStatus(int);
|
|---|
| 87 | int ParseInput(char*, const char *Param[]);
|
|---|
| 88 | };
|
|---|
| 89 |
|
|---|
| 90 | bool Match(const char *, const char *);
|
|---|
| 91 | bool ConvertToDouble(const char *, double *);
|
|---|
| 92 | bool ConvertToInt(const char *, int *);
|
|---|
| 93 |
|
|---|
| 94 | #endif
|
|---|