Changeset 39 for hvcontrol


Ignore:
Timestamp:
05/13/09 10:42:59 (16 years ago)
Author:
lstark
Message:
several bugs fixed, higher precision reached
Location:
hvcontrol
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • hvcontrol/HV.conf

    r35 r39  
    1 # Main configuration file for the HV control program V1.0, 2009 04 23, 17:13:36
     1# Main configuration file for the HV control program V1.0, 2009 05 13, 11:37:07
    22# Note: this file will be updated at program exit
    33
  • hvcontrol/Makefile

    r35 r39  
    33#
    44
    5 SOURCES = hvcontrol.cpp src/CCCommand.cc src/ConsoleCommand.cc src/HV.cc src/HVConfig.cc src/HVCalib.cc src/HVMonitor.cc src/HVStatus.cc src/Log.cc src/ProcessIO.cc src/ReadCard.cc src/Utilities.cc ../../fact_repos.svn/pixelmap/Pixel.cc ../../fact_repos.svn/pixelmap/PixelMap.cc
     5SOURCES = hvcontrol.cpp src/CCCommand.cc src/ConsoleCommand.cc src/HV.cc src/HVConfig.cc src/HVCalib.cc src/HVMonitor.cc src/HVStatus.cc src/Log.cc src/ProcessIO.cc src/ReadCard.cc src/Utilities.cc ../fact_repos.svn/pixelmap/Pixel.cc ../fact_repos.svn/pixelmap/PixelMap.cc
    66
    77OBJECTS = $(addsuffix .o, $(basename $(SOURCES)))
  • hvcontrol/src/CCCommand.cc

    r35 r39  
    2929    return;
    3030  }
    31  
     31
     32// Allows immediate reuse of socket after closing (circumvents TIME_WAIT)
     33  int Value=1;
     34  if (setsockopt(ServerSocket, SOL_SOCKET, SO_REUSEADDR, (char *) &Value, sizeof (Value)) == -1) {
     35    sprintf(str,"Warning: Could not set server socket option SO_REUSEADDR (%s).\n",strerror(errno));
     36    m->PrintMessage(str);
     37  }
     38
    3239  SocketAddress.sin_family = PF_INET;
    3340  SocketAddress.sin_port = htons((unsigned short) m->config->fCCPort);
  • hvcontrol/src/HVStatus.cc

    r35 r39  
    5353      status->OC[i][j]   = FALSE;
    5454
    55       for (int k=0;k<MAX_NUM_CHANNELS;k++)
     55      for (int k=0;k<MAX_NUM_CHANNELS;k++){
    5656        status->HV[i][j][k] = 0;
     57        status->HVV[i][j][k] = 0.0;
     58      }
    5759    }
    5860  }
  • hvcontrol/src/HVStatus.h

    r14 r39  
    5050 
    5151  unsigned int VRef[MAX_NUM_HVBOARDS][MAX_NUM_CHAINS];     
    52   unsigned int HV[MAX_NUM_HVBOARDS][MAX_NUM_CHAINS][MAX_NUM_CHANNELS];
     52  unsigned int HV[MAX_NUM_HVBOARDS][MAX_NUM_CHAINS][MAX_NUM_CHANNELS];      // HV value in DAC
     53  float HVV[MAX_NUM_HVBOARDS][MAX_NUM_CHAINS][MAX_NUM_CHANNELS];            // HV value in volts
    5354
    5455  float fTimeOut;
  • hvcontrol/src/ProcessIO.cc

    r35 r39  
    349349          if (!allchannels) {
    350350 // Convert from HV to DAC values
    351             if (!(config->IsDAC))
     351            if (!(config->IsDAC)){
     352              status->HVV[i][j][channel]=hvoltageV;
    352353              hvoltage = calib->HVToDAC(hvoltageV,i,j,channel);
     354              printf("HV = %f, dac hv = %d .\n",hvoltageV,hvoltage);
     355            }
    353356            if ((hv->GetHVBoard(i))->SetHV(stdout,j,channel,hvoltage,rbuf,status->Verbose)==1){
    354357              status->HV[i][j][channel]=hvoltage;
    355358              UpdateStatus(i,rbuf);
    356359             
    357               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);
     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));
    358361              DoPrompt(str);
    359362              if (status->Verbose) {
     
    376379            for (int k=0;k<MAX_NUM_CHANNELS;k++) {
    377380 // Convert from HV to DAC values
    378               if (!(config->IsDAC))
     381              if (!(config->IsDAC)){
     382                status->HVV[i][j][channel]=hvoltageV;
    379383                hvoltage = calib->HVToDAC(hvoltageV,i,j,k);
     384              }
    380385              if ((hv->GetHVBoard(i))->SetHV(stdout,j,k,hvoltage,rbuf,status->Verbose)==1) {
    381386                status->HV[i][j][k]=hvoltage;
     
    383388               
    384389                if (status->Verbose) {
    385                   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);
     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);
    386392                  DoPrompt(str);
    387393                  sPrintStatus(status,str,i);
     
    455461      //      std::cout << "Channel: " << channel << std::endl;
    456462
    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         }*/
    465 
    466463      // Binary input
    467464      if (tolower(status->Param[2][0])=='x' && strlen(status->Param[2])>2) {
     
    506503      //Convert from HV to DAC values
    507504      if (!(config->IsDAC)){
    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;
     505        hvoltageV = status->HVV[board][chain][channel]+hvdiffV;
     506        status->HVV[board][chain][channel] = hvoltageV;
     507        printf("hv+diff = %f .\n",hvoltageV);
     508        hvdiff = calib->HVToDAC(hvoltageV,board,chain,channel) - status->HV[board][chain][channel];
     509        printf("dac new = %d, dac old = %d.\n",calib->HVToDAC(hvoltageV,board,chain,channel),status->HV[board][chain][channel]);
     510        printf("dac diff = %d .\n",hvdiff);
    512511      }
    513512      StopMonitor();
     
    516515     
    517516      hvoltage = status->HV[board][chain][channel];
     517      //      printf("dac hv = %d .\n",hvoltage);
    518518      for (int k=0;k<=abs((int)(hvdiff/config->fHVMaxDiff));k++){
    519519        if (k<abs((int)(hvdiff/config->fHVMaxDiff))){
     
    526526       
    527527        status->HV[board][chain][channel]=hvoltage;
     528        printf("dac hv rampingup= %d .\n",hvoltage);
    528529        if ((hv->GetHVBoard(board))->SetHV(stdout,chain,channel,hvoltage,rbuf,status->Verbose)==1) {
    529530          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);
     531          if (k==(abs((int)(hvdiff/config->fHVMaxDiff)))){
     532            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));
     533            //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);
    532534            DoPrompt(str);
    533535            sPrintStatus(status,str,board); // Print status only to socket
     
    540542        }
    541543      }          // for loop over k
    542         //          Sleep(1);
    543544      if (status->Verbose) {
    544545        sPrintStatus(status,str,board);
Note: See TracChangeset for help on using the changeset viewer.