Changeset 10118 for fact/BIASctrl
- Timestamp:
- 01/25/11 09:47:27 (14 years ago)
- Location:
- fact/BIASctrl
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/BIASctrl/Crate.cc
r10096 r10118 32 32 Present[i][j] = false; 33 33 Current[i][j] = 0; 34 CurrentOffset[i][j] = 0;35 34 } 36 35 } … … 293 292 294 293 295 // ***** Determine offset for current measurement *****296 bool Crate::CurrentCalib(double Voltage) {297 298 // Set voltage of all channels and wait for current to settle299 if (GlobalSet((int) (Voltage/90*0xfff)) != 1) return false;300 sleep(1);301 302 // Measure current of all channels303 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 312 294 // ***** Set all voltages of board to zero ***** 313 295 void Crate::ClearVoltageArrays() { … … 343 325 344 326 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]; 346 328 } 347 329 -
fact/BIASctrl/Crate.h
r10096 r10118 35 35 double Volt[MAX_NUM_BOARDS][NUM_CHANNELS]; // Voltage in Volt 36 36 float Current[MAX_NUM_BOARDS][NUM_CHANNELS]; 37 float CurrentOffset[MAX_NUM_BOARDS][NUM_CHANNELS]; // Offset for current measurement38 37 39 38 std::vector<unsigned char> Communicate(std::string); … … 63 62 int GlobalSet(double); 64 63 bool Synch(); 65 bool CurrentCalib(double);66 64 double GetVoltage(unsigned int); 67 65 unsigned int GetDAC(unsigned int); -
fact/BIASctrl/User.cc
r10107 r10118 16 16 } CommandList[] = 17 17 {{"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"}, 19 20 {"gs", &User::cmd_gs, 1, "[crate] <volt>", "Global voltage set"}, 20 21 {"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"},22 22 {"mode", &User::cmd_mode, 1, "<static|dynamic>", "Set voltage stabilization mode"}, 23 23 {"load", &User::cmd_load, 1, "<file>", "Load and set bias settings from file"}, … … 63 63 } 64 64 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())); 67 69 68 70 // Install DIM command (after all initialized) … … 90 92 91 93 delete DIMCommand; 92 delete pm;94 delete PixMap; 93 95 delete ConsoleOut; 94 96 free(ConsoleText); … … 169 171 for (unsigned int n=1; n < Parameter.size()-1; n+=2) { 170 172 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 176 184 else { 177 185 vector<string> T = Tokenize(Parameter[n], "/"); … … 181 189 Chan.Max = MAX_NUM_BOARDS*NUM_CHANNELS-1; 182 190 183 if (Parameter[n] == "-") continue;184 185 191 if (T.size() == 2) { 186 192 if(!ConvertToRange(T[0], Crt) || !ConvertToRange(T[1], Chan)) { … … 204 210 } 205 211 206 207 212 // Loop over given crates and channels 208 213 for (int i=Crt.Min; i<=Crt.Max; i++) for (int j=Chan.Min; j<=Chan.Max; j++) { … … 342 347 } 343 348 } 344 }345 346 //347 // Determine current measurement offset348 //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 determination359 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 }367 349 } 368 350 -
fact/BIASctrl/User.h
r10070 r10118 26 26 enum RunMode {mode_static, mode_dynamic}; 27 27 28 PixelMap * pm;28 PixelMap *PixMap; 29 29 DimCommand *DIMCommand; 30 30 DimService *ConsoleOut; … … 66 66 void cmd_exit(); void cmd_rate(); 67 67 void cmd_timeout(); void cmd_reset(); 68 void cmd_help(); void cmd_ccal(); 69 void cmd_mode(); 68 void cmd_help(); void cmd_mode(); 70 69 }; 71 70
Note:
See TracChangeset
for help on using the changeset viewer.