Changeset 100 for hvcontrol/src
- Timestamp:
- 08/12/09 12:15:02 (15 years ago)
- Location:
- hvcontrol/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
hvcontrol/src/HV.cc
r98 r100 22 22 m = PIO; 23 23 24 fTestMode = m->config->TestMode;25 fTestModeWrap = 0;26 27 24 SetTimeOut(m->config->fTimeOut); 28 25 BoardNumber = DeviceNumber; … … 34 31 LastWrapCount = -1; 35 32 36 if (fTestMode) {37 fDescriptor = 99;38 return;39 }40 41 33 ClearVoltageArrays(); 42 34 … … 78 70 // Destructor (Resetting board) 79 71 HVBoard::~HVBoard() { 80 if(fDescriptor >= 0 && !fTestMode) {72 if(fDescriptor >= 0) { 81 73 Reset(); 82 74 close(fDescriptor); … … 87 79 // Communicate: Write and read from HV Board until fTimeOut has been reached 88 80 // 89 // Returns: 0 readerror, 1 success, -1 fTimeOut exceeded81 // Returns: 0 error, 1 success, -1 fTimeOut exceeded 90 82 int HVBoard::Communicate(unsigned char* wbuf, int Bytes) { 91 83 … … 96 88 // === Write data === 97 89 if (write(fDescriptor, wbuf, Bytes) < Bytes) { 98 m->PrintMessage("Error: could not write (all) data to HV board\n");90 m->PrintMessage("Error: Could not write (all) data to HV board\n"); 99 91 return 0; 100 92 } … … 128 120 } 129 121 LastWrapCount = rbuf & 0X07; 130 for (int i=0; i<NUM_CHAINS; i++) Overcurrent[i] =(rbuf & (0X08 << i));122 for (int i=0; i<NUM_CHAINS; i++) Overcurrent[i] = (rbuf & (0X08 << i)); 131 123 ResetButton = (bool) (rbuf & 0X80); 132 124 … … 140 132 int HVBoard::Reset() { 141 133 142 if (fTestMode) return 1;143 144 134 unsigned char wbuf[] = {REG_RESET,0,0}; 145 135 int ret; … … 153 143 int HVBoard::GetStatus() { 154 144 155 if (fTestMode) return 1;156 157 145 unsigned char wbuf[] = {REG_STATUS,0,0}; 158 146 … … 164 152 int HVBoard::SetHV(int chain, unsigned int channel, int hv) { 165 153 166 if (fTestMode){ 167 m->PrintMessage("Test mode: Nothing to be done. \n"); 168 return 1; 169 } 154 unsigned char wbuf[] = {0,0,0}; 155 int ret; 170 156 171 unsigned char wbuf[] = {0,0,0}; 172 173 if (hv > 0x3FFF) { 174 m->PrintMessage(" Error: HV beyond upper 0x3FFF\n"); 157 if (hv<0 || hv > 0x3FFF) { 158 m->PrintMessage("Error: Voltage out of range 0-0x3FFF\n"); 175 159 return 0; 176 160 } 177 if (hv<0) hv = 0;178 161 179 162 switch (chain) { … … 183 166 case 3: wbuf[0] = REG_HV3; break; 184 167 185 default : m->PrintMessage(" Error: chain %d does not exist\n",chain); return 0;168 default : m->PrintMessage(" Error: Chain %d does not exist\n",chain); return 0; 186 169 } 187 170 … … 192 175 wbuf[2] |= (unsigned char)(hv & 0X000000FF); // Add [D7-D0] 193 176 194 return Communicate(wbuf, 3); 177 if ((ret = Communicate(wbuf, 3)) == 1) HV[chain][channel] = hv; 178 return ret; 195 179 } 196 180 -
hvcontrol/src/HV.h
r98 r100 33 33 34 34 int BoardNumber; 35 int fTestModeWrap;36 bool fTestMode;37 35 class ProcessIO *m; 38 36 -
hvcontrol/src/HVCalib.cc
r90 r100 7 7 sabrina.stark@phys.ethz.ch 8 8 9 Contents: Class reading the calibration tab elfor DAC to HV values9 Contents: Class reading the calibration table for DAC to HV values 10 10 11 11 \*************************************************************************/ … … 24 24 HVCalib::HVCalib(HVConfig* hvConfig) { 25 25 26 char calibfile[80]; 27 int idac, idacOld; 28 int istep, ihv1000, ihvOld; 29 char dLine[6000]; 26 char calibfile[80], dLine[6000]; 27 int idac, idacOld, istep, ihv1000, ihvOld; 30 28 bool first = true; 31 29 float hv1000,dac; 32 30 double intpart; 33 31 34 iDACMin = hvConfig->DACMin; 35 fHVCalibSlope = hvConfig->fHVCalibSlope; 36 NDACValues = hvConfig->DACMax - hvConfig->DACMin; 32 Config = hvConfig; 33 34 iDACMin = Config->DACMin; 35 fHVCalibSlope = Config->fHVCalibSlope; 36 NDACValues = Config->DACMax - Config->DACMin; 37 37 NHVValues = 10*NDACValues; 38 38 39 40 HVArray = new double***[hvConfig->NumHVBoards]; 41 for(int i=0; i<hvConfig->NumHVBoards; i++) { 42 HVArray[i] = new double**[NUM_CHAINS]; 39 HVArray = new double*** [Config->NumHVBoards]; 40 DACArray = new int*** [Config->NumHVBoards]; 41 for(int i=0; i<Config->NumHVBoards; i++) { 42 HVArray[i] = new double** [NUM_CHAINS]; 43 DACArray[i] = new int** [NUM_CHAINS]; 43 44 for(int j=0; j<NUM_CHAINS; j++) { 44 HVArray[i][j] = new double*[NUM_CHANNELS]; 45 HVArray[i][j] = new double* [NUM_CHANNELS]; 46 DACArray[i][j] = new int* [NUM_CHANNELS]; 45 47 for(int k=0; k<NUM_CHANNELS; k++) { 46 HVArray[i][j][k] = new double[NDACValues]; 48 HVArray[i][j][k] = new double [NDACValues]; 49 DACArray[i][j][k] = new int [NHVValues]; 47 50 } 48 51 } 49 52 } 50 53 51 DACArray = new int***[hvConfig->NumHVBoards]; 52 for(int i=0; i<hvConfig->NumHVBoards; i++) { 53 DACArray[i] = new int**[NUM_CHAINS]; 54 for(int j=0; j<NUM_CHAINS; j++) { 55 DACArray[i][j] = new int*[NUM_CHANNELS]; 56 for(int k=0; k<NUM_CHANNELS; k++) { 57 DACArray[i][j][k] = new int[NHVValues]; 58 } 59 } 60 } 61 62 for(int i=0; i<hvConfig->NumHVBoards; i++){ 54 for(int i=0; i<Config->NumHVBoards; i++){ 63 55 for(int j=0; j<NUM_CHAINS; j++){ 64 56 sprintf(calibfile,"Calib/%s_%c%d.txt",hvConfig->fUSBDevice[i],65+j,1); … … 68 60 fin >> dac; 69 61 idacOld = 0; 70 if ((int) dac >= hvConfig->DACMin) {62 if ((int) dac >= Config->DACMin) { 71 63 if (first){ 72 64 iDACMin = (int) dac; … … 76 68 istep = idac - idacOld; 77 69 for(int k=0; k<NUM_CHANNELS; k++){ 70 if (idac>=NDACValues) break; 71 78 72 fin>>HVArray[i][j][k][idac]; 73 79 74 for (int l=1; l<istep;l++){ 80 75 HVArray[i][j][k][idac-istep+l] = HVArray[i][j][k][idac-istep] + l*(HVArray[i][j][k][idac]-HVArray[i][j][k][idac-istep])/istep; … … 93 88 } 94 89 95 for(int i=0; i< hvConfig->NumHVBoards; i++){96 for(int j=0; j<NUM_CHAINS;j++){97 for(int k=0; k<NUM_CHANNELS;k++){90 for(int i=0; i<Config->NumHVBoards; i++){ 91 for(int j=0; j<NUM_CHAINS; j++){ 92 for(int k=0; k<NUM_CHANNELS; k++){ 98 93 ihvOld = 0; 99 94 first = true; 100 for (int l=0; l<NDACValues; l++){95 for (int l=0; l<NDACValues; l++){ 101 96 if (l == 0){ 102 97 ihvOld = 0; … … 129 124 HVCalib::~HVCalib() { 130 125 131 132 for (int i=0; i<MAX_NUM_HVBOARDS; i++){ 133 for (int j=0; j<NUM_CHAINS;j++){ 134 for (int k=0; k<NUM_CHANNELS;k++){ 135 delete [] HVArray[i][j][k]; 136 delete [] HVArray; 126 for(int i=0; i<Config->NumHVBoards; i++) { 127 for(int j=0; j<NUM_CHAINS; j++) { 128 for(int k=0; k<NUM_CHANNELS; k++) { 129 delete[] HVArray[i][j][k]; 130 delete[] DACArray[i][j][k]; 137 131 } 132 delete[] HVArray[i][j]; 133 delete[] DACArray[i][j]; 138 134 } 135 delete[] HVArray[i]; 136 delete[] DACArray[i]; 139 137 } 140 141 for (int i=0; i<MAX_NUM_HVBOARDS; i++){ 142 for (int j=0; j<NUM_CHAINS;j++){ 143 for (int k=0; k<NUM_CHANNELS;k++){ 144 delete [] DACArray[i][j][k]; 145 delete [] DACArray; 146 } 147 } 148 } 138 delete[] HVArray; 139 delete[] DACArray; 149 140 } 150 141 … … 175 166 ihv = (int) (hv1000<0 ? ceil(hv1000) : floor(hv1000)); 176 167 } 168 if (ihv >= NHVValues) ihv = NHVValues; 177 169 return DACArray[board][chain][channel][ihv]; 178 170 } 179 171 } 180 -
hvcontrol/src/HVCalib.h
r90 r100 16 16 int NDACValues; 17 17 int NHVValues; 18 int iDACMin; 19 double fHVCalibSlope; 18 20 21 HVConfig *Config; 22 19 23 public: 20 24 21 HVCalib(HVConfig * hvConfig);25 HVCalib(HVConfig *); 22 26 ~HVCalib(); 23 24 int iDACMin;25 double fHVCalibSlope;26 27 27 28 int HVToDAC(double hv, int board, int chain, int channel); -
hvcontrol/src/HVConfig.cc
r93 r100 16 16 HVConfig::HVConfig(const char *configfile) { 17 17 18 fUSBDevice = new char*[MAX_NUM_HVBOARDS];19 20 for (int i=0; i<MAX_NUM_HVBOARDS; i++) {21 fUSBDevice[i] = new char[BUFFER_LENGTH];22 USBDeviceNumber[i] = 0;23 }24 25 TestMode = false;26 NumHVBoards = 0;27 fStatusRefreshRate = 1.;28 fTimeOut = 1.;29 DACMin = 11008;30 DACMax = 12496;31 fHVCalibOffset = -.8;32 fHVCalibSlope = 0.0064;33 fHVMaxDiff = 1;34 35 18 // Read configuration file 36 19 FILE *f; 37 char str[MAX_COM_SIZE], dev[MAX_COM_SIZE];38 int j = 0;39 20 40 21 if ((f = fopen(configfile,"r")) == NULL) { … … 42 23 throw; 43 24 } 44 elseprintf("Opening configuration file: %s\n", configfile);25 printf("Opening configuration file: %s\n", configfile); 45 26 27 // Determine number of entries in 'Boards' card and allocate memeory 28 NumHVBoards = (int) ReadCard("Boards", NULL, 'n', f); 29 fUSBDevice = new char* [NumHVBoards]; 30 for (int i=0; i<NumHVBoards; i++) fUSBDevice[i] = new char [BUFFER_LENGTH]; 31 ReadCard("Boards", fUSBDevice, 'S', f, NumHVBoards); 32 46 33 ReadCard("LogFile", fLogFile, 's',f); 47 34 ReadCard("PixMapTable", fPixMapTable,'s',f); 48 35 ReadCard("SlowDirectory", fSlowDir, 's',f); 49 50 ReadCard("TestMode", &str, 's',f);51 if (!strcmp(str,"TRUE")) TestMode = true;52 53 for (int i=0; i<MAX_NUM_HVBOARDS; i++) {54 sprintf(str,"Board%d",i);55 56 if (ReadCard(str, dev, 's', f)) {57 USBDeviceNumber[j] = i;58 sprintf(fUSBDevice[j++],"%s",dev);59 NumHVBoards++;60 }61 }62 63 36 ReadCard("TimeOut", &fTimeOut, 'f', f); 64 37 ReadCard("StatusRefreshRate", &fStatusRefreshRate, 'f', f); … … 76 49 HVConfig::~HVConfig() { 77 50 78 for (int i=0; i< MAX_NUM_HVBOARDS; i++) delete[] fUSBDevice[i];79 delete 51 for (int i=0; i<NumHVBoards; i++) delete[] fUSBDevice[i]; 52 delete[] fUSBDevice; 80 53 } 81 54 … … 83 56 // ReadCard function (original version by F. Goebel) 84 57 // Data is read into an array if MaxNum is larger than 1 85 bool ReadCard(const char *card_flag, void *store, char Type, FILE *File, unsigned int MaxNum) { 58 // If Type is 'n', the number of elements for the card is counted. 59 // Type 'S' is for reading an array of strings 60 unsigned int ReadCard(const char *card_flag, void *store, char Type, FILE *File, unsigned int MaxNum) { 86 61 87 62 char *card_name, *card_val, Buffer[MAX_COM_SIZE]; … … 97 72 98 73 // Read numbers of given type (if MaxNum>1 read array) 99 while ((card_val=strtok(NULL," \t\n")) != NULL&& Count++<MaxNum) {74 while ((card_val=strtok(NULL," \t\n"))!=NULL && card_val[0]!='#' && Count++<MaxNum) { 100 75 switch (Type) { 101 76 case 'I': *(((int *&) store)++) = (int) strtol(card_val, NULL, 10); … … 113 88 case 's': sprintf((char *) store, "%s", card_val); 114 89 break; 115 case 'c': *((char *) store) = card_val[0]; 90 case 'S': sprintf(*(((char **&) store)++), "%s", card_val); 91 break; 92 case 'c': *(((char *&) store)++) = card_val[0]; 93 break; 94 case 'n': MaxNum = UINT_MAX; 116 95 break; 117 96 default: fprintf(stderr,"Warning: Unknown type '%c' for reading of configuration file\n", Type); 118 return false;97 return 0; 119 98 } 120 99 } 121 return true; // Finished reading data for card name100 return Count; // Finished reading data for card name 122 101 } 123 return false;102 return 0; 124 103 } 125 104 -
hvcontrol/src/HVConfig.h
r93 r100 7 7 #include <stdlib.h> 8 8 #include <stdio.h> 9 #include <limits.h> 9 10 10 #define MAX_COM_SIZE 1000 11 #define MAX_NUM_HVBOARDS 20 11 #define MAX_COM_SIZE 5000 12 12 #define NUM_CHAINS 4 13 13 #define NUM_CHANNELS 32 … … 29 29 30 30 int NumHVBoards; 31 int USBDeviceNumber[MAX_NUM_HVBOARDS]; 32 33 int fCCPort; 34 35 bool TestMode; 31 char **fUSBDevice; 32 // char (*fUSBDevice)[BUFFER_LENGTH]; 36 33 37 34 char fLogFile[BUFFER_LENGTH]; 38 35 char fSlowDir[BUFFER_LENGTH]; 39 char** fUSBDevice;40 36 41 37 char fPixMapTable[BUFFER_LENGTH]; 38 int fCCPort; 42 39 43 40 float fTimeOut; … … 46 43 int DACMin; 47 44 int DACMax; 48 49 45 float fHVCalibOffset; 50 46 float fHVCalibSlope; 51 52 47 unsigned int fHVMaxDiff; 53 48 }; 54 49 55 boolReadCard(const char *, void *, char, FILE *, unsigned int=1);50 unsigned int ReadCard(const char *, void *, char, FILE *, unsigned int=1); 56 51 57 52 #endif -
hvcontrol/src/ProcessIO.cc
r98 r100 36 36 LastBoard = -1; 37 37 FirstChain = 0; 38 LastChain = 3;38 LastChain = NUM_CHAINS-1; 39 39 40 40 if (config->fStatusRefreshRate >= MIN_RATE && config->fStatusRefreshRate <= MAX_RATE) … … 43 43 44 44 // Open HV devices 45 if(config->TestMode){ 46 fprintf(stdout,"Test mode: One HVBoard initialized as dummy.\n"); 47 fHVBoard[NumHVBoards] = new HVBoard(0, 0, this); 48 NumHVBoards++; 49 } 50 else { 51 for (int i=0; i<config->NumHVBoards; i++) { 52 fHVBoard[NumHVBoards] = new HVBoard(config->USBDeviceNumber[i], config->fUSBDevice[i], this); 53 if(fHVBoard[NumHVBoards]->fDescriptor >= 0) { 54 printf("Synchronized and reset HV board %d (%s)\n",i,config->fUSBDevice[i]); 55 NumHVBoards++; 56 } 57 else { 58 printf("Failed to synchronize to HV board %d (%s)\n",i,config->fUSBDevice[i]); 59 delete fHVBoard[NumHVBoards]; 60 } 45 fHVBoard = new HVBoard* [config->NumHVBoards]; 46 for (int i=0; i<config->NumHVBoards; i++) { 47 fHVBoard[NumHVBoards] = new HVBoard(i, config->fUSBDevice[i], this); 48 if(fHVBoard[NumHVBoards]->fDescriptor >= 0) { 49 printf("Synchronized and reset HV board %d (%s)\n",i,config->fUSBDevice[i]); 50 NumHVBoards++; 51 } 52 else { 53 printf("Failed to synchronize to HV board %d (%s)\n",i,config->fUSBDevice[i]); 54 delete fHVBoard[NumHVBoards]; 61 55 } 62 56 } … … 79 73 ProcessIO::~ProcessIO() { 80 74 75 delete SlowDataClass; 76 81 77 for (int i=0; i<NumHVBoards; i++) delete fHVBoard[i]; 82 83 delete SlowDataClass; delete config; delete pm; 78 delete[] fHVBoard; 79 80 delete pm; delete calib; delete config; 84 81 85 82 if(Logfile != NULL) { 86 if(!fclose(Logfile)) printf("Closing logfile\n"); 87 else perror("Error closing logfile"); 83 if(fclose(Logfile) != 0) perror("Error closing logfile"); 88 84 } 89 85 } … … 145 141 LastChain = 3; 146 142 } 147 else if (NParam==2 && atoi(Param[1])>=0 && atoi(Param[1])< 4) {143 else if (NParam==2 && atoi(Param[1])>=0 && atoi(Param[1])<NUM_CHAINS) { 148 144 FirstChain = atoi(Param[1]); 149 145 LastChain = FirstChain; 150 146 } 151 else if (NParam==3 && atoi(Param[1])>=0 && atoi(Param[1])< 4&&152 atoi(Param[2])>0 && atoi(Param[2])< 4) {147 else if (NParam==3 && atoi(Param[1])>=0 && atoi(Param[1])<NUM_CHAINS && 148 atoi(Param[2])>0 && atoi(Param[2])<NUM_CHAINS) { 153 149 FirstChain = atoi(Param[1]); 154 150 LastChain = atoi(Param[2]); … … 164 160 PrintMessage( " Log file: %s\n" 165 161 " Pixel map table: %s\n" 166 " Test mode: %s\n"167 162 " %d USB devices:\n", config->fLogFile, config->fPixMapTable, 168 config-> TestMode ? "yes" : "no", config->NumHVBoards);169 for (int i=0; i<NumHVBoards;i++) {170 PrintMessage(" Board %d: %s\n ", config->USBDeviceNumber[i], config->fUSBDevice[i]);171 } 172 PrintMessage( " \nTimeOut: %.2f s\n"163 config->NumHVBoards); 164 for (int i=0; i<config->NumHVBoards; i++) { 165 PrintMessage(" Board %d: %s\n ", i, config->fUSBDevice[i]); 166 } 167 PrintMessage( " TimeOut: %.2f s\n" 173 168 " StatusRefreshRate: %.2f Hz\n" 174 169 " CCPort: %d\n" … … 211 206 212 207 213 // Set new high voltage -------------------------------------------------------------------------------------- 208 // Set new high voltage (if no boards available, simply returns OK) 209 // First reponse to socket should be 'OK' if no error occurred. 214 210 if (Match(Param[0], "hv") || Match(Param[0], "hvdiff")) { 215 211 216 if (!NumHVBoards) return; 217 218 int hvoltage, DACValue, Errors=0, Board, Chain=0, Channel=0; 212 int hvoltage, DACValue, Errors=0, Board=-1, Chain=-1, Channel=-1; 219 213 double hvoltageV; 220 bool allchannels = false, SetDac = false;221 222 // Need two parameters or three if last is 'dac'214 bool SetDac; 215 216 // Need two or parameters 223 217 if (NParam<3 || NParam>4) { 224 PrintMessage("ERROR - usage: hv <channel>|<all> <voltage> [dac]\n"); 225 return; 226 } 227 228 if (NParam==4 && Match(Param[3], "dac")) SetDac = true; 229 218 PrintMessage("Usage: hv/hvdiff <channel>|<all> <voltage> [dac]\n"); 219 return; 220 } 221 222 // Evaluate voltage parameter 223 if (NParam==4 && Match(Param[3], "dac")) { 224 SetDac = true; 225 if (!ConvertToInt(Param[2], &hvoltage)) { 226 PrintMessage("Error: Wrong number format for DAC voltage setting\n"); 227 return; 228 } 229 } 230 else { 231 SetDac = false; 232 if (!ConvertToDouble(Param[2], &hvoltageV)) { 233 PrintMessage("Error: Wrong number format for voltage setting\n"); 234 return; 235 } 236 } 237 230 238 // Evaluate pixel or channel parameter 231 if((Board = pm->Pixel_to_HVboard(Param[1])) != 999999999) { 239 if(pm->Pixel_to_HVboard(Param[1]) != 999999999) { 240 Board = pm->Pixel_to_HVboard(Param[1]); 232 241 Chain = pm->Pixel_to_HVchain(Param[1]); 233 242 Channel = pm->Pixel_to_HVchannel(Param[1]); 234 243 } 235 else if (Match(Param[1], "all")) allchannels = true; 236 else if (ConvertToInt(Param[1], &Channel)) { 237 Board = -1; 238 Chain = -1; 239 } 240 else { 241 PrintMessage("ERROR - wrong input format - usage: hv <channel>|<all> <voltage>\n"); 242 return; 243 } 244 // Check channel limits (voltage limit is only checked in SetHV()) 245 if (Channel<0 || Channel>31) { 246 PrintMessage("ERROR - channel out of range (0...31)!\n"); 247 return; 248 } 249 250 if (SetDac && !ConvertToInt(Param[2], &hvoltage)) { 251 PrintMessage("ERROR - wrong number format for DAC voltage setting\n"); 252 return; 253 } 254 if (!SetDac && !ConvertToDouble(Param[2], &hvoltageV)) { 255 PrintMessage("ERROR - wrong number format for voltage setting\n"); 256 return; 257 } 244 else if (!Match(Param[1], "all") && !ConvertToInt(Param[1], &Channel)) { 245 PrintMessage("Error: Wrong channel identification\n"); 246 return; 247 } 258 248 259 249 for (int i=FirstBoard; i<=LastBoard; i++) { 260 if ( !allchannels && Board != 999999999 && i !=Board && Board!=-1) continue;250 if (i!=Board && Board!=-1) continue; 261 251 262 252 for (int j=FirstChain; j<=LastChain; j++) { 263 if ( !allchannels && Chain != 999999999 && j !=Chain && Chain!=-1) continue;253 if (j!=Chain && Chain!=-1) continue; 264 254 265 255 for (int k=0; k<NUM_CHANNELS; k++) { 266 if ( !allchannels && k!= Channel) continue;256 if (k!=Channel && Channel!=-1) continue; 267 257 268 258 // Convert from HV to DAC values … … 277 267 } 278 268 279 // Set new voltage (if DAC value, update cali lbrated value)269 // Set new voltage (if DAC value, update calibrated value) 280 270 if(!RampVoltage(DACValue, i, j, k)) Errors++; 281 elseif(SetDac) fHVBoard[i]->HVV[j][k] = calib->DACToHV(fHVBoard[i]->HV[j][k], i, j, k);271 if(SetDac) fHVBoard[i]->HVV[j][k] = calib->DACToHV(fHVBoard[i]->HV[j][k], i, j, k); 282 272 283 273 } // Channels … … 285 275 } // Boards 286 276 287 if (Errors > 0) PrintMessage(" Warning:Errors on %d channel(s) occurred\n", Errors);288 else PrintMessage("OK - no error (s)\n");277 if (Errors > 0) PrintMessage("ERROR - Errors on %d channel(s) occurred\n", Errors); 278 else PrintMessage("OK - no errors\n"); 289 279 290 280 return; … … 436 426 state = active; 437 427 pthread_kill(HVMonitor, SIGUSR1); 438 PrintMessage(" OK - status monitoring activated\n");428 PrintMessage("Status monitoring activated\n"); 439 429 return; 440 430 } … … 617 607 618 608 if (fHVBoard[Board]->SetHV(Chain, Channel, fHVBoard[Board]->HV[Chain][Channel]+Diff) == 1) { 619 fHVBoard[Board]->HV[Chain][Channel] += Diff;620 621 609 if (Verbose) { 622 PrintMessage(" OK - board %d: high voltage of chain %d channel %d set to %d | 0X%.4X | %f V\n",fHVBoard[Board]->GetBoardNumber(),Chain, Channel, Target, Target, calib->DACToHV(Target,fHVBoard[Board]->GetBoardNumber(),Chain,Channel));610 PrintMessage("Board %d: high voltage of chain %d channel %d set to %d | 0X%.4X | %f V\n",fHVBoard[Board]->GetBoardNumber(),Chain, Channel, Target, Target, calib->DACToHV(Target,fHVBoard[Board]->GetBoardNumber(),Chain,Channel)); 623 611 PrintBoardStatus(Board); 624 612 } 625 613 } 626 614 else { 627 PrintMessage("E RROR -Could not set HV of board %d, chain %d, channel %d. Skipping channel\n",fHVBoard[Board]->GetBoardNumber(),Chain,Channel);628 SlowDataClass->NewEntry("Error");629 SlowDataClass->AddToEntry("%s %d %d %d %d %.2f ",fHVBoard[Board]->BoardName,Board, Chain, Channel, Target, calib->DACToHV(Target,Board,Chain,Channel));615 PrintMessage("Error: Could not set HV of board %d, chain %d, channel %d. Skipping channel\n",fHVBoard[Board]->GetBoardNumber(),Chain,Channel); 616 //SlowDataClass->NewEntry("Error"); 617 //SlowDataClass->AddToEntry("%s %d %d %d %d %.2f ",fHVBoard[Board]->BoardName,Board, Chain, Channel, Target, calib->DACToHV(Target,Board,Chain,Channel)); 630 618 return false; 631 619 } 632 620 } 633 SlowDataClass->NewEntry("Value");634 SlowDataClass->AddToEntry("%s %d %d %d %d %.2f ",fHVBoard[Board]->BoardName,Board, Chain, Channel, Target, calib->DACToHV(Target,Board,Chain,Channel));621 //SlowDataClass->NewEntry("Value"); 622 //SlowDataClass->AddToEntry("%s %d %d %d %d %.2f ",fHVBoard[Board]->BoardName,Board, Chain, Channel, Target, calib->DACToHV(Target,Board,Chain,Channel)); 635 623 return true; 636 624 } … … 676 664 } 677 665 678 679 // Get index of board with sequential number board680 int ProcessIO::GetBoardIdx(int board) {681 682 for (int i=0; i<MAX_NUM_HVBOARDS; i++) {683 if (board == fHVBoard[i]->GetBoardNumber()) return i;684 }685 return -1;686 }687 666 688 667 // Print current board status -
hvcontrol/src/ProcessIO.h
r93 r100 32 32 HVConfig *config; 33 33 HVCalib *calib; 34 HVBoard * fHVBoard[MAX_NUM_HVBOARDS];35 SlowData *SlowDataClass;34 HVBoard **fHVBoard; 35 SlowData *SlowDataClass; 36 36 37 37 pthread_mutex_t control_mutex; … … 70 70 void Monitor(); 71 71 void ResetBoard(int); 72 int GetBoardIdx(int);73 72 void PrintBoardStatus(int); 74 73 int ParseInput(char*, const char *Param[]);
Note:
See TracChangeset
for help on using the changeset viewer.