| 1 |
|
|---|
| 2 | #ifndef HVSTATUS_H_SEEN
|
|---|
| 3 | #define HVSTATUS_H_SEEN
|
|---|
| 4 |
|
|---|
| 5 | #include <stdio.h>
|
|---|
| 6 | #include <stdlib.h>
|
|---|
| 7 | #include <string.h>
|
|---|
| 8 | #include <time.h>
|
|---|
| 9 | #include <sys/socket.h>
|
|---|
| 10 | #include <unistd.h>
|
|---|
| 11 | #include <pthread.h>
|
|---|
| 12 |
|
|---|
| 13 | #include "Types.h"
|
|---|
| 14 | #include "HVConfig.h"
|
|---|
| 15 |
|
|---|
| 16 | typedef enum stateenum { active, stopped, na } state_enum;
|
|---|
| 17 | typedef enum connection { disconnected, connected } connect_enum;
|
|---|
| 18 |
|
|---|
| 19 | typedef struct status_str {
|
|---|
| 20 |
|
|---|
| 21 | pthread_t HVMonitor;
|
|---|
| 22 |
|
|---|
| 23 | char Prompt[MAX_COM_SIZE];
|
|---|
| 24 |
|
|---|
| 25 | bool Log;
|
|---|
| 26 | bool Verbose;
|
|---|
| 27 |
|
|---|
| 28 | char Param[10][MAX_COM_SIZE], *Pc; // For parser
|
|---|
| 29 | int NParam;
|
|---|
| 30 |
|
|---|
| 31 | connect_enum cc_state;
|
|---|
| 32 |
|
|---|
| 33 | int Socket; // PrintMessage() uses this socket, -1 if not connected
|
|---|
| 34 | pthread_t SocketThread; // exit function sends signal to this thread
|
|---|
| 35 |
|
|---|
| 36 | int CCPort;
|
|---|
| 37 | char CCClient[STR_LENGTH];
|
|---|
| 38 |
|
|---|
| 39 | char** fUSBDevice;
|
|---|
| 40 | int USBDeviceNumber[MAX_NUM_HVBOARDS];
|
|---|
| 41 | int USBMinDeviceNumber;
|
|---|
| 42 | int USBMaxDeviceNumber;
|
|---|
| 43 |
|
|---|
| 44 | int NumHVBoards;
|
|---|
| 45 | int FirstBoard;
|
|---|
| 46 | int LastBoard;
|
|---|
| 47 |
|
|---|
| 48 | int FirstChain;
|
|---|
| 49 | int LastChain;
|
|---|
| 50 |
|
|---|
| 51 | unsigned int VRef[MAX_NUM_HVBOARDS][MAX_NUM_CHAINS];
|
|---|
| 52 | unsigned int HV[MAX_NUM_HVBOARDS][MAX_NUM_CHAINS][MAX_NUM_CHANNELS]; // HV value in DAC
|
|---|
| 53 | float HVV[MAX_NUM_HVBOARDS][MAX_NUM_CHAINS][MAX_NUM_CHANNELS]; // HV value in volts
|
|---|
| 54 |
|
|---|
| 55 | float fTimeOut;
|
|---|
| 56 | float fStatusRefreshRate;
|
|---|
| 57 |
|
|---|
| 58 | bool OC[MAX_NUM_HVBOARDS][MAX_NUM_CHAINS]; // Overcurrent flag
|
|---|
| 59 | bool MR[MAX_NUM_HVBOARDS]; // Manual reset
|
|---|
| 60 |
|
|---|
| 61 | bool isok[MAX_NUM_HVBOARDS];
|
|---|
| 62 | state_enum state;
|
|---|
| 63 |
|
|---|
| 64 | bool IsUpdated[MAX_NUM_HVBOARDS];
|
|---|
| 65 |
|
|---|
| 66 | int WC[2][MAX_NUM_HVBOARDS];
|
|---|
| 67 |
|
|---|
| 68 | int CCCommand;
|
|---|
| 69 | int Exit;
|
|---|
| 70 | int Stop;
|
|---|
| 71 |
|
|---|
| 72 | } Status;
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 | void InitStatus(Status* status, HVConfig* config);
|
|---|
| 76 | void ReInitStatus(Status* status);
|
|---|
| 77 | void ReInitStatusOneBoard(Status* status, int board);
|
|---|
| 78 | void PrintStatus(Status* status, HVConfig* config, FILE* fptr);
|
|---|
| 79 | void sPrintStatus(Status* status, char* str, int i);
|
|---|
| 80 | char* GetStateStr(Status* status);
|
|---|
| 81 |
|
|---|
| 82 | #endif
|
|---|