Index: trunk/FACT++/src/feedback.cc
===================================================================
--- trunk/FACT++/src/feedback.cc	(revision 13138)
+++ trunk/FACT++/src/feedback.cc	(revision 13163)
@@ -165,5 +165,5 @@
         vector<float> vec(2*BIAS::kNumChannels);
         for (int i=0; i<BIAS::kNumChannels; i++)
-            vec[i+416] = diff;
+            vec[i+BIAS::kNumChannels] = diff;
 
         avg = 0;
@@ -185,5 +185,5 @@
                 const double Im = double(fCurrentsAvg[i])/fCursorCur;
                 const double I  = Im>fCalibration[i] ? Im-fCalibration[i] : 0;
-                vec[i+416] += R * I*conv;
+                vec[i+BIAS::kNumChannels] += R * I*conv;
                 if (fCalibration[i]>0)
                 {
@@ -194,5 +194,5 @@
             avg /= num;
 
-            fCurrentsAvg.assign(416, 0);
+            fCurrentsAvg.assign(BIAS::kNumChannels, 0);
             fCursorCur = 0;
         }
@@ -215,6 +215,6 @@
         Info(msg);
 
-        DimClient::sendCommandNB((char*)"BIAS_CONTROL/SET_GAPD_REFERENCE_OFFSET",
-                                 (void*)&diff, sizeof(float));
+        DimClient::sendCommandNB("BIAS_CONTROL/SET_ALL_CHANNELS_OFFSET",
+                                 vec.data()+BIAS::kNumChannels, BIAS::kNumChannels*sizeof(float));
 
         fCursorTemp++;
@@ -223,5 +223,5 @@
     int AverageCurrents()
     {
-        if (fBiasA.getSize()!=416*sizeof(int16_t))
+        if (fBiasA.getSize()!=BIAS::kNumChannels*sizeof(int16_t))
             return -1;
 
@@ -234,5 +234,5 @@
         const int16_t *ptr = static_cast<int16_t*>(fBiasA.getData());
 
-        for (int i=0; i<416; i++)
+        for (int i=0; i<BIAS::kNumChannels; i++)
         {
             fCurrentsAvg[i] += ptr[i];
@@ -260,9 +260,9 @@
             return;
 
-        fCalibration.resize(416*2);
-        for (int i=0; i<416; i++)
-        {
-            fCalibration[i]     = double(fCurrentsAvg[i])/fCursorCur;
-            fCalibration[i+416] = sqrt(double(fCurrentsRms[i])/fCursorCur-fCalibration[i]*fCalibration[i]);
+        fCalibration.resize(BIAS::kNumChannels*2);
+        for (int i=0; i<BIAS::kNumChannels; i++)
+        {
+            fCalibration[i]                    = double(fCurrentsAvg[i])/fCursorCur;
+            fCalibration[i+BIAS::kNumChannels] = sqrt(double(fCurrentsRms[i])/fCursorCur-fCalibration[i]*fCalibration[i]);
         }
 
@@ -476,5 +476,5 @@
 
         for (int i=0; i<BIAS::kNumChannels; i++)
-            vec[i+416] = avg[i]<5*2.5 ? 0 : correction[i];
+            vec[i+BIAS::kNumChannels] = avg[i]<5*2.5 ? 0 : correction[i];
 
         fDimDeviation.setQuality(fControlType);
@@ -486,6 +486,6 @@
         Info("Sending new relative offset to biasctrl.");
 
-        DimClient::sendCommandNB((char*)"BIAS_CONTROL/ADD_REFERENCE_VOLTAGES",
-                                 (void*)(vec.data()+416), 416*sizeof(float));
+        DimClient::sendCommandNB("BIAS_CONTROL/ADD_REFERENCE_VOLTAGES",
+                                 vec.data()+BIAS::kNumChannels, BIAS::kNumChannels*sizeof(float));
     }
 
@@ -569,9 +569,9 @@
         // ----- Calculate average currents -----
 
-        vector<float> A(416);
-        for (int i=0; i<416; i++)
+        vector<float> A(BIAS::kNumChannels);
+        for (int i=0; i<BIAS::kNumChannels; i++)
             A[i] = double(fCurrentsAvg[i]) / fCursorCur;
 
-        fCurrentsAvg.assign(416, 0);
+        fCurrentsAvg.assign(BIAS::kNumChannels, 0);
         fCursorCur = 0;
 
@@ -618,6 +618,6 @@
         Info("Sending new global relative offset to biasctrl.");
 
-        DimClient::sendCommandNB((char*)"BIAS_CONTROL/ADD_REFERENCE_VOLTAGES",
-                                 (void*)(vec.data()+nch), nch*sizeof(float));
+        DimClient::sendCommandNB("BIAS_CONTROL/ADD_REFERENCE_VOLTAGES",
+                                 vec.data()+BIAS::kNumChannels, BIAS::kNumChannels*sizeof(float));
     }
 
@@ -719,5 +719,5 @@
                 Out() << setw(2) << k << "|" << setw(2) << j*4 << "|";
                 for (int i=0; i<4; i++)
-                    Out() << Tools::Form(" %6.1f+-%4.1f", fCalibration[k*32+j*4+i], fCalibration[k*32+j*4+i+416]);
+                    Out() << Tools::Form(" %6.1f+-%4.1f", fCalibration[k*32+j*4+i], fCalibration[k*32+j*4+i+BIAS::kNumChannels]);
                 Out() << endl;
             }
@@ -766,5 +766,5 @@
         fStartTime = Time();
 
-        fSP = valarray<double>(0., 416);
+        fSP = valarray<double>(0., BIAS::kNumChannels);
 
         vector<float> vec(2*BIAS::kNumChannels);
@@ -776,6 +776,6 @@
         fPV[2].resize(0);
 
-        fCurrentsAvg.assign(416, 0);
-        fCurrentsRms.assign(416, 0);
+        fCurrentsAvg.assign(BIAS::kNumChannels, 0);
+        fCurrentsRms.assign(BIAS::kNumChannels, 0);
 
         if (fKp==0 && fKi==0 && fKd==0)
@@ -924,6 +924,6 @@
         fCursorTemp =  0;
         fCursorTemp = 0;
-        fCurrentsAvg.assign(416, 0);
-        fCurrentsRms.assign(416, 0);
+        fCurrentsAvg.assign(BIAS::kNumChannels, 0);
+        fCurrentsRms.assign(BIAS::kNumChannels, 0);
         fCalibration.resize(0);
         fStartTime = Time();
@@ -1072,5 +1072,5 @@
                         "|Avg[dac]:Average offset (5000uA/4096dac)"
                         "|Rms[dac]:Rms of offset (5000uA/4096dac)"),
-        fSP(416),
+        fSP(BIAS::kNumChannels),
         fKp(0), fKi(0), fKd(0), fT(-1),
         fCurrentRequestInterval(0),
