Changeset 183 for hvcontrol/src
- Timestamp:
- 03/12/10 15:54:15 (15 years ago)
- Location:
- hvcontrol/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
hvcontrol/src/HV.cc
r161 r183 30 30 Name = new DimService (Buffer, BoardName); 31 31 32 for (int i=0; i<NUM_CHAINS; i++) { 33 for (int j=0; j<NUM_CHANNELS; j++) { 34 snprintf(Buffer, sizeof(Buffer), SERVER_NAME"/VOLT/ID%.2d/%.2d-%.3d", BoardNumber, i, j); 35 BiasVolt[i][j] = new DimService (Buffer, HVV[i][j]); 36 } 37 Overcurrent[i] = false; 38 } 32 snprintf(Buffer, sizeof(Buffer), SERVER_NAME"/VOLT/ID%.2d", BoardNumber); 33 BiasVolt = new DimService (Buffer, "D", HVV, NUM_CHAINS*NUM_CHANNELS*sizeof(double)); 34 35 for (int i=0; i<NUM_CHAINS; i++) Overcurrent[i] = false; 39 36 ResetButton = false; 40 37 WrapOK = true; … … 87 84 88 85 delete Name; 89 for (int i=0; i<NUM_CHAINS; i++) { 90 for (int j=0; j<NUM_CHANNELS; j++) { 91 delete BiasVolt[i][j]; 92 } 93 } 86 delete BiasVolt; 94 87 } 95 88 … … 202 195 for (int k=0; k<NUM_CHANNELS; k++){ 203 196 HV[j][k] = 0; 204 HVV[j][k] = 0.0; 205 206 // Update DIM services 207 BiasVolt[j][k]->updateService(); 197 HVV[j][k] = 0.0; 208 198 } 209 199 } 200 // Update DIM services 201 BiasVolt->updateService(); 210 202 } 211 203 -
hvcontrol/src/HV.h
r161 r183 55 55 56 56 DimService *Name; 57 DimService *BiasVolt [NUM_CHAINS][NUM_CHANNELS];57 DimService *BiasVolt; 58 58 59 59 void ClearVoltageArrays(); -
hvcontrol/src/ProcessIO.cc
r161 r183 14 14 static char* state_str[] = {"active", "stopped", "n.a."}; 15 15 16 17 ProcessIO::ProcessIO(const char *ConfigFile): 16 ProcessIO::ProcessIO(): 18 17 DimCommand((char *) SERVER_NAME"/Command", (char *) "C"), 19 18 EvidenceServer(SERVER_NAME) { … … 24 23 // Create DIM text output service 25 24 Textout = new DimService (SERVER_NAME"/Textout", (char *) ""); 25 UpdateDelay = 0.0; 26 26 27 27 // Initialize status variables 28 28 state = active; 29 29 Exit = false; 30 CmdFromSocket = false;31 Socket = -1;32 30 33 31 NumHVBoards = 0; … … 38 36 39 37 // Get configuration data 40 char *Boards = GetConfig(SERVER_NAME " Boards"); 41 fPixMapTable = GetConfig(SERVER_NAME " PixMapTable"); 42 fTimeOut = atof(GetConfig(SERVER_NAME " TimeOut")); 43 fStatusRefreshRate = atof(GetConfig(SERVER_NAME " StatusRefreshRate")); 44 fCCPort = atoi(GetConfig(SERVER_NAME " CCPort")); 45 DACMin = atoi(GetConfig(SERVER_NAME " DACMin")); 46 DACMax = atoi(GetConfig(SERVER_NAME " DACMax")); 47 fHVCalibOffset = atof(GetConfig(SERVER_NAME " HVCalibOffset")); 48 fHVCalibSlope = atof(GetConfig(SERVER_NAME " HVCalibSlope")); 49 fHVMaxDiff = atoi(GetConfig(SERVER_NAME " HVMaxDiff")); 38 char *Boards = GetConfig("Boards"); 39 fPixMapTable = GetConfig("PixMapTable"); 40 fTimeOut = atof(GetConfig("TimeOut")); 41 fStatusRefreshRate = atof(GetConfig("StatusRefreshRate")); 42 DACMin = atoi(GetConfig("DACMin")); 43 DACMax = atoi(GetConfig("DACMax")); 44 fHVCalibOffset = atof(GetConfig("HVCalibOffset")); 45 fHVCalibSlope = atof(GetConfig("HVCalibSlope")); 46 fHVMaxDiff = atoi(GetConfig("HVMaxDiff")); 50 47 51 48 if (fStatusRefreshRate < MIN_RATE || fStatusRefreshRate > MAX_RATE) fStatusRefreshRate = 1; … … 164 161 PrintMessage( " TimeOut: %.2f s\n" 165 162 " StatusRefreshRate: %.2f Hz\n" 166 " CCPort: %d\n"167 163 " DACMin value: %d\n" 168 164 " DACMax value: %d\n" … … 170 166 " HVCalibSlope : %f\n" 171 167 " HVMaxDiff : %u\n", fTimeOut, 172 fStatusRefreshRate, fCCPort,DACMin,168 fStatusRefreshRate, DACMin, 173 169 DACMax, fHVCalibOffset, fHVCalibSlope, 174 170 fHVMaxDiff); … … 182 178 PrintMessage(" board <i>|<i> <j>|<all> Address board i, boards i-j or all boards or list boards\n" 183 179 " chain <i>|<i> <j>|<all> Address chain i, chains i-j or all chains\n" 184 " hv <PXL id>|<ch>|<all> <v> Set bias of pixel ID, ch. or all ch. of active chain(s)/board(s)\n" 185 " hvdiff <PXL id>|<ch>|<all> <diff> Change bias by <diff>\n" 180 " hv <PXL id>|<ch>|<all> <v> Set/change bias of pixel, ch. or all ch. of active chain(s)/board(s)\n" 186 181 " status [dac] Show status information (DAC values if requested)\n" 187 182 " config Print configuration\n" … … 204 199 // Set new bias voltage (if no boards available, simply returns OK) 205 200 // First reponse to socket should be 'OK' if no error occurred. 206 if (Match(Param[0], "hv") || Match(Param[0], "hvdiff")) {201 if (Match(Param[0], "hv")) { 207 202 208 203 int hvoltage, DACValue, Errors=0, Board=-1, Chain=-1, Channel=-1; … … 212 207 // Need two or parameters 213 208 if (NParam<3 || NParam>4) { 214 PrintMessage("Usage: hv /hvdiff<channel>|<all> <voltage> [dac]\n");209 PrintMessage("Usage: hv <channel>|<all> <voltage> [dac]\n"); 215 210 return; 216 211 } … … 250 245 if (k!=Channel && Channel!=-1) continue; 251 246 252 // hvdiff isignored if DAC value is zero253 if ( (strlen(Param[0])>2 || isdigit(*Param[2])==0) && (fHVBoard[i]->HV[j][k] == 0)) continue;247 // Voltage change ignored if DAC value is zero 248 if (isdigit(*Param[2])==0 && fHVBoard[i]->HV[j][k] == 0) continue; 254 249 255 250 // Determine new DAC values 256 251 if (!SetDac){ 257 if ( strlen(Param[0])>2 || isdigit(*Param[2])==0) fHVBoard[i]->HVV[j][k] += hvoltageV; // hvdiff252 if (isdigit(*Param[2])==0) fHVBoard[i]->HVV[j][k] += hvoltageV; // voltage change 258 253 else fHVBoard[i]->HVV[j][k] = hvoltageV; 259 254 DACValue = calib->HVToDAC(fHVBoard[i]->HVV[j][k], i, j, k); 260 255 } 261 256 else { 262 if (strlen(Param[0])>2 || isdigit(*Param[2])==0) DACValue = fHVBoard[i]->HV[j][k] + hvoltage; // hvdiff257 if (isdigit(*Param[2])==0) DACValue = fHVBoard[i]->HV[j][k] + hvoltage; // voltage change 263 258 else DACValue = hvoltage; 264 259 } … … 269 264 270 265 // Update DIM services 271 fHVBoard[i]->BiasVolt[j][k]->updateService();272 266 //fHVBoard[i]->BiasVolt[j][k]->updateService(); 267 UpdateDelay = 1.0; 273 268 } // Channels 274 269 } // Chains 275 270 } // Boards 276 271 277 if (Errors > 0) PrintMessage("ERROR - Errors on %d channel(s) occurred\n", Errors); 278 else PrintMessage("OK - no errors\n"); 272 if (Errors > 0) PrintMessage("Errors on %d channel(s) occurred\n", Errors); 279 273 280 274 return; … … 318 312 319 313 // Update DIM services 320 fHVBoard[Board]->BiasVolt[Chain][Channel]->updateService();321 314 //fHVBoard[Board]->BiasVolt[Chain][Channel]->updateService(); 315 UpdateDelay = 1.0; 322 316 if(++Channel == NUM_CHANNELS) { 323 317 Chain++; … … 440 434 PrintMessage("\n Status monitor: %s\n", state_str[state]); 441 435 PrintMessage(" Status refresh rate [Hz]: %.2f\n", fStatusRefreshRate); 442 PrintMessage(" Socket state: %s\n", Socket==-1 ? "disconnected":"connected");443 436 PrintMessage(" Total number of boards: %d\n", NumHVBoards); 444 437 PrintMessage(" Active boards: %d\n\n", LastBoard - FirstBoard + 1); … … 519 512 else if(Match(Param[0], "exit")) { 520 513 521 if (CmdFromSocket) {522 PrintMessage("Exit command not allowed over socket.\n");523 return;524 }525 526 514 Exit = true; 527 pthread_kill(HVMonitor, SIGUSR1); 528 pthread_kill(SocketThread, SIGUSR1); 529 515 pthread_kill(HVMonitor, SIGUSR1); 530 516 return; 531 517 } … … 549 535 va_list ArgumentPointer; 550 536 va_start(ArgumentPointer, Format); 551 if (CmdFromSocket) DoPrintMessage(Format, ArgumentPointer, Client); 552 else DoPrintMessage(Format, ArgumentPointer, Console); 537 DoPrintMessage(Format, ArgumentPointer, Console); 553 538 va_end(ArgumentPointer); 554 539 } … … 575 560 Textout->updateService(Textbuffer); 576 561 577 // Print to socket578 if((Target & Client) && Socket!=-1) {579 write(Socket, Textbuffer, strlen(Textbuffer));580 }581 582 562 // Send to log 583 563 if(Target & Log) { 584 564 char *Buf; 585 565 if (asprintf(&Buf, "%s %s", SERVER_NAME, Textbuffer) != -1) { 586 DimClient::sendCommand ("DColl/Log", Buf);566 DimClient::sendCommandNB("DColl/Log", Buf); 587 567 free(Buf); 588 568 } 589 else DimClient::sendCommand ("DColl/Log", SERVER_NAME" asprintf() failed");569 else DimClient::sendCommandNB("DColl/Log", SERVER_NAME" asprintf() failed"); 590 570 } 591 571 } … … 648 628 } 649 629 } 650 630 } 631 632 if (UpdateDelay >= 0) { 633 UpdateDelay -= 1.0/(NumHVBoards*fStatusRefreshRate); 634 if (UpdateDelay <= 0) for (int i=0; i<NumHVBoards; i++) { 635 fHVBoard[i]->BiasVolt->updateService(); 636 } 651 637 } 652 638 } … … 700 686 701 687 // 702 // Command handling (the only command is 'B IAS/Command')688 // Command handling (the only command is 'Bias/Command') 703 689 // 704 690 void ProcessIO::commandHandler() { 705 691 706 // Log command707 PrintMessage(Log, "DIM> %s\n", getString());708 709 // Process command710 692 pthread_mutex_lock(&control_mutex); 711 693 CommandControl(getString()); -
hvcontrol/src/ProcessIO.h
r161 r183 28 28 #define MAX_NUM_TOKEN 10 29 29 30 enum MsgTarget {Console=1, Log=2, Client=4,All=7};30 enum MsgTarget {Console=1, Log=2, All=7}; 31 31 typedef enum stateenum {active, stopped, na} state_enum; 32 32 … … 36 36 PixelMap *pm; 37 37 DimService *Textout; 38 38 float UpdateDelay; 39 39 40 void commandHandler(); 40 41 41 42 public: 42 43 //HVConfig *config; 43 44 44 HVCalib *calib; 45 45 HVBoard **fHVBoard; … … 50 50 const char *Param[MAX_NUM_TOKEN]; // For parser 51 51 int NParam; 52 bool CmdFromSocket;53 52 54 53 // Configuration data … … 56 55 float fTimeOut; 57 56 float fStatusRefreshRate; 58 int fCCPort;59 57 int DACMin; 60 58 int DACMax; … … 65 63 // Status variables 66 64 pthread_t HVMonitor; // exit function sends signal to these threads 67 pthread_t SocketThread;68 65 69 int Socket; // -1 if not connected70 71 66 int NumHVBoards; 72 67 int FirstBoard; … … 79 74 80 75 // Methods 81 ProcessIO( const char *);76 ProcessIO(); 82 77 ~ProcessIO(); 83 78
Note:
See TracChangeset
for help on using the changeset viewer.