Esempio n. 1
0
        private void timer_getData_Tick(object sender, EventArgs e)
        {
            PerformanceCounter performanceCounter = new PerformanceCounter();
            ErrorCode          err;

            performanceCounter.Start();
            err = instantAiCtrl1.Read(comboBox_chanStart.SelectedIndex, chanCountSet, m_dataScaled);
            if (err != ErrorCode.Success)
            {
                HandleError(err);
                timer_getData.Stop();
            }
            m_simpleGraph.Chart(m_dataScaled,
                                chanCountSet,
                                1,
                                1.0 * trackBar.Value / 1000);
            RefreshListView();

            performanceCounter.Stop();
            int interval = (int)(trackBar.Value - performanceCounter.Duration * 1000 - 0.5);

            if (interval > 1)
            {
                timer_getData.Interval = interval;
            }
        }
Esempio n. 2
0
        private void timer_getData_Tick(object sender, EventArgs e)
        {
            PerformanceCounter performanceCounter = new PerformanceCounter();
            ErrorCode          err;

            performanceCounter.Start();
            err = instantAiCtrl1.Read(0, chanCountSet, m_dataScaled);
            if (err != ErrorCode.Success)
            {
                HandleError(err);
                timer_getData.Stop();
            }
            m_simpleGraph.Chart(m_dataScaled, chanCountSet, 1, 1.0 * trackBar.Value / 1000);
            int chanCount = comboBox_chanCount.SelectedIndex + 1;

            using (FileStream fs = File.Open(fname, FileMode.OpenOrCreate))
            {
                StreamWriter w = new StreamWriter(fs);
                w.BaseStream.Seek(0, SeekOrigin.End);
                time += timer_getData.Interval;
                w.Write(time.ToString() + " ");
                for (int i = 0; i < chanCount; ++i)
                {
                    //写文件
                    w.Write((m_dataScaled[i]).ToString() + " ");
                    //写数组
                    xreal[i].Add(m_dataScaled[i]);
                }
                w.Write("\r\n");
                w.Flush();
                w.Close();
            }

            RefreshListView();
            performanceCounter.Stop();
            int interval = (int)(trackBar.Value - performanceCounter.Duration * 1000 - 0.5);

            if (interval > 1)
            {
                timer_getData.Interval = interval;
            }
        }