Changeset 10118 for fact/BIASctrl


Ignore:
Timestamp:
01/25/11 09:47:27 (14 years ago)
Author:
ogrimm
Message:
Adapted various programs to new PixelMap class
Location:
fact/BIASctrl
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • fact/BIASctrl/Crate.cc

    r10096 r10118  
    3232          Present[i][j] = false;
    3333          Current[i][j] = 0;
    34           CurrentOffset[i][j] = 0;
    3534        }
    3635  }
     
    293292
    294293
    295 // ***** Determine offset for current measurement *****
    296 bool Crate::CurrentCalib(double Voltage) {
    297 
    298   // Set voltage of all channels and wait for current to settle
    299   if (GlobalSet((int) (Voltage/90*0xfff)) != 1) return false;
    300   sleep(1);
    301  
    302   // Measure current of all channels
    303   if (ReadAll() != 1) return false;
    304 
    305   for (int i=0; i<MAX_NUM_BOARDS; i++) for (int j=0; j<NUM_CHANNELS; j++) {
    306         CurrentOffset[i][j] = Current[i][j];
    307   }
    308   return true;
    309 }
    310 
    311 
    312294// ***** Set all voltages of board to zero *****
    313295void Crate::ClearVoltageArrays() {
     
    343325
    344326  if (Channel >= MAX_NUM_BOARDS*NUM_CHANNELS) return 0;
    345   else return Current[Channel/NUM_CHANNELS][Channel%NUM_CHANNELS]-CurrentOffset[Channel/NUM_CHANNELS][Channel%NUM_CHANNELS];
     327  else return Current[Channel/NUM_CHANNELS][Channel%NUM_CHANNELS];
    346328}
    347329
  • fact/BIASctrl/Crate.h

    r10096 r10118  
    3535        double Volt[MAX_NUM_BOARDS][NUM_CHANNELS];      // Voltage in Volt
    3636        float Current[MAX_NUM_BOARDS][NUM_CHANNELS];
    37         float CurrentOffset[MAX_NUM_BOARDS][NUM_CHANNELS]; // Offset for current measurement
    3837
    3938        std::vector<unsigned char> Communicate(std::string);
     
    6362        int GlobalSet(double);
    6463        bool Synch();
    65         bool CurrentCalib(double);
    6664        double GetVoltage(unsigned int);
    6765        unsigned int GetDAC(unsigned int);
  • fact/BIASctrl/User.cc

    r10107 r10118  
    1616  } CommandList[] =
    1717   {{"synch", &User::cmd_synch, 0, "", "Synchronize board"},
    18     {"hv", &User::cmd_hv, 2, "<id>|<ch>|<all> <v>", "Change bias of pixel or (all) chan. of active boards"},
     18    {"pixel", &User::cmd_hv, 2, "<pixel id> <v>", "Change bias of pixel"},
     19        {"channel", &User::cmd_hv, 2, "<channel|all> <v>", "Change bias of (all) channels of active boards"},
    1920    {"gs", &User::cmd_gs, 1, "[crate] <volt>", "Global voltage set"},
    2021        {"status", &User::cmd_status, 0, "[dac|current]", "Show status information (DAC values if requested)"},
    21         {"ccal", &User::cmd_ccal, 1, "<volt>", "Calibrate current measurement at given voltage"},
    2222        {"mode", &User::cmd_mode, 1, "<static|dynamic>", "Set voltage stabilization mode"},
    2323        {"load", &User::cmd_load, 1, "<file>", "Load and set bias settings from file"},
     
    6363  }
    6464
    65   // Create instances
    66   pm     = new PixelMap(GetConfig("PixMapTable"));
     65  // Create PixelMap instance (map from config server)
     66  DimRpcInfo RPC((char *) "ConfigRequest", (char *) "");
     67  RPC.setData((char *) "Misc PixelMap");
     68  PixMap = new PixelMap(std::string(RPC.getString(), RPC.getSize()));
    6769 
    6870  // Install DIM command (after all initialized)
     
    9092
    9193  delete DIMCommand;   
    92   delete pm;
     94  delete PixMap;
    9395  delete ConsoleOut;   
    9496  free(ConsoleText); 
     
    169171  for (unsigned int n=1; n < Parameter.size()-1; n+=2) {
    170172
    171         // Extract channel identification
    172         if (pm->Pixel_to_HVboard(Parameter[n]) != 999999999) {
    173       Crt.Min = Crt.Max = pm->Pixel_to_HVboard(Parameter[n]);
    174       Chan.Min = Chan.Max = pm->Pixel_to_HVchain(Parameter[n])*NUM_CHANNELS + pm->Pixel_to_HVchannel(Parameter[n]);
    175         }
     173        // Pixel identification?
     174        if (Match(Parameter[0], "pixel")) {
     175          // Skip if first character is not digit
     176          if (isdigit(Parameter[n][0] == 0)) continue;
     177          // Skip if pixel ID not existing
     178          if (PixMap->Pixel_to_HVcrate(atoi(Parameter[n].c_str())) == PixMap->PM_ERROR_CODE) continue;
     179
     180      Crt.Min = Crt.Max = PixMap->Pixel_to_HVcrate(atoi(Parameter[n].c_str()));
     181      Chan.Min = Chan.Max = PixMap->Pixel_to_HVboard(atoi(Parameter[n].c_str()))*NUM_CHANNELS + PixMap->Pixel_to_HVchannel(atoi(Parameter[n].c_str()));
     182        }
     183        // Channel identification
    176184        else {
    177185      vector<string> T = Tokenize(Parameter[n], "/");
     
    181189          Chan.Max = MAX_NUM_BOARDS*NUM_CHANNELS-1;
    182190         
    183           if (Parameter[n] == "-") continue;
    184 
    185191          if (T.size() == 2) {
    186192                if(!ConvertToRange(T[0], Crt) || !ConvertToRange(T[1], Chan)) {
     
    204210        }
    205211
    206 
    207212        // Loop over given crates and channels
    208213        for (int i=Crt.Min; i<=Crt.Max; i++) for (int j=Chan.Min; j<=Chan.Max; j++) {
     
    342347        }
    343348  }   
    344 }
    345 
    346 //
    347 // Determine current measurement offset
    348 //
    349 void User::cmd_ccal() {
    350 
    351   double Voltage;
    352    
    353   if (!ConvertToDouble(Parameter[1], &Voltage)) {
    354     PrintMessage("Error with format of voltage parameter\n"); 
    355         return;
    356   }
    357 
    358   // Execute current offset determination
    359   for (unsigned int i=0; i<Crates.size(); i++) {
    360         if (!Crates[i]->CurrentCalib(Voltage)) {
    361       PrintMessage("Error with current calibration of crate %d\n", i);
    362           return;
    363         }
    364 
    365         PrintMessage("Current calibration of crate %d done\n", i);
    366   }
    367349}
    368350
  • fact/BIASctrl/User.h

    r10070 r10118  
    2626        enum RunMode {mode_static, mode_dynamic};
    2727
    28         PixelMap *pm;
     28        PixelMap *PixMap;
    2929        DimCommand *DIMCommand;
    3030        DimService *ConsoleOut;
     
    6666        void cmd_exit();        void cmd_rate();
    6767        void cmd_timeout();     void cmd_reset();
    68         void cmd_help();        void cmd_ccal();
    69         void cmd_mode();
     68        void cmd_help();        void cmd_mode();
    7069};
    7170
Note: See TracChangeset for help on using the changeset viewer.