private void button7_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex == -1) { MessageBox.Show("No ND Filter Selected.", "Calibration Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int Idx = comboBox1.SelectedIndex; if (comboBox2.SelectedIndex == -1) { MessageBox.Show("No Module Selected.", "Calibration Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int ModIdx = comboBox2.SelectedIndex; if (myMgr.GetType(ModIdx) == SpectType.NoSpectrometer) { MessageBox.Show("Module Spectromter Not Assigned.", "Calibration Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (MessageBox.Show("Remove All Unit from Test Module", "Calibration Information", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.Cancel) { return; } ModLB.SelectedIndex = ModIdx; DarkRefBtn_Click(sender, e); button1_Click(sender, e); if (MessageBox.Show("Load ND Filter To Test Module", "Calibration Information", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.Cancel) { return; } List <float> wl = new List <float>(); wl = myMgr.GetWaveLength(ModIdx); //List<double> cnt = new List<double>(); measVal = myMgr.GetCount(ModIdx); InitChart((int)measVal.Max()); if ((wl == null) || (measVal == null)) { MessageBox.Show("Error Getting Spectrum."); return; } UpdateChart(wl, measVal); Thread.Sleep(500); InitTransChart(); //Calculate Normalized Value TransVal = CalculateTransRatio(darkRef, whiteRef, measVal); UpdateChart(wl, TransVal); int sIdx = 0; int idx = 0; InitCaliLV(); List <float> NDTransData = new List <float>(); for (int i = 0; i < NDInfo[Idx].data.Count; i++) { ListViewItem item = NICaliLV.Items.Add(NICaliLV.Items.Count + ""); item.SubItems.Add(NDInfo[Idx].data[i].waveLength.ToString()); item.SubItems.Add(NDInfo[Idx].data[i].min.ToString("F2")); item.SubItems.Add(NDInfo[Idx].data[i].max.ToString("F2")); item.SubItems.Add(NDInfo[Idx].data[i].Nominal.ToString("F2")); idx = NearestIndex(sIdx, NDInfo[Idx].data[i].waveLength, wl); sIdx = idx; item.SubItems.Add(TransVal[idx].ToString("F2")); item.UseItemStyleForSubItems = false; NDTransData.Add(TransVal[idx]); double min = NDInfo[Idx].data[i].Nominal * (NDInfo[Idx].data[i].min / 100); double max = NDInfo[Idx].data[i].Nominal * (NDInfo[Idx].data[i].max / 100); double diff = TransVal[idx] - NDInfo[Idx].data[i].Nominal; if ((diff < min) || (diff > max)) { item.SubItems.Add("Fail"); item.SubItems[6].BackColor = Color.Red; } else { item.SubItems.Add("Pass"); item.SubItems[6].BackColor = Color.Lime; } item.EnsureVisible(); } SaveNDFilterData(NDInfo[Idx], NDTransData, ModIdx + 1, NDInfo[Idx]); MessageBox.Show("ND Filter Calibration Completed.", "Calibration Information", MessageBoxButtons.OK, MessageBoxIcon.Information); }