/// <summary> /// 每隔10ms刷新用户界面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled = false; samplesToPreview = int.Parse(textBox_previewSamples.Text); double length = 0; bool recordDone = false; //步骤5:获取流盘状态,包括已流盘长度和流盘是否结束标志位 dstask.GetRecordStatus(out length, out recordDone); if (recordDone) { //流盘已结束 buttonStop_Click(null, null); progressBar1.Value = progressBar1.Maximum; } else { //步骤6:流盘仍在进行中,预览最新流盘数据并显示 dstask.ReadLatestData(ref priewData); ArrayManipulation.Transpose(priewData, ref transposedData); easyChart_signal.Plot(transposedData); for (int i = 0; i < channelNumbers.Count; i++) { ArrayManipulation.GetArraySubset(transposedData, i, ref singleChannelPriewData, ArrayManipulation.IndexType.row); Spectrum.PowerSpectrum(singleChannelPriewData, double.Parse(textBox_sampleRate.Text), ref singleChannelSpectrumData, out spectrumInterval[i], SpectrumUnits.V2); ArrayManipulation.ReplaceArraySubset(singleChannelSpectrumData, ref previewSpectrumBufferTransposed, i, ArrayManipulation.IndexType.row); } easyChart_spectrum.Plot(previewSpectrumBufferTransposed, 0, spectrumInterval[0]); progressBar1.Value = (int)(length / double.Parse(textBox_recordLength.Text) * progressBar1.Maximum); timer1.Enabled = true; } }
public override void Fetch(ref double[,] fetchData) { double[,] data = new double[_samplesToRead, simChList.Count]; List <double[]> Data = new List <double[]>(); for (int i = 0; i < simChList.Count; i++) { double[] simData = new double[_samplesToRead]; double[] noise = new double[_samplesToRead]; Generation.UniformWhiteNoise(ref noise, 0.03); if (i == 0) { Generation.SquareWave(ref simData, 1, 50, 10); } else { Generation.SineWave(ref simData, 1, 0, 10); } ArrayCalculation.Add(simData, noise, ref simData); Data.Add(simData); } for (int i = 0; i < Data.Count; i++) { ArrayManipulation.ReplaceArraySubset(Data.ElementAt(i), ref data, i, ArrayManipulation.IndexType.column); } fetchData = data; }
private void timer_measure_Tick(object sender, EventArgs e) { timer_measure.Enabled = false; if (dataAvailable) { MathEngineHandler.WfmSubset(readData, device.SelectedChannels.ToList(), (double)numericUpDown_sampleRate.Value); ArrayManipulation.Transpose(readData, ref displayData); MathEngineHandler.Process(); if (spectrumMode) { for (int i = 0; i < readData.GetLength(1); i++) { ArrayManipulation.GetArraySubset(readData, i, ref tempData, ArrayManipulation.IndexType.column); Spectrum.PowerSpectrum(tempData, _sampleRate, ref tempSpecData, out df); ArrayManipulation.ReplaceArraySubset(tempSpecData, ref displayData, i, ArrayManipulation.IndexType.row); } easyChart1.Plot(displayData, 0, df); } else { if (checkBox_timeDisplay.Checked) { easyChart1.Plot(displayData, 0, 1.0 / (double)numericUpDown_sampleRate.Value); } else { easyChart1.Plot(displayData); } } easyChart1.SeriesNames = _seriesDefaultNames; easyChart1.SeriesNames = _chNames.ToArray(); dgv_mathEngine.Invalidate(); if (isSingleRun) { easyButton_stop_Click(null, null); } else { device.Stop(); easyButton_contStart_Click(null, null); } } else { timer_measure.Enabled = true; } }
public virtual void ReplaceSubset <T>(ref T[] src, int startIdx, T[] elements) { ArrayManipulation.ReplaceArraySubset(elements, ref src, startIdx); }
public virtual void ReplaceSubset <T>(ref T[] src, int startIdx, T element) { ArrayManipulation.ReplaceArraySubset(new T[1] { element }, ref src, startIdx); }