Changeset 10096


Ignore:
Timestamp:
01/11/11 12:06:18 (14 years ago)
Author:
ogrimm
Message:
Small changes to limit error messages in case crate communication breaks
Location:
fact/BIASctrl
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • fact/BIASctrl/Crate.cc

    r10070 r10096  
    119119  // === Lock device ===
    120120  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
    122125  // === Write data ===
    123126  if ((N = write(fDescriptor, Buf.data(), Buf.size())) < (int) Buf.size()) {
     
    125128    else m->Message(m->ERROR, "Could write only %d of %d bytes to board", N, Buf.size());
    126129    ErrorCount++;
    127         goto ExitCommunicate;
     130       
    128131  }
    129132
     
    132135        FD_ZERO(&SelectDescriptor);   FD_SET(fDescriptor, &SelectDescriptor);
    133136        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));
    136138        }
    137139
  • fact/BIASctrl/Crate.h

    r10070 r10096  
    1717#define NUM_CHANNELS 32         // Channels per bias board
    1818#define BAUDRATE B115200
    19 const float RESISTOR = 1000;            // Resistance in Ohm for voltage correction
    20 
     19const float RESISTOR = 1000;    // Resistance in Ohm for voltage correction
     20const int MAX_ERR_COUNT = 10;   // Maximum number of errors before reporting stopped
    2121class User;
    2222
  • fact/BIASctrl/History.txt

    r10070 r10096  
    4417/11/2010      Added possibility for bulk transfers (ReadAll(), SetChannels())
    5524/11/2010      Ramping for many channels possible with bulk transfers
    6 7/12/2010       Added dynamic mode.
     67/12/2010       Added dynamic mode
     76/1/2011        RampVoltages() had infinite loop if crate communication stopped
  • fact/BIASctrl/User.cc

    r10070 r10096  
    5454
    5555    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());
    5757       Crates.push_back(New);
    5858    }
    5959    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());
    6161          delete New;
    6262    }
     
    150150void User::cmd_synch() {
    151151
    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  }
    154156}
    155157
     
    219221  }
    220222
    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  }
    222230}
    223231
     
    325333  if (!ConvertToDouble(Parameter[1], &Voltage)) return;
    326334
    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        }
    329339  }   
    330340}
     
    343353
    344354  // 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  }
    351363}
    352364
     
    481493
    482494  map<unsigned int, double> Target;
    483   unsigned int Errors = 0;
     495  int Errors = 0;
    484496
    485497  // Ramp until all channels at desired value
    486   while (!Voltages.empty()) {
     498  while (!Voltages.empty() && Errors < MAX_ERR_COUNT) {
    487499    // Remove channels already at target (check for DAC, not for floating-point voltage)
    488500        for (map<unsigned int, double>::iterator it = Voltages.begin(); it != Voltages.end(); ++it) {
     
    517529  while (!ExitRequest) {
    518530        for (unsigned int i=0; i<Crates.size(); i++) {
    519       if (Crates[i]->ErrorCount > 10) {
     531      if (Crates[i]->ErrorCount > MAX_ERR_COUNT) {
    520532        if (!Warned) {
    521533          Warned = true;
Note: See TracChangeset for help on using the changeset viewer.