Changeset 93 for hvcontrol


Ignore:
Timestamp:
07/28/09 09:15:18 (15 years ago)
Author:
ogrimm
Message:
Added writing of slow data
Location:
hvcontrol
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • hvcontrol/History.txt

    r90 r93  
    1717            option to set usage of DAC values. Instead, a third parameter 'dac'
    1818            to the 'hv' and 'hvdiff' commands chooses DAC values.
     1924/7/2009   Lockfile is deleted if configuration file cannot be read
     2027/7/2009   Slow data is written for every HV ramp to file given in configuration
  • hvcontrol/Makefile

    r90 r93  
    33#
    44
    5 SOURCES = hvcontrol.cpp src/HV.cc src/HVConfig.cc src/HVCalib.cc src/ProcessIO.cc ../pixelmap/Pixel.cc ../pixelmap/PixelMap.cc
     5SOURCES = hvcontrol.cpp src/HV.cc src/HVConfig.cc src/HVCalib.cc src/ProcessIO.cc ../pixelmap/Pixel.cc ../pixelmap/PixelMap.cc ../drsdaq/SlowData.cc
    66OBJECTS = $(addsuffix .o, $(basename $(SOURCES)))
    7 INCDIRS   = -I. -I../pixelmap -I./src
     7INCDIRS   = -I. -I./src
    88
    99CPPFLAGS = -O3 -Wall -DOS_LINUX
  • hvcontrol/hvcontrol.cpp

    r90 r93  
    55  reads and monitors status of the G-APD HV supply
    66
    7   Name:         hvcontrol.cpp
    8 
    9   Actions:      Do global initialization, start threads 
    10 
    11   Created by:   Sebastian Commichau, November 2008
    12                 commichau@phys.ethz.ch
    13   Updated by:   Sabrina Stark, June 2008
    14                 sabrina.stark@phys.ethz.ch
    15 
     7  Sebastian Commichau, Sabrina Stark, Oliver Grimm
     8 
    169\**************************************************************/
    1710
     
    2720#include "ProcessIO.h"
    2821
    29 #include <readline/readline.h>  // Must be after including ftdi.h!
     22#include <readline/readline.h>
    3023#include <readline/history.h>
    3124
     
    4841int main(int argc, char *argv[]) {
    4942
    50   char config_file[] = DEFAULT_CONFIG, str[MAX_COM_SIZE];
     43  char str[MAX_COM_SIZE];
    5144  pthread_t thread_ConsoleCommand,thread_HVMonitor,thread_CCCommand;
    5245  int LockDescriptor;
     
    9386
    9487  // Construct main instance and create mutex for thread synchronization
    95   ProcessIO pio(config_file);
     88  ProcessIO pio(argc==3 ? argv[2] : DEFAULT_CONFIG);
    9689  if (pthread_mutex_init(&pio.control_mutex, NULL) != 0) {
    9790    perror("pthread_mutex_init failed");
  • hvcontrol/src/HV.cc

    r90 r93  
    1212
    1313#include "HV.h"
    14 
     14#include "ProcessIO.h" // Must be not in HV.h to avoid problem with declaring class ProcessIO
    1515
    1616// Constructor
    17 HVBoard::HVBoard(int DeviceNumber, char *DeviceName, bool TestMode, float TimeOut, bool verbose) {
     17HVBoard::HVBoard(int DeviceNumber, char *DeviceName, class ProcessIO *PIO) {
    1818   
    1919  char Buffer[BUFFER_LENGTH];
    2020  struct termios tio;
    2121 
    22   fTestMode = TestMode;
     22  m = PIO;
     23
     24  fTestMode = m->config->TestMode;
    2325  fTestModeWrap = 0;
    24 
    25   SetTimeOut(TimeOut);
     26 
     27  SetTimeOut(m->config->fTimeOut);
    2628  BoardNumber = DeviceNumber;
    2729  BoardName = DeviceName;
     
    4244  snprintf(Buffer, BUFFER_LENGTH, "/dev/%s",DeviceName);
    4345  if ((fDescriptor = open(Buffer, O_RDWR|O_NOCTTY|O_NDELAY)) == -1) {
    44     if(errno != 2) printf("Error: Could not open device %d/%s (%s)\n", DeviceNumber,DeviceName, strerror(errno));
     46    if(errno != 2) m->PrintMessage("Error: Could not open device %d/%s (%s)\n", DeviceNumber,DeviceName, strerror(errno));
    4547    return;
    4648  }
     
    4850  // Get current serial port settings
    4951  if (tcgetattr(fDescriptor, &tio) == -1) {
    50     printf("tcgetattr(...) failed (%d/%s)\n", errno, strerror(errno));
     52    m->PrintMessage("Error: tcgetattr() failed (%d/%s)\n", errno, strerror(errno));
    5153    return;   
    5254  }
    5355
    5456  // Set baudrate and raw mode
    55   if (cfsetspeed(&tio, BAUDRATE) == -1) printf("Error: Could not set baud rate (%s)\n", strerror(errno));
     57  if (cfsetspeed(&tio, BAUDRATE) == -1) m->PrintMessage("Error: Could not set baud rate (%s)\n", strerror(errno));
    5658  cfmakeraw(&tio);
    57   if (tcsetattr(fDescriptor, TCSANOW, &tio ) == -1) printf("Errsor with tcsetattr(...) (%s)\n", strerror(errno));
     59  if (tcsetattr(fDescriptor, TCSANOW, &tio ) == -1) m->PrintMessage("Error: tcsetattr() failed (%s)\n", strerror(errno));
    5860
    5961  //  Synchronize HV board (if fails, closes device and sets fDescriptor to -2)
     
    6264 
    6365  while(++trial<=3) {
    64     if((ret = Communicate(stdout, &wbuf, 1, verbose)) == 1) {
    65       Reset(stdout, verbose);
     66    if((ret = Communicate(&wbuf, 1)) == 1) {
     67      Reset();
    6668      return;
    6769    }
     
    7779HVBoard::~HVBoard() {
    7880  if(fDescriptor >= 0 && !fTestMode) {
    79     Reset(stdout, false);
     81    Reset();
    8082    close(fDescriptor);
    8183  }
     
    8688//
    8789// Returns: 0 read error, 1 success, -1 fTimeOut exceeded
    88 int HVBoard::Communicate(FILE* fptr, unsigned char* wbuf, int Bytes, bool verbose) {
     90int HVBoard::Communicate(unsigned char* wbuf, int Bytes) {
    8991
    9092  unsigned char rbuf;
     
    9496  // === Write data ===
    9597  if (write(fDescriptor, wbuf, Bytes) < Bytes) {
    96     fprintf(fptr," Error: could not write (all) data to HV board\n");
    97     return 0;
    98   }
    99   if (verbose) {
    100     fprintf(fptr,"%d bytes written:\n", Bytes);
    101     for (int i=0; i<Bytes; i++) fprintf(fptr," Byte %d: %#.2x\n",i,wbuf[i]);
     98    m->PrintMessage("Error: could not write (all) data to HV board\n");
     99    return 0;
     100  }
     101  if (m->Verbose) {
     102    m->PrintMessage("%d bytes written:\n", Bytes);
     103    for (int i=0; i<Bytes; i++) m->PrintMessage(" Byte %d: %#.2x\n",i,wbuf[i]);
    102104  }
    103105
     
    106108  struct timeval WaitTime = {(long) fTimeOut, (long) ((fTimeOut-(long) fTimeOut)*1e6)};
    107109  if (select(fDescriptor+1, &SelectDescriptor, NULL, NULL, &WaitTime)==-1) {
    108     printf("Error with select() (%d/%s)\n", errno,strerror(errno));
     110    m->PrintMessage("Error with select() (%d/%s)\n", errno,strerror(errno));
    109111    return 0;
    110112  }
    111113  // Time-out expired?
    112114  if (!FD_ISSET(fDescriptor, &SelectDescriptor)) {
    113     if (verbose) printf("Time-out of %.2f seconds expired while reading\n", fTimeOut);
     115    if (m->Verbose) m->PrintMessage("Time-out of %.2f seconds expired while reading\n", fTimeOut);
    114116    return -1;
    115117  }
    116118  // Read error?   
    117119  if ((ret = read(fDescriptor, &rbuf, 1)) == -1) {
    118     fprintf(stderr, " Read error (%s)\n", strerror(errno));
     120    m->PrintMessage("Read error (%s)\n", strerror(errno));
    119121    return 0;
    120122  }
     
    129131  ResetButton = (bool) (rbuf & 0X80);
    130132
    131   if (verbose && ret==1) fprintf(fptr," 1 byte read: %#.2x\n", rbuf); 
     133  if (m->Verbose && ret==1) m->PrintMessage(" 1 byte read: %#.2x\n", rbuf); 
    132134 
    133135  return 1;
     
    136138
    137139/* Reset HV board - uses TRead() and has same return values */
    138 int HVBoard::Reset(FILE* fptr, bool verbose) {
     140int HVBoard::Reset() {
    139141 
    140142  if (fTestMode) return 1;
     
    143145  int ret;
    144146 
    145   if((ret = Communicate(fptr, wbuf, 3, verbose)) == 1) ClearVoltageArrays(); 
     147  if((ret = Communicate(wbuf, 3)) == 1) ClearVoltageArrays(); 
    146148  return ret;
    147149}
     
    149151
    150152/* Read status register - uses TRead() and has same return values */
    151 int HVBoard::GetStatus(FILE* fptr, bool verbose) {
     153int HVBoard::GetStatus() {
    152154
    153155  if (fTestMode) return 1;
     
    155157  unsigned char wbuf[] = {REG_STATUS,0,0};
    156158 
    157   return Communicate(fptr, wbuf, 3, verbose);
     159  return Communicate(wbuf, 3);
    158160}
    159161
    160162
    161163/* Set high voltage - uses TRead() and has same return values */
    162 int HVBoard::SetHV(FILE* fptr, int chain, unsigned int channel, unsigned int hv, bool verbose) {
     164int HVBoard::SetHV(int chain, unsigned int channel, unsigned int hv) {
    163165
    164166  if (fTestMode){
    165     printf("Test mode: Nothing to be done. \n");
     167    m->PrintMessage("Test mode: Nothing to be done. \n");
    166168    return 1;
    167169  }
     
    170172
    171173  if (!(hv>=0 && hv<=0x3FFF)) {
    172     fprintf(fptr," Error: HV beyond limits [0 - 0x3FFF]\n");
     174    m->PrintMessage(" Error: HV beyond limits [0 - 0x3FFF]\n");
    173175    return 0;
    174176  }
     
    180182    case 3: wbuf[0] = REG_HV3; break;
    181183
    182     default : fprintf(fptr," Error: chain %d does not exist\n",chain); return 0;
     184    default : m->PrintMessage(" Error: chain %d does not exist\n",chain); return 0;
    183185  }
    184186 
     
    189191  wbuf[2] |= (unsigned char)(hv & 0X000000FF);              // Add [D7-D0]
    190192   
    191   return Communicate(fptr, wbuf, 3, verbose);
     193  return Communicate(wbuf, 3);
    192194}
    193195
  • hvcontrol/src/HV.h

    r90 r93  
    99#include <sys/ioctl.h>
    1010
    11 #include <HVConfig.h>
     11#include "HVConfig.h"
    1212
    1313#define BAUDRATE B115200
     
    1818#define REG_HV2     0X30
    1919#define REG_HV3     0X38
    20 
    2120#define REG_RESET   0XF8
    2221#define REG_STATUS  0X80
     
    2726#define BIT_OC2    (1<<5)
    2827#define BIT_OC3    (1<<6)
    29 
    3028#define BIT_RESET  (1<<7)
    3129
     30class ProcessIO;
    3231
    3332class HVBoard {
     
    3635   int fTestModeWrap;
    3736   bool fTestMode;
    38 
     37   class ProcessIO *m;
     38   
    3939 public:
    4040 
    41    HVBoard(int, char *, bool, float, bool);
     41   HVBoard(int, char *, class ProcessIO *);
    4242   ~HVBoard();
    4343
     
    5454
    5555   void ClearVoltageArrays();
    56    int Reset(FILE*, bool);
    57    int GetStatus(FILE*, bool);
    58    int SetHV(FILE*, int, unsigned int, unsigned int, bool);
     56   int Reset();
     57   int GetStatus();
     58   int SetHV(int, unsigned int, unsigned int);
    5959   int GetBoardNumber() {return BoardNumber;}
    60    int Communicate(FILE*, unsigned char*, int, bool);
     60   int Communicate(unsigned char*, int);
    6161   void SetTimeOut(double);
    6262};
  • hvcontrol/src/HVConfig.cc

    r90 r93  
    1414
    1515
    16 HVConfig::HVConfig(FILE* fptr, char *configfile) {
     16HVConfig::HVConfig(const char *configfile) {
    1717
    18   fLogFile   = new char[BUFFER_LENGTH];
    1918  fUSBDevice = new char*[MAX_NUM_HVBOARDS];
    2019
    21   fPixMapTable = new char[BUFFER_LENGTH];
    22    
    2320  for (int i=0; i<MAX_NUM_HVBOARDS; i++) {
    2421    fUSBDevice[i]      = new char[BUFFER_LENGTH];
    2522    USBDeviceNumber[i] = 0;
    26 
    27     for (int j=0; j<NUM_CHAINS; j++) {
    28       for (int k=0; k<2; k++) Coef[i][j][k] = 0.;
    29     }
    3023  }
    3124
    3225  TestMode           = false;
    3326  NumHVBoards        = 0;
    34   FileName           = configfile;
    3527  fStatusRefreshRate = 1.;
    3628  fTimeOut           = 1.;
     
    3931  fHVCalibOffset      = -.8;
    4032  fHVCalibSlope       = 0.0064;
    41   fHVMaxDiff          = 1; 
    42 
    43   if (configfile != NULL) {
    44     if (!ReadHVConfig(fptr, configfile)) {
    45       fprintf(fptr, "Error (HVConfig): could not configure HV control\n");
    46       exit(1);
    47     }
    48   }
    49 }
    50 
    51 
    52 HVConfig::~HVConfig() {
    53 
    54   delete [] fLogFile;   delete [] fPixMapTable;
    55   for (int i=0; i<MAX_NUM_HVBOARDS; i++) delete [] fUSBDevice[i];
    56   delete [] fUSBDevice;
    57 }
    58 
    59 
    60 int HVConfig::ReadHVConfig(FILE* fptr, char *configfile) {
    61 
     33  fHVMaxDiff          = 1;
     34 
     35  // Read configuration file
    6236  FILE *f;
    6337  char str[MAX_COM_SIZE], dev[MAX_COM_SIZE];
     
    6539
    6640  if ((f = fopen(configfile,"r")) == NULL) {
    67     fprintf(fptr,"Could not open configuration file: %s\n", configfile);
    68     return 0;
     41    printf("Could not open configuration file: %s\n", configfile);
     42    throw;
    6943  }
    70   else fprintf(fptr,"Opening configuration file: %s\n", configfile);
     44  else printf("Opening configuration file: %s\n", configfile);
    7145 
    72   ReadCard("LogFile",    fLogFile,    's',f);
    73   ReadCard("PixMapTable",fPixMapTable,'s',f);
     46  ReadCard("LogFile",       fLogFile,    's',f);
     47  ReadCard("PixMapTable",   fPixMapTable,'s',f);
     48  ReadCard("SlowDirectory", fSlowDir,    's',f);
     49 
    7450  ReadCard("TestMode",   &str,        's',f);
    7551  if (!strcmp(str,"TRUE")) TestMode = true;
     
    9571
    9672  fclose(f);
    97   return 1;
    9873}
    9974
    10075
    101 int HVConfig::PrintHVConfig(FILE *fptr) {
    102  
    103   fprintf(fptr," \n HV control configuration (%s):\n\n", FileName);
    104   fprintf(fptr," Log file:          %s\n", fLogFile);
    105   fprintf(fptr," Pixel map table:   %s\n", fPixMapTable);
    106   fprintf(fptr," Test mode:         %s\n", TestMode ? "yes" : "no");
    107   fprintf(fptr," %d USB devices:\n", NumHVBoards);
    108  
    109   for (int i=0;i<NumHVBoards;i++)
    110     fprintf(fptr," Board%d: %s\n", USBDeviceNumber[i], fUSBDevice[i]);
    111  
    112   fprintf(fptr,"\n");
    113   fprintf(fptr," TimeOut:           %.2f s\n",   fTimeOut);
    114   fprintf(fptr," StatusRefreshRate: %.2f Hz\n",fStatusRefreshRate);
    115   fprintf(fptr," CCPort:            %d\n",       fCCPort);
    116   fprintf(fptr," DACMin value:      %d\n",     DACMin);
    117   fprintf(fptr," DACMax value:      %d\n",     DACMax);
    118   fprintf(fptr," HVCalibOffset :    %f\n",     fHVCalibOffset);
    119   fprintf(fptr," HVCalibSlope :     %f\n",     fHVCalibSlope);
    120   fprintf(fptr," HVMaxDiff :        %u\n",     fHVMaxDiff);
    121  
    122   return 1;
     76HVConfig::~HVConfig() {
     77
     78  for (int i=0; i<MAX_NUM_HVBOARDS; i++) delete [] fUSBDevice[i];
     79  delete [] fUSBDevice;
    12380}
     81
    12482
    12583// ReadCard function (original version by F. Goebel)
  • hvcontrol/src/HVConfig.h

    r90 r93  
    2525 public:
    2626
    27   HVConfig(FILE* fptr, char *configfile=NULL);
     27  HVConfig(const char *);
    2828  ~HVConfig();
    29 
    30   int ReadHVConfig(FILE* fptr, char *configfile);
    31   int PrintHVConfig(FILE* fptr);
    3229
    3330  int NumHVBoards;
     
    3835  bool TestMode;
    3936
    40   float Coef[MAX_NUM_HVBOARDS][NUM_CHAINS][2];
    41  
    42   char*  FileName;
    43   char*  fLogFile;
     37  char   fLogFile[BUFFER_LENGTH];
     38  char   fSlowDir[BUFFER_LENGTH];
    4439  char** fUSBDevice;
    4540
    46   char*  fPixMapTable;
     41  char   fPixMapTable[BUFFER_LENGTH];
    4742 
    4843  float  fTimeOut;
     
    5651 
    5752  unsigned int  fHVMaxDiff;
    58 
    5953};
    6054
  • hvcontrol/src/ProcessIO.cc

    r90 r93  
    1414static char* state_str[]    = {"active", "stopped", "n.a."};
    1515
    16 ProcessIO::ProcessIO(char *ConfigFile) {
     16
     17ProcessIO::ProcessIO(const char *ConfigFile) {
    1718
    1819  // Get program start time
     
    2021
    2122  // Create instances
    22   config = new HVConfig(stdout,ConfigFile);
     23  config = new HVConfig(ConfigFile);
    2324  calib  = new HVCalib(config);
    2425  pm     = new PixelMap(config->fPixMapTable);
     
    4445  if(config->TestMode){
    4546    fprintf(stdout,"Test mode: One HVBoard initialized as dummy.\n");
    46     fHVBoard[NumHVBoards] = new HVBoard(0, 0, config->TestMode, config->fTimeOut, Verbose);
     47    fHVBoard[NumHVBoards] = new HVBoard(0, 0, this);
    4748    NumHVBoards++;
    4849  }
    4950  else {
    5051    for (int i=0; i<config->NumHVBoards; i++) {
    51       fHVBoard[NumHVBoards] = new HVBoard(config->USBDeviceNumber[i], config->fUSBDevice[i], config->TestMode, config->fTimeOut, Verbose);
     52      fHVBoard[NumHVBoards] = new HVBoard(config->USBDeviceNumber[i], config->fUSBDevice[i], this);
    5253      if(fHVBoard[NumHVBoards]->fDescriptor >= 0) {
    5354         printf("Synchronized and reset HV board %d (%s)\n",i,config->fUSBDevice[i]);
     
    6667  PrintMessage(MsgToLog,"********** Logging started **********\n");
    6768
    68   // Print configuration to log file
    69   if(Logfile) config->PrintHVConfig(Logfile);
     69  // Create instance of slow data class
     70  SlowDataClass = new SlowData("HV", config->fSlowDir);
     71  if (SlowDataClass->ErrorCode != 0) {
     72    PrintMessage("Warning: Could not open slowdata file (%s)\n", strerror(SlowDataClass->ErrorCode));
     73  }
     74  SlowDataClass->NewEntry("Value-Info", "Issued if new HV value set successfull: Board-Num HV-Board-Name Chain Channel DAC-Target Converted-Value");
     75  SlowDataClass->NewEntry("Error-Info", "Issued if error occurs when trying to set new HV value: Board-Num HV-Board-Name Chain Channel Attempted-DAC-Target Converted-Value");
    7076}
    7177
     
    7581  for (int i=0; i<NumHVBoards; i++) delete fHVBoard[i];
    7682
    77   delete config;    delete pm;
     83  delete SlowDataClass;   delete config;    delete pm;
    7884 
    7985  if(Logfile != NULL) {
     
    156162  // Print HV utility configuration
    157163  else if (Match(Param[0], "config")) {
    158 
    159     config->PrintHVConfig(stdout);
    160    
     164    PrintMessage( " Log file:          %s\n"
     165                  " Pixel map table:   %s\n"
     166                  " Test mode:         %s\n"
     167                  " %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"
     173                  " StatusRefreshRate: %.2f Hz\n"
     174                  " CCPort:            %d\n"
     175                  " DACMin value:      %d\n"
     176                  " DACMax value:      %d\n"
     177                  " HVCalibOffset :    %f\n"
     178                  " HVCalibSlope :     %f\n"
     179                  " HVMaxDiff :        %u\n", config->fTimeOut,
     180                  config->fStatusRefreshRate, config->fCCPort, config->DACMin,
     181                  config->DACMax, config->fHVCalibOffset, config->fHVCalibSlope,
     182                  config->fHVMaxDiff);
     183
    161184    return;
    162185  }
     
    287310    }
    288311       
    289     StopMonitor();
    290 
    291312    while (fgets(Buffer, sizeof(Buffer), File) != NULL) {
    292313      for (int Board=0; Board<NumHVBoards; Board++) {
     
    314335    } // while()
    315336           
    316     StartMonitor();
    317        
    318337    if (NBoards != NumHVBoards) {
    319338      PrintMessage("Warning: Could not load HV settings for all connected HV boards\n");
     
    333352    double Rate;
    334353   
    335     if (!NumHVBoards) return;
    336 
    337354    if (NParam != 2) {
    338355      PrintMessage("Usage: rate <Hz>\n");
     
    351368    }
    352369
    353     StopMonitor();
    354370    fStatusRefreshRate = Rate;
    355371    PrintMessage("Refresh rate set to %.2f Hz\n", fStatusRefreshRate);
    356     StartMonitor();
    357372
    358373    return;
     
    363378
    364379    if (!NumHVBoards) return;
    365 
    366     StopMonitor();
    367     ResetActiveBoards();
    368     StartMonitor();
     380    for (int i=FirstBoard; i<=LastBoard; i++) ResetBoard(i);
    369381    return;
    370382  }
     
    416428  else if (Match(Param[0], "start")) {
    417429
    418     if (!NumHVBoards) return;
    419    
    420     StartMonitor();
     430    state = active;
     431    pthread_kill(HVMonitor, SIGUSR1);
    421432    PrintMessage("OK - status monitoring activated\n");
    422 
    423433    return; 
    424434  }
     
    463473  else if (Match(Param[0], "stop")) {
    464474
    465     if (!NumHVBoards) return;
    466    
    467     StopMonitor();   
     475    state = stopped;
     476    pthread_kill(HVMonitor, SIGUSR1);
    468477    PrintMessage("Status monitor stopped\n");
    469478
     
    594603bool ProcessIO::RampVoltage(unsigned int Target, int Board, int Chain, int Channel) {
    595604
    596   int Diff;
    597  
    598605  while (fHVBoard[Board]->HV[Chain][Channel] != (int) Target) {   
    599     Diff = Target - fHVBoard[Board]->HV[Chain][Channel];
     606    int Diff = Target - fHVBoard[Board]->HV[Chain][Channel];
    600607    if (Diff > (int) config->fHVMaxDiff) Diff = config->fHVMaxDiff;
    601608
    602     if (fHVBoard[Board]->SetHV(stdout, Chain, Channel, fHVBoard[Board]->HV[Chain][Channel]+Diff, Verbose)==1) {
     609    if (fHVBoard[Board]->SetHV(Chain, Channel, fHVBoard[Board]->HV[Chain][Channel]+Diff) == 1) {
    603610      fHVBoard[Board]->HV[Chain][Channel] += Diff;
    604611
     
    610617    else {
    611618      PrintMessage("ERROR - Could not set HV of board %d, chain %d, channel %d. Skipping channel\n",fHVBoard[Board]->GetBoardNumber(),Chain,Channel);
     619      SlowDataClass->NewEntry("Error");
     620      SlowDataClass->AddToEntry("%s %d %d %d %d %.2f ",fHVBoard[Board]->BoardName,Board, Chain, Channel, Target, calib->DACToHV(Target,Board,Chain,Channel));
    612621      return false;
    613622    }
    614623  }
     624  SlowDataClass->NewEntry("Value");
     625  SlowDataClass->AddToEntry("%s %d %d %d %d %.2f ",fHVBoard[Board]->BoardName,Board, Chain, Channel, Target, calib->DACToHV(Target,Board,Chain,Channel));
    615626  return true;
    616627}
    617628
    618 void ProcessIO::StartMonitor() {
    619 
    620   state = active;
    621   pthread_kill(HVMonitor, SIGUSR1);
    622 }
    623 
    624 
    625 void ProcessIO::StopMonitor() {
    626 
    627   state = stopped;
    628   pthread_kill(HVMonitor, SIGUSR1);
    629 }
    630 
    631 
     629
     630// Check board status
    632631void ProcessIO::Monitor() {
    633632
    634633  for (int i=0; i<NumHVBoards; i++) {
    635634
    636     if (fHVBoard[i]->GetStatus(stdout,false)!=1) {
     635    if (fHVBoard[i]->GetStatus() != 1) {
    637636      PrintMessage("Error: Monitor, could not read status of board %d\n", fHVBoard[i]->GetBoardNumber());
    638637    }
     
    653652      }
    654653    }
    655   }
    656 }
    657 
    658 
    659 void ProcessIO::ResetActiveBoards() {
    660  
    661   for (int i=FirstBoard; i<=LastBoard; i++) ResetBoard(i);
    662 }
    663 
    664 
     654   
     655  }
     656}
     657
     658
     659// Send reset to board and clear voltage arrays
    665660void ProcessIO::ResetBoard(int i) {
    666661   
    667   if (fHVBoard[i]->Reset(stdout,Verbose) == 1) {
     662  if (fHVBoard[i]->Reset() == 1) {
    668663    PrintMessage("Reset of board %d\n", fHVBoard[i]->GetBoardNumber());
    669664    PrintBoardStatus(i);
     
    673668
    674669
     670// Get index of board with sequential number board
    675671int ProcessIO::GetBoardIdx(int board) {
    676672
     
    681677}
    682678
    683 
     679// Print current board status
    684680void ProcessIO::PrintBoardStatus(int i) {
    685681
     
    716712}
    717713
     714
    718715// Check if two strings match (min 1 character must match)
    719716bool Match(const char *str, const char *cmd) {
     
    721718}
    722719
     720
    723721// Convert string to double
    724722// Returns false if conversion did not stop on whitespace or EOL character
  • hvcontrol/src/ProcessIO.h

    r90 r93  
    1212#include "HV.h"
    1313#include "../pixelmap/PixelMap.h"
     14#include "../drsdaq/SlowData.h"
    1415
    1516#define MAX_NUM_TOKEN 10
     
    3233  HVCalib     *calib;
    3334  HVBoard* fHVBoard[MAX_NUM_HVBOARDS];
    34 
     35  SlowData* SlowDataClass;
     36 
    3537  pthread_mutex_t control_mutex;
    3638
     
    5860   
    5961  // Methods
    60   ProcessIO(char *);
     62  ProcessIO(const char *);
    6163  ~ProcessIO();
    6264
     
    6668  void CommandControl(char*);
    6769  bool RampVoltage(unsigned int, int, int, int);
    68   void StartMonitor();
    69   void StopMonitor();
    7070  void Monitor();
    71   void ResetActiveBoards();
    7271  void ResetBoard(int);
    7372  int GetBoardIdx(int);
    74 
    7573  void PrintBoardStatus(int);
    76 
    7774  int ParseInput(char*, const char *Param[]);
    7875};
Note: See TracChangeset for help on using the changeset viewer.