- Timestamp:
- 01/11/11 12:06:18 (14 years ago)
- Location:
- fact/BIASctrl
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/BIASctrl/Crate.cc
r10070 r10096 119 119 // === Lock device === 120 120 flockfile(File); 121 121 122 // Do not try to communicate if crate has too many errors 123 if (ErrorCount > MAX_ERR_COUNT) goto ExitCommunicate; 124 122 125 // === Write data === 123 126 if ((N = write(fDescriptor, Buf.data(), Buf.size())) < (int) Buf.size()) { … … 125 128 else m->Message(m->ERROR, "Could write only %d of %d bytes to board", N, Buf.size()); 126 129 ErrorCount++; 127 goto ExitCommunicate;130 128 131 } 129 132 … … 132 135 FD_ZERO(&SelectDescriptor); FD_SET(fDescriptor, &SelectDescriptor); 133 136 if (select(fDescriptor+1, &SelectDescriptor, NULL, NULL, &WaitTime)==-1) { 134 m->Message(m->ERROR, "Error with select() (%s)", strerror(errno)); 135 goto ExitCommunicate; 137 m->Message(m->FATAL, "Error with select() (%s)", strerror(errno)); 136 138 } 137 139 -
fact/BIASctrl/Crate.h
r10070 r10096 17 17 #define NUM_CHANNELS 32 // Channels per bias board 18 18 #define BAUDRATE B115200 19 const float RESISTOR = 1000; 20 19 const float RESISTOR = 1000; // Resistance in Ohm for voltage correction 20 const int MAX_ERR_COUNT = 10; // Maximum number of errors before reporting stopped 21 21 class User; 22 22 -
fact/BIASctrl/History.txt
r10070 r10096 4 4 17/11/2010 Added possibility for bulk transfers (ReadAll(), SetChannels()) 5 5 24/11/2010 Ramping for many channels possible with bulk transfers 6 7/12/2010 Added dynamic mode. 6 7/12/2010 Added dynamic mode 7 6/1/2011 RampVoltages() had infinite loop if crate communication stopped -
fact/BIASctrl/User.cc
r10070 r10096 54 54 55 55 if (New->InitOK && New->Synch()) { 56 PrintMessage("Synchronized and reset board%s (#%d)\n", Boards[i].c_str(), Crates.size());56 PrintMessage("Synchronized and reset crate %s (#%d)\n", Boards[i].c_str(), Crates.size()); 57 57 Crates.push_back(New); 58 58 } 59 59 else { 60 Message(WARN, "Failed to synchronize board%s", Boards[i].c_str());60 Message(WARN, "Failed to synchronize crate %s", Boards[i].c_str()); 61 61 delete New; 62 62 } … … 150 150 void User::cmd_synch() { 151 151 152 if (Crates[0]->Synch()) PrintMessage("Synchronized board %d\n", 0); 153 else PrintMessage("Failed to synchronize board %d\n", 0); 152 for (unsigned int i=0; i<Crates.size(); i++) { 153 if (Crates[i]->Synch()) PrintMessage("Synchronized crate %d\n", i); 154 else PrintMessage("Failed to synchronize crate %d\n", i); 155 } 154 156 } 155 157 … … 219 221 } 220 222 221 if (Errors > 0) Message(ERROR, "%d errors occurred from SetChannels()", Errors); 223 // Error message only if not yet too many errors 224 if (Errors > 0) { 225 for (unsigned int i=0; i<Crates.size(); i++) { 226 if (Crates[i]->ErrorCount > MAX_ERR_COUNT) return; 227 } 228 Message(ERROR, "%d errors occurred from SetChannels()", Errors); 229 } 222 230 } 223 231 … … 325 333 if (!ConvertToDouble(Parameter[1], &Voltage)) return; 326 334 327 if (Crates[0]->GlobalSet(Voltage) != 1) { 328 PrintMessage("Error: Could not global set board %d\n", 0); 335 for (unsigned int i=0; i<Crates.size(); i++) { 336 if (Crates[i]->GlobalSet(Voltage) != 1) { 337 PrintMessage("Error: Could not global set crate %d\n", i); 338 } 329 339 } 330 340 } … … 343 353 344 354 // Execute current offset determination 345 if (!Crates[0]->CurrentCalib(Voltage)) { 346 PrintMessage("Error with current calibration of board %d\n", 0); 347 return; 348 } 349 350 PrintMessage("Current calibration of board %d done\n", 0); 355 for (unsigned int i=0; i<Crates.size(); i++) { 356 if (!Crates[i]->CurrentCalib(Voltage)) { 357 PrintMessage("Error with current calibration of crate %d\n", i); 358 return; 359 } 360 361 PrintMessage("Current calibration of crate %d done\n", i); 362 } 351 363 } 352 364 … … 481 493 482 494 map<unsigned int, double> Target; 483 unsignedint Errors = 0;495 int Errors = 0; 484 496 485 497 // Ramp until all channels at desired value 486 while (!Voltages.empty() ) {498 while (!Voltages.empty() && Errors < MAX_ERR_COUNT) { 487 499 // Remove channels already at target (check for DAC, not for floating-point voltage) 488 500 for (map<unsigned int, double>::iterator it = Voltages.begin(); it != Voltages.end(); ++it) { … … 517 529 while (!ExitRequest) { 518 530 for (unsigned int i=0; i<Crates.size(); i++) { 519 if (Crates[i]->ErrorCount > 10) {531 if (Crates[i]->ErrorCount > MAX_ERR_COUNT) { 520 532 if (!Warned) { 521 533 Warned = true;
Note:
See TracChangeset
for help on using the changeset viewer.