Exemplo n.º 1
0
        lpcie.Errs setSyncDinStream()
        {
            lpcie.Errs err;

            /* разрешаем или запрещаем поток синхронного ввода
             * с цифровых линий в зависимости от состояния переключателя */
            if (chkSyncDin.Checked)
            {
                err = hnd.StreamsEnable(X502.Streams.DIN);
            }
            else
            {
                err = hnd.StreamsDisable(X502.Streams.DIN);
            }
            return(err);
        }
Exemplo n.º 2
0
        public void LoadSettings(LCard502Pars _pars, L502Ch[] _channels)
        {
            CurrentSensors = Convert.ToUInt32(_channels.Length);
            string a = "LCard502.LoadSettings: Не удалось задать параметры";

            hnd.LChannelCount = (uint)_channels.Length;
            VoltPercent       = new double[_channels.Length];
            double[] K = { 10, 20, 50, 100, 200, 500 };
            for (int i = 0; i < _channels.Length; i++)
            {
                string aa = string.Format("LCard502E.LoadSettings: Канал[{0}]: {1}", i, _channels[i].ToString());
                pr(aa);
                AdapterPars p = new AdapterPars(_channels[i]);
                LFATAL(aa, hnd.SetLChannel((uint)i, p.phy_ch, p.mode, p.range, p.avg));
                VoltPercent[i] = K[_channels[i].Range];
            }
            // Настраиваем источник частоты синхронизации
            L502.Sync[] f_sync_mode = { L502.Sync.INTERNAL, L502.Sync.EXTERNAL_MASTER };
            hnd.SyncMode = f_sync_mode[_pars.SyncMode];
//            hnd.SyncMode = L502.Sync.EXTERNAL_MASTER;

            // RAG Чтобы не поставил - не работает - ихний баг.
            //            L502.Sync[] f_sync_start_mode = { L502.Sync.DI_SYN1_RISE, L502.Sync.DI_SYN2_RISE, L502.Sync.DI_SYN1_FALL, L502.Sync.DI_SYN2_FALL };
            //            hnd.SyncStartMode = f_sync_start_mode[_pars.SyncStartMode];

            f_acq = _pars.FrequencyPerChannel * _channels.Length * 4;
            double f_lch = _pars.FrequencyPerChannel;

            // настраиваем частоту сбора с АЦП
            LFATAL(a, hnd.SetAdcFreq(ref f_acq, ref f_lch));
            // Parameters.frequencyCollect = f_acq;
            // Parameters.frequencyPerChannel = f_lch;
            // Записываем настройки в модуль

            double f_din_save = _pars.TTL.Frequency;

            LFATAL(a, hnd.SetDinFreq(ref f_din_save));
            LFATAL(a, hnd.Configure(0));
#if TTL_SIGNALS
            LFATAL("LCard502::Start: не смогли разрешить потоки: ", hnd.StreamsEnable(L502.Streams.ADC | L502.Streams.DIN));
#else
            LFATAL("LCard502::Start: не смогли разрешить потоки: ", hnd.StreamsEnable(L502.Streams.ADC));
#endif
        }
Exemplo n.º 3
0
        private void button18_Click(object sender, EventArgs e)
        {
            if (imp_mode == false)
            {
                UInt32   imp_length_val = Convert.ToUInt32(imp_length.Text, 10), period, delay;
                UInt32[] imp_array = new UInt32[imp_length_val];
                if (imp_state1.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period1.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay1.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 1;
                    }
                }
                if (imp_state2.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period2.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay2.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 2;
                    }
                }
                if (imp_state3.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period3.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay3.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 4;
                    }
                }
                if (imp_state4.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period4.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay4.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 8;
                    }
                }
                if (imp_state5.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period5.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay5.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 16;
                    }
                }
                if (imp_state6.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period6.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay6.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 32;
                    }
                }
                if (imp_state7.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period7.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay7.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 64;
                    }
                }
                if (imp_state8.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period8.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay8.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 128;
                    }
                }
                if (imp_state9.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period9.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay9.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 256;
                    }
                }
                if (imp_state10.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period10.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay10.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 512;
                    }
                }
                if (imp_state11.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period11.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay11.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 1024;
                    }
                }
                if (imp_state12.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period12.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay12.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 2048;
                    }
                }
                if (imp_state13.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period13.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay13.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 4096;
                    }
                }
                if (imp_state14.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period14.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay14.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 8192;
                    }
                }
                if (imp_state15.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period15.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay15.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 16384;
                    }
                }
                if (imp_state16.CheckState == CheckState.Checked)
                {
                    period = Convert.ToUInt32(imp_period16.Text, 10);
                    delay  = Convert.ToUInt32(imp_delay16.Text, 10);
                    for (UInt32 j = delay; j < period + delay; j++)
                    {
                        imp_array[j] = imp_array[j] + 32768;
                    }
                }

                imp_mode = true;
                //запись в буфер платы (постоянный режим)
                if (imp_single.CheckState == CheckState.Checked)
                {
                    hnd.StreamsEnable(X502.Streams.DOUT);
                    hnd.PreloadStart();
                    hnd.PrepareData(null, null, imp_array, imp_length_val, X502.DacOutFlags.VOLT, null);
                    hnd.Send(imp_array, imp_length_val, 10);
                    hnd.StreamsStart();
                }
                else if (imp_single.CheckState == CheckState.Unchecked)
                {
                    hnd.StreamsEnable(X502.Streams.DOUT);
                    hnd.OutCycleLoadStart(imp_length_val);
                    hnd.Send(imp_array, imp_length_val, 10);
                    hnd.OutCycleSetup(X502.OutCycleFlags.FORCE);
                    hnd.StreamsStart();
                    updateControls();
                }
            }
            else
            {
                hnd.StreamsStop();
                hnd.AsyncOutDig(0, 0);
                imp_mode = false;
                updateControls();


                imp_state1.CheckState  = CheckState.Unchecked;
                imp_state2.CheckState  = CheckState.Unchecked;
                imp_state3.CheckState  = CheckState.Unchecked;
                imp_state4.CheckState  = CheckState.Unchecked;
                imp_state5.CheckState  = CheckState.Unchecked;
                imp_state6.CheckState  = CheckState.Unchecked;
                imp_state7.CheckState  = CheckState.Unchecked;
                imp_state8.CheckState  = CheckState.Unchecked;
                imp_state9.CheckState  = CheckState.Unchecked;
                imp_state10.CheckState = CheckState.Unchecked;
                imp_state11.CheckState = CheckState.Unchecked;
                imp_state12.CheckState = CheckState.Unchecked;
                imp_state13.CheckState = CheckState.Unchecked;
                imp_state14.CheckState = CheckState.Unchecked;
                imp_state15.CheckState = CheckState.Unchecked;
                imp_state16.CheckState = CheckState.Unchecked;
            }
        }