Changeset 100 for hvcontrol/src


Ignore:
Timestamp:
08/12/09 12:15:02 (15 years ago)
Author:
ogrimm
Message:
Number of HV boards (almost) unlimited.
Location:
hvcontrol/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • hvcontrol/src/HV.cc

    r98 r100  
    2222  m = PIO;
    2323
    24   fTestMode = m->config->TestMode;
    25   fTestModeWrap = 0;
    26  
    2724  SetTimeOut(m->config->fTimeOut);
    2825  BoardNumber = DeviceNumber;
     
    3431  LastWrapCount = -1;
    3532 
    36   if (fTestMode) {
    37     fDescriptor = 99;
    38     return;
    39   }
    40 
    4133  ClearVoltageArrays();
    4234
     
    7870// Destructor (Resetting board)
    7971HVBoard::~HVBoard() {
    80   if(fDescriptor >= 0 && !fTestMode) {
     72  if(fDescriptor >= 0) {
    8173    Reset();
    8274    close(fDescriptor);
     
    8779// Communicate: Write and read from HV Board until fTimeOut has been reached
    8880//
    89 // Returns: 0 read error, 1 success, -1 fTimeOut exceeded
     81// Returns: 0 error, 1 success, -1 fTimeOut exceeded
    9082int HVBoard::Communicate(unsigned char* wbuf, int Bytes) {
    9183
     
    9688  // === Write data ===
    9789  if (write(fDescriptor, wbuf, Bytes) < Bytes) {
    98     m->PrintMessage("Error: could not write (all) data to HV board\n");
     90    m->PrintMessage("Error: Could not write (all) data to HV board\n");
    9991    return 0;
    10092  }
     
    128120  }
    129121  LastWrapCount = rbuf & 0X07; 
    130   for (int i=0; i<NUM_CHAINS; i++) Overcurrent[i]=(rbuf & (0X08 << i));
     122  for (int i=0; i<NUM_CHAINS; i++) Overcurrent[i] = (rbuf & (0X08 << i));
    131123  ResetButton = (bool) (rbuf & 0X80);
    132124
     
    140132int HVBoard::Reset() {
    141133 
    142   if (fTestMode) return 1;
    143 
    144134  unsigned char wbuf[] = {REG_RESET,0,0};
    145135  int ret;
     
    153143int HVBoard::GetStatus() {
    154144
    155   if (fTestMode) return 1;
    156 
    157145  unsigned char wbuf[] = {REG_STATUS,0,0};
    158146 
     
    164152int HVBoard::SetHV(int chain, unsigned int channel, int hv) {
    165153
    166   if (fTestMode){
    167     m->PrintMessage("Test mode: Nothing to be done. \n");
    168     return 1;
    169   }
     154  unsigned char wbuf[] = {0,0,0};
     155  int ret;
    170156 
    171   unsigned char wbuf[] = {0,0,0};
    172 
    173   if (hv > 0x3FFF) {
    174     m->PrintMessage(" Error: HV beyond upper 0x3FFF\n");
     157  if (hv<0 || hv > 0x3FFF) {
     158    m->PrintMessage("Error: Voltage out of range 0-0x3FFF\n");
    175159    return 0;
    176160  }
    177   if (hv<0) hv = 0;
    178161 
    179162  switch (chain) {
     
    183166    case 3: wbuf[0] = REG_HV3; break;
    184167
    185     default : m->PrintMessage(" Error: chain %d does not exist\n",chain); return 0;
     168    default : m->PrintMessage(" Error: Chain %d does not exist\n",chain); return 0;
    186169  }
    187170 
     
    192175  wbuf[2] |= (unsigned char)(hv & 0X000000FF);              // Add [D7-D0]
    193176   
    194   return Communicate(wbuf, 3);
     177  if ((ret = Communicate(wbuf, 3)) == 1) HV[chain][channel] = hv;
     178  return ret;
    195179}
    196180
  • hvcontrol/src/HV.h

    r98 r100  
    3333 
    3434   int BoardNumber;
    35    int fTestModeWrap;
    36    bool fTestMode;
    3735   class ProcessIO *m;
    3836   
  • hvcontrol/src/HVCalib.cc

    r90 r100  
    77                sabrina.stark@phys.ethz.ch
    88
    9   Contents:     Class reading the calibration tabel for DAC to HV values
     9  Contents:     Class reading the calibration table for DAC to HV values
    1010
    1111\*************************************************************************/
     
    2424HVCalib::HVCalib(HVConfig* hvConfig) {
    2525
    26   char calibfile[80];
    27   int idac, idacOld;
    28   int istep, ihv1000, ihvOld;
    29   char dLine[6000];
     26  char calibfile[80], dLine[6000];
     27  int idac, idacOld, istep, ihv1000, ihvOld;
    3028  bool first = true;
    3129  float hv1000,dac;
    3230  double intpart;
    3331
    34   iDACMin = hvConfig->DACMin;
    35   fHVCalibSlope = hvConfig->fHVCalibSlope;
    36   NDACValues = hvConfig->DACMax - hvConfig->DACMin;
     32  Config = hvConfig;
     33 
     34  iDACMin = Config->DACMin;
     35  fHVCalibSlope = Config->fHVCalibSlope;
     36  NDACValues = Config->DACMax - Config->DACMin;
    3737  NHVValues = 10*NDACValues;
    3838
    39 
    40   HVArray = new double***[hvConfig->NumHVBoards];
    41   for(int i=0; i<hvConfig->NumHVBoards; i++) {
    42     HVArray[i] = new double**[NUM_CHAINS];
     39  HVArray = new double*** [Config->NumHVBoards];
     40  DACArray = new int*** [Config->NumHVBoards];
     41  for(int i=0; i<Config->NumHVBoards; i++) {
     42    HVArray[i] = new double** [NUM_CHAINS];
     43    DACArray[i] = new int** [NUM_CHAINS];
    4344    for(int j=0; j<NUM_CHAINS; j++) {
    44       HVArray[i][j] = new double*[NUM_CHANNELS];
     45      HVArray[i][j] = new double* [NUM_CHANNELS];
     46      DACArray[i][j] = new int* [NUM_CHANNELS];
    4547      for(int k=0; k<NUM_CHANNELS; k++) {
    46         HVArray[i][j][k] = new double[NDACValues];
     48        HVArray[i][j][k] = new double [NDACValues];
     49        DACArray[i][j][k] = new int [NHVValues];
    4750      }
    4851    }
    4952  }
    5053
    51   DACArray = new int***[hvConfig->NumHVBoards];
    52   for(int i=0; i<hvConfig->NumHVBoards; i++) {
    53     DACArray[i] = new int**[NUM_CHAINS];
    54     for(int j=0; j<NUM_CHAINS; j++) {
    55       DACArray[i][j] = new int*[NUM_CHANNELS];
    56       for(int k=0; k<NUM_CHANNELS; k++) {
    57         DACArray[i][j][k] = new int[NHVValues];
    58       }
    59     }
    60   }
    61 
    62   for(int i=0; i<hvConfig->NumHVBoards; i++){
     54  for(int i=0; i<Config->NumHVBoards; i++){
    6355    for(int j=0; j<NUM_CHAINS; j++){
    6456      sprintf(calibfile,"Calib/%s_%c%d.txt",hvConfig->fUSBDevice[i],65+j,1);
     
    6860        fin >> dac;
    6961        idacOld = 0;
    70         if ((int) dac >= hvConfig->DACMin) {
     62        if ((int) dac >= Config->DACMin) {
    7163          if (first){
    7264            iDACMin = (int) dac;
     
    7668          istep = idac - idacOld;
    7769          for(int k=0; k<NUM_CHANNELS; k++){
     70            if (idac>=NDACValues) break;
     71
    7872            fin>>HVArray[i][j][k][idac];
     73
    7974            for (int l=1; l<istep;l++){
    8075              HVArray[i][j][k][idac-istep+l] = HVArray[i][j][k][idac-istep] + l*(HVArray[i][j][k][idac]-HVArray[i][j][k][idac-istep])/istep;
     
    9388  }
    9489
    95   for(int i=0; i<hvConfig->NumHVBoards; i++){
    96     for(int j=0;j<NUM_CHAINS;j++){
    97       for(int k=0;k<NUM_CHANNELS;k++){
     90  for(int i=0; i<Config->NumHVBoards; i++){
     91    for(int j=0; j<NUM_CHAINS; j++){
     92      for(int k=0; k<NUM_CHANNELS; k++){
    9893        ihvOld = 0;
    9994        first = true;
    100         for (int l=0; l<NDACValues;l++){
     95        for (int l=0; l<NDACValues; l++){
    10196          if (l == 0){
    10297            ihvOld = 0;
     
    129124HVCalib::~HVCalib() {
    130125
    131 
    132   for (int i=0; i<MAX_NUM_HVBOARDS; i++){
    133     for (int j=0; j<NUM_CHAINS;j++){
    134       for (int k=0; k<NUM_CHANNELS;k++){
    135         delete [] HVArray[i][j][k];
    136         delete [] HVArray;
     126  for(int i=0; i<Config->NumHVBoards; i++) {
     127    for(int j=0; j<NUM_CHAINS; j++) {
     128      for(int k=0; k<NUM_CHANNELS; k++) {
     129        delete[] HVArray[i][j][k];
     130        delete[] DACArray[i][j][k];
    137131      }
     132      delete[] HVArray[i][j];
     133      delete[] DACArray[i][j];
    138134    }
     135    delete[] HVArray[i];
     136    delete[] DACArray[i];
    139137  }
    140 
    141   for (int i=0; i<MAX_NUM_HVBOARDS; i++){
    142     for (int j=0; j<NUM_CHAINS;j++){
    143       for (int k=0; k<NUM_CHANNELS;k++){
    144         delete [] DACArray[i][j][k];
    145         delete [] DACArray;
    146       }
    147     }
    148   }
     138  delete[] HVArray;
     139  delete[] DACArray;
    149140}
    150141
     
    175166      ihv = (int) (hv1000<0 ? ceil(hv1000) : floor(hv1000));
    176167    }
     168    if (ihv >= NHVValues) ihv = NHVValues;
    177169    return DACArray[board][chain][channel][ihv];
    178170  }
    179171}
    180 
  • hvcontrol/src/HVCalib.h

    r90 r100  
    1616  int NDACValues;
    1717  int NHVValues;
     18  int iDACMin;
     19  double fHVCalibSlope;
    1820
     21  HVConfig *Config;
     22 
    1923 public:
    2024
    21   HVCalib(HVConfig *hvConfig);
     25  HVCalib(HVConfig *);
    2226  ~HVCalib();
    23 
    24   int iDACMin;
    25   double fHVCalibSlope;
    2627
    2728  int HVToDAC(double hv, int board, int chain, int channel);
  • hvcontrol/src/HVConfig.cc

    r93 r100  
    1616HVConfig::HVConfig(const char *configfile) {
    1717
    18   fUSBDevice = new char*[MAX_NUM_HVBOARDS];
    19 
    20   for (int i=0; i<MAX_NUM_HVBOARDS; i++) {
    21     fUSBDevice[i]      = new char[BUFFER_LENGTH];
    22     USBDeviceNumber[i] = 0;
    23   }
    24 
    25   TestMode           = false;
    26   NumHVBoards        = 0;
    27   fStatusRefreshRate = 1.;
    28   fTimeOut           = 1.;
    29   DACMin             = 11008;
    30   DACMax             = 12496;
    31   fHVCalibOffset      = -.8;
    32   fHVCalibSlope       = 0.0064;
    33   fHVMaxDiff          = 1;
    34  
    3518  // Read configuration file
    3619  FILE *f;
    37   char str[MAX_COM_SIZE], dev[MAX_COM_SIZE];
    38   int j = 0;
    3920
    4021  if ((f = fopen(configfile,"r")) == NULL) {
     
    4223    throw;
    4324  }
    44   else printf("Opening configuration file: %s\n", configfile);
     25  printf("Opening configuration file: %s\n", configfile);
    4526 
     27  // Determine number of entries in 'Boards' card and allocate memeory
     28  NumHVBoards = (int) ReadCard("Boards", NULL, 'n', f);
     29  fUSBDevice = new char* [NumHVBoards];
     30  for (int i=0; i<NumHVBoards; i++) fUSBDevice[i] = new char [BUFFER_LENGTH];
     31  ReadCard("Boards", fUSBDevice, 'S', f, NumHVBoards);
     32
    4633  ReadCard("LogFile",       fLogFile,    's',f);
    4734  ReadCard("PixMapTable",   fPixMapTable,'s',f);
    4835  ReadCard("SlowDirectory", fSlowDir,    's',f);
    49  
    50   ReadCard("TestMode",   &str,        's',f);
    51   if (!strcmp(str,"TRUE")) TestMode = true;
    52 
    53   for (int i=0; i<MAX_NUM_HVBOARDS; i++) {
    54     sprintf(str,"Board%d",i);
    55 
    56     if (ReadCard(str, dev, 's', f)) {
    57       USBDeviceNumber[j] = i;
    58       sprintf(fUSBDevice[j++],"%s",dev);
    59       NumHVBoards++;     
    60     }
    61   }
    62  
    6336  ReadCard("TimeOut",           &fTimeOut,           'f', f);
    6437  ReadCard("StatusRefreshRate", &fStatusRefreshRate, 'f', f);
     
    7649HVConfig::~HVConfig() {
    7750
    78   for (int i=0; i<MAX_NUM_HVBOARDS; i++) delete [] fUSBDevice[i];
    79   delete [] fUSBDevice;
     51  for (int i=0; i<NumHVBoards; i++) delete[] fUSBDevice[i];
     52  delete[] fUSBDevice;
    8053}
    8154
     
    8356// ReadCard function (original version by F. Goebel)
    8457// Data is read into an array if MaxNum is larger than 1
    85 bool ReadCard(const char *card_flag, void *store, char Type, FILE *File, unsigned int MaxNum) {
     58// If Type is 'n', the number of elements for the card is counted.
     59// Type 'S' is for reading an array of strings
     60unsigned int ReadCard(const char *card_flag, void *store, char Type, FILE *File, unsigned int MaxNum) {
    8661 
    8762  char *card_name, *card_val, Buffer[MAX_COM_SIZE];
     
    9772
    9873    // Read numbers of given type (if MaxNum>1 read array)
    99     while ((card_val=strtok(NULL," \t\n")) != NULL && Count++<MaxNum) {
     74    while ((card_val=strtok(NULL," \t\n"))!=NULL && card_val[0]!='#' && Count++<MaxNum) {
    10075      switch (Type) {
    10176        case 'I': *(((int *&) store)++) = (int) strtol(card_val, NULL, 10);
     
    11388        case 's': sprintf((char *) store, "%s", card_val);
    11489                  break;
    115         case 'c': *((char *) store) = card_val[0];
     90        case 'S': sprintf(*(((char **&) store)++), "%s", card_val);
     91                  break;
     92        case 'c': *(((char *&) store)++) = card_val[0];
     93                  break;
     94        case 'n': MaxNum = UINT_MAX;
    11695                  break;
    11796        default:  fprintf(stderr,"Warning: Unknown type '%c' for reading of configuration file\n", Type);
    118                   return false;
     97                  return 0;
    11998      }
    12099    }
    121     return true;  // Finished reading data for card name 
     100    return Count;  // Finished reading data for card name 
    122101  }
    123   return false;
     102  return 0;
    124103}
    125104
  • hvcontrol/src/HVConfig.h

    r93 r100  
    77#include <stdlib.h>
    88#include <stdio.h>
     9#include <limits.h>
    910
    10 #define MAX_COM_SIZE 1000
    11 #define MAX_NUM_HVBOARDS 20
     11#define MAX_COM_SIZE 5000
    1212#define NUM_CHAINS 4
    1313#define NUM_CHANNELS 32
     
    2929
    3030  int NumHVBoards;
    31   int USBDeviceNumber[MAX_NUM_HVBOARDS];
    32 
    33   int fCCPort;
    34 
    35   bool TestMode;
     31  char **fUSBDevice;
     32//  char (*fUSBDevice)[BUFFER_LENGTH];
    3633
    3734  char   fLogFile[BUFFER_LENGTH];
    3835  char   fSlowDir[BUFFER_LENGTH];
    39   char** fUSBDevice;
    4036
    4137  char   fPixMapTable[BUFFER_LENGTH];
     38  int fCCPort;
    4239 
    4340  float  fTimeOut;
     
    4643  int DACMin;
    4744  int DACMax;
    48 
    4945  float  fHVCalibOffset;
    5046  float  fHVCalibSlope;
    51  
    5247  unsigned int  fHVMaxDiff;
    5348};
    5449
    55 bool ReadCard(const char *, void *, char, FILE *, unsigned int=1);
     50unsigned int ReadCard(const char *, void *, char, FILE *, unsigned int=1);
    5651
    5752#endif
  • hvcontrol/src/ProcessIO.cc

    r98 r100  
    3636  LastBoard   = -1;
    3737  FirstChain  = 0;
    38   LastChain   = 3;
     38  LastChain   = NUM_CHAINS-1;
    3939 
    4040  if (config->fStatusRefreshRate >= MIN_RATE && config->fStatusRefreshRate <= MAX_RATE)
     
    4343   
    4444  // Open HV devices
    45   if(config->TestMode){
    46     fprintf(stdout,"Test mode: One HVBoard initialized as dummy.\n");
    47     fHVBoard[NumHVBoards] = new HVBoard(0, 0, this);
    48     NumHVBoards++;
    49   }
    50   else {
    51     for (int i=0; i<config->NumHVBoards; i++) {
    52       fHVBoard[NumHVBoards] = new HVBoard(config->USBDeviceNumber[i], config->fUSBDevice[i], this);
    53       if(fHVBoard[NumHVBoards]->fDescriptor >= 0) {
    54          printf("Synchronized and reset HV board %d (%s)\n",i,config->fUSBDevice[i]);
    55          NumHVBoards++;
    56       }
    57       else {
    58         printf("Failed to synchronize to HV board %d (%s)\n",i,config->fUSBDevice[i]);
    59         delete fHVBoard[NumHVBoards];
    60       }
     45  fHVBoard = new HVBoard* [config->NumHVBoards];
     46  for (int i=0; i<config->NumHVBoards; i++) {
     47    fHVBoard[NumHVBoards] = new HVBoard(i, config->fUSBDevice[i], this);
     48    if(fHVBoard[NumHVBoards]->fDescriptor >= 0) {
     49       printf("Synchronized and reset HV board %d (%s)\n",i,config->fUSBDevice[i]);
     50       NumHVBoards++;
     51    }
     52    else {
     53      printf("Failed to synchronize to HV board %d (%s)\n",i,config->fUSBDevice[i]);
     54      delete fHVBoard[NumHVBoards];
    6155    }
    6256  }
     
    7973ProcessIO::~ProcessIO() {
    8074 
     75  delete SlowDataClass;     
     76
    8177  for (int i=0; i<NumHVBoards; i++) delete fHVBoard[i];
    82 
    83   delete SlowDataClass;   delete config;    delete pm;
     78  delete[] fHVBoard;
     79   
     80  delete pm;   delete calib;    delete config;   
    8481 
    8582  if(Logfile != NULL) {
    86     if(!fclose(Logfile)) printf("Closing logfile\n");
    87     else perror("Error closing logfile");
     83    if(fclose(Logfile) != 0) perror("Error closing logfile");
    8884  }
    8985}
     
    145141      LastChain = 3;
    146142    }
    147     else if (NParam==2 && atoi(Param[1])>=0 && atoi(Param[1])<4) {
     143    else if (NParam==2 && atoi(Param[1])>=0 && atoi(Param[1])<NUM_CHAINS) {
    148144      FirstChain = atoi(Param[1]);
    149145      LastChain = FirstChain;
    150146    }
    151     else if (NParam==3 && atoi(Param[1])>=0 && atoi(Param[1])<4 &&
    152            atoi(Param[2])>0 && atoi(Param[2])<4) {
     147    else if (NParam==3 && atoi(Param[1])>=0 && atoi(Param[1])<NUM_CHAINS &&
     148           atoi(Param[2])>0 && atoi(Param[2])<NUM_CHAINS) {
    153149      FirstChain = atoi(Param[1]);
    154150      LastChain = atoi(Param[2]);
     
    164160    PrintMessage( " Log file:          %s\n"
    165161                  " Pixel map table:   %s\n"
    166                   " Test mode:         %s\n"
    167162                  " %d USB devices:\n", config->fLogFile, config->fPixMapTable,
    168                   config->TestMode ? "yes" : "no", config->NumHVBoards); 
    169     for (int i=0;i<NumHVBoards;i++) {
    170       PrintMessage(" Board%d: %s\n ", config->USBDeviceNumber[i], config->fUSBDevice[i]);
    171     }
    172     PrintMessage( "\n TimeOut:           %.2f s\n"
     163                  config->NumHVBoards); 
     164    for (int i=0; i<config->NumHVBoards; i++) {
     165      PrintMessage(" Board %d: %s\n ", i, config->fUSBDevice[i]);
     166    }
     167    PrintMessage( " TimeOut:           %.2f s\n"
    173168                  " StatusRefreshRate: %.2f Hz\n"
    174169                  " CCPort:            %d\n"
     
    211206
    212207
    213   // Set new high voltage --------------------------------------------------------------------------------------
     208  // Set new high voltage (if no boards available, simply returns OK)
     209  // First reponse to socket should be 'OK' if no error occurred.
    214210  if (Match(Param[0], "hv") || Match(Param[0], "hvdiff")) {
    215211
    216     if (!NumHVBoards) return;
    217 
    218     int hvoltage, DACValue, Errors=0, Board, Chain=0, Channel=0;
     212    int hvoltage, DACValue, Errors=0, Board=-1, Chain=-1, Channel=-1;
    219213    double hvoltageV;
    220     bool allchannels = false, SetDac = false;
    221    
    222     // Need two parameters or three if last is 'dac'
     214    bool SetDac;
     215   
     216    // Need two or parameters
    223217    if (NParam<3 || NParam>4) {
    224       PrintMessage("ERROR - usage: hv <channel>|<all> <voltage> [dac]\n");
    225       return;
    226     }
    227 
    228     if (NParam==4 && Match(Param[3], "dac")) SetDac = true;
    229    
     218      PrintMessage("Usage: hv/hvdiff <channel>|<all> <voltage> [dac]\n");
     219      return;
     220    }
     221
     222    // Evaluate voltage parameter
     223    if (NParam==4 && Match(Param[3], "dac")) {
     224      SetDac = true;
     225      if (!ConvertToInt(Param[2], &hvoltage)) {
     226        PrintMessage("Error: Wrong number format for DAC voltage setting\n");
     227        return;
     228      }
     229    }
     230    else {
     231      SetDac = false;
     232      if (!ConvertToDouble(Param[2], &hvoltageV)) {
     233        PrintMessage("Error: Wrong number format for voltage setting\n");
     234        return;
     235      }
     236    }
     237
    230238    // Evaluate pixel or channel parameter   
    231     if((Board = pm->Pixel_to_HVboard(Param[1])) != 999999999) {
     239    if(pm->Pixel_to_HVboard(Param[1]) != 999999999) {
     240      Board = pm->Pixel_to_HVboard(Param[1]);
    232241      Chain = pm->Pixel_to_HVchain(Param[1]);
    233242      Channel = pm->Pixel_to_HVchannel(Param[1]);
    234243    }
    235     else if (Match(Param[1], "all")) allchannels = true;
    236     else if (ConvertToInt(Param[1], &Channel)) {
    237       Board = -1;
    238       Chain = -1;
    239     }
    240     else {
    241       PrintMessage("ERROR - wrong input format - usage: hv <channel>|<all> <voltage>\n");
    242       return;
    243     }
    244     // Check channel limits (voltage limit is only checked in SetHV())
    245     if (Channel<0 || Channel>31) {
    246       PrintMessage("ERROR - channel out of range (0...31)!\n");
    247       return;
    248     }
    249 
    250     if (SetDac && !ConvertToInt(Param[2], &hvoltage)) {
    251       PrintMessage("ERROR - wrong number format for DAC voltage setting\n");
    252       return;
    253     }
    254     if (!SetDac && !ConvertToDouble(Param[2], &hvoltageV)) {
    255       PrintMessage("ERROR - wrong number format for voltage setting\n");
    256       return;
    257     }
     244    else if (!Match(Param[1], "all") && !ConvertToInt(Param[1], &Channel)) {
     245      PrintMessage("Error: Wrong channel identification\n");
     246      return;
     247    }
    258248
    259249    for (int i=FirstBoard; i<=LastBoard; i++) {
    260       if (!allchannels && Board != 999999999 && i != Board && Board!=-1) continue;
     250      if (i!=Board && Board!=-1) continue;
    261251
    262252      for (int j=FirstChain; j<=LastChain; j++) {
    263         if (!allchannels && Chain != 999999999 && j != Chain && Chain!=-1) continue;
     253        if (j!=Chain && Chain!=-1) continue;
    264254
    265255        for (int k=0; k<NUM_CHANNELS; k++) {
    266           if (!allchannels && k!= Channel) continue;
     256          if (k!=Channel && Channel!=-1) continue;
    267257
    268258          // Convert from HV to DAC values
     
    277267          }
    278268         
    279           // Set new voltage (if DAC value, update calilbrated value)
     269          // Set new voltage (if DAC value, update calibrated value)
    280270          if(!RampVoltage(DACValue, i, j, k)) Errors++;
    281           else if(SetDac) fHVBoard[i]->HVV[j][k] = calib->DACToHV(fHVBoard[i]->HV[j][k], i, j, k);
     271          if(SetDac) fHVBoard[i]->HVV[j][k] = calib->DACToHV(fHVBoard[i]->HV[j][k], i, j, k);
    282272
    283273        } // Channels   
     
    285275    } // Boards
    286276
    287     if (Errors > 0) PrintMessage("Warning: Errors on %d channel(s) occurred\n", Errors);
    288     else PrintMessage("OK - no error(s)\n");
     277    if (Errors > 0) PrintMessage("ERROR - Errors on %d channel(s) occurred\n", Errors);
     278    else PrintMessage("OK - no errors\n");
    289279   
    290280    return;
     
    436426    state = active;
    437427    pthread_kill(HVMonitor, SIGUSR1);
    438     PrintMessage("OK - status monitoring activated\n");
     428    PrintMessage("Status monitoring activated\n");
    439429    return; 
    440430  }
     
    617607
    618608    if (fHVBoard[Board]->SetHV(Chain, Channel, fHVBoard[Board]->HV[Chain][Channel]+Diff) == 1) {
    619       fHVBoard[Board]->HV[Chain][Channel] += Diff;
    620 
    621609      if (Verbose) {
    622         PrintMessage("OK - board %d: high voltage of chain %d channel %d set to %d | 0X%.4X | %f V\n",fHVBoard[Board]->GetBoardNumber(),Chain, Channel, Target, Target, calib->DACToHV(Target,fHVBoard[Board]->GetBoardNumber(),Chain,Channel));
     610        PrintMessage("Board %d: high voltage of chain %d channel %d set to %d | 0X%.4X | %f V\n",fHVBoard[Board]->GetBoardNumber(),Chain, Channel, Target, Target, calib->DACToHV(Target,fHVBoard[Board]->GetBoardNumber(),Chain,Channel));
    623611        PrintBoardStatus(Board);
    624612      }
    625613    }
    626614    else {
    627       PrintMessage("ERROR - Could not set HV of board %d, chain %d, channel %d. Skipping channel\n",fHVBoard[Board]->GetBoardNumber(),Chain,Channel);
    628       SlowDataClass->NewEntry("Error");
    629       SlowDataClass->AddToEntry("%s %d %d %d %d %.2f ",fHVBoard[Board]->BoardName,Board, Chain, Channel, Target, calib->DACToHV(Target,Board,Chain,Channel));
     615      PrintMessage("Error: Could not set HV of board %d, chain %d, channel %d. Skipping channel\n",fHVBoard[Board]->GetBoardNumber(),Chain,Channel);
     616      //SlowDataClass->NewEntry("Error");
     617      //SlowDataClass->AddToEntry("%s %d %d %d %d %.2f ",fHVBoard[Board]->BoardName,Board, Chain, Channel, Target, calib->DACToHV(Target,Board,Chain,Channel));
    630618      return false;
    631619    }
    632620  }
    633   SlowDataClass->NewEntry("Value");
    634   SlowDataClass->AddToEntry("%s %d %d %d %d %.2f ",fHVBoard[Board]->BoardName,Board, Chain, Channel, Target, calib->DACToHV(Target,Board,Chain,Channel));
     621  //SlowDataClass->NewEntry("Value");
     622  //SlowDataClass->AddToEntry("%s %d %d %d %d %.2f ",fHVBoard[Board]->BoardName,Board, Chain, Channel, Target, calib->DACToHV(Target,Board,Chain,Channel));
    635623  return true;
    636624}
     
    676664}
    677665
    678 
    679 // Get index of board with sequential number board
    680 int ProcessIO::GetBoardIdx(int board) {
    681 
    682   for (int i=0; i<MAX_NUM_HVBOARDS; i++) {
    683     if (board == fHVBoard[i]->GetBoardNumber()) return i;
    684   }
    685   return -1;
    686 }
    687666
    688667// Print current board status
  • hvcontrol/src/ProcessIO.h

    r93 r100  
    3232  HVConfig    *config;
    3333  HVCalib     *calib;
    34   HVBoard* fHVBoard[MAX_NUM_HVBOARDS];
    35   SlowData* SlowDataClass;
     34  HVBoard **fHVBoard;
     35  SlowData *SlowDataClass;
    3636 
    3737  pthread_mutex_t control_mutex;
     
    7070  void Monitor();
    7171  void ResetBoard(int);
    72   int GetBoardIdx(int);
    7372  void PrintBoardStatus(int);
    7473  int ParseInput(char*, const char *Param[]);
Note: See TracChangeset for help on using the changeset viewer.