Ejemplo n.º 1
0
        private void CreateTimeGraph(ZedGraphControl zgc, double[] sectionBuffers)
        {
            try
            {
                DrawClass       DC         = DrawClass.GetInstance();
                List <double[]> excel_Info = new List <double[]> {
                };
                excel_Info = DC.DrawChart(zgc, sectionBuffers);

                if (SavecheckBox.Checked)
                {
                    _log.Info("Start store raw data");
                    sd.CreateExcelFile(excel_Info[0], excel_Info[1], sectionBuffers);
                }
            }
            catch (Exception err)
            {
                waveformAiCtrl.Stop();
                _log.Error("Time domain calculate or drawing Error message is---" + err.Message);
                MessageBox.Show(err.Message);
                waveformAiCtrl.Dispose();
                SamplingTextbox.Enabled     = true;
                DataLengthtextBox.Enabled   = true;
                ChanneltextBox.Enabled      = true;
                FreqrangetextBox.Enabled    = true;
                DeviceIDtextBox.Enabled     = true;
                FreqMintextBox.Enabled      = true;
                FreqMaxtextBox.Enabled      = true;
                StartAcquisitionBtn.Enabled = true;
                StopAcquisitionBtn.Enabled  = false;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 关闭驱动
 /// </summary>
 public void CloseDevice()
 {
     timerAi.Enabled  = false;
     timerDi.Enabled  = false;
     timerCnt.Enabled = false;
     waveformAiCtrlUsb4704.Dispose();
     instantDiCtrlUsb4704.Dispose();
     instantDoCtrlUsb4704.Dispose();
     eventCounterCtrlUsb4704.Dispose();
     instantAoCtrlUsb4704.Dispose();
 }
Ejemplo n.º 3
0
        private void CreateFreqMaxGraph(ZedGraphControl zgc, double[] sectionBuffers)
        {
            zgc.GraphPane.CurveList.Clear();

            int FreqMin = int.Parse(FreqMintextBox.Text);
            int FreqMax = int.Parse(FreqMaxtextBox.Text);

            convertClkRate = int.Parse(SamplingTextbox.Text);
            sectionLength  = int.Parse(DataLengthtextBox.Text);
            Freqrange      = int.Parse(FreqrangetextBox.Text);
            Complex[] fftsamples = new Complex[sectionLength];
            xMaxchartxaxis[0] = xMaxchartxaxis[0] + 1 * sectionLength / convertClkRate;
            for (int i = 0; i < sectionLength; i++)
            {
                fftsamples[i] = sectionBuffers[i];
            }
            Fourier.Forward(fftsamples, FourierOptions.NoScaling);
            double[] mag    = new double[sectionBuffers.Length];
            double[] fftmax = new double[1];
            for (int i = FreqMin; i < FreqMax; i++)
            {
                mag[i] = (2.0 / sectionLength) * (Math.Abs(Math.Sqrt(Math.Pow(fftsamples[i].Real, 2) + Math.Pow(fftsamples[i].Imaginary, 2))));
            }

            fftmax[0] = mag.Max();

            GraphPane myPane = zgc.GraphPane;

            // Set the titles and axis labels
            double[] y = sectionBuffers;
            LineItem myCurve;

            if (LongTermcheckBox.Checked)
            {
                list.Add(xMaxchartxaxis, fftmax);
                // Generate a blue curve with circle symbols, and "My Curve 2" in the legend
                myCurve            = myPane.AddCurve("Channel 0", list, Color.DarkGreen, SymbolType.Square);
                myCurve.Line.Width = 3.0f;
                zgc.AxisChange();
                zgc.Refresh();
                StreamcheckBox.Checked = false;
            }

            else if (StreamcheckBox.Checked)
            {
                list.Add(xMaxchartxaxis, fftmax);
                // Generate a blue curve with circle symbols, and "My Curve 2" in the legend
                myCurve            = myPane.AddCurve("Channel 0", list, Color.DarkGreen, SymbolType.Square);
                myCurve.Line.Width = 3.0f;
                zgc.AxisChange();
                zgc.Refresh();
                if (list.Count >= 20)
                {
                    list.RemoveAt(0);
                }
                LongTermcheckBox.Checked = false;
            }
            else
            {
                MessageBox.Show("chart attribute is null");
                errorCode = waveformAiCtrl.Stop();
                if (BioFailed(errorCode))
                {
                    throw new Exception();
                }
                waveformAiCtrl.Dispose();
                SamplingTextbox.Enabled   = true;
                DataLengthtextBox.Enabled = true;
                ChanneltextBox.Enabled    = true;
                FreqrangetextBox.Enabled  = true;
                DeviceIDtextBox.Enabled   = true;
                FreqMintextBox.Enabled    = true;
                FreqMaxtextBox.Enabled    = true;
                button2.Enabled           = true;
                button3.Enabled           = false;
            }
        }