Changeset 226 for drsdaq/HVFeedback.cc
- Timestamp:
- 06/18/10 12:25:29 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
drsdaq/HVFeedback.cc
r211 r226 25 25 // Constructor: Initialise feedback 26 26 // 27 HVFeedback::HVFeedback(DAQReadout* DAQClass){//: 28 //EvidenceServer(SERVER_NAME){ 27 HVFeedback::HVFeedback(DAQReadout* DAQClass){ 29 28 30 29 m = DAQClass; … … 139 138 } 140 139 141 // Update DIM service regularly140 // Update DIM count service regularly 142 141 if (time(NULL)-LastServiceUpdate > 2) { 143 142 LastServiceUpdate = time(NULL); … … 148 147 149 148 // Feedback action 149 std::stringstream Cmd; 150 150 151 for (i=m->FirstBoard; i<=m->LastBoard; i++) { 151 152 for (j=0; j<fNumberOfChips; j++) { … … 165 166 166 167 if(fabs(Average[i][j][k]) < 2*Sigma[i][j][k]) printf("Too noisy!\n"); 167 else WriteHVCommand("hv %s %+f\n",PixMap->DRS_to_Pixel(i,j,k).c_str(), Correction); 168 168 else { 169 Cmd << PixMap->DRS_to_Pixel(i,j,k)+" " << std::showpos << Correction << " "; 170 } 169 171 break; 170 172 … … 175 177 case FB_ResponseFirst: // First point of response measurement done 176 178 Buffer[i][j][k] = Average[i][j][k]; 177 if(!PixMap->DRS_to_Pixel(i,j,k).empty()) WriteHVCommand("hv %s %+f",PixMap->DRS_to_Pixel(i,j,k).c_str(), DiffVoltage); 179 if(!PixMap->DRS_to_Pixel(i,j,k).empty()) { 180 Cmd << PixMap->DRS_to_Pixel(i,j,k) << " " << std::showpos << DiffVoltage << " "; 181 } 178 182 break; 179 183 … … 184 188 } 185 189 else Response[i][j][k] = DiffVoltage/(Buffer[i][j][k]-Average[i][j][k]); 186 if(!PixMap->DRS_to_Pixel(i,j,k).empty()) WriteHVCommand("hv %s %+f",PixMap->DRS_to_Pixel(i,j,k).c_str(), -DiffVoltage/2); 190 if(!PixMap->DRS_to_Pixel(i,j,k).empty()) { 191 Cmd << PixMap->DRS_to_Pixel(i,j,k) << " " << std::showpos << -DiffVoltage/2 << " "; 192 } 187 193 break; 188 194 … … 196 202 FeedbackAverage->updateService(); 197 203 FeedbackSigma->updateService(); 204 205 // Send command 206 if (!Cmd.str().empty()) { 207 DimClient::sendCommand("Bias/Command", ("hv "+Cmd.str()).c_str()); 208 } 198 209 199 210 switch (FBMode) { … … 269 280 else { 270 281 FBMode = Mode; 271 if (Mode != FB_ResponseFirst) m-> State(m->INFO, "%s", FBState_Description[FBMode]);272 else m-> State(m->INFO, "%s (voltage difference %.3f)", FBState_Description[FBMode], DiffVoltage);282 if (Mode != FB_ResponseFirst) m->Message(m->INFO, "%s", FBState_Description[FBMode]); 283 else m->Message(m->INFO, "%s (voltage difference %.3f)", FBState_Description[FBMode], DiffVoltage); 273 284 ClearAverages(); 274 285 } … … 320 331 void HVFeedback::MeasureResponse(float U) { 321 332 333 std::stringstream Cmd; 334 322 335 if (U==0) { 323 336 m->PrintMessage("HV Feedback: Error, voltage difference must not non-zero.\n"); … … 325 338 } 326 339 327 for (int i=m->FirstBoard; i<=m->LastBoard; i++) 328 for (int j=0; j<fNumberOfChips; j++) 329 for (int k=0; k<fNumberOfChannels; k++) { 330 if(!PixMap->DRS_to_Pixel(i,j,k).empty()) { 331 WriteHVCommand("hv %s %+f\n",PixMap->DRS_to_Pixel(i,j,k).c_str(), -U/2); 332 } 333 } 340 for (int i=m->FirstBoard; i<=m->LastBoard; i++) { 341 for (int j=0; j<fNumberOfChips; j++) { 342 for (int k=0; k<fNumberOfChannels; k++) { 343 if(!PixMap->DRS_to_Pixel(i,j,k).empty()) { 344 Cmd << PixMap->DRS_to_Pixel(i,j,k) << " " << std::showpos << -U/2 << " "; 345 } 346 } 347 } 348 } 349 350 // Send command 351 if (!Cmd.str().empty()) { 352 DimClient::sendCommand("Bias/Command", ("hv "+Cmd.str()).c_str()); 353 } 354 334 355 DiffVoltage = U; 335 356 SetFBMode(FB_ResponseFirst, true); … … 351 372 352 373 // 353 // Write bias voltage commmand354 //355 bool HVFeedback::WriteHVCommand(const char *Format, ...) {356 357 char Textbuffer[MAX_COM_SIZE];358 359 va_list ArgumentPointer; va_start(ArgumentPointer, Format);360 vsnprintf(Textbuffer, sizeof(Textbuffer), Format, ArgumentPointer);361 362 DimClient::sendCommand("Bias/Command", Textbuffer);363 return true;364 }365 366 //367 374 // Print feedback configuration 368 375 //
Note:
See TracChangeset
for help on using the changeset viewer.