private void ExportDataDialog_Load(object sender, EventArgs e) { FileFormatComboBox.SelectedIndex = FileFormatComboBox.FindStringExact("CSV"); MeasurementTypeComboBox.SelectedIndex = MeasurementTypeComboBox.FindStringExact("Verification"); }
private void ExportNCC(string fileName, List <Channel> selectedChannels, DateTime start, DateTime end) { // Validate detector ID if (DetectorIDTextBox.Text.Length > 11) { MessageBox.Show("Detector ID must be 11 or fewer characters"); return; } while (DetectorIDTextBox.Text.Length < 11) { DetectorIDTextBox.Text += " "; } // Validate item ID if (ItemIDTextBox.Text.Length > 12) { MessageBox.Show("Item ID must be 12 or fewer characters"); return; } while (ItemIDTextBox.Text.Length < 12) { ItemIDTextBox.Text += " "; } NCCWriter writer = new NCCWriter(); if (MeasurementTypeComboBox.SelectedIndex == MeasurementTypeComboBox.FindStringExact("Background")) { writer.NCCMode = NCCWriter.NCCType.BACKGROUND; } else if (MeasurementTypeComboBox.SelectedIndex == MeasurementTypeComboBox.FindStringExact("Normalization")) { writer.NCCMode = NCCWriter.NCCType.NORMALIZATION; } if (MeasurementTypeComboBox.SelectedIndex == MeasurementTypeComboBox.FindStringExact("Verification")) { writer.NCCMode = NCCWriter.NCCType.VERIFICATION; } writer.SetDetectorID(DetectorIDTextBox.Text); writer.SetItemID(ItemIDTextBox.Text); writer.Cycles = new List <NCCWriter.Cycle>(); foreach (Channel chan in selectedChannels) { chan.GetInstrument().LoadData(ChannelCompartment.Process, start, end); } List <DateTime> dates = selectedChannels[0].GetTimeStamps(ChannelCompartment.Process); for (int i = 0; i < dates.Count; i++) { if (dates[i] >= start && dates[i] <= end) { NCCWriter.Cycle cycle = new NCCWriter.Cycle(); cycle.DateAndTime = dates[i]; if (i < dates.Count - 1) { cycle.CountSeconds = (ushort)(dates[i + 1] - dates[i]).TotalSeconds; } else { cycle.CountSeconds = (ushort)(dates[i] - dates[i - 1]).TotalSeconds; } cycle.Totals = selectedChannels[0].GetValues(ChannelCompartment.Process)[i]; switch (selectedChannels.Count) { case 1: cycle.RPlusA = 0; cycle.A = 0; cycle.Scaler1 = 0; cycle.Scaler2 = 0; break; case 2: cycle.RPlusA = selectedChannels[1].GetValues(ChannelCompartment.Process)[i]; cycle.A = 0; cycle.Scaler1 = 0; cycle.Scaler2 = 0; break; case 3: cycle.RPlusA = selectedChannels[1].GetValues(ChannelCompartment.Process)[i]; cycle.A = selectedChannels[2].GetValues(ChannelCompartment.Process)[i]; cycle.Scaler1 = 0; cycle.Scaler2 = 0; break; case 4: cycle.RPlusA = selectedChannels[1].GetValues(ChannelCompartment.Process)[i]; cycle.A = selectedChannels[2].GetValues(ChannelCompartment.Process)[i]; cycle.Scaler1 = selectedChannels[3].GetValues(ChannelCompartment.Process)[i]; cycle.Scaler2 = 0; break; default: cycle.RPlusA = selectedChannels[1].GetValues(ChannelCompartment.Process)[i]; cycle.A = selectedChannels[2].GetValues(ChannelCompartment.Process)[i]; cycle.Scaler1 = selectedChannels[3].GetValues(ChannelCompartment.Process)[i]; cycle.Scaler2 = selectedChannels[4].GetValues(ChannelCompartment.Process)[i]; break; } writer.Cycles.Add(cycle); } } try { writer.WriteNeutronCyclesFile(FileTextBox.Text); } catch (Exception ex) { MessageBox.Show("Export Error\n" + ex.Message); System.Windows.Forms.Cursor.Current = Cursors.Default; return; } MessageBox.Show("Export complete!"); DialogResult = DialogResult.OK; Dispose(); }