Changeset 35 for hvcontrol/src
- Timestamp:
- 04/24/09 14:06:49 (16 years ago)
- Location:
- hvcontrol/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
hvcontrol/src/CCCommand.cc
r14 r35 79 79 m->status->Pc = comline; 80 80 81 sprintf(str,"Test in CCComand: %s",m->status->Pc);82 printf(str);83 81 84 82 ParseInput(m->status->Pc,&(m->status->NParam),m->status->Param); -
hvcontrol/src/HV.cc
r14 r35 334 334 335 335 unsigned char wbuf[] = {0,0,0}; 336 336 337 337 if (!(hv>=0.0 && hv<=0X3FFF)) { 338 338 fprintf(fptr," Error: HV beyond limits [0 - 0x3FFF]\n"); 339 339 return 0; 340 340 } 341 341 342 342 343 switch (chain) { -
hvcontrol/src/HVConfig.cc
r14 r35 36 36 fTimeOut = 1.; 37 37 IsDAC = true; 38 DACMin = 11008; 39 DACMax = 12496; 40 HVMin = 67.0; 41 HVMax = 76.0; 38 42 fHVCalibOffset = -.8; 39 43 fHVCalibSlope = 0.0064; … … 91 95 ReadCard("CCClient", fCCClient, 's', f); 92 96 ReadCard("IsDAC", &str, 's', f); 97 ReadCard("DACMin", &DACMin, 'I', f); 98 ReadCard("DACMax", &DACMax, 'I', f); 99 ReadCard("HVMin", &HVMin, 'f', f); 100 ReadCard("HVMax", &HVMax, 'f', f); 93 101 ReadCard("HVCalibOffset", &fHVCalibOffset, 'f', f); 94 102 ReadCard("HVCalibSlope", &fHVCalibSlope, 'f', f); … … 121 129 fprintf(fptr," CCClient: %s\n\n", fCCClient); 122 130 fprintf(fptr," Set DAC values: %s\n\n", IsDAC ? "yes" : "no"); 131 fprintf(fptr," DACMin value: %d\n\n", DACMin); 132 fprintf(fptr," DACMax value: %d\n\n", DACMax); 133 fprintf(fptr," HVMin value: %f\n\n", HVMin); 134 fprintf(fptr," HVMax value: %f\n\n", HVMax); 123 135 fprintf(fptr," HVCalibOffset : %f\n\n", fHVCalibOffset); 124 136 fprintf(fptr," HVCalibSlope : %f\n\n", fHVCalibSlope); … … 166 178 fprintf(f,"CCClient %s # Central Control client name\n\n",fCCClient); 167 179 fprintf(f,"IsDAC %s # Define here if user input is interpreted as DAC value or voltage\n\n",((IsDAC) ? "TRUE" : "FALSE")); 180 fprintf(f,"DACMin %d # Starting point for calibration of DAC to voltage values\n",DACMin); 181 fprintf(f,"DACMax %d # End point for calibration of DAC to voltage values\n",DACMax); 182 fprintf(f,"HVMin %f # Starting point for calibration of voltage to DAC values\n",HVMin); 183 fprintf(f,"HVMax %f # End point for calibration of voltage to DAC values\n",HVMax); 168 184 fprintf(f,"HVCalibOffset %f # Calibration of DAC to voltage values\n",fHVCalibOffset); 169 185 fprintf(f,"HVCalibSlope %f # Calibration of DAC to voltage values\n\n",fHVCalibSlope); -
hvcontrol/src/HVConfig.h
r14 r35 36 36 float fStatusRefreshRate; 37 37 38 int DACMin; 39 int DACMax; 40 float HVMin; 41 float HVMax; 42 38 43 float fHVCalibOffset; 39 44 float fHVCalibSlope; -
hvcontrol/src/HVStatus.cc
r14 r35 162 162 163 163 if (status->Socket != -1) // Print status string to socket if open 164 write(status->Socket,str,strlen(str) );164 write(status->Socket,str,strlen(str)+1); 165 165 166 166 } -
hvcontrol/src/ProcessIO.cc
r14 r35 22 22 status = new Status; 23 23 config = new HVConfig(stdout,ConfigFile); 24 calib = new HVCalib(config); 24 25 log = new Log(config->fLogPath); 25 26 hv = new HV(config->fUSBDevice,config->USBDeviceNumber,stdout); 27 28 pm = new PixelMap("../fact_repos.svn/config/PixelMap.txt"); 26 29 27 30 // Initialize status structure (HVStatus.cc/h) … … 85 88 config->WriteHVConfig(stdout,config->FileName); 86 89 87 if (hv) delete hv; 88 if (status) delete status; 89 if (config) delete config; 90 if (log) delete log; 90 delete hv; 91 delete status; 92 delete config; 93 delete log; 94 delete pm; 91 95 92 96 } … … 104 108 puts(" help Print help"); 105 109 puts(" hv <ch>|<all> [b][x]<v> Set chan. <ch>|<all> chan. of active chain(s)/board(s) to <v>"); 106 puts(" hvdiff <ch>|<all> [b][x]<diff> Set chan. <ch>|<all> chan. of active chain(s)/board(s) to <diff>"); 110 // puts(" hvdiff <ch>|<all> [b][x]<diff> Set chan. <ch>|<all> chan. of active chain(s)/board(s) to <diff>"); 111 puts(" hvdiff <PXL id> <diff> Set HV difference of pixel PXL id to <diff>"); 107 112 puts(" list List all HV boards"); 108 113 puts(" load <file> Load HV settings from <file>"); … … 128 133 int ProcessIO::CommandControl() { 129 134 130 // bool IsDAC;131 // float fHVCalibOffset;132 // float fHVCalibSlope;133 // float fHVMaxDiff;134 135 135 136 136 // Adress HV board … … 340 340 } 341 341 342 if (!(config->IsDAC))343 hvoltage=(unsigned int)((hvoltageV-config->fHVCalibOffset)/config->fHVCalibSlope);344 342 345 343 StopMonitor(); … … 350 348 for (int j=status->FirstChain;j<=status->LastChain;j++) { 351 349 if (!allchannels) { 352 if ((hv->GetHVBoard(i))->SetHV(stdout,j,channel,hvoltage,rbuf,status->Verbose)==1) { 353 350 // Convert from HV to DAC values 351 if (!(config->IsDAC)) 352 hvoltage = calib->HVToDAC(hvoltageV,i,j,channel); 353 if ((hv->GetHVBoard(i))->SetHV(stdout,j,channel,hvoltage,rbuf,status->Verbose)==1){ 354 354 status->HV[i][j][channel]=hvoltage; 355 sprintf(str, "Test1 status->HV = %d\n",hvoltage);356 DoPrompt(str);357 355 UpdateStatus(i,rbuf); 358 356 … … 370 368 errors++; 371 369 } 372 373 370 } 371 374 372 else { 375 376 373 sprintf(str,"updating board %d chain %d\n",hv->GetHVBoard(i)->GetBoardNumber(),j); 377 374 DoPrompt(str); 378 375 379 380 376 for (int k=0;k<MAX_NUM_CHANNELS;k++) { 377 // Convert from HV to DAC values 378 if (!(config->IsDAC)) 379 hvoltage = calib->HVToDAC(hvoltageV,i,j,k); 381 380 if ((hv->GetHVBoard(i))->SetHV(stdout,j,k,hvoltage,rbuf,status->Verbose)==1) { 382 383 381 status->HV[i][j][k]=hvoltage; 384 382 UpdateStatus(i,rbuf); … … 436 434 int hvdiff = 0; 437 435 unsigned int hvoltage = 0; 436 float hvoltageV = 0.0; 438 437 float hvdiffV = 0.0; 439 int channel = 0; 440 bool allchannels = FALSE; 438 std::string pixelname(status->Param[1]); 439 unsigned int board = 0; 440 unsigned int chain = 0; 441 unsigned int channel = 0; 442 441 443 442 444 if (status->Param[1][0]>0 && status->Param[2][0]>0) { 443 445 446 447 // Set board 448 board = pm->Pixel_to_HVboard(pixelname); 449 // std::cout << "Board: " << board << std::endl; 450 // Set chain 451 chain = pm->Pixel_to_HVchain(status->Param[1]); 452 // std::cout << "Chain: " << chain << std::endl; 444 453 // Set channel 445 if (IsNoDigit(status->Param[1])) 446 channel = atoi(status->Param[1]); 447 else if(status->Param[1][0] == 'a') 448 allchannels = TRUE; 449 else { 450 DoPrompt("error: wrong input format - usage: hvdiff <channel>|<all> <hv difference>\n"); 451 return 0; 452 } 454 channel = pm->Pixel_to_HVchannel(status->Param[1]); 455 // std::cout << "Channel: " << channel << std::endl; 456 457 /* if (IsNoDigit(status->Param[1])) 458 channel = atoi(status->Param[1]); 459 else if(status->Param[1][0] == 'a') 460 allchannels = TRUE; 461 else { 462 DoPrompt("error: wrong input format - usage: hvdiff <channel>|<all> <hv difference>\n"); 463 return 0; 464 }*/ 453 465 454 466 // Binary input … … 481 493 return 0; 482 494 } 483 else if (hvdiff>0X3FFF) { 484 DoPrompt("difference of high voltage out of range (Vmin: -16383, Vmax: 16383)!\n"); 485 return 0; 486 } 487 else if (hvdiffV>78.0 && (-78.0<hvdiffV)) { 488 DoPrompt("difference of high voltage out of range (Vmin: -78.0, Vmax: 78.0)!\n"); 489 return 0; 490 } 491 495 else if (hvdiff>config->DACMax || hvdiff <(-(config->DACMax))) { 496 sprintf(str,"difference of high voltage [hvdiff:%d] out of range (Vmin: 0.0, Vmax: %d)!\n", hvdiff,config->DACMax); 497 DoPrompt(str); 498 return 0; 499 } 500 else if (hvdiffV>(calib->DACToHV(config->DACMax,0,0,0))|| hvdiffV<-(calib->DACToHV(config->DACMax,0,0,0))) { 501 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)); 502 DoPrompt(str); 503 return 0; 504 } 505 506 //Convert from HV to DAC values 492 507 if (!(config->IsDAC)){ 493 hvdiff=(int)(hvdiffV/config->fHVCalibSlope); 508 hvoltage = status->HV[board][chain][channel]; 509 hvoltageV = calib->DACToHV(hvoltage,board,chain,channel); 510 hvoltageV = hvoltageV + hvdiffV; 511 hvdiff = calib->HVToDAC(hvoltageV,board,chain,channel) - hvoltage; 494 512 } 495 513 StopMonitor(); 496 514 497 498 for (int i=status->FirstBoard;i<=status->LastBoard;i++) { 499 500 for (int j=status->FirstChain;j<=status->LastChain;j++) { 501 if (!allchannels) { 502 hvoltage = status->HV[i][j][channel]; 503 for (int k=0;k<=abs((int)(hvdiff/config->fHVMaxDiff));k++){ 504 if (k<abs((int)(hvdiff/config->fHVMaxDiff))){ 505 hvoltage=(unsigned int)(hvoltage + config->fHVMaxDiff*hvdiff/abs(hvdiff)); 506 } 507 if (k==(int)(abs((int)(hvdiff/config->fHVMaxDiff)))){ 508 hvoltage=(unsigned int)(hvoltage + (hvdiff%(int)config->fHVMaxDiff)); 509 } 510 511 512 status->HV[i][j][channel]=hvoltage; 513 if ((hv->GetHVBoard(i))->SetHV(stdout,j,channel,hvoltage,rbuf,status->Verbose)==1) { 514 UpdateStatus(i,rbuf); 515 sprintf(str,"board %d: high voltage of chain %d channel %d set to %d | 0X%.4X\n",hv->GetHVBoard(i)->GetBoardNumber(),j,channel,hvoltage,hvoltage); 516 DoPrompt(str); 517 if (status->Verbose) { 518 sPrintStatus(status,str,i); 519 DoPrompt(str); 520 } 521 sPrintStatus(status,str,i); // Print status only to socket 522 } 523 else { 524 sprintf(str,"board %d error: could not set hv - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber()); 525 DoPrompt(str); 526 errors++; 527 } 528 // Sleep(1); 529 } 515 516 517 hvoltage = status->HV[board][chain][channel]; 518 for (int k=0;k<=abs((int)(hvdiff/config->fHVMaxDiff));k++){ 519 if (k<abs((int)(hvdiff/config->fHVMaxDiff))){ 520 hvoltage=(unsigned int)(hvoltage + config->fHVMaxDiff*hvdiff/abs(hvdiff)); 521 } 522 if (k==(int)(abs((int)(hvdiff/config->fHVMaxDiff)))){ 523 hvoltage=(unsigned int)(hvoltage + (hvdiff%(int)config->fHVMaxDiff)); 524 } 525 526 527 status->HV[board][chain][channel]=hvoltage; 528 if ((hv->GetHVBoard(board))->SetHV(stdout,chain,channel,hvoltage,rbuf,status->Verbose)==1) { 529 UpdateStatus(board,rbuf); 530 if (k==(int)(abs((int)(hvdiff/config->fHVMaxDiff)))){ 531 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); 532 DoPrompt(str); 533 sPrintStatus(status,str,board); // Print status only to socket 530 534 } 531 else { 532 533 sprintf(str,"updating board %d chain %d\n",hv->GetHVBoard(i)->GetBoardNumber(),j); 534 DoPrompt(str); 535 536 537 for (int k=0;k<MAX_NUM_CHANNELS;k++) { 538 int hvoltage = status->HV[i][j][k]; 539 for (int l=0;l<=abs((int)(hvdiff/config->fHVMaxDiff));l++){ 540 if (l<abs((int)(hvdiff/config->fHVMaxDiff))) 541 hvoltage=(unsigned int)(hvoltage + config->fHVMaxDiff*hvdiff/abs(hvdiff)); 542 if (l==(int)(abs((int)(hvdiff/config->fHVMaxDiff)))) 543 hvoltage=(unsigned int)(hvoltage + (hvdiff%(int)config->fHVMaxDiff)); 544 status->HV[i][j][k]=hvoltage; 545 if ((hv->GetHVBoard(i))->SetHV(stdout,j,k,hvoltage,rbuf,status->Verbose)==1) { 546 547 UpdateStatus(i,rbuf); 548 549 if (status->Verbose) { 550 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); 551 DoPrompt(str); 552 sPrintStatus(status,str,i); 553 DoPrompt(str); 554 } 555 sPrintStatus(status,str,i); // Print status only to socket 556 557 } 558 else { 559 sprintf(str,"board %d error: could not set HV - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber()); 560 DoPrompt(str); 561 errors++; 562 } 563 // Sleep(0.001); 564 } 565 } 566 } 567 } 568 } 535 } 536 else { 537 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); 538 DoPrompt(str); 539 errors++; 540 } 541 } // for loop over k 542 // Sleep(1); 543 if (status->Verbose) { 544 sPrintStatus(status,str,board); 545 DoPrompt(str); 546 } 547 548 569 549 StartMonitor(); 570 550 571 551 if (errors) { 572 sprintf(str,"warning %d error(s) => check timeout and try again\n",errors);552 sprintf(str,"warning %d error(s)\n",errors); 573 553 DoPrompt(str); 574 554 } … … 579 559 } 580 560 else { 581 sprintf(str,"usage: hvdiff < channel>|<all> <hv difference>\n");561 sprintf(str,"usage: hvdiff <PXL id> <hv difference>\n"); 582 562 DoPrompt(str); 583 563 } 584 564 return 0; 585 565 586 566 } 587 567 588 568 // End: Write difference of high voltage -------------------------------------------------------------------- -
hvcontrol/src/ProcessIO.h
r14 r35 28 28 #include "Log.h" 29 29 #include "HVConfig.h" 30 #include "HVCalib.h" 30 31 #include "Utilities.h" 31 32 #include "HV.h" 33 34 #include <iostream> 35 #include "../../fact_repos.svn/pixelmap/PixelMap.h" 32 36 33 37 … … 45 49 char bdata[16]; 46 50 51 PixelMap *pm; 52 47 53 public: 48 54 49 55 HVConfig* config; 56 HVCalib* calib; 50 57 Status* status; 51 58 Log* log;
Note:
See TracChangeset
for help on using the changeset viewer.