| 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, Client=4, 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 |
|
|---|
| 39 | void commandHandler();
|
|---|
| 40 |
|
|---|
| 41 | public:
|
|---|
| 42 |
|
|---|
| 43 | //HVConfig *config;
|
|---|
| 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 | bool CmdFromSocket;
|
|---|
| 53 |
|
|---|
| 54 | // Configuration data
|
|---|
| 55 | char *fPixMapTable;
|
|---|
| 56 | float fTimeOut;
|
|---|
| 57 | float fStatusRefreshRate;
|
|---|
| 58 | int fCCPort;
|
|---|
| 59 | int DACMin;
|
|---|
| 60 | int DACMax;
|
|---|
| 61 | float fHVCalibOffset;
|
|---|
| 62 | float fHVCalibSlope;
|
|---|
| 63 | unsigned int fHVMaxDiff;
|
|---|
| 64 |
|
|---|
| 65 | // Status variables
|
|---|
| 66 | pthread_t HVMonitor; // exit function sends signal to these threads
|
|---|
| 67 | pthread_t SocketThread;
|
|---|
| 68 |
|
|---|
| 69 | int Socket; // -1 if not connected
|
|---|
| 70 |
|
|---|
| 71 | int NumHVBoards;
|
|---|
| 72 | int FirstBoard;
|
|---|
| 73 | int LastBoard;
|
|---|
| 74 | int FirstChain;
|
|---|
| 75 | int LastChain;
|
|---|
| 76 |
|
|---|
| 77 | state_enum state;
|
|---|
| 78 | bool Exit;
|
|---|
| 79 |
|
|---|
| 80 | // Methods
|
|---|
| 81 | ProcessIO(const char *);
|
|---|
| 82 | ~ProcessIO();
|
|---|
| 83 |
|
|---|
| 84 | void PrintMessage(MsgTarget, const char *, ...);
|
|---|
| 85 | void PrintMessage(const char *, ...);
|
|---|
| 86 | void DoPrintMessage(const char *, va_list, MsgTarget);
|
|---|
| 87 | void CommandControl(char*);
|
|---|
| 88 | bool RampVoltage(unsigned int, int, int, int);
|
|---|
| 89 | void Monitor();
|
|---|
| 90 | void ResetBoard(int);
|
|---|
| 91 | void PrintBoardStatus(int);
|
|---|
| 92 | int ParseInput(char*, const char *Param[]);
|
|---|
| 93 | };
|
|---|
| 94 |
|
|---|
| 95 | bool Match(const char *, const char *);
|
|---|
| 96 | bool ConvertToDouble(const char *, double *);
|
|---|
| 97 | bool ConvertToInt(const char *, int *);
|
|---|
| 98 |
|
|---|
| 99 | #endif
|
|---|