private void OKBtn_Click(object sender, EventArgs e) { NCCReporter.LMLoggers.LognLM applog = NC.App.Logger(NCCReporter.LMLoggers.AppSection.App); string dest = UIIntegration.GetUsersFolder("Select Destination", string.Empty); if (string.IsNullOrEmpty(dest)) { return; } if (DetectorCurrentRadioButton.Checked) { List <Detector> l = new List <Detector>(); l.Add(Integ.GetCurrentAcquireDetector()); INCCInitialDataDetectorFile iddf = INCCKnew.FromDetectors(l); iddf.Save(dest); } else if (DetectorAllRadioButton.Checked) { List <Detector> l = NC.App.DB.Detectors; INCCInitialDataDetectorFile iddf = INCCKnew.FromDetectors(l); iddf.Save(dest); } else if (CalibrationCurrentRadioButton.Checked) { List <Detector> l = new List <Detector>(); l.Add(Integ.GetCurrentAcquireDetector()); List <INCCInitialDataCalibrationFile> lidcf = INCCKnew.CalibFromDetectors(l); if (lidcf.Count > 0) { if (!lidcf[0].Save(dest)) { applog.TraceEvent(NCCReporter.LogLevels.Warning, 33154, "No calibration parameters for " + lidcf[0].Name); } } } else if (CalibrationAllRadioButton.Checked) { List <Detector> l = NC.App.DB.Detectors; List <INCCInitialDataCalibrationFile> lidcf = INCCKnew.CalibFromDetectors(l); foreach (INCCInitialDataCalibrationFile idcf in lidcf) { if (!idcf.Save(dest)) { applog.TraceEvent(NCCReporter.LogLevels.Warning, 33154, "No calibration parameters for " + idcf.Name); } } } Close(); }
public uint CombinedCalculation(out Isotopics newIsotopics, bool INCCParity, NCCReporter.LMLoggers.LognLM logger) { MassSum = 0; uint res = 0; newIsotopics = null; foreach (CompositeIsotopic ci in isotopicComponents) { if (ci.pu_mass == 0.0f) { continue; } res = ci.CalculateDecayAndMass(ref_date, INCCParity, logger); if (res != 0) { break; } } if (res != 0) { return(res); } MassSum = CalculateMassSums(); if (MassSum <= 0) { logger.TraceEvent(NCCReporter.LogLevels.Error, 36784, "Sum of masses = 0."); res = 36784; } else { newIsotopics = CreateIsotopicsFromSums(ref_date, INCCParity, MassSum); } return(res); }
static void ResetMeasurement() { if (NC.App.Opstate.Measurement != null) { NC.App.Opstate.Measurement = null; NCCReporter.LMLoggers.LognLM log = NC.App.Loggers.Logger(NCCReporter.LMLoggers.AppSection.Control); long mem = GC.GetTotalMemory(false); log.TraceEvent(NCCReporter.LogLevels.Verbose, 4255, "Total GC Memory is {0:N0}Kb", mem / 1024L); log.TraceEvent(NCCReporter.LogLevels.Verbose, 4248, "GC now"); GC.Collect(); GC.WaitForPendingFinalizers(); log.TraceEvent(NCCReporter.LogLevels.Verbose, 4284, "GC complete"); mem = GC.GetTotalMemory(true); log.TraceEvent(NCCReporter.LogLevels.Verbose, 4255, "Total GC Memory now {0:N0}Kb", mem / 1024L); } }
private void OKBtn_Click(object sender, EventArgs e) { bool notify = true; NCCReporter.LMLoggers.LognLM ctrllog = N.App.Loggers.Logger(NCCReporter.LMLoggers.AppSection.Control); foreach (ListViewItem lvi in MeasurementView.Items) { if (lvi.Selected) { int lvIndex = 0; if (!int.TryParse(lvi.SubItems[5].Text, out lvIndex)) // 5 has the original mlist index of this sorted row element { continue; } MeasId mid = mlist[lvIndex].MeasurementId; ctrllog.TraceEvent(NCCReporter.LogLevels.Info, 22222, "Deleting " + mid.MeasOption.PrintName() + " " + mid.MeasDateTime.ToString("yy.MM.dd HH:mm:ss") + ", #" + mid.UniqueId + " for " + det.Id.DetectorId); N.App.DB.DeleteMeasurement(mlist[lvIndex].MeasurementId); notify = false; } } LoadList(notify); }
/// <summary> /// update isotopic composition data in db to calling date's values /// </summary> /// <param name="PuMass">mass of item</param> /// <param name="ref_date">date to update to </param> /// <param name="curiso">current iso</param> /// <param name="newiso">updated iso</param> /// <param name="logger">should be thru the global state</param> /// <param name="INCCParity">if true, ignore current day fraction in calculations</param> /// <returns>updated isotopics</returns> public static CompositeIsotopics update_comp_isotopics(double PuMass, /* mass of item */ DateTimeOffset ref_date, /* date to update to */ CompositeIsotopics curiso, NCCReporter.LMLoggers.LognLM logger, bool INCCParity) { double ref_days; double pu_days; double am_days; Tuple[] iso_mass = MakeArray(); Tuple[] decay_fract_pu_to_am = MakeArray(); Tuple[] decay_fract_am_to_now = MakeArray(); Tuple[] decay_fract_pu_to_now = MakeArray(); Tuple[] cur_mass = MakeArray(); double temp = 0.0; double temp_sum = 0.0; double cur_mass_sum = 0.0; //double x, y; part of err computation. hn double pu_mass = PuMass; if (pu_mass <= 0.0) { pu_mass = 1.0; } double isosum = 0.0; for (Isotope iso = Isotope.pu238; iso <= Isotope.pu242; iso++) { isosum += curiso[iso].v; } if (isosum <= 0.0) { logger.TraceEvent(NCCReporter.LogLevels.Warning, 36783, "Unable to update isotopics, sum of Pu isotopes must be greater than zero"); return(null); } CompositeIsotopics newcompiso = new CompositeIsotopics(); //dev note: roundabout way to do this from INCC code // The INCC6 parity flag is used to toggle this behavior: // INCC literally truncates the fractional date here, so it is always at time of the full day // gen_date_time_str_to_seconds (&seconds, results.meas_date, "00:00:00", GEN_DTF_IAEA); // ref_days = (double) seconds / SECONDS_PER_DAY; // if (INCCParity) { pu_days = (curiso.pu_date.Date.Subtract(ZeroIAEATime)).TotalDays; am_days = (curiso.am_date.Date.Subtract(ZeroIAEATime)).TotalDays; ref_days = (long)(ref_date.Date.Subtract(ZeroIAEATime)).TotalDays; } else { pu_days = (curiso.pu_date.Subtract(ZeroIAEATime)).TotalDays; am_days = (curiso.am_date.Subtract(ZeroIAEATime)).TotalDays; ref_days = (long)(ref_date.Subtract(ZeroIAEATime)).TotalDays; } for (Isotope iso = Isotope.pu238; iso <= Isotope.pu242; iso++) { iso_mass[(int)iso].v = (curiso[iso].v * pu_mass / 100.0); decay_fract_pu_to_am[(int)iso].v = Math.Exp((-LN2 / Halflives[(int)iso]) * (am_days - pu_days)); decay_fract_pu_to_now[(int)iso].v = Math.Exp((-LN2 / Halflives[(int)iso]) * (ref_days - pu_days)); } decay_fract_am_to_now[(int)Isotope.pu241].v = Math.Exp((-LN2 / Halflives[(int)Isotope.pu241]) * (ref_days - am_days)); decay_fract_am_to_now[(int)Isotope.am241].v = Math.Exp((-LN2 / Halflives[(int)Isotope.am241]) * (ref_days - am_days)); for (Isotope iso = Isotope.pu238; iso <= Isotope.pu242; iso++) { cur_mass[(int)iso].v = iso_mass[(int)iso].v * decay_fract_pu_to_now[(int)iso].v; } cur_mass[(int)Isotope.am241].v = decay_fract_am_to_now[(int)Isotope.am241].v * curiso[Isotope.am241].v / 100.0; for (Isotope iso = Isotope.pu238; iso <= Isotope.pu242; iso++) { temp_sum += decay_fract_pu_to_am[(int)iso].v * iso_mass[(int)iso].v; } temp = decay_fract_pu_to_am[(int)Isotope.pu241].v * iso_mass[(int)Isotope.pu241].v * (decay_fract_am_to_now[(int)Isotope.am241].v - decay_fract_am_to_now[(int)Isotope.pu241].v) * (LN2 / Halflives[(int)Isotope.pu241]) / ((LN2 / Halflives[(int)Isotope.pu241]) - (LN2 / Halflives[(int)Isotope.am241])); cur_mass[(int)Isotope.am241].v = (cur_mass[(int)Isotope.am241].v * temp_sum) + temp; for (Isotope iso = Isotope.pu238; iso <= Isotope.pu242; iso++) { cur_mass_sum += cur_mass[(int)iso].v; } if (cur_mass_sum <= 0.0) { logger.TraceEvent(NCCReporter.LogLevels.Warning, 36784, "Unable to update isotopics, mass sum must be greater than zero"); return(null); } else { logger.TraceEvent(NCCReporter.LogLevels.Verbose, 36722, "'update_isotopics' mass sum " + cur_mass_sum); } newcompiso.pu_date = new DateTime(ref_date.Ticks); newcompiso.am_date = new DateTime(ref_date.Ticks); for (Isotope iso = Isotope.pu238; iso <= Isotope.am241; iso++) { newcompiso[iso].v = 100.0 * cur_mass[(int)iso].v / cur_mass_sum; } //todo: composite isotopics have no err values? hn /*for (Isotope iso = Isotope.pu238; iso <= Isotope.pu242; iso++) * { * if (curiso[iso].v != 0) * newcompiso[iso].sigma = curiso[iso].sigma * newcompiso[iso].v / curiso[iso].v; * else * newcompiso[iso].sigma = curiso[iso].sigma; * * }*/ //todo: composite isotopics have no err values? hn /*if (curiso[Isotope.am241].v != 0.0) * { * x = (decay_fract_am_to_now[(int)Isotope.am241].v / 100.0) * temp_sum * * curiso[Isotope.am241].sigma; * temp = decay_fract_pu_to_am[(int)Isotope.pu241].v * * (decay_fract_am_to_now[(int)Isotope.am241].v - decay_fract_am_to_now[(int)Isotope.pu241].v) * (LN2 / PU241HL) / ((LN2 / PU241HL) - (LN2 / AM241HL)); * y = temp * (pu_mass / 100.0) * curiso[Isotope.pu241].sigma; * newcompiso[Isotope.am241].sigma = Math.Sqrt(x * x + y * y) / cur_mass_sum * 100.0; * } * else * newcompiso[Isotope.am241].sigma = curiso[Isotope.am241].sigma;*/ return(newcompiso); }
public uint CalculateDecayAndMass(DateTime ref_date, bool INCCParity, NCCReporter.LMLoggers.LognLM logger) { double ref_days; double pu_days; double am_days; Tuple[] iso_mass = Isotopics.MakeArray(); Tuple[] decay_fract_pu_to_am = Isotopics.MakeArray(); Tuple[] decay_fract_am_to_now = Isotopics.MakeArray(); Tuple[] decay_fract_pu_to_now = Isotopics.MakeArray(); double temp = 0.0; double temp_sum = 0.0; double pumass = pu_mass; double isosum = 0.0; for (Isotope iso = Isotope.pu238; iso <= Isotope.pu242; iso++) { isosum += isotopes[(int)iso].v; } if (isosum <= 0.0) { logger.TraceEvent(NCCReporter.LogLevels.Warning, 36783, "Unable to update isotopics, sum of Pu isotopes must be greater than zero"); return(36783); } Tuple[] newiso = Isotopics.MakeArray(); if (INCCParity) { pu_days = (pu_date.Date.Subtract(Isotopics.ZeroIAEATime)).TotalDays; am_days = (am_date.Date.Subtract(Isotopics.ZeroIAEATime)).TotalDays; ref_days = (long)(ref_date.Date.Subtract(Isotopics.ZeroIAEATime)).TotalDays; } else { pu_days = (pu_date.Subtract(Isotopics.ZeroIAEATime)).TotalDays; am_days = (am_date.Subtract(Isotopics.ZeroIAEATime)).TotalDays; ref_days = (long)(ref_date.Subtract(Isotopics.ZeroIAEATime)).TotalDays; } for (Isotope iso = Isotope.pu238; iso <= Isotope.pu242; iso++) { iso_mass[(int)iso].v = (isotopes[(int)iso].v * pumass / 100.0); decay_fract_pu_to_am[(int)iso].v = Math.Exp((-Isotopics.LN2 / Isotopics.Halflives[(int)iso]) * (am_days - pu_days)); decay_fract_pu_to_now[(int)iso].v = Math.Exp((-Isotopics.LN2 / Isotopics.Halflives[(int)iso]) * (ref_days - pu_days)); } decay_fract_am_to_now[(int)Isotope.pu241].v = Math.Exp((-Isotopics.LN2 / Isotopics.Halflives[(int)Isotope.pu241]) * (ref_days - am_days)); decay_fract_am_to_now[(int)Isotope.am241].v = Math.Exp((-Isotopics.LN2 / Isotopics.Halflives[(int)Isotope.am241]) * (ref_days - am_days)); for (Isotope iso = Isotope.pu238; iso <= Isotope.pu242; iso++) { CurrentMass[(int)iso].v = iso_mass[(int)iso].v * decay_fract_pu_to_now[(int)iso].v; } CurrentMass[(int)Isotope.am241].v = decay_fract_am_to_now[(int)Isotope.am241].v * isotopes[(int)Isotope.am241].v / 100.0; for (Isotope iso = Isotope.pu238; iso <= Isotope.pu242; iso++) { temp_sum += (decay_fract_pu_to_am[(int)iso].v * iso_mass[(int)iso].v); } temp = decay_fract_pu_to_am[(int)Isotope.pu241].v * iso_mass[(int)Isotope.pu241].v * (decay_fract_am_to_now[(int)Isotope.am241].v - decay_fract_am_to_now[(int)Isotope.pu241].v) * (Isotopics.LN2 / Isotopics.Halflives[(int)Isotope.pu241]) / ((Isotopics.LN2 / Isotopics.Halflives[(int)Isotope.pu241]) - (Isotopics.LN2 / Isotopics.Halflives[(int)Isotope.am241])); CurrentMass[(int)Isotope.am241].v = (CurrentMass[(int)Isotope.am241].v * temp_sum) + temp; return(0); }