private void DrawEnergyValue() { for (int i = 0; i < SpInfo.numPixls; i++) { if (SpInfo.WavelengthArray[i] > 10000000000) { SpInfo.WavelengthArray[i] = SpInfo.WavelengthArray[i - 1]; } if (SpInfo.DataA[i] > 10000000000) { SpInfo.DataA[i] = SpInfo.DataA[i - 1]; } } SpInfo.DataX = SpInfo.WavelengthArray; SpInfo.w1 = Math.Floor((double)(SpInfo.DataX[0] / 100.0)) * 100.0; SpInfo.w2 = Math.Ceiling((double)(SpInfo.DataX[SpInfo.DataX.Length - 1] / 100.0)) * 100.0; Spectrometer.Data[] dataGet = new Spectrometer.Data[1]; dataGet[0].DataX = SpInfo.WavelengthArray; dataGet[0].DataE = SpInfo.DataA; this.ViewStylemy = ViewStyle.Energy; DrawDelegate delegate2 = new DrawDelegate(this.Draw); this.Draw("能量图", dataGet, 0); this.txtMeanErr.Text = this.DataHandlingmy.MeanValue(dataGet[0].DataE).ToString("0.000e0"); this.txtMaxStdErr.Text = this.DataHandlingmy.MaxValue(dataGet[0].DataE).ToString("0.000e0"); }
private void btnBackGrd_Click(object sender, EventArgs e) { byte[] buffer; this.timer1.Enabled = false; try { if (!Home.serialPortSetDevice.IsOpen) { Home.serialPortSetDevice.Open(); } buffer = Home.SPControlWord["LightOn"]; Home.serialPortSetDevice.Write(buffer, 0, buffer.Length); Thread.Sleep(500); buffer = Home.SPControlWord["ReferenceOn"]; Home.serialPortSetDevice.Write(buffer, 0, buffer.Length); Thread.Sleep(500); } catch (Exception exception1) { MessageBox.Show(exception1.ToString()); return; } this.prgsBarGetEnergy.Visible = true; this.MySpectrometer._ProgressBar = this.prgsBarGetEnergy; this.MySpectrometer.GetSingleBeam(Spectrometer.spectrometerIndex, ref SpInfo, true); SpInfo.DataAB = SpInfo.DataA; SpInfo.DataA = null; this.DataIOmy.TXTSaveData(Application.StartupPath.ToString() + @"\background", SpInfo.DataX, SpInfo.DataAB); Spectrometer.Data[] dataGet = new Spectrometer.Data[1]; dataGet[0].DataX = SpInfo.WavelengthArray; dataGet[0].DataE = SpInfo.DataA; this.ViewStylemy = ViewStyle.Energy; DrawDelegate method = new DrawDelegate(this.Draw); base.BeginInvoke(method, new object[] { "能量图", dataGet, 0 }); this.Draw("背景能量图", dataGet, 0); this.MySpectrometer.ReadDK(ref SpInfo); MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); try { if (!Home.serialPortSetDevice.IsOpen) { Home.serialPortSetDevice.Open(); } buffer = Home.SPControlWord["ReferenceOff"]; Home.serialPortSetDevice.Write(buffer, 0, buffer.Length); } catch (Exception exception2) { MessageBox.Show(exception2.ToString()); } }
private void ReDraw(object sender, EventArgs e) { if (this.ViewStylemy == Form_offLine.ViewStyle.Spec) { Form_offLine.DrawDelegate drawDelegate = new Form_offLine.DrawDelegate(this.Draw); int index1 = this.comboBox1.SelectedIndex < 0 ? 0 : this.comboBox1.SelectedIndex; if (this.Data.Length > 0) { this.BeginInvoke((Delegate)drawDelegate, (object)"光谱图", (object)this.Data, (object)index1); } Spectrometer.Data[] dataArray = new Spectrometer.Data[1]; dataArray[0].DataX = this.Data[index1].DataX; dataArray[0].DataY = new double[dataArray[0].DataX.Length]; for (int index2 = 0; index2 < dataArray[0].DataX.Length; ++index2) { dataArray[0].DataY[index2] = this.StdErrY[index1, index2]; } TextBox txtMeanErr = this.txtMeanErr; double num = this.DataHandlingmy.MeanValue(dataArray[0].DataY); string str1 = num.ToString("0.000e0"); txtMeanErr.Text = str1; TextBox txtMaxStdErr = this.txtMaxStdErr; num = this.DataHandlingmy.MaxValue(dataArray[0].DataY); string str2 = num.ToString("0.000e0"); txtMaxStdErr.Text = str2; } else if (this.ViewStylemy == Form_offLine.ViewStyle.Energy) { Form_offLine.DrawDelegate drawDelegate = new Form_offLine.DrawDelegate(this.Draw); int num = this.comboBox1.SelectedIndex < 0 ? 0 : this.comboBox1.SelectedIndex; if (this.Data == null) { return; } this.BeginInvoke((Delegate)drawDelegate, (object)"能量图", (object)this.Data, (object)num); } else if (this.ViewStylemy == Form_offLine.ViewStyle.Mean) { this.btnMeanView_Click(sender, e); } else { if (this.ViewStylemy != Form_offLine.ViewStyle.StdErr) { return; } this.btnStdErrView_Click(sender, e); } }
private void btnMeanView_Click(object sender, EventArgs e) { DrawDelegate method = new DrawDelegate(this.Draw); int selectedIndex = this.comboBox1.SelectedIndex; Spectrometer.Data[] dataArray = new Spectrometer.Data[1]; if (Spectrometer.DataGet != null) { dataArray[0].DataX = Spectrometer.DataGet[selectedIndex].DataX; dataArray[0].DataY = new double[dataArray[0].DataX.Length]; for (int i = 0; i < dataArray[0].DataX.Length; i++) { dataArray[0].DataY[i] = this.MeanY[selectedIndex, i]; } this.ViewStylemy = ViewStyle.Mean; base.BeginInvoke(method, new object[] { "平均谱图", dataArray, 0 }); } }
private void btnMeanView_Click(object sender, EventArgs e) { Form_offLine.DrawDelegate drawDelegate = new Form_offLine.DrawDelegate(this.Draw); int selectedIndex = this.comboBox1.SelectedIndex; Spectrometer.Data[] dataArray = new Spectrometer.Data[1]; if (this.Data == null) { return; } dataArray[0].DataX = this.Data[selectedIndex].DataX; dataArray[0].DataY = new double[dataArray[0].DataX.Length]; for (int index = 0; index < dataArray[0].DataX.Length; ++index) { dataArray[0].DataY[index] = this.MeanY[selectedIndex, index]; } this.ViewStylemy = Form_offLine.ViewStyle.Mean; this.BeginInvoke((Delegate)drawDelegate, (object)"平均谱图", (object)dataArray, (object)0); }
private void btnStdErrView_Click(object sender, EventArgs e) { DrawDelegate method = new DrawDelegate(this.Draw); int selectedIndex = this.comboBox1.SelectedIndex; Spectrometer.Data[] dataArray = new Spectrometer.Data[1]; if (Spectrometer.DataGet != null) { dataArray[0].DataX = Spectrometer.DataGet[selectedIndex].DataX; dataArray[0].DataY = new double[dataArray[0].DataX.Length]; for (int i = 0; i < dataArray[0].DataX.Length; i++) { dataArray[0].DataY[i] = this.StdErrY[selectedIndex, i]; } this.ViewStylemy = ViewStyle.StdErr; base.BeginInvoke(method, new object[] { "标准差图", dataArray, 0 }); this.txtMeanErr.Text = this.DataHandlingmy.MeanValue(dataArray[0].DataY).ToString("0.000e0"); this.txtMaxStdErr.Text = this.DataHandlingmy.MaxValue(dataArray[0].DataY).ToString("0.000e0"); } }
private void btnStdErrView_Click(object sender, EventArgs e) { Form_offLine.DrawDelegate drawDelegate = new Form_offLine.DrawDelegate(this.Draw); int selectedIndex = this.comboBox1.SelectedIndex; Spectrometer.Data[] dataArray = new Spectrometer.Data[1]; if (this.Data == null) { return; } dataArray[0].DataX = this.Data[selectedIndex].DataX; dataArray[0].DataY = new double[dataArray[0].DataX.Length]; for (int index = 0; index < dataArray[0].DataX.Length; ++index) { dataArray[0].DataY[index] = this.StdErrY[selectedIndex, index]; } this.ViewStylemy = Form_offLine.ViewStyle.StdErr; this.BeginInvoke((Delegate)drawDelegate, (object)"标准差图", (object)dataArray, (object)0); this.txtMeanErr.Text = this.DataHandlingmy.MeanValue(dataArray[0].DataY).ToString("0.000e0"); this.txtMaxStdErr.Text = this.DataHandlingmy.MaxValue(dataArray[0].DataY).ToString("0.000e0"); }