Пример #1
0
        private void timer_outputData_Tick(object sender, EventArgs e)
        {
            DateTime beforDT = System.DateTime.Now;

            watch.Start();
            if (m_isCheckedA)
            {
                double temp = m_amplitude2 / 2;
                if (temp <= m_offset2)
                {
                    m_dataScaled[0] = m_waveformGenerator.GetOnePoint(m_formStyleA, m_wavePointsIndexA++, m_amplitude2, m_offset2);
                    if (m_wavePointsIndexA == m_PointCountPerWave)
                    {
                        m_wavePointsIndexA = 0;
                        if (output_num > 0)
                        {
                            output_num--;
                        }
                        else if (output_num == 0)
                        {
                            timer_outputData.Stop();
                        }
                    }
                }
                else
                {
                    m_offset2       = temp;
                    m_dataScaled[0] = m_waveformGenerator.GetOnePoint(m_formStyleA, m_wavePointsIndexA++, m_amplitude2, m_offset2);
                    if (m_wavePointsIndexA == m_PointCountPerWave)
                    {
                        m_wavePointsIndexA = 0;
                        if (output_num > 0)
                        {
                            output_num--;
                        }
                        else if (output_num == 0)
                        {
                            timer_outputData.Stop();
                        }
                    }
                }
            }
            if (m_isCheckedB)
            {
                double temp2 = m_amplitude4 / 2;
                if (temp2 <= m_offset4)
                {
                    if (m_channelCount > 1)
                    {
                        m_dataScaled[1] = m_waveformGenerator.GetOnePoint(m_formStyleB, m_wavePointsIndexB++, m_amplitude4, m_offset4);
                    }
                    if (m_wavePointsIndexB == m_PointCountPerWave)
                    {
                        m_wavePointsIndexB = 0;
                    }
                }
                else
                {
                    m_offset4 = temp2;

                    if (m_channelCount > 1)
                    {
                        m_dataScaled[1] = m_waveformGenerator.GetOnePoint(m_formStyleB, m_wavePointsIndexB++, m_amplitude4, m_offset4);
                    }
                    if (m_wavePointsIndexB == m_PointCountPerWave)
                    {
                        m_wavePointsIndexB = 0;
                    }
                }
            }

            m_err = m_instantAoCtrl.Write(m_channelStart, m_channelCount, m_dataScaled);
            DateTime afterDT = System.DateTime.Now;
            TimeSpan ts      = afterDT.Subtract(beforDT);

            Console.WriteLine("DateTime总共花费{0}ms.", ts.TotalMilliseconds);


            CheckError(m_err);
            watch.Stop();                      //停止监视
            TimeSpan timespan = watch.Elapsed; //获取当前实例测量得出的总时间
            //listBox1.Items.Add((timespan.TotalMilliseconds.ToString()));  //总毫秒数
        }