/// <summary> /// Save a detector and its related class instances on the in-memory collections to the database /// </summary> /// <param name="newdet">The detector to persist</param> public static void PersistDetectorAndAssociations(Detector newdet) { // write detector essentials to DB, detector must be in DB before related insertions try { CentralizedState.App.DB.UpdateDetector(newdet); // write detector and related sr_parms to database BackgroundParameters bp = CentralizedState.App.DB.BackgroundParameters.Get(newdet); CentralizedState.App.DB.BackgroundParameters.Set(newdet, bp); NormParameters np = CentralizedState.App.DB.NormParameters.Get(newdet); CentralizedState.App.DB.NormParameters.Set(newdet, np); UnattendedParameters unp = CentralizedState.App.DB.UnattendedParameters.Get(newdet); CentralizedState.App.DB.UnattendedParameters.Set(newdet, unp); AddASourceSetup aass = CentralizedState.App.DB.AASSParameters.Get(newdet); CentralizedState.App.DB.AASSParameters.Set(newdet, aass); HVCalibrationParameters hv = CentralizedState.App.DB.HVParameters.Get(newdet); CentralizedState.App.DB.HVParameters.Set(newdet, hv); } catch (Exception) { } }
/// <summary> /// Create a new detector in-memory, with the related classes. /// Emulates the INCC relationship constructor, caller must insert new det into global list, then update to DB later for persistence /// </summary> /// <param name="model">detector to copy</param> /// <param name="newId">New detector name</param> /// <param name="elecId">Electronics id (just a string)</param> /// <param name="typeDesc">Type description (just a string)</param> /// <param name="srType">Actual instrument type</param> /// <returns>The newly created in-memory Detector class instance</returns> static public Detector CreateDetectorWithAssociations(Detector model, string newId, string elecId, string typeDesc, InstrType srType = InstrType.AMSR) { if (model != null) { Detector det = new Detector(model); // copies the SR too det.Id.SetIdDetails(newId, elecId, typeDesc, model.Id.SRType); // copy the model detector's related parameters (skips stratum) NormParameters n = CentralizedState.App.DB.NormParameters.Get(model); NormParameters Norm = new NormParameters(n); BackgroundParameters b = CentralizedState.App.DB.BackgroundParameters.Get(model); BackgroundParameters Background = new BackgroundParameters(b); UnattendedParameters u = CentralizedState.App.DB.UnattendedParameters.Get(model); UnattendedParameters Unatt = new UnattendedParameters(u); AddASourceSetup a = CentralizedState.App.DB.AASSParameters.Get(model); AddASourceSetup Aass = new AddASourceSetup(a); HVCalibrationParameters h = CentralizedState.App.DB.HVParameters.Get(model); HVCalibrationParameters Hv = new HVCalibrationParameters(h); // add copied param instances to in-memory maps CentralizedState.App.DB.NormParameters.Map.Add(det, Norm); CentralizedState.App.DB.UnattendedParameters.Map.Add(det, Unatt); CentralizedState.App.DB.BackgroundParameters.Map.Add(det, Background); CentralizedState.App.DB.AASSParameters.Map.Add(det, Aass); CentralizedState.App.DB.HVParameters.Map.Add(det, Hv); CentralizedState.App.DB.Detectors.Add(det); // add detector to in-memory list return(det); } else { Detector det = new Detector(); det.Id.SetIdDetails(newId, elecId, typeDesc, srType); if (srType.IsListMode()) { det.Id.FullConnInfo = new LMConnectionInfo(); } // add fresh param instances to in-memory maps CentralizedState.App.DB.NormParameters.Map.Add(det, new NormParameters()); CentralizedState.App.DB.UnattendedParameters.Map.Add(det, new UnattendedParameters()); CentralizedState.App.DB.BackgroundParameters.Map.Add(det, new BackgroundParameters()); CentralizedState.App.DB.AASSParameters.Map.Add(det, new AddASourceSetup()); CentralizedState.App.DB.HVParameters.Map.Add(det, new HVCalibrationParameters()); CentralizedState.App.DB.Detectors.Add(det); // add detector to in-memory list return(det); } /* * todo: create analysis selector (or it happens automatically when first referenced?) * creating a stratum association * */ }
public IDDSetupUnattendedMeas(Detector d) { InitializeComponent(); det = d; up = new UnattendedParameters(); up.Copy(NC.App.DB.UnattendedParameters.GetMap()[det]); MaxTimeTextBox.Text = up.ErrorSeconds.ToString(); AutoImportCheckBox.Checked = up.AutoImport; DoublesThresholdTextBox.Text = up.AASThreshold.ToString("F4"); this.Text += " for detector " + det.Id.DetectorName; }
private void OKBtn_Click(object sender, EventArgs e) { UnattendedParameters cur = NC.App.DB.UnattendedParameters.Map[det]; if (up.CompareTo(cur) != 0) { // copy changes back to original NC.App.DB.UnattendedParameters.Map[det] = up; // in the in-memory map NC.App.DB.UnattendedParameters.Set(det, up); // in the database } DialogResult = DialogResult.OK; Close(); }
public IDDSetupUnattendedMeas(Detector d) { InitializeComponent(); det = d; up = new UnattendedParameters(); if (det == null) return; if (NC.App.DB.UnattendedParameters.Map.ContainsKey(det)) up.Copy(NC.App.DB.UnattendedParameters.Map[det]); MaxTimeTextBox.Text = up.ErrorSeconds.ToString(); AutoImportCheckBox.Checked = up.AutoImport; DoublesThresholdTextBox.Text = up.AASThreshold.ToString("F1"); Text += " for detector " + det.Id.DetectorName; }
public IDDSetupUnattendedMeas(Detector d) { InitializeComponent(); det = d; up = new UnattendedParameters(); if (det == null) { return; } if (NC.App.DB.UnattendedParameters.Map.ContainsKey(det)) { up.Copy(NC.App.DB.UnattendedParameters.Map[det]); } MaxTimeTextBox.Text = up.ErrorSeconds.ToString(); AutoImportCheckBox.Checked = up.AutoImport; DoublesThresholdTextBox.Text = up.AASThreshold.ToString("F1"); Text += " for detector " + det.Id.DetectorName; }
/// <summary> /// Create a new detector in-memory, with the related classes. /// Emulates the INCC relationship constructor, caller must insert new det into global list, then update to DB later for persistence /// </summary> /// <param name="model">detector to copy</param> /// <param name="newId">New detector name</param> /// <param name="elecId">Electronics id (just a string)</param> /// <param name="typeDesc">Type description (just a string)</param> /// <param name="srType">Actual instrument type</param> /// <returns>The newly created in-memory Detector class instance</returns> public static Detector CreateDetectorWithAssociations(Detector model, string newId, string elecId, string typeDesc, InstrType srType = InstrType.AMSR) { if (model != null) { Detector det = new Detector(model); // copies the SR too det.Id.SetIdDetails(newId, elecId, typeDesc, model.Id.SRType); // copy the model detector's related parameters (skips stratum) NormParameters n = CentralizedState.App.DB.NormParameters.Get(model); NormParameters Norm = new NormParameters(n); BackgroundParameters b = CentralizedState.App.DB.BackgroundParameters.Get(model); BackgroundParameters Background = new BackgroundParameters(b); UnattendedParameters u = CentralizedState.App.DB.UnattendedParameters.Get(model); UnattendedParameters Unatt = new UnattendedParameters(u); AddASourceSetup a = CentralizedState.App.DB.AASSParameters.Get(model); AddASourceSetup Aass = new AddASourceSetup(a); HVCalibrationParameters h = CentralizedState.App.DB.HVParameters.Get(model); HVCalibrationParameters Hv = new HVCalibrationParameters(h); // add copied param instances to in-memory maps CentralizedState.App.DB.NormParameters.Map.Add(det, Norm); CentralizedState.App.DB.UnattendedParameters.Map.Add(det, Unatt); CentralizedState.App.DB.BackgroundParameters.Map.Add(det, Background); CentralizedState.App.DB.AASSParameters.Map.Add(det, Aass); CentralizedState.App.DB.HVParameters.Map.Add(det, Hv); CentralizedState.App.DB.Detectors.Add(det); // add detector to in-memory list return det; } else { Detector det = new Detector(); det.Id.SetIdDetails(newId, elecId, typeDesc,srType); if (srType.IsListMode()) det.Id.FullConnInfo = new LMConnectionInfo(); // add fresh param instances to in-memory maps CentralizedState.App.DB.NormParameters.Map.Add(det, new NormParameters()); CentralizedState.App.DB.UnattendedParameters.Map.Add(det, new UnattendedParameters()); CentralizedState.App.DB.BackgroundParameters.Map.Add(det, new BackgroundParameters()); CentralizedState.App.DB.AASSParameters.Map.Add(det, new AddASourceSetup()); CentralizedState.App.DB.HVParameters.Map.Add(det, new HVCalibrationParameters()); CentralizedState.App.DB.Detectors.Add(det); // add detector to in-memory list return det; } /* * todo: create analysis selector (or it happens automatically when first referenced?) * creating a stratum association * */ }