Changeset 80
- Timestamp:
- 07/01/09 20:47:49 (15 years ago)
- Location:
- hvcontrol
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
hvcontrol/HV.conf
r75 r80 6 6 PixMapTable ../config/PixelMap.txt 7 7 8 T imeOut 0.10 s # Timeout to return from read (0.01,...5.00) s8 TestMode TRUE #Test Mode: if no HV boards are connected, the test mode can be used.TimeOut 1.00 s # Timeout to return from read (0.01,...5.00) s 9 9 10 10 StatusRefreshRate 50.00 Hz # Status update rate (0.01,...50.00) Hz -
hvcontrol/src/CCCommand.cc
r39 r80 86 86 m->status->Pc = comline; 87 87 88 89 88 ParseInput(m->status->Pc,&(m->status->NParam),m->status->Param); 90 89 -
hvcontrol/src/HV.cc
r35 r80 26 26 27 27 28 HV::HV(char** usbdevice, int* usbdevicenumber, FILE* f): fNumberOfBoards(0) { 29 28 HV::HV(char** usbdevice, int* usbdevicenumber, FILE* f,bool TestMode): fNumberOfBoards(0) { 29 30 fTestMode = TestMode; 31 30 32 int i = 0, j = 0, ret = 0; 31 33 … … 50 52 i = 0; 51 53 54 if(fTestMode){ 55 fprintf(stdout,"Test mode: One HVBoard initialized as dummy.\n"); 56 fHVBoard[fNumberOfBoards] = new HVBoard("dummy", 0, &ftdic[fNumberOfBoards],fTestMode); 57 fNumberOfBoards++; 58 return; 59 } 52 60 // Obtain information on FTDI devices 53 61 for (curdev = devlist; (curdev != NULL && i<MAX_NUM_HVBOARDS); i++) { … … 88 96 ftdi_set_latency_timer(&ftdic[fNumberOfBoards], USB_LATENCY_TIMER); 89 97 90 fHVBoard[fNumberOfBoards] = new HVBoard(serial, usbdevicenumber[j], &ftdic[fNumberOfBoards] );98 fHVBoard[fNumberOfBoards] = new HVBoard(serial, usbdevicenumber[j], &ftdic[fNumberOfBoards],fTestMode); 91 99 fNumberOfBoards++; 92 100 /* … … 113 121 114 122 115 / * Bubble-sort HV boards according to board number */123 // Bubble-sort HV boards according to board number 116 124 void HV::ArrangeHVBoards(HVBoard** fHVBoard, int size) { 125 126 if(fTestMode){ 127 return; 128 } 117 129 118 130 HVBoard* tmp; … … 130 142 131 143 HV::~HV() { 144 145 if(fTestMode){ 146 fprintf(stdout,"Test mode: No FTDI device has to be closed.\n"); 147 return; 148 } 132 149 133 150 int i, ret = 0; … … 157 174 158 175 159 HVBoard::HVBoard(char* serial, int number, struct ftdi_context* ftdic ) : fTimeOut(.5)176 HVBoard::HVBoard(char* serial, int number, struct ftdi_context* ftdic,bool TestMode) : fTimeOut(.5) 160 177 { 161 178 179 fTestMode = TestMode; 180 fTestModeWrap = 0; 162 181 FTDI_C = ftdic; 163 182 sprintf(Serial,"%s",serial); … … 209 228 210 229 int HVBoard::Write(unsigned char* data, int size) { 230 if (fTestMode) 231 return 3; // implying that 3 bytes are written 232 211 233 #ifdef DO_CAST 212 234 return ftdi_write_data(FTDI_C, (char*)data, size); … … 217 239 218 240 int HVBoard::Read(unsigned char* data, int size) { 241 if (fTestMode) { 242 data[0] = fTestModeWrap; 243 // fprintf(stdout," Read Data 0X%.2X\n",data[0]); 244 fTestModeWrap++; 245 fTestModeWrap = fTestModeWrap%8; 246 return 1; // one byte read 247 } 219 248 #ifdef DO_CAST 220 249 return ftdi_read_data(FTDI_C, (char*)data, size); … … 233 262 */ 234 263 int HVBoard::TRead(FILE* fptr, unsigned char* rbuf, bool verbose) { 235 264 265 if (fTestMode) { 266 Read(rbuf,BUFFER_LENGTH); 267 return 1; // rbuf read 268 } 269 236 270 char str[STR_LENGTH]; 237 271 … … 278 312 int HVBoard::Reset(FILE* fptr, unsigned char* rbuf, bool verbose) { 279 313 314 if (fTestMode) 315 return 1; 316 280 317 char str[STR_LENGTH]; 281 318 … … 303 340 /* Read status register - uses TRead() and has same return values */ 304 341 int HVBoard::GetStatus(FILE* fptr, unsigned char* rbuf, bool verbose) { 342 if (fTestMode){ 343 // printf("Test mode. (Get Status) \n"); 344 return TRead(fptr,rbuf,verbose); 345 return 1; 346 } 305 347 306 348 char str[STR_LENGTH]; … … 330 372 /* Set high voltage - uses TRead() and has same return values */ 331 373 int HVBoard::SetHV(FILE* fptr, int chain, unsigned int channel, unsigned int hv, unsigned char* rbuf, bool verbose) { 374 375 if (fTestMode){ 376 printf("Test mode: Nothing to be done. \n"); 377 return 1; 378 } 379 332 380 333 381 char str[STR_LENGTH]; … … 380 428 /* Set reference voltage - uses TRead() and has same return values */ 381 429 int HVBoard::SetVRef(FILE* fptr, int chain, unsigned int vref, unsigned char* rbuf, bool verbose) { 382 430 431 if (fTestMode){ 432 printf("Test mode. Nothing to be done.\n"); 433 return 1; 434 } 435 383 436 char str[STR_LENGTH]; 384 437 … … 463 516 */ 464 517 int HVBoard::Init(bool verbose) { 518 465 519 466 520 unsigned char wbuf = REG_STATUS; -
hvcontrol/src/HV.h
r14 r80 1 #ifndef HV_H_SEEN 2 #define HV_H_SEEN 1 3 2 4 #include "Types.h" … … 14 16 #endif 15 17 #endif 16 17 18 #ifndef HV_H_SEEN19 #define HV_H_SEEN20 18 21 19 … … 62 60 public: 63 61 64 HVBoard(char* serial, int number, struct ftdi_context* ftdic );62 HVBoard(char* serial, int number, struct ftdi_context* ftdic, bool TestMode); 65 63 ~HVBoard(); 64 65 bool fTestMode; 66 66 67 67 int Init(bool verbose); … … 87 87 int BoardNumber; 88 88 float fTimeOut; // [s] timeout to return from read 89 int fTestModeWrap; 89 90 90 91 }; … … 96 97 public: 97 98 98 HV(char** usbdevice, int* usbdevicenumber, FILE* f );99 HV(char** usbdevice, int* usbdevicenumber, FILE* f,bool TestMode); 99 100 ~HV(); 100 101 101 102 int fNumberOfBoards; 102 103 int fMaxNumberOfBoards; 104 105 bool fTestMode; 103 106 104 107 HVBoard* fHVBoard[MAX_NUM_HVBOARDS]; -
hvcontrol/src/HVConfig.cc
r46 r80 33 33 } 34 34 35 TestMode = false; 35 36 NumHVBoards = 0; 36 37 FileName = configfile; … … 81 82 } 82 83 83 ReadCard("LogPath", fLogPath, 's',f);84 ReadCard("LogPath", fLogPath, 's',f); 84 85 85 86 ReadCard("PixMapTable",fPixMapTable,'s',f); 87 88 ReadCard("TestMode", &str, 's',f); 89 if (!strcmp(str,"TRUE")) 90 TestMode = true; 91 86 92 87 93 for (int i=0;i<MAX_NUM_HVBOARDS;i++) { … … 124 130 fprintf(fptr," Log path: %s\n\n", fLogPath); 125 131 fprintf(fptr," Pixel map table: %s\n\n", fPixMapTable); 132 fprintf(fptr," Test mode: %s\n\n", TestMode ? "yes" : "no"); 126 133 fprintf(fptr," %.2d USB devices:\n\n", NumHVBoards); 127 134 … … 178 185 fprintf(f,"PixMapTable %s\n\n", fPixMapTable); 179 186 187 fprintf(f,"TestMode %s #Test Mode: if no HV boards are connected, the test mode can be used.",((TestMode) ? "TRUE" : "FALSE")); 188 180 189 fprintf(f,"TimeOut %.2f s # Timeout to return from read (%.2f,...%.2f) s\n\n",fTimeOut,MIN_TIMEOUT,MAX_TIMEOUT); 181 190 -
hvcontrol/src/HVConfig.h
r46 r80 26 26 char *fCCClient; 27 27 28 bool TestMode; 29 28 30 bool IsDAC; 29 31 float Coef[MAX_NUM_HVBOARDS][MAX_NUM_CHAINS][2]; -
hvcontrol/src/HVStatus.cc
r39 r80 163 163 status->WC[1][i]); 164 164 165 if (status->Socket != -1) // Print status string to socket if open166 write(status->Socket,str,strlen(str)+1);165 // if (status->Socket != -1) // Print status string to socket if open 166 // write(status->Socket,str,strlen(str)+1); 167 167 168 168 } -
hvcontrol/src/ProcessIO.cc
r72 r80 24 24 calib = new HVCalib(config); 25 25 log = new Log(config->fLogPath); 26 hv = new HV(config->fUSBDevice,config->USBDeviceNumber,stdout );26 hv = new HV(config->fUSBDevice,config->USBDeviceNumber,stdout,config->TestMode); 27 27 28 28 pm = new PixelMap(config->fPixMapTable); … … 75 75 pthread_mutex_init (&control_mutex, NULL); 76 76 pthread_cond_init (&control_cond, NULL); 77 77 78 sprintf(str,"**************** End of constructor ProcessIO ************\n"); 79 DoPrompt(str); 80 78 81 } 79 82 … … 150 153 // Wrong type of argument 151 154 else if (!IsNoDigit(status->Param[1]) || !IsNoDigit(status->Param[2]) || status->Param[3][0] || !status->Param[1][0]) { 152 sprintf(str," usage: <board> <i>|<i> <j>|<all>\n");155 sprintf(str,"ERROR - usage: <board> <i>|<i> <j>|<all>\n"); 153 156 DoPrompt(str); 154 157 return 0; … … 158 161 159 162 if (!IsBoard(atoi(status->Param[1]))) { 160 sprintf(str," board #%d does not exist\n", atoi(status->Param[1]));163 sprintf(str,"ERROR -board #%d does not exist\n", atoi(status->Param[1])); 161 164 DoPrompt(str); 162 165 return 0; … … 165 168 if (status->Param[2][0]) 166 169 if (!IsBoard(atoi(status->Param[2]))) { 167 sprintf(str," board #%d does not exist\n", atoi(status->Param[2]));170 sprintf(str,"ERROR -board #%d does not exist\n", atoi(status->Param[2])); 168 171 DoPrompt(str); 169 172 return 0; … … 206 209 } 207 210 else if (!IsNoDigit(status->Param[1]) || !status->Param[1][0]) { 208 sprintf(str," usage: <chain> <i>|<i> <j>|<all>\n");211 sprintf(str,"ERROR -usage: <chain> <i>|<i> <j>|<all>\n"); 209 212 DoPrompt(str); 210 213 return 0; … … 226 229 227 230 if (atoi(status->Param[1]) < 0 || atoi(status->Param[1]) > 3) { 228 sprintf(str," chain #%d does not exist\n", atoi(status->Param[1]));231 sprintf(str,"ERROR -chain #%d does not exist\n", atoi(status->Param[1])); 229 232 DoPrompt(str); 230 233 } … … 232 235 233 236 if ((atoi(status->Param[2]) < 0 || atoi(status->Param[2]) > 3) && (atoi(status->Param[1]) != atoi(status->Param[2]))) { 234 sprintf(str," chain #%d does not exist\n", atoi(status->Param[2]));237 sprintf(str,"ERROR -chain #%d does not exist\n", atoi(status->Param[2])); 235 238 DoPrompt(str); 236 239 } … … 297 300 allchannels = TRUE; 298 301 else { 299 DoPrompt(" error:wrong input format - usage: hv <channel>|<all> <voltage>\n");302 DoPrompt("ERROR - wrong input format - usage: hv <channel>|<all> <voltage>\n"); 300 303 return 0; 301 304 } … … 304 307 if (tolower(status->Param[2][0])=='x' && strlen(status->Param[2])>2) { 305 308 if (sPrintHex2Dec(Chop(status->Param[2]+1),&hvoltage)!=0) { 306 DoPrompt(" error:wrong input format - usage: hv <channel>|<all> <voltage>\n");309 DoPrompt("ERROR - wrong input format - usage: hv <channel>|<all> <voltage>\n"); 307 310 return 0; 308 311 } … … 311 314 else if (tolower(status->Param[2][0])=='b' && strlen(status->Param[2])>2) { 312 315 if (sPrintBin2Dec(Chop(status->Param[2]+1),&hvoltage)!=0) { 313 DoPrompt(" wrong input format - usage: hv <channel>|<all> <voltage>\n");316 DoPrompt("ERROR - wrong input format - usage: hv <channel>|<all> <voltage>\n"); 314 317 return 0; 315 318 } … … 322 325 // Wrong input format 323 326 else { 324 DoPrompt(" wrong input format - usage: hv <channel>|<all> <voltage>\n");327 DoPrompt("ERROR - wrong input format - usage: hv <channel>|<all> <voltage>\n"); 325 328 return 0; 326 329 } … … 328 331 // Check limits 329 332 if (channel>31 || channel <0) { 330 DoPrompt(" channel out of range (0...31)!\n");333 DoPrompt("ERROR - channel out of range (0...31)!\n"); 331 334 return 0; 332 335 } 333 336 else if ((hvoltage>0X3FFF || hvoltage <0)&&config->IsDAC) { 334 DoPrompt(" high voltage out of range (Vmin: 0, Vmax: 16383)!\n");337 DoPrompt("ERROR - high voltage out of range (Vmin: 0, Vmax: 16383)!\n"); 335 338 return 0; 336 339 } 337 340 else if ((hvoltage>78.0 || hvoltage <0)&&(!(config->IsDAC))) { 338 DoPrompt(" high voltage out of range (Vmin: 0, Vmax: 78.)!\n");341 DoPrompt("ERROR - high voltage out of range (Vmin: 0, Vmax: 78.)!\n"); 339 342 return 0; 340 343 } … … 365 368 UpdateStatus(i,rbuf); 366 369 367 sprintf(str," board %d: high voltage of chain %d channel %d set to %d | 0X%.4X | %f V\n",hv->GetHVBoard(i)->GetBoardNumber(),j,channel,hvoltage,hvoltage,calib->DACToHV(hvoltage,hv->GetHVBoard(i)->GetBoardNumber(),j,channel));370 sprintf(str,"OK - board %d: high voltage of chain %d channel %d set to %d | 0X%.4X | %f V\n",hv->GetHVBoard(i)->GetBoardNumber(),j,channel,hvoltage,hvoltage,calib->DACToHV(hvoltage,hv->GetHVBoard(i)->GetBoardNumber(),j,channel)); 368 371 // DoPrompt(str); 369 372 if (status->Verbose) { … … 374 377 } 375 378 else { 376 sprintf(str," board %d error: could not set hv - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber());379 sprintf(str,"ERROR - board %d error: could not set hv - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber()); 377 380 DoPrompt(str); 378 381 errors++; … … 381 384 } 382 385 else { 383 sprintf(str," updating board %d chain %d\n",hv->GetHVBoard(i)->GetBoardNumber(),j);386 sprintf(str,"OK - updating board %d chain %d\n",hv->GetHVBoard(i)->GetBoardNumber(),j); 384 387 DoPrompt(str); 385 388 … … 404 407 405 408 if (status->Verbose) { 406 sprintf(str," board %d: high voltage of chain %d channel %d set to %d | 0X%.4X | %f V\n",hv->GetHVBoard(i)->GetBoardNumber(),j,channel,hvoltage,hvoltage,calib->DACToHV(hvoltage,hv->GetHVBoard(i)->GetBoardNumber(),j,channel));409 sprintf(str,"OK - board %d: high voltage of chain %d channel %d set to %d | 0X%.4X | %f V\n",hv->GetHVBoard(i)->GetBoardNumber(),j,channel,hvoltage,hvoltage,calib->DACToHV(hvoltage,hv->GetHVBoard(i)->GetBoardNumber(),j,channel)); 407 410 //sprintf(str,"board %d: high voltage of chain %d channel %d set to %d | 0X%.4X\n",hv->GetHVBoard(i)->GetBoardNumber(),j,k,hvoltage,hvoltage); 408 411 // DoPrompt(str); … … 414 417 415 418 else { 416 sprintf(str," board %d error: could not set HV - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber());419 sprintf(str,"ERROR - board %d error: could not set HV - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber()); 417 420 DoPrompt(str); 418 421 errors++; … … 429 432 430 433 if (errors) { 431 sprintf(str," warning %d error(s) => check timeout and try again\n",errors);434 sprintf(str,"ERROR - warning %d error(s) => check timeout and try again\n",errors); 432 435 DoPrompt(str); 433 436 } 434 437 else { 435 sprintf(str," no error(s)... success!\n");438 sprintf(str,"OK - no error(s)... success!\n"); 436 439 DoPrompt(str); 437 440 } … … 439 442 } 440 443 else { 441 sprintf(str," usage: hv <channel>|<all> <voltage>\n");444 sprintf(str,"ERROR - usage: hv <channel>|<all> <voltage>\n"); 442 445 DoPrompt(str); 443 446 } … … 481 484 if (tolower(status->Param[2][0])=='x' && strlen(status->Param[2])>2) { 482 485 if (sPrintHex2Dec(Chop(status->Param[2]+1),(unsigned int *)hvdiff)!=0) { 483 DoPrompt(" error:wrong input format - usage: hvdiff <channel>|<all> <hv difference>\n");486 DoPrompt("ERROR - wrong input format - usage: hvdiff <channel>|<all> <hv difference>\n"); 484 487 return 0; 485 488 } … … 488 491 else if (tolower(status->Param[2][0])=='b' && strlen(status->Param[2])>2) { 489 492 if (sPrintBin2Dec(Chop(status->Param[2]+1),(unsigned int *)hvdiff)!=0) { 490 DoPrompt(" wrong input format - usage: hvdiff <channel>|<all> <hv difference>\n");493 DoPrompt("ERROR - wrong input format - usage: hvdiff <channel>|<all> <hv difference>\n"); 491 494 return 0; 492 495 } … … 499 502 // Wrong input format 500 503 else { 501 DoPrompt(" wrong input format - usage: hvdiff <channel>|<all> <hv difference>\n");504 DoPrompt("ERROR - wrong input format - usage: hvdiff <channel>|<all> <hv difference>\n"); 502 505 return 0; 503 506 } 504 507 // Check limits 505 508 if (channel>31 || channel <0) { 506 DoPrompt("channel out of range (0...31)!\n"); 509 sprintf(str,"ERROR - channel out of range (0...31)!\n"); 510 DoPrompt(str); 507 511 return 0; 508 512 } 509 513 else if (hvdiff>config->DACMax || hvdiff <(-(config->DACMax))) { 510 sprintf(str," difference of high voltage [hvdiff:%d] out of range (Vmin: 0.0, Vmax: %d)!\n", hvdiff,config->DACMax);514 sprintf(str,"ERROR - difference of high voltage [hvdiff:%d] out of range (Vmin: 0.0, Vmax: %d)!\n", hvdiff,config->DACMax); 511 515 DoPrompt(str); 512 516 return 0; 513 517 } 514 518 else if (hvdiffV>(calib->DACToHV(config->DACMax,0,0,0))|| hvdiffV<-(calib->DACToHV(config->DACMax,0,0,0))) { 515 sprintf(str,"difference of high voltage [hvdiff:%f] out of range (Vmin: 0.0, Vmax: %f)!\n",hvdiffV,calib->DACToHV(config->DACMax,0,0,0)); 516 DoPrompt(str); 517 return 0; 518 } 519 520 sprintf(str,"Error - Test \n"); 521 DoPrompt(str); 522 if (status->Socket != -1) // Print status string to socket if open 523 write(status->Socket,str,strlen(str)+1); 524 sPrintStatus(status,str,0); // Print status only to socket 525 526 519 sprintf(str,"ERROR - difference of high voltage [hvdiff:%f] out of range (Vmin: 0.0, Vmax: %f)!\n",hvdiffV,calib->DACToHV(config->DACMax,0,0,0)); 520 DoPrompt(str); 521 return 0; 522 } 523 527 524 528 525 … … 556 553 UpdateStatus(board,rbuf); 557 554 if (k==(abs((int)(hvdiff/config->fHVMaxDiff)))){ 558 sprintf(str," board %d: high voltage of chain %d channel %d set to %d | 0X%.4X | %f V\n",hv->GetHVBoard(board)->GetBoardNumber(),chain,channel,hvoltage,hvoltage,calib->DACToHV(hvoltage,hv->GetHVBoard(board)->GetBoardNumber(),chain,channel));555 sprintf(str,"OK - board %d: high voltage of chain %d channel %d set to %d | 0X%.4X | %f V\n",hv->GetHVBoard(board)->GetBoardNumber(),chain,channel,hvoltage,hvoltage,calib->DACToHV(hvoltage,hv->GetHVBoard(board)->GetBoardNumber(),chain,channel)); 559 556 //sprintf(str,"board %d: high voltage of chain %d channel %d set to %d | 0X%.4X\n",hv->GetHVBoard(board)->GetBoardNumber(),chain,channel,hvoltage,hvoltage); 560 557 DoPrompt(str); … … 563 560 } 564 561 else { 565 sprintf(str," board %d chain %d channel %d error: could not set hv - check timeout and try again\n",hv->GetHVBoard(board)->GetBoardNumber(), chain, channel);562 sprintf(str,"ERROR - board %d chain %d channel %d error: could not set hv - check timeout and try again\n",hv->GetHVBoard(board)->GetBoardNumber(), chain, channel); 566 563 DoPrompt(str); 567 564 errors++; … … 577 574 578 575 if (errors) { 579 sprintf(str," warning %d error(s)\n",errors);576 sprintf(str,"ERROR - warning %d error(s)\n",errors); 580 577 DoPrompt(str); 581 578 } 582 579 else { 583 sprintf(str," no error(s)... success!\n");580 sprintf(str,"OK - no error(s)... success!\n"); 584 581 DoPrompt(str); 585 582 } 586 583 } 587 584 else { 588 sprintf(str," usage: hvdiff <PXL id> <hv difference>\n");585 sprintf(str,"ERROR - usage: hvdiff <PXL id> <hv difference>\n"); 589 586 DoPrompt(str); 590 587 } … … 600 597 else if (Match(status->Param[0], "list")) { 601 598 602 sprintf(str," %d HV board(s) active:\n",hv->GetNumberOfBoards());599 sprintf(str,"OK - %d HV board(s) active:\n",hv->GetNumberOfBoards()); 603 600 DoPrompt(str); 604 601 605 602 for (int i=0;i<hv->GetNumberOfBoards();i++) { 606 sprintf(str," board %d (%s)\n",(hv->GetHVBoard(i))->GetBoardNumber(),(hv->GetHVBoard(i))->GetSerial());603 sprintf(str,"OK - board %d (%s)\n",(hv->GetHVBoard(i))->GetBoardNumber(),(hv->GetHVBoard(i))->GetSerial()); 607 604 DoPrompt(str); 608 605 } … … 634 631 635 632 if (status->Verbose) { 636 sprintf(str," file \"%s\" opened\n",Chop(status->Param[1]));633 sprintf(str,"OK - file \"%s\" opened\n",Chop(status->Param[1])); 637 634 DoPrompt(str); 638 635 } … … 651 648 board = j; 652 649 653 sprintf(str," found HV settings for board %d (%s)\n",hv->GetHVBoard(board)->GetBoardNumber(),Chop(param[1]));650 sprintf(str,"OK - found HV settings for board %d (%s)\n",hv->GetHVBoard(board)->GetBoardNumber(),Chop(param[1])); 654 651 DoPrompt(str); 655 652 … … 666 663 667 664 if (!((nrows)%4)) { 668 sprintf(str," updating board %d chain %d\n",hv->GetHVBoard(board)->GetBoardNumber(),chain);665 sprintf(str,"OK - updating board %d chain %d\n",hv->GetHVBoard(board)->GetBoardNumber(),chain); 669 666 DoPrompt(str); 670 667 } … … 683 680 684 681 if (status->Verbose) { 685 sprintf(str," board %d: high voltage of chain %d channel %d set to %d | 0X%.4X\n",682 sprintf(str,"OK - board %d: high voltage of chain %d channel %d set to %d | 0X%.4X\n", 686 683 hv->GetHVBoard(board)->GetBoardNumber(),chain,channel,hvoltage,hvoltage); 687 684 DoPrompt(str); … … 691 688 } 692 689 else { 693 sprintf(str," board %d error: could not set HV - check timeout and try again\n",hv->GetHVBoard(board)->GetBoardNumber());690 sprintf(str,"ERROR - board %d error: could not set HV - check timeout and try again\n",hv->GetHVBoard(board)->GetBoardNumber()); 694 691 DoPrompt(str); 695 692 errors++; … … 709 706 710 707 if (fclose (file)) { 711 sprintf(str," error:could not close file \"%s\"\n",Chop(status->Param[1]));708 sprintf(str,"ERROR - could not close file \"%s\"\n",Chop(status->Param[1])); 712 709 DoPrompt(str); 713 710 } 714 711 else { 715 712 if (status->Verbose) { 716 sprintf(str," file \"%s\" closed\n",Chop(status->Param[1]));713 sprintf(str,"OK - file \"%s\" closed\n",Chop(status->Param[1])); 717 714 DoPrompt(str); 718 715 } … … 720 717 721 718 if (nboards!=hv->GetNumberOfBoards()) { 722 sprintf(str," warning: could not load HV settings for all connected HV boards\n");719 sprintf(str,"ERROR - warning: could not load HV settings for all connected HV boards\n"); 723 720 DoPrompt(str); 724 721 } 725 722 else { 726 sprintf(str," success: read HV settings for all connected HV boards\n");723 sprintf(str,"OK - success: read HV settings for all connected HV boards\n"); 727 724 DoPrompt(str); 728 725 } 729 726 730 727 if (errors) { 731 sprintf(str," warning %d error(s) => check timeout and try again\n",errors);728 sprintf(str,"ERROR - warning %d error(s) => check timeout and try again\n",errors); 732 729 DoPrompt(str); 733 730 } 734 731 else { 735 sprintf(str," no error(s)... success!\n");732 sprintf(str,"OK - no error(s)... success!\n"); 736 733 DoPrompt(str); 737 734 } … … 739 736 } 740 737 else { 741 sprintf(str," error:could not open file \"%s\"\n",Chop(status->Param[1]));738 sprintf(str,"ERROR - could not open file \"%s\"\n",Chop(status->Param[1])); 742 739 DoPrompt(str); 743 740 } … … 745 742 } 746 743 else 747 DoPrompt(" usage: load <file>\n");744 DoPrompt("ERROR - usage: load <file>\n"); 748 745 749 746 StartMonitor(); … … 759 756 if (Match(status->Param[1], "on") && status->Param[1][0]) { 760 757 status->Log = TRUE; 761 sprintf(str," logging enabled\n");758 sprintf(str,"OK - logging enabled\n"); 762 759 DoPrompt(str); 763 760 } … … 765 762 else if (Match(status->Param[1], "off") && status->Param[1][0]) { 766 763 status->Log = FALSE; 767 sprintf(str," logging disabled\n");764 sprintf(str,"OK -logging disabled\n"); 768 765 DoPrompt(str); 769 766 } 770 767 771 768 else 772 DoPrompt(" usage: log <on>|<off>\n");769 DoPrompt("ERROR - usage: log <on>|<off>\n"); 773 770 774 771 return 0; … … 785 782 786 783 if (!IsNoDigit(status->Param[1])) { 787 DoPrompt(" wrong input format - usage: rate <rate>\n");784 DoPrompt("ERROR - wrong input format - usage: rate <rate>\n"); 788 785 return 0; 789 786 } 790 787 // Check limits 791 788 else if (atof(status->Param[1]) < MIN_RATE || atof(status->Param[1]) > MAX_RATE) { 792 sprintf(str," refresh rate out of range (min: %.2f Hz, max: %.2f Hz)!\n",MIN_RATE,MAX_RATE);789 sprintf(str,"ERROR - refresh rate out of range (min: %.2f Hz, max: %.2f Hz)!\n",MIN_RATE,MAX_RATE); 793 790 DoPrompt(str); 794 791 return 0; … … 797 794 StopMonitor(); 798 795 status->fStatusRefreshRate=atof(status->Param[1]); 799 sprintf(str," status refresh rate set to %.2f Hz\n",status->fStatusRefreshRate);796 sprintf(str,"OK - status refresh rate set to %.2f Hz\n",status->fStatusRefreshRate); 800 797 DoPrompt(str); 801 798 } … … 805 802 } 806 803 else { 807 sprintf(str," usage: rate <rate>\n");804 sprintf(str,"ERROR - usage: rate <rate>\n"); 808 805 DoPrompt(str); 809 806 } … … 859 856 else if (Match(status->Param[0], "root")) { 860 857 861 sprintf(str," starting ROOT... type '.q' to return\n");858 sprintf(str,"OK - starting ROOT... type '.q' to return\n"); 862 859 DoPrompt(str); 863 860 system ("root"); … … 874 871 875 872 if (SaveHVSettings(Chop(status->Param[1]))) { 876 sprintf(str," HV settings written to \"%s\"\n",Chop(status->Param[1]));873 sprintf(str,"OK - HV settings written to \"%s\"\n",Chop(status->Param[1])); 877 874 DoPrompt(str); 878 875 } … … 889 886 time_now = localtime(&time_now_secs); 890 887 891 sprintf(buffer," hvsettings/HV_%04d-%02d-%02d_%02d-%02d-%02d.txt",888 sprintf(buffer,"OK - hvsettings/HV_%04d-%02d-%02d_%02d-%02d-%02d.txt", 892 889 1900 + time_now->tm_year, 893 890 1 + time_now->tm_mon, … … 901 898 902 899 if (SaveHVSettings(buffer)) { 903 sprintf(str," HV settings successfully written to \"%s\"\n",buffer);900 sprintf(str,"OK - HV settings successfully written to \"%s\"\n",buffer); 904 901 DoPrompt(str); 905 902 } … … 918 915 919 916 if (status->state==active) { 920 sprintf(str," status monitoring is already active\n");917 sprintf(str,"OK - status monitoring is already active\n"); 921 918 DoPrompt(str); 922 919 return 0; … … 925 922 StartMonitor(); 926 923 927 sprintf(str," status monitoring activated\n");924 sprintf(str,"OK - status monitoring activated\n"); 928 925 DoPrompt(str); 929 926 … … 953 950 954 951 if (status->state!=active) { 955 sprintf(str," status monitoring is already deactivated\n");952 sprintf(str,"OK - status monitoring is already deactivated\n"); 956 953 DoPrompt(str); 957 954 return 0; … … 960 957 StopMonitor(); 961 958 962 sprintf(str," warning: status monitoring deactivated\n");959 sprintf(str,"ERROR - warning: status monitoring deactivated\n"); 963 960 DoPrompt(str); 964 961 … … 1137 1134 1138 1135 if (!IsNoDigit(status->Param[1])) { 1139 DoPrompt(" wrong input format - usage: timeout <time>\n");1136 DoPrompt("ERROR - wrong input format - usage: timeout <time>\n"); 1140 1137 return 0; 1141 1138 } 1142 1139 // Check limits 1143 1140 else if (atof(status->Param[1]) < MIN_TIMEOUT || atof(status->Param[1]) > MAX_TIMEOUT) { 1144 sprintf(str," timeout out of range (min: %.2f s, max: %.2f s)!\n",MIN_TIMEOUT,MAX_TIMEOUT);1141 sprintf(str,"ERROR -timeout out of range (min: %.2f s, max: %.2f s)!\n",MIN_TIMEOUT,MAX_TIMEOUT); 1145 1142 DoPrompt(str); 1146 1143 return 0; … … 1151 1148 (hv->GetHVBoard(i))->SetTimeOut((float)atof(status->Param[1])); 1152 1149 status->fTimeOut = atof(status->Param[1]); 1153 sprintf(str," timeout set to %.2f s\n",status->fTimeOut);1150 sprintf(str,"OK - timeout set to %.2f s\n",status->fTimeOut); 1154 1151 1155 1152 DoPrompt(str); … … 1160 1157 } 1161 1158 else { 1162 sprintf(str," usage: timeout <time>\n");1159 sprintf(str,"ERROR - usage: timeout <time>\n"); 1163 1160 DoPrompt(str); 1164 1161 } … … 1173 1170 double difftime = GetDiffTime(&StartTime); 1174 1171 1175 sprintf(str," %d:%02d:%02d\n",(int)difftime/SECONDS_HOUR,((int)difftime/SECONDS_MINUTE)%SECONDS_MINUTE,(int)difftime%SECONDS_MINUTE);1172 sprintf(str,"OK - %d:%02d:%02d\n",(int)difftime/SECONDS_HOUR,((int)difftime/SECONDS_MINUTE)%SECONDS_MINUTE,(int)difftime%SECONDS_MINUTE); 1176 1173 DoPrompt(str); 1177 1174 … … 1185 1182 if (Match(status->Param[1], "on") && status->Param[1][0]) { 1186 1183 if (status->Verbose == TRUE) { 1187 sprintf(str," verbosity is already enabled\n");1184 sprintf(str,"OK - verbosity is already enabled\n"); 1188 1185 DoPrompt(str); 1189 1186 } 1190 1187 else { 1191 1188 status->Verbose = TRUE; 1192 sprintf(str," verbosity enabled\n");1189 sprintf(str,"OK - verbosity enabled\n"); 1193 1190 DoPrompt(str); 1194 1191 } … … 1197 1194 else if (Match(status->Param[1], "off") && status->Param[1][0]) { 1198 1195 if (status->Verbose == FALSE) { 1199 sprintf(str," verbosity is already disabled\n");1196 sprintf(str,"OK - verbosity is already disabled\n"); 1200 1197 DoPrompt(str); 1201 1198 } 1202 1199 else { 1203 1200 status->Verbose = FALSE; 1204 sprintf(str," verbosity disabled\n");1201 sprintf(str,"OK - verbosity disabled\n"); 1205 1202 DoPrompt(str); 1206 1203 } … … 1208 1205 1209 1206 else 1210 DoPrompt(" usage: verbose <on>|<off>\n");1207 DoPrompt("ERROR - usage: verbose <on>|<off>\n"); 1211 1208 1212 1209 return 0; … … 1227 1224 if (tolower(status->Param[1][0])=='x' && strlen(status->Param[1])>2) { 1228 1225 if (sPrintHex2Dec(Chop(status->Param[1]+1),&voltage)!=0) { 1229 DoPrompt(" error:wrong input format - usage: vref <voltage>\n");1226 DoPrompt("ERROR - wrong input format - usage: vref <voltage>\n"); 1230 1227 return 0; 1231 1228 } … … 1234 1231 else if (tolower(status->Param[1][0])=='b' && strlen(status->Param[1])>2) { 1235 1232 if (sPrintBin2Dec(Chop(status->Param[1]+1),&voltage)!=0) { 1236 DoPrompt(" wrong input format - usage: vref <voltage>\n");1233 DoPrompt("ERROR - wrong input format - usage: vref <voltage>\n"); 1237 1234 return 0; 1238 1235 } … … 1243 1240 // Wrong input format 1244 1241 else { 1245 DoPrompt(" wrong input format - usage: vref <voltage>\n");1242 DoPrompt("ERROR - wrong input format - usage: vref <voltage>\n"); 1246 1243 return 0; 1247 1244 } … … 1249 1246 // Check limits 1250 1247 if (voltage>0X3FFF || voltage <0) { 1251 DoPrompt(" reference voltage out of range (Vmin: 0, Vmax: 16383)!\n");1248 DoPrompt("ERROR - reference voltage out of range (Vmin: 0, Vmax: 16383)!\n"); 1252 1249 return 0; 1253 1250 } … … 1259 1256 for (int j=status->FirstChain;j<=status->LastChain;j++) { 1260 1257 if (((hv->GetHVBoard(i))->SetVRef(stdout,j,voltage,rbuf,status->Verbose)==1)) { 1261 sprintf(str," board %d: reference voltage of chain %d set to %d | 0X%.4X\n",hv->GetHVBoard(i)->GetBoardNumber(),j,voltage,voltage);1258 sprintf(str,"OK - board %d: reference voltage of chain %d set to %d | 0X%.4X\n",hv->GetHVBoard(i)->GetBoardNumber(),j,voltage,voltage); 1262 1259 status->VRef[i][j]=voltage; 1263 1260 DoPrompt(str); … … 1266 1263 DoPrompt(str); 1267 1264 } else { 1268 sprintf(str," board %d error: could not set vref - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber());1265 sprintf(str,"ERROR - board %d error: could not set vref - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber()); 1269 1266 DoPrompt(str); 1270 1267 } … … 1274 1271 } 1275 1272 else { 1276 sprintf(str," usage: vref <voltage>\n");1273 sprintf(str,"ERROR - usage: vref <voltage>\n"); 1277 1274 DoPrompt(str); 1278 1275 } … … 1361 1358 1362 1359 if (strchr(status->Param[0],'\n') == 0) 1363 sprintf(str," unknown command: %s\n",status->Param[0]);1360 sprintf(str,"ERROR - unknown command: %s\n",status->Param[0]); 1364 1361 else 1365 sprintf(str," unknown command: %s",status->Param[0]);1362 sprintf(str,"ERROR - unknown command: %s",status->Param[0]); 1366 1363 1367 1364 DoPrompt(str); … … 1385 1382 timeinfo = localtime(&rawtime); // Get local time 1386 1383 fflush(stdout); 1387 sprintf(str," current date/time is: %s",asctime(timeinfo));1384 sprintf(str,"OK - current date/time is: %s",asctime(timeinfo)); 1388 1385 DoPrompt(str); 1389 1386 … … 1391 1388 1392 1389 void ProcessIO::DoPrompt(char* str) { 1393 1390 if (str!=NULL) { 1391 if (status->Socket != -1) // Print status string to socket if open 1392 write(status->Socket,str,strlen(str)+1); 1393 } 1394 else { 1395 if (status->Socket != -1) // Print status string to socket if open 1396 write(status->Socket,"OK\n",3); 1397 } 1394 1398 if (str!=NULL) { 1395 1399 if (status->NumHVBoards == 0) { … … 1470 1474 } 1471 1475 } 1472 1473 1474 1476 } 1475 1477 … … 1592 1594 1593 1595 if (status->NumHVBoards==0) 1594 DoPrompt(" no HV boards available!\n");1596 DoPrompt("ERROR - no HV boards available!\n"); 1595 1597 1596 1598 return status->NumHVBoards; … … 1603 1605 1604 1606 if (hv->GetNumberOfBoards()) 1605 printf(" Initialization:\n");1607 printf("OK - Initialization:\n"); 1606 1608 1607 1609 for (int i=0;i<hv->GetNumberOfBoards();i++) { 1608 printf(" HV board %d (%s):\n",hv->GetHVBoard(i)->GetBoardNumber(),hv->GetHVBoard(i)->GetSerial());1610 printf("OK - HV board %d (%s):\n",hv->GetHVBoard(i)->GetBoardNumber(),hv->GetHVBoard(i)->GetSerial()); 1609 1611 nb+=hv->GetHVBoard(i)->Init(status->Verbose); 1610 1612 } … … 1662 1664 1663 1665 if ((hv->GetHVBoard(i))->GetStatus(stdout,rbuf,FALSE)!=1) { 1664 sprintf(str," board %d error: could not read status - check timeout and status refresh rate...",hv->GetHVBoard(i)->GetBoardNumber());1666 sprintf(str,"ERROR - board %d error: could not read status - check timeout and status refresh rate...",hv->GetHVBoard(i)->GetBoardNumber()); 1665 1667 PrintMessage(str); 1666 1668 } … … 1669 1671 1670 1672 if (status->MR[i]) { 1671 sprintf(str," warning: manual reset of board %d!",hv->GetHVBoard(i)->GetBoardNumber());1673 sprintf(str,"ERROR - warning: manual reset of board %d!",hv->GetHVBoard(i)->GetBoardNumber()); 1672 1674 PrintMessage(str); 1673 1675 StopMonitor(); … … 1678 1680 1679 1681 if (!status->isok[i]) { 1680 sprintf(str," error:wrap counter mismatch board %d (%d,%d)!",hv->GetHVBoard(i)->GetBoardNumber(),status->WC[0][i],status->WC[1][i]);1682 sprintf(str,"ERROR - wrap counter mismatch board %d (%d,%d)!",hv->GetHVBoard(i)->GetBoardNumber(),status->WC[0][i],status->WC[1][i]); 1681 1683 PrintMessage(str); 1682 1684 } … … 1684 1686 for (int j=0;j<MAX_NUM_CHAINS;j++) 1685 1687 if (status->OC[i][j]) { 1686 sprintf(str," warning: overcurrent in chain %d of board %d!",j,hv->GetHVBoard(i)->GetBoardNumber());1688 sprintf(str,"ERROR - warning: overcurrent in chain %d of board %d!",j,hv->GetHVBoard(i)->GetBoardNumber()); 1687 1689 PrintMessage(str); 1688 1690 ResetBoard(i); … … 1697 1699 for (int i=status->FirstBoard;i<=status->LastBoard;i++) { 1698 1700 if ((hv->GetHVBoard(i))->Reset(stdout,rbuf,status->Verbose)==1) { 1699 sprintf(str," software reset done board %d\n",hv->GetHVBoard(i)->GetBoardNumber());1701 sprintf(str,"OK - software reset done board %d\n",hv->GetHVBoard(i)->GetBoardNumber()); 1700 1702 DoPrompt(str); 1701 1703 UpdateStatus(i,rbuf); … … 1704 1706 } 1705 1707 else { 1706 sprintf(str," board %d error: could not reset - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber());1708 sprintf(str,"ERROR - board %d error: could not reset - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber()); 1707 1709 DoPrompt(str); 1708 1710 } … … 1716 1718 for (int i=0;i<hv->GetNumberOfBoards();i++) { 1717 1719 if ((hv->GetHVBoard(i))->Reset(stdout,rbuf,status->Verbose)==1) { 1718 sprintf(str," software reset done board %d\n",hv->GetHVBoard(i)->GetBoardNumber());1720 sprintf(str,"OK - software reset done board %d\n",hv->GetHVBoard(i)->GetBoardNumber()); 1719 1721 DoPrompt(str); 1720 1722 UpdateStatus(i,rbuf); … … 1723 1725 } 1724 1726 else { 1725 sprintf(str," board %d error: could not reset - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber());1727 sprintf(str,"ERROR - board %d error: could not reset - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber()); 1726 1728 DoPrompt(str); 1727 1729 } … … 1734 1736 1735 1737 if ((hv->GetHVBoard(i))->Reset(stdout,rbuf,status->Verbose)==1) { 1736 sprintf(str," software reset done board %d",hv->GetHVBoard(i)->GetBoardNumber());1738 sprintf(str,"OK - software reset done board %d",hv->GetHVBoard(i)->GetBoardNumber()); 1737 1739 PrintMessage(str); 1738 1740 UpdateStatus(i,rbuf); … … 1741 1743 } 1742 1744 else { 1743 sprintf(str," board %d error: could not reset - check timeout and try again",hv->GetHVBoard(i)->GetBoardNumber());1745 sprintf(str,"ERROR - board %d error: could not reset - check timeout and try again",hv->GetHVBoard(i)->GetBoardNumber()); 1744 1746 PrintMessage(str); 1745 1747 } … … 1761 1763 1762 1764 if ((fptr = fopen(filename,"w")) == NULL) { 1763 sprintf(str," error:could not open file \"%s\"\n", filename);1765 sprintf(str,"ERROR - could not open file \"%s\"\n", filename); 1764 1766 return 0; 1765 1767 }
Note:
See TracChangeset
for help on using the changeset viewer.