void Init()
 {
     _Calibrations = new Calibration[ChannelCount * GainCount];
     for (int i = 0; i < _Calibrations.Length; i++)
     {
         _Calibrations[i].Gain = 1;
         _Calibrations[i].Offset = 0;
     }
 }
        public void Set(int channel, int gain, Calibration calibration)
        {
            #region /Проверка аргументов/
            if (channel < 0 || channel >= ChannelCount)
                throw new ArgumentOutOfRangeException("channel");
            if (gain < 0 || gain >= GainCount)
                throw new ArgumentOutOfRangeException("gain");
            #endregion /Проверка аргументов/

            _Calibrations[ChannelCount * gain + channel] = calibration;
        }
        private void btnStart_Click(object sender, EventArgs e)
        {
            try
            {
                
                _text.Text += Environment.NewLine +"Начинаем измерять";

                _device.ClearProtocol();
                _device.Reset(false);
                _device.SetMeasMode(false, true);

                _text.Text += Environment.NewLine +"Посылаем настройки";
                _device.SetChStates(true, true, true, true, false);
                int chcount = 4;
                int datasize = 1000;

                _device.SetSegment(0, datasize, false);
                _device.SetSamplingPeriod(0.000001, false);

                _device.SetSynchSettings(true, true, true, 0, 1, 32768, true);

                //_device.SetFreqLevels(31000, 33200, false);

                _device.SetGains(true, true, false, false, false);

                Calibration[] callibrs = new Calibration[chcount];
                callibrs[0] = _device.GetCalibration(0, 1);
                callibrs[1] = _device.GetCalibration(1, 1);
                callibrs[2] = _device.GetCalibration(2, 0);
                callibrs[3] = _device.GetCalibration(3, 0);

                _device.SetChannelModes(0, 0, 0, 0, true);

                _text.Text += Environment.NewLine +"Запуск измерения";
                _device.Start(true);

                _text.Text += Environment.NewLine + "Ждем данные";
                Thread.Sleep(50);
                R4RegisterBase r4 = _device.GetStatus();

                while (!r4.MemIsEnd)
                {
                    Thread.Sleep(50);
                    r4 = _device.GetStatus();
                }

                _text.Text += Environment.NewLine + "Получаем данные данные";
                _text.SelectionStart = _text.TextLength - 1;
                _text.ScrollToCaret();

                var startpos = (uint)(r4.PreReg - (r4.PreReg % chcount));// chcount - кол-во активных каналов

                float[][] buffer = new float[][] { new float[datasize], new float[datasize], new float[datasize], new float[datasize] };

                uint segment = (startpos) >> 8;
                uint offset = (startpos) & 0xFF;

                // Указываем адрес, откуда будем читать
                _device.PrepareForReading((uint)segment);
                int count = datasize * chcount;

                var rawdata = new ushort[(int)(count + offset)];
                _device.GetData(rawdata);

                for (int k = 0, j = 0; j < datasize; j++)
                {
                    for (int i = 0; i < chcount; i++)
                        if (buffer[i].Length > 0)
                        {
                            buffer[i][j] = ParseRawData(rawdata[offset + k], i, callibrs[i]);
                            k++;
                        }
                }

                var sb = new StringBuilder(8 * 1024);
                sb.AppendLine("Результаты:");

                for (int i = 0; i < datasize; i++)
                    sb.AppendLine(string.Format("{0}: {1}\t|\t{2}\t|\t{3}\t|\t{4}", i, buffer[0][i], buffer[1][i], buffer[2][i], buffer[3][i]));

                sb.AppendLine("Завершили");

                _text.Text += Environment.NewLine + sb;
            }
            catch (Exception ex)
            {
                _text.Text += Environment.NewLine + "Ошибка:" + ex.Message;
            }
            _text.SelectionStart = _text.TextLength-1;
            _text.ScrollToCaret();
        }
 protected virtual float ParseRawData(ushort value, int ch, Calibration calibr)
 {
     return calibr.ToValue(value);
 }