Changeset 264 for hvcontrol/src/ProcessIO.cc
- Timestamp:
- 07/27/10 07:27:04 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
hvcontrol/src/ProcessIO.cc
r230 r264 30 30 {"rate", &ProcessIO::cmd_rate, 1, "<rate>", "Set status refresh rate in Hz"}, 31 31 {"timeout", &ProcessIO::cmd_timeout, 1, "<time>", "Set timeout to return from read in seconds"}, 32 {"reset", &ProcessIO::cmd_reset, 0, "", "Reset active bias board "},32 {"reset", &ProcessIO::cmd_reset, 0, "", "Reset active bias boards"}, 33 33 {"start", &ProcessIO::cmd_start, 0, "", "Start bias status monitor"}, 34 34 {"stop", &ProcessIO::cmd_stop, 0, "", "Stop bias status monitor"}, … … 53 53 FirstBoard = 0; 54 54 LastBoard = -1; 55 56 // Initialize mutex for thread synchronisation57 if (pthread_mutex_init(&Mutex, NULL) != 0) {58 Message(FATAL, "pthread_mutex_init() failed");59 }60 55 61 56 // DIM console service used in PrintMessage() … … 109 104 delete calib; 110 105 delete ConsoleOut; 111 free(ConsoleText); 112 113 // Destroy mutex 114 if (pthread_mutex_destroy(&Mutex) != 0) Message(ERROR, "pthread_mutex_destroy() failed"); 106 free(ConsoleText); 115 107 } 116 108 … … 370 362 void ProcessIO::cmd_reset() { 371 363 372 for (int i=FirstBoard; i<=LastBoard; i++) ResetBoard(i); 364 for (int i=FirstBoard; i<=LastBoard; i++) { 365 if (fHVBoard[i]->Reset() == 1) { 366 PrintMessage("Reset of board %d\n", fHVBoard[i]->GetBoardNumber()); 367 PrintBoardStatus(i); 368 } 369 else PrintMessage("Error: Could not reset board %d\n",fHVBoard[i]->GetBoardNumber()); 370 } 373 371 } 374 372 … … 527 525 528 526 static bool Warned = false; 529 int Ret;530 531 // Lock because command execution runs in different thread532 if ((Ret = pthread_mutex_lock(&Mutex)) != 0) {533 Message(FATAL, "pthread_mutex_lock() failed in commandHandler() (%s)", strerror(Ret));534 }535 527 536 528 for (int i=0; i<NumHVBoards; i++) { … … 549 541 if (fHVBoard[i]->ResetButton) { 550 542 Message(INFO, "Manual reset of board %d", fHVBoard[i]->GetBoardNumber()); 551 ResetBoard(i);543 fHVBoard[i]->Reset(); 552 544 } 553 545 … … 558 550 for (int j=0; j<NUM_CHAINS; j++) { 559 551 if (fHVBoard[i]->Overcurrent[j]) { 560 Message(WARN, "Warning: Overcurrent in chain %d of board %d ",j,fHVBoard[i]->GetBoardNumber());561 ResetBoard(i);552 Message(WARN, "Warning: Overcurrent in chain %d of board %d, resetting board",j,fHVBoard[i]->GetBoardNumber()); 553 fHVBoard[i]->Reset(); 562 554 } 563 555 } 564 } 565 566 // Unlock 567 if ((Ret = pthread_mutex_unlock(&Mutex)) != 0) { 568 Message(FATAL, "pthread_mutex_lock() failed in commandHandler() (%s)", strerror(Ret)); 569 } 570 571 } 572 573 574 // Send reset to board and clear voltage arrays 575 void ProcessIO::ResetBoard(int i) { 576 577 if (fHVBoard[i]->Reset() == 1) { 578 PrintMessage("Reset of board %d\n", fHVBoard[i]->GetBoardNumber()); 579 PrintBoardStatus(i); 580 } 581 else PrintMessage("Error: Could not reset board %d\n",fHVBoard[i]->GetBoardNumber()); 582 } 556 } 557 } 558 583 559 584 560 … … 597 573 598 574 599 // Command handling (mutex needed because of monitor thread)575 // Command handling 600 576 void ProcessIO::commandHandler() { 601 577 602 int Ret;603 604 if ((Ret = pthread_mutex_lock(&Mutex)) != 0) {605 Message(FATAL, "pthread_mutex_lock() failed in commandHandler() (%s)", strerror(Ret));606 }607 608 578 if ((getCommand()==Command) && (*(Command->getString()+Command->getSize()-1)=='\0')) { 609 SendToLog("Command '%s' from %s (ID %d)", Command->getString(), getClientName(), getClientId());610 579 CommandControl(Command->getString()); 611 }612 613 if ((Ret = pthread_mutex_unlock(&Mutex)) != 0) {614 Message(FATAL, "pthread_mutex_unlock() failed in commandHandler() (%s)", strerror(Ret));615 580 } 616 581 }
Note:
See TracChangeset
for help on using the changeset viewer.