- Timestamp:
- 07/28/09 09:15:18 (15 years ago)
- Location:
- hvcontrol
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
hvcontrol/History.txt
r90 r93 17 17 option to set usage of DAC values. Instead, a third parameter 'dac' 18 18 to the 'hv' and 'hvdiff' commands chooses DAC values. 19 24/7/2009 Lockfile is deleted if configuration file cannot be read 20 27/7/2009 Slow data is written for every HV ramp to file given in configuration -
hvcontrol/Makefile
r90 r93 3 3 # 4 4 5 SOURCES = hvcontrol.cpp src/HV.cc src/HVConfig.cc src/HVCalib.cc src/ProcessIO.cc ../pixelmap/Pixel.cc ../pixelmap/PixelMap.cc 5 SOURCES = hvcontrol.cpp src/HV.cc src/HVConfig.cc src/HVCalib.cc src/ProcessIO.cc ../pixelmap/Pixel.cc ../pixelmap/PixelMap.cc ../drsdaq/SlowData.cc 6 6 OBJECTS = $(addsuffix .o, $(basename $(SOURCES))) 7 INCDIRS = -I. -I. ./pixelmap -I./src7 INCDIRS = -I. -I./src 8 8 9 9 CPPFLAGS = -O3 -Wall -DOS_LINUX -
hvcontrol/hvcontrol.cpp
r90 r93 5 5 reads and monitors status of the G-APD HV supply 6 6 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 16 9 \**************************************************************/ 17 10 … … 27 20 #include "ProcessIO.h" 28 21 29 #include <readline/readline.h> // Must be after including ftdi.h!22 #include <readline/readline.h> 30 23 #include <readline/history.h> 31 24 … … 48 41 int main(int argc, char *argv[]) { 49 42 50 char config_file[] = DEFAULT_CONFIG,str[MAX_COM_SIZE];43 char str[MAX_COM_SIZE]; 51 44 pthread_t thread_ConsoleCommand,thread_HVMonitor,thread_CCCommand; 52 45 int LockDescriptor; … … 93 86 94 87 // Construct main instance and create mutex for thread synchronization 95 ProcessIO pio( config_file);88 ProcessIO pio(argc==3 ? argv[2] : DEFAULT_CONFIG); 96 89 if (pthread_mutex_init(&pio.control_mutex, NULL) != 0) { 97 90 perror("pthread_mutex_init failed"); -
hvcontrol/src/HV.cc
r90 r93 12 12 13 13 #include "HV.h" 14 14 #include "ProcessIO.h" // Must be not in HV.h to avoid problem with declaring class ProcessIO 15 15 16 16 // Constructor 17 HVBoard::HVBoard(int DeviceNumber, char *DeviceName, bool TestMode, float TimeOut, bool verbose) {17 HVBoard::HVBoard(int DeviceNumber, char *DeviceName, class ProcessIO *PIO) { 18 18 19 19 char Buffer[BUFFER_LENGTH]; 20 20 struct termios tio; 21 21 22 fTestMode = TestMode; 22 m = PIO; 23 24 fTestMode = m->config->TestMode; 23 25 fTestModeWrap = 0; 24 25 SetTimeOut( TimeOut);26 27 SetTimeOut(m->config->fTimeOut); 26 28 BoardNumber = DeviceNumber; 27 29 BoardName = DeviceName; … … 42 44 snprintf(Buffer, BUFFER_LENGTH, "/dev/%s",DeviceName); 43 45 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)); 45 47 return; 46 48 } … … 48 50 // Get current serial port settings 49 51 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)); 51 53 return; 52 54 } 53 55 54 56 // 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)); 56 58 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)); 58 60 59 61 // Synchronize HV board (if fails, closes device and sets fDescriptor to -2) … … 62 64 63 65 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(); 66 68 return; 67 69 } … … 77 79 HVBoard::~HVBoard() { 78 80 if(fDescriptor >= 0 && !fTestMode) { 79 Reset( stdout, false);81 Reset(); 80 82 close(fDescriptor); 81 83 } … … 86 88 // 87 89 // Returns: 0 read error, 1 success, -1 fTimeOut exceeded 88 int HVBoard::Communicate( FILE* fptr, unsigned char* wbuf, int Bytes, bool verbose) {90 int HVBoard::Communicate(unsigned char* wbuf, int Bytes) { 89 91 90 92 unsigned char rbuf; … … 94 96 // === Write data === 95 97 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]); 102 104 } 103 105 … … 106 108 struct timeval WaitTime = {(long) fTimeOut, (long) ((fTimeOut-(long) fTimeOut)*1e6)}; 107 109 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)); 109 111 return 0; 110 112 } 111 113 // Time-out expired? 112 114 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); 114 116 return -1; 115 117 } 116 118 // Read error? 117 119 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)); 119 121 return 0; 120 122 } … … 129 131 ResetButton = (bool) (rbuf & 0X80); 130 132 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); 132 134 133 135 return 1; … … 136 138 137 139 /* Reset HV board - uses TRead() and has same return values */ 138 int HVBoard::Reset( FILE* fptr, bool verbose) {140 int HVBoard::Reset() { 139 141 140 142 if (fTestMode) return 1; … … 143 145 int ret; 144 146 145 if((ret = Communicate( fptr, wbuf, 3, verbose)) == 1) ClearVoltageArrays();147 if((ret = Communicate(wbuf, 3)) == 1) ClearVoltageArrays(); 146 148 return ret; 147 149 } … … 149 151 150 152 /* Read status register - uses TRead() and has same return values */ 151 int HVBoard::GetStatus( FILE* fptr, bool verbose) {153 int HVBoard::GetStatus() { 152 154 153 155 if (fTestMode) return 1; … … 155 157 unsigned char wbuf[] = {REG_STATUS,0,0}; 156 158 157 return Communicate( fptr, wbuf, 3, verbose);159 return Communicate(wbuf, 3); 158 160 } 159 161 160 162 161 163 /* 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) {164 int HVBoard::SetHV(int chain, unsigned int channel, unsigned int hv) { 163 165 164 166 if (fTestMode){ 165 printf("Test mode: Nothing to be done. \n");167 m->PrintMessage("Test mode: Nothing to be done. \n"); 166 168 return 1; 167 169 } … … 170 172 171 173 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"); 173 175 return 0; 174 176 } … … 180 182 case 3: wbuf[0] = REG_HV3; break; 181 183 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; 183 185 } 184 186 … … 189 191 wbuf[2] |= (unsigned char)(hv & 0X000000FF); // Add [D7-D0] 190 192 191 return Communicate( fptr, wbuf, 3, verbose);193 return Communicate(wbuf, 3); 192 194 } 193 195 -
hvcontrol/src/HV.h
r90 r93 9 9 #include <sys/ioctl.h> 10 10 11 #include <HVConfig.h>11 #include "HVConfig.h" 12 12 13 13 #define BAUDRATE B115200 … … 18 18 #define REG_HV2 0X30 19 19 #define REG_HV3 0X38 20 21 20 #define REG_RESET 0XF8 22 21 #define REG_STATUS 0X80 … … 27 26 #define BIT_OC2 (1<<5) 28 27 #define BIT_OC3 (1<<6) 29 30 28 #define BIT_RESET (1<<7) 31 29 30 class ProcessIO; 32 31 33 32 class HVBoard { … … 36 35 int fTestModeWrap; 37 36 bool fTestMode; 38 37 class ProcessIO *m; 38 39 39 public: 40 40 41 HVBoard(int, char *, bool, float, bool);41 HVBoard(int, char *, class ProcessIO *); 42 42 ~HVBoard(); 43 43 … … 54 54 55 55 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); 59 59 int GetBoardNumber() {return BoardNumber;} 60 int Communicate( FILE*, unsigned char*, int, bool);60 int Communicate(unsigned char*, int); 61 61 void SetTimeOut(double); 62 62 }; -
hvcontrol/src/HVConfig.cc
r90 r93 14 14 15 15 16 HVConfig::HVConfig( FILE* fptr,char *configfile) {16 HVConfig::HVConfig(const char *configfile) { 17 17 18 fLogFile = new char[BUFFER_LENGTH];19 18 fUSBDevice = new char*[MAX_NUM_HVBOARDS]; 20 19 21 fPixMapTable = new char[BUFFER_LENGTH];22 23 20 for (int i=0; i<MAX_NUM_HVBOARDS; i++) { 24 21 fUSBDevice[i] = new char[BUFFER_LENGTH]; 25 22 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 }30 23 } 31 24 32 25 TestMode = false; 33 26 NumHVBoards = 0; 34 FileName = configfile;35 27 fStatusRefreshRate = 1.; 36 28 fTimeOut = 1.; … … 39 31 fHVCalibOffset = -.8; 40 32 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 62 36 FILE *f; 63 37 char str[MAX_COM_SIZE], dev[MAX_COM_SIZE]; … … 65 39 66 40 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; 69 43 } 70 else fprintf(fptr,"Opening configuration file: %s\n", configfile);44 else printf("Opening configuration file: %s\n", configfile); 71 45 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 74 50 ReadCard("TestMode", &str, 's',f); 75 51 if (!strcmp(str,"TRUE")) TestMode = true; … … 95 71 96 72 fclose(f); 97 return 1;98 73 } 99 74 100 75 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; 76 HVConfig::~HVConfig() { 77 78 for (int i=0; i<MAX_NUM_HVBOARDS; i++) delete [] fUSBDevice[i]; 79 delete [] fUSBDevice; 123 80 } 81 124 82 125 83 // ReadCard function (original version by F. Goebel) -
hvcontrol/src/HVConfig.h
r90 r93 25 25 public: 26 26 27 HVConfig( FILE* fptr, char *configfile=NULL);27 HVConfig(const char *); 28 28 ~HVConfig(); 29 30 int ReadHVConfig(FILE* fptr, char *configfile);31 int PrintHVConfig(FILE* fptr);32 29 33 30 int NumHVBoards; … … 38 35 bool TestMode; 39 36 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]; 44 39 char** fUSBDevice; 45 40 46 char * fPixMapTable;41 char fPixMapTable[BUFFER_LENGTH]; 47 42 48 43 float fTimeOut; … … 56 51 57 52 unsigned int fHVMaxDiff; 58 59 53 }; 60 54 -
hvcontrol/src/ProcessIO.cc
r90 r93 14 14 static char* state_str[] = {"active", "stopped", "n.a."}; 15 15 16 ProcessIO::ProcessIO(char *ConfigFile) { 16 17 ProcessIO::ProcessIO(const char *ConfigFile) { 17 18 18 19 // Get program start time … … 20 21 21 22 // Create instances 22 config = new HVConfig( stdout,ConfigFile);23 config = new HVConfig(ConfigFile); 23 24 calib = new HVCalib(config); 24 25 pm = new PixelMap(config->fPixMapTable); … … 44 45 if(config->TestMode){ 45 46 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); 47 48 NumHVBoards++; 48 49 } 49 50 else { 50 51 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); 52 53 if(fHVBoard[NumHVBoards]->fDescriptor >= 0) { 53 54 printf("Synchronized and reset HV board %d (%s)\n",i,config->fUSBDevice[i]); … … 66 67 PrintMessage(MsgToLog,"********** Logging started **********\n"); 67 68 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"); 70 76 } 71 77 … … 75 81 for (int i=0; i<NumHVBoards; i++) delete fHVBoard[i]; 76 82 77 delete config; delete pm;83 delete SlowDataClass; delete config; delete pm; 78 84 79 85 if(Logfile != NULL) { … … 156 162 // Print HV utility configuration 157 163 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 161 184 return; 162 185 } … … 287 310 } 288 311 289 StopMonitor();290 291 312 while (fgets(Buffer, sizeof(Buffer), File) != NULL) { 292 313 for (int Board=0; Board<NumHVBoards; Board++) { … … 314 335 } // while() 315 336 316 StartMonitor();317 318 337 if (NBoards != NumHVBoards) { 319 338 PrintMessage("Warning: Could not load HV settings for all connected HV boards\n"); … … 333 352 double Rate; 334 353 335 if (!NumHVBoards) return;336 337 354 if (NParam != 2) { 338 355 PrintMessage("Usage: rate <Hz>\n"); … … 351 368 } 352 369 353 StopMonitor();354 370 fStatusRefreshRate = Rate; 355 371 PrintMessage("Refresh rate set to %.2f Hz\n", fStatusRefreshRate); 356 StartMonitor();357 372 358 373 return; … … 363 378 364 379 if (!NumHVBoards) return; 365 366 StopMonitor(); 367 ResetActiveBoards(); 368 StartMonitor(); 380 for (int i=FirstBoard; i<=LastBoard; i++) ResetBoard(i); 369 381 return; 370 382 } … … 416 428 else if (Match(Param[0], "start")) { 417 429 418 if (!NumHVBoards) return; 419 420 StartMonitor(); 430 state = active; 431 pthread_kill(HVMonitor, SIGUSR1); 421 432 PrintMessage("OK - status monitoring activated\n"); 422 423 433 return; 424 434 } … … 463 473 else if (Match(Param[0], "stop")) { 464 474 465 if (!NumHVBoards) return; 466 467 StopMonitor(); 475 state = stopped; 476 pthread_kill(HVMonitor, SIGUSR1); 468 477 PrintMessage("Status monitor stopped\n"); 469 478 … … 594 603 bool ProcessIO::RampVoltage(unsigned int Target, int Board, int Chain, int Channel) { 595 604 596 int Diff;597 598 605 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]; 600 607 if (Diff > (int) config->fHVMaxDiff) Diff = config->fHVMaxDiff; 601 608 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) { 603 610 fHVBoard[Board]->HV[Chain][Channel] += Diff; 604 611 … … 610 617 else { 611 618 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)); 612 621 return false; 613 622 } 614 623 } 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)); 615 626 return true; 616 627 } 617 628 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 632 631 void ProcessIO::Monitor() { 633 632 634 633 for (int i=0; i<NumHVBoards; i++) { 635 634 636 if (fHVBoard[i]->GetStatus( stdout,false)!=1) {635 if (fHVBoard[i]->GetStatus() != 1) { 637 636 PrintMessage("Error: Monitor, could not read status of board %d\n", fHVBoard[i]->GetBoardNumber()); 638 637 } … … 653 652 } 654 653 } 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 665 660 void ProcessIO::ResetBoard(int i) { 666 661 667 if (fHVBoard[i]->Reset( stdout,Verbose) == 1) {662 if (fHVBoard[i]->Reset() == 1) { 668 663 PrintMessage("Reset of board %d\n", fHVBoard[i]->GetBoardNumber()); 669 664 PrintBoardStatus(i); … … 673 668 674 669 670 // Get index of board with sequential number board 675 671 int ProcessIO::GetBoardIdx(int board) { 676 672 … … 681 677 } 682 678 683 679 // Print current board status 684 680 void ProcessIO::PrintBoardStatus(int i) { 685 681 … … 716 712 } 717 713 714 718 715 // Check if two strings match (min 1 character must match) 719 716 bool Match(const char *str, const char *cmd) { … … 721 718 } 722 719 720 723 721 // Convert string to double 724 722 // Returns false if conversion did not stop on whitespace or EOL character -
hvcontrol/src/ProcessIO.h
r90 r93 12 12 #include "HV.h" 13 13 #include "../pixelmap/PixelMap.h" 14 #include "../drsdaq/SlowData.h" 14 15 15 16 #define MAX_NUM_TOKEN 10 … … 32 33 HVCalib *calib; 33 34 HVBoard* fHVBoard[MAX_NUM_HVBOARDS]; 34 35 SlowData* SlowDataClass; 36 35 37 pthread_mutex_t control_mutex; 36 38 … … 58 60 59 61 // Methods 60 ProcessIO(c har *);62 ProcessIO(const char *); 61 63 ~ProcessIO(); 62 64 … … 66 68 void CommandControl(char*); 67 69 bool RampVoltage(unsigned int, int, int, int); 68 void StartMonitor();69 void StopMonitor();70 70 void Monitor(); 71 void ResetActiveBoards();72 71 void ResetBoard(int); 73 72 int GetBoardIdx(int); 74 75 73 void PrintBoardStatus(int); 76 77 74 int ParseInput(char*, const char *Param[]); 78 75 };
Note:
See TracChangeset
for help on using the changeset viewer.