Changeset 13163
- Timestamp:
- 03/22/12 10:19:09 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/feedback.cc
r13138 r13163 165 165 vector<float> vec(2*BIAS::kNumChannels); 166 166 for (int i=0; i<BIAS::kNumChannels; i++) 167 vec[i+ 416] = diff;167 vec[i+BIAS::kNumChannels] = diff; 168 168 169 169 avg = 0; … … 185 185 const double Im = double(fCurrentsAvg[i])/fCursorCur; 186 186 const double I = Im>fCalibration[i] ? Im-fCalibration[i] : 0; 187 vec[i+ 416] += R * I*conv;187 vec[i+BIAS::kNumChannels] += R * I*conv; 188 188 if (fCalibration[i]>0) 189 189 { … … 194 194 avg /= num; 195 195 196 fCurrentsAvg.assign( 416, 0);196 fCurrentsAvg.assign(BIAS::kNumChannels, 0); 197 197 fCursorCur = 0; 198 198 } … … 215 215 Info(msg); 216 216 217 DimClient::sendCommandNB( (char*)"BIAS_CONTROL/SET_GAPD_REFERENCE_OFFSET",218 (void*)&diff,sizeof(float));217 DimClient::sendCommandNB("BIAS_CONTROL/SET_ALL_CHANNELS_OFFSET", 218 vec.data()+BIAS::kNumChannels, BIAS::kNumChannels*sizeof(float)); 219 219 220 220 fCursorTemp++; … … 223 223 int AverageCurrents() 224 224 { 225 if (fBiasA.getSize()!= 416*sizeof(int16_t))225 if (fBiasA.getSize()!=BIAS::kNumChannels*sizeof(int16_t)) 226 226 return -1; 227 227 … … 234 234 const int16_t *ptr = static_cast<int16_t*>(fBiasA.getData()); 235 235 236 for (int i=0; i< 416; i++)236 for (int i=0; i<BIAS::kNumChannels; i++) 237 237 { 238 238 fCurrentsAvg[i] += ptr[i]; … … 260 260 return; 261 261 262 fCalibration.resize( 416*2);263 for (int i=0; i< 416; i++)264 { 265 fCalibration[i] = double(fCurrentsAvg[i])/fCursorCur;266 fCalibration[i+ 416] = sqrt(double(fCurrentsRms[i])/fCursorCur-fCalibration[i]*fCalibration[i]);262 fCalibration.resize(BIAS::kNumChannels*2); 263 for (int i=0; i<BIAS::kNumChannels; i++) 264 { 265 fCalibration[i] = double(fCurrentsAvg[i])/fCursorCur; 266 fCalibration[i+BIAS::kNumChannels] = sqrt(double(fCurrentsRms[i])/fCursorCur-fCalibration[i]*fCalibration[i]); 267 267 } 268 268 … … 476 476 477 477 for (int i=0; i<BIAS::kNumChannels; i++) 478 vec[i+ 416] = avg[i]<5*2.5 ? 0 : correction[i];478 vec[i+BIAS::kNumChannels] = avg[i]<5*2.5 ? 0 : correction[i]; 479 479 480 480 fDimDeviation.setQuality(fControlType); … … 486 486 Info("Sending new relative offset to biasctrl."); 487 487 488 DimClient::sendCommandNB( (char*)"BIAS_CONTROL/ADD_REFERENCE_VOLTAGES",489 (void*)(vec.data()+416), 416*sizeof(float));488 DimClient::sendCommandNB("BIAS_CONTROL/ADD_REFERENCE_VOLTAGES", 489 vec.data()+BIAS::kNumChannels, BIAS::kNumChannels*sizeof(float)); 490 490 } 491 491 … … 569 569 // ----- Calculate average currents ----- 570 570 571 vector<float> A( 416);572 for (int i=0; i< 416; i++)571 vector<float> A(BIAS::kNumChannels); 572 for (int i=0; i<BIAS::kNumChannels; i++) 573 573 A[i] = double(fCurrentsAvg[i]) / fCursorCur; 574 574 575 fCurrentsAvg.assign( 416, 0);575 fCurrentsAvg.assign(BIAS::kNumChannels, 0); 576 576 fCursorCur = 0; 577 577 … … 618 618 Info("Sending new global relative offset to biasctrl."); 619 619 620 DimClient::sendCommandNB( (char*)"BIAS_CONTROL/ADD_REFERENCE_VOLTAGES",621 (void*)(vec.data()+nch), nch*sizeof(float));620 DimClient::sendCommandNB("BIAS_CONTROL/ADD_REFERENCE_VOLTAGES", 621 vec.data()+BIAS::kNumChannels, BIAS::kNumChannels*sizeof(float)); 622 622 } 623 623 … … 719 719 Out() << setw(2) << k << "|" << setw(2) << j*4 << "|"; 720 720 for (int i=0; i<4; i++) 721 Out() << Tools::Form(" %6.1f+-%4.1f", fCalibration[k*32+j*4+i], fCalibration[k*32+j*4+i+ 416]);721 Out() << Tools::Form(" %6.1f+-%4.1f", fCalibration[k*32+j*4+i], fCalibration[k*32+j*4+i+BIAS::kNumChannels]); 722 722 Out() << endl; 723 723 } … … 766 766 fStartTime = Time(); 767 767 768 fSP = valarray<double>(0., 416);768 fSP = valarray<double>(0., BIAS::kNumChannels); 769 769 770 770 vector<float> vec(2*BIAS::kNumChannels); … … 776 776 fPV[2].resize(0); 777 777 778 fCurrentsAvg.assign( 416, 0);779 fCurrentsRms.assign( 416, 0);778 fCurrentsAvg.assign(BIAS::kNumChannels, 0); 779 fCurrentsRms.assign(BIAS::kNumChannels, 0); 780 780 781 781 if (fKp==0 && fKi==0 && fKd==0) … … 924 924 fCursorTemp = 0; 925 925 fCursorTemp = 0; 926 fCurrentsAvg.assign( 416, 0);927 fCurrentsRms.assign( 416, 0);926 fCurrentsAvg.assign(BIAS::kNumChannels, 0); 927 fCurrentsRms.assign(BIAS::kNumChannels, 0); 928 928 fCalibration.resize(0); 929 929 fStartTime = Time(); … … 1072 1072 "|Avg[dac]:Average offset (5000uA/4096dac)" 1073 1073 "|Rms[dac]:Rms of offset (5000uA/4096dac)"), 1074 fSP( 416),1074 fSP(BIAS::kNumChannels), 1075 1075 fKp(0), fKi(0), fKd(0), fT(-1), 1076 1076 fCurrentRequestInterval(0),
Note:
See TracChangeset
for help on using the changeset viewer.