Changeset 46 for hvcontrol


Ignore:
Timestamp:
05/22/09 15:07:38 (15 years ago)
Author:
lstark
Message:
path of pixel map integrated in config file
Location:
hvcontrol
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • hvcontrol/HV.conf

    r39 r46  
    1 # Main configuration file for the HV control program V1.0, 2009 05 13, 11:37:07
     1# Main configuration file for the HV control program V1.0, 2009 05 22, 15:16:02
    22# Note: this file will be updated at program exit
    33
    44LogPath            /home/lstark/hvcontrol/log/
     5
     6PixMapTable        ../config/PixelMap.txt
    57
    68TimeOut            0.10 s   # Timeout to return from read (0.01,...5.00) s
  • hvcontrol/Makefile

    r41 r46  
    77OBJECTS = $(addsuffix .o, $(basename $(SOURCES)))
    88
    9 #INCDIRS   = -I. -IDRS -I../pixelmap
    109INCDIRS   = -I. -I../pixelmap -I./src
    1110
  • hvcontrol/src/HVCalib.cc

    r40 r46  
    9999  }
    100100
    101   //  for(int i=0; i<hvConfig->NumHVBoards; i++){
    102     for(int i=0; i<1; i++){
    103       //  for(int j=0;j<NCHAIN;j++){
    104       for(int j=0;j<1;j++){
    105         //      for(int k=0;k<NCHANNEL;k++){
    106       for(int k=0;k<1;k++){
     101  for(int i=0; i<hvConfig->NumHVBoards; i++){
     102    //  for(int i=0; i<1; i++){
     103    for(int j=0;j<NCHAIN;j++){
     104      //  for(int j=0;j<1;j++){
     105      for(int k=0;k<NCHANNEL;k++){
     106        //for(int k=0;k<1;k++){
    107107        ihvOld = 0;
    108108        first = true;
  • hvcontrol/src/HVConfig.cc

    r35 r46  
    2121  fUSBDevice = new char*[MAX_NUM_HVBOARDS];
    2222  fCCClient  = new char[FILENAME_MAX_SIZE];
     23
     24  fPixMapTable = new char[FILENAME_MAX_SIZE];
    2325   
    2426  for (int i=0; i<MAX_NUM_HVBOARDS; i++) {
     
    5658
    5759  delete [] fLogPath;
     60  delete [] fPixMapTable;
    5861
    5962  for (int i=0; i<MAX_NUM_HVBOARDS; i++)
     
    7881  }
    7982 
    80   ReadCard("LogPath",fLogPath,'s',f);
     83  ReadCard("LogPath",    fLogPath,'s',f);
     84
     85  ReadCard("PixMapTable",fPixMapTable,'s',f);
    8186
    8287  for (int i=0;i<MAX_NUM_HVBOARDS;i++) {
     
    118123  fprintf(fptr," HV control configuration (%s):\n\n", FileName);
    119124  fprintf(fptr," Log path:          %s\n\n", fLogPath);
     125  fprintf(fptr," Pixel map table:   %s\n\n", fPixMapTable);
    120126  fprintf(fptr," %.2d USB devices:\n\n", NumHVBoards);
    121127 
     
    170176
    171177  fprintf(f,"LogPath            %s\n\n",   fLogPath);
     178  fprintf(f,"PixMapTable        %s\n\n",   fPixMapTable);
    172179
    173180  fprintf(f,"TimeOut            %.2f s   # Timeout to return from read (%.2f,...%.2f) s\n\n",fTimeOut,MIN_TIMEOUT,MAX_TIMEOUT);
  • hvcontrol/src/HVConfig.h

    r35 r46  
    3333  char** fUSBDevice;
    3434
     35  char*  fPixMapTable;
     36 
    3537  float  fTimeOut;
    3638  float  fStatusRefreshRate;
  • hvcontrol/src/ProcessIO.cc

    r39 r46  
    2626  hv      = new HV(config->fUSBDevice,config->USBDeviceNumber,stdout);
    2727 
    28   pm = new PixelMap("../fact_repos.svn/config/PixelMap.txt");
     28  pm = new PixelMap(config->fPixMapTable);
     29  printf("PixMapTable = %s. \n",config->fPixMapTable);
    2930
    3031  // Initialize status structure (HVStatus.cc/h)
     
    284285
    285286    int errors = 0;
    286     unsigned int hvoltage = 0;
     287    unsigned int hvoltage = 0, hvAll = 0;
    287288    float hvoltageV = 0.0;
    288     int channel = 0;
     289    int channel = 0, hvdiff = 0;
    289290    bool allchannels = FALSE;
    290291
     
    352353              status->HVV[i][j][channel]=hvoltageV;
    353354              hvoltage = calib->HVToDAC(hvoltageV,i,j,channel);
    354               printf("HV = %f, dac hv = %d .\n",hvoltageV,hvoltage);
    355355            }
    356             if ((hv->GetHVBoard(i))->SetHV(stdout,j,channel,hvoltage,rbuf,status->Verbose)==1){
    357               status->HV[i][j][channel]=hvoltage;
    358               UpdateStatus(i,rbuf);
    359              
    360               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));
    361               DoPrompt(str);
    362               if (status->Verbose) {
    363                 sPrintStatus(status,str,i);
    364                 DoPrompt(str);
     356            hvdiff = hvoltage - status->HV[i][j][channel];
     357            for (int k=0;k<=abs((int)(hvdiff/config->fHVMaxDiff));k++){
     358              if (k<abs((int)(hvdiff/config->fHVMaxDiff))){
     359                hvoltage=(unsigned int)(status->HV[i][j][channel] + config->fHVMaxDiff*hvdiff/abs(hvdiff));
    365360              }
    366               sPrintStatus(status,str,i); // Print status only to socket
    367             }
    368             else {
    369               sprintf(str,"board %d error: could not set hv - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber());
    370               DoPrompt(str);
    371               errors++;
    372             }
    373           }
    374 
    375           else {
    376             sprintf(str,"updating board %d chain %d\n",hv->GetHVBoard(i)->GetBoardNumber(),j);
    377             DoPrompt(str);
    378            
    379             for (int k=0;k<MAX_NUM_CHANNELS;k++) {
    380  // Convert from HV to DAC values
    381               if (!(config->IsDAC)){
    382                 status->HVV[i][j][channel]=hvoltageV;
    383                 hvoltage = calib->HVToDAC(hvoltageV,i,j,k);
     361              if (k==(abs((int)(hvdiff/config->fHVMaxDiff)))){
     362                hvoltage=(unsigned int)(status->HV[i][j][channel] + (hvdiff%(int)config->fHVMaxDiff));
    384363              }
    385               if ((hv->GetHVBoard(i))->SetHV(stdout,j,k,hvoltage,rbuf,status->Verbose)==1) {
    386                 status->HV[i][j][k]=hvoltage;
     364             
     365              if ((hv->GetHVBoard(i))->SetHV(stdout,j,channel,hvoltage,rbuf,status->Verbose)==1){
     366                status->HV[i][j][channel]=hvoltage;
    387367                UpdateStatus(i,rbuf);
    388368               
     369                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                //              DoPrompt(str);
    389371                if (status->Verbose) {
    390                   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));
    391                   //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);
    392                   DoPrompt(str);
    393372                  sPrintStatus(status,str,i);
    394373                  DoPrompt(str);
    395374                }
    396375                sPrintStatus(status,str,i); // Print status only to socket
    397                
    398376              }
    399377              else {
    400                 sprintf(str,"board %d error: could not set HV - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber());
     378                sprintf(str,"board %d error: could not set hv - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber());
    401379                DoPrompt(str);
    402380                errors++;
     381              }
     382            }
     383          }
     384          else {
     385            sprintf(str,"updating board %d chain %d\n",hv->GetHVBoard(i)->GetBoardNumber(),j);
     386            DoPrompt(str);
     387         
     388            for (int k=0;k<MAX_NUM_CHANNELS;k++) {
     389 // Convert from HV to DAC values
     390              if (!(config->IsDAC)){
     391                status->HVV[i][j][k]=hvoltageV;
     392                hvoltage = calib->HVToDAC(hvoltageV,i,j,k);
     393              }
     394              hvAll = hvoltage;
     395              hvdiff = hvAll - status->HV[i][j][k];
     396              for (int l=0;l<=abs((int)(hvdiff/config->fHVMaxDiff));l++){
     397                if (l<abs((int)(hvdiff/config->fHVMaxDiff))){
     398                  hvoltage=(unsigned int)(status->HV[i][j][k] + config->fHVMaxDiff*hvdiff/abs(hvdiff));
     399                }
     400                if (l==(abs((int)(hvdiff/config->fHVMaxDiff)))){
     401                  hvoltage=(unsigned int)(status->HV[i][j][k] + (hvdiff%(int)config->fHVMaxDiff));
     402                }
     403                if ((hv->GetHVBoard(i))->SetHV(stdout,j,k,hvoltage,rbuf,status->Verbose)==1) {
     404                  status->HV[i][j][k]=hvoltage;
     405                  UpdateStatus(i,rbuf);
     406                 
     407                  if (status->Verbose) {
     408                    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,"board %d: high voltage of chain %d channel %d set to %d | 0X%.4X\n",hv->GetHVBoard(i)->GetBoardNumber(),j,k,hvoltage,hvoltage);
     410                    //   DoPrompt(str);
     411                    sPrintStatus(status,str,i);
     412                    DoPrompt(str);
     413                  }
     414                  sPrintStatus(status,str,i); // Print status only to socket
     415                }
     416               
     417                else {
     418                  sprintf(str,"board %d error: could not set HV - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber());
     419                  DoPrompt(str);
     420                  errors++;
     421                }
    403422              }
    404423            }
Note: See TracChangeset for help on using the changeset viewer.