Changeset 98
- Timestamp:
- 07/29/09 08:50:44 (15 years ago)
- Location:
- hvcontrol
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
hvcontrol/History.txt
r93 r98 19 19 24/7/2009 Lockfile is deleted if configuration file cannot be read 20 20 27/7/2009 Slow data is written for every HV ramp to file given in configuration 21 29/7/2009 Fixed bug with loading HV settings. No error is produced on negative 22 DAC values (the value is set to zero). -
hvcontrol/src/HV.cc
r93 r98 162 162 163 163 /* Set high voltage - uses TRead() and has same return values */ 164 int HVBoard::SetHV(int chain, unsigned int channel, unsignedint hv) {164 int HVBoard::SetHV(int chain, unsigned int channel, int hv) { 165 165 166 166 if (fTestMode){ … … 171 171 unsigned char wbuf[] = {0,0,0}; 172 172 173 if (!(hv>=0 && hv<=0x3FFF)) { 174 m->PrintMessage(" Error: HV beyond limits [0 - 0x3FFF]\n"); 175 return 0; 176 } 173 if (hv > 0x3FFF) { 174 m->PrintMessage(" Error: HV beyond upper 0x3FFF\n"); 175 return 0; 176 } 177 if (hv<0) hv = 0; 177 178 178 179 switch (chain) { -
hvcontrol/src/HV.h
r93 r98 56 56 int Reset(); 57 57 int GetStatus(); 58 int SetHV(int, unsigned int, unsignedint);58 int SetHV(int, unsigned int, int); 59 59 int GetBoardNumber() {return BoardNumber;} 60 60 int Communicate(unsigned char*, int); -
hvcontrol/src/ProcessIO.cc
r93 r98 296 296 297 297 char Buffer[MAX_COM_SIZE]; 298 int NBoards = 0, Errors = 0, Chain ;298 int NBoards = 0, Errors = 0, Chain, Channel; 299 299 unsigned int DACValue; 300 300 FILE *File; … … 313 313 for (int Board=0; Board<NumHVBoards; Board++) { 314 314 if (Match(fHVBoard[Board]->BoardName, Buffer)) { 315 316 PrintMessage("Found HV settings for board %d (%s)\n",fHVBoard[Board]->GetBoardNumber(), fHVBoard[Board]->BoardName); 317 318 Chain = 0; 319 while (fgets(Buffer, sizeof(Buffer), File) && Chain<NUM_CHAINS) { 320 if (strlen(Buffer) == 1) continue; // Ignore if only newline character 321 322 for (int Channel=0; Channel<NUM_CHANNELS; Channel++) { 323 if (sscanf(Buffer, "%u", &DACValue) != 1) { 324 PrintMessage("Error reading DAC values from file, terminating\n"); 325 return; 326 } 327 if (!RampVoltage(DACValue, Board, Chain, Channel)) Errors++; 315 PrintMessage("Found HV settings for board %d (%s)\n\r",fHVBoard[Board]->GetBoardNumber(), fHVBoard[Board]->BoardName); 316 317 Chain = 0; Channel = 0; 318 while (fscanf(File, "%u", &DACValue)==1 && Chain<NUM_CHAINS) { 319 if (!RampVoltage(DACValue, Board, Chain, Channel)) { 320 Errors++; 321 PrintMessage("Error: Could not ramp chain %d, channel %d\n", Chain, Channel); 322 } 323 else { 324 PrintMessage("Ramped chain %d, channel %d to %u (%.2f V) \r", 325 Chain,Channel,DACValue,calib->DACToHV(DACValue,Board,Chain,Channel)); 326 } 327 fHVBoard[Board]->HVV[Chain][Channel] = calib->DACToHV(fHVBoard[Board]->HV[Chain][Channel], Board, Chain, Channel); 328 if(++Channel == NUM_CHANNELS) { 329 Chain++; 330 Channel = 0; 328 331 } 329 Chain++;330 332 } 331 PrintMessage("Finished updating board.\n"); 333 if (ferror(File) != 0) { 334 PrintMessage("Error reading DAC value from file, terminating. (%s)\n",strerror(errno)); 335 return; 336 } 337 else PrintMessage("\nFinished updating board\n"); 332 338 NBoards++; 333 339 } … … 583 589 if(strlen(Textbuffer)>0 && Textbuffer[strlen(Textbuffer)-1]=='\n') { 584 590 printf("\r%s%s", Textbuffer, Prompt); // New prompt 585 fflush(stdout);586 591 } 587 592 else printf("%s", Textbuffer); 588 } 589 // Print to log file 590 if((Target & MsgToLog) && Logfile!=NULL) { 591 fprintf(Logfile, "%s", Textbuffer); 592 fflush(Logfile); 593 fflush(stdout); 593 594 } 594 595 // Print to socket 595 596 if((Target & MsgToSocket) && Socket!=-1) { 596 597 write(Socket, Textbuffer, strlen(Textbuffer)); 598 } 599 // Print to log file (repace carriage return by linefeed) 600 if((Target & MsgToLog) && Logfile!=NULL) { 601 for (unsigned int i=0; i<strlen(Textbuffer); i++) { 602 if(Textbuffer[i] == '\r') Textbuffer[i] = '\n'; 603 } 604 fprintf(Logfile, "%s", Textbuffer); 605 fflush(Logfile); 597 606 } 598 607 }
Note:
See TracChangeset
for help on using the changeset viewer.