/// <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) { } }
public IDDBackgroundSetup(Detector dt = null, BackgroundParameters bg = null) { InitializeComponent(); if (det == null) det = Integ.GetCurrentAcquireDetector(); else det = dt; if (bp == null) bp = Integ.GetCurrentBackgroundParams(det); else bp = bg; bp.modified = false; this.Text += " for detector " + det.Id.DetectorName; foreach (Control nt in this.Controls) { if (nt.GetType() == typeof(NumericTextBox)) { ((NumericTextBox)nt).NumberFormat = NumericTextBox.Formatter.F6; ((NumericTextBox)nt).ToValidate = NumericTextBox.ValidateType.Float; ((NumericTextBox)nt).Min = -100.0; ((NumericTextBox)nt).Max = 100000.0; } } FieldFiller(); }
public IDDBackgroundSetup(Detector dt = null, BackgroundParameters bg = null) { InitializeComponent(); if (det == null) { det = Integ.GetCurrentAcquireDetector(); } else { det = dt; } if (bp == null) { bp = Integ.GetCurrentBackgroundParams(det); } else { bp = bg; } bp.modified = false; this.Text += " for detector " + det.Id.DetectorName; foreach (Control nt in this.Controls) { if (nt.GetType() == typeof(NumericTextBox)) { ((NumericTextBox)nt).NumberFormat = NumericTextBox.Formatter.F6; ((NumericTextBox)nt).ToValidate = NumericTextBox.ValidateType.Float; ((NumericTextBox)nt).Min = -100.0; ((NumericTextBox)nt).Max = 100000.0; } } FieldFiller(); }
private void workerDoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; if (worker == null) { throw (new ArgumentException("Worker thread has been started with an incorrecect sender")); } BackgroundParameters parameters = e.Argument as BackgroundParameters; if (parameters == null) { throw (new ArgumentException("Worker thread has been started with an incorrect parameter")); } if (RunParameters.IsWindows) { Thread.CurrentThread.Name = "TS File Reader for PID " + parameters.PID + " Table " + parameters.Table; } Thread.CurrentThread.Priority = ThreadPriority.Lowest; while (!worker.CancellationPending) { getSection(parameters); } resetEvent.Set(); }
public override void DrawBackground(BackgroundParameters parms) { float[] rgba = parms.Color.GetNormalizedValues(); _openGL.ClearColor(rgba[0], rgba[1], rgba[2], rgba[3]); if (rgba[3] != 1) { StrokeParameters stroke = Canvas.StrokeParameters; FillParameters fill = Canvas.FillParameters; bool strokeDisabled = stroke.Disabled; bool fillDisabled = fill.Disabled; Canvas.SetNoStroke(); Canvas.SetFill(parms.Color); DrawRectangle(0, 0, Canvas.Width, Canvas.Height); stroke.Disabled = strokeDisabled; fill.Disabled = fillDisabled; Canvas.SetStroke(stroke); Canvas.SetFill(fill); } else { _openGL.Clear(OpenGL.GL_COLOR_BUFFER_BIT); } }
/// <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 static BackgroundParameters GetCurrentBackgroundParams(Detector det) { BackgroundParameters bp = new BackgroundParameters(); if ((det != null) && (CentralizedState.App.DB.BackgroundParameters.Get(det.Id.DetectorName) != null)) { bp.Copy(CentralizedState.App.DB.BackgroundParameters.Map[det]); } return(bp); }
private void getSection(BackgroundWorker worker, BackgroundParameters parameters) { Collection <Mpeg2Section> mpeg2Sections = null; try { mpeg2Sections = getNextSection(); if (mpeg2Sections == null) { return; } } catch (ArgumentOutOfRangeException) { return; } Lock("GetSection"); if (Sections.Count >= parameters.MaxSections) { bool waitOver = false; do { Release("GetSectionA"); if (worker.CancellationPending) { return; } Thread.Sleep(100); Lock("GetSectionB"); waitOver = Sections.Count < parameters.MaxSections; }while (!waitOver); } foreach (Mpeg2Section mpeg2Section in mpeg2Sections) { if (tables == null || (tables != null && tables.Contains((byte)mpeg2Section.Table))) { /*if (Sections.Count < parameters.MaxSections)*/ Sections.Add(mpeg2Section); } /*else * Logger.Instance.Write("Section rejected: PID 0x" + mpeg2Section.PID.ToString("X") + " table 0x" + mpeg2Section.Table.ToString("X"));*/ } Release("GetSection"); }
public override void DrawBackground(BackgroundParameters parms) { using (DeviceContextHandler dch = GetDeviceContextHandler()) { if (parms.Image != null) { dch.DrawingSurface.DrawImage(parms.Image.Bitmap, 0, 0, Canvas.Width, Canvas.Height); } else { //dch.Graphics.FillRectangle(parms.ToBrush(), 0, 0, _graphics.Width, _graphics.Height); dch.DrawingSurface.Clear(parms.Color.ToSystemColor()); } } }
public unsafe void BuildDetector(INCCInitialDataDetectorFile iddf, int num) { INCCDB DB = NC.App.DB; detector_rec d = iddf.Detector[0]; sr_parms_rec sr = iddf.SRParms[0]; bkg_parms_rec bkh = iddf.BKGParms[0]; norm_parms_rec norm = iddf.NormParms[0]; tm_bkg_parms_rec tmbkg = iddf.TMBKGParms[0]; add_a_source_setup_rec aass = iddf.AASParms[0]; InstrType srtype = (InstrType)sr.sr_type; bool overwrite = NC.App.AppContext.OverwriteImportedDefs; mlogger.TraceEvent(LogLevels.Verbose, 34100, "Building '{0}' detector '{1}' from {2} {3}", srtype.ToString(), TransferUtils.str(d.detector_id, INCC.MAX_DETECTOR_ID_LENGTH), num, iddf.Path); // if the detector is not known internally, then // add the detector to the list of detectors in memory, and // associate a new set of SR, Bkg and Norm and AB params with the new detector // todo: What are the HV Params from INCC5, and once that is known, can they be transferred to the INCC6 HV Param and results tables Detector det = new Detector(); if (srtype.IsListMode()) det.Id.FullConnInfo = new LMConnectionInfo(); try { // this transfer should be a method in this class, it will be used elsewhere too det.Id.DetectorId = TransferUtils.str(d.detector_id, INCC.MAX_DETECTOR_ID_LENGTH); det.Id.SRType = srtype; det.Id.Type = TransferUtils.str(d.detector_type, INCC.DETECTOR_TYPE_LENGTH); det.Id.ElectronicsId = TransferUtils.str(d.electronics_id, INCC.ELECTRONICS_ID_LENGTH); det.Id.ConnInfo = sr.sr_port_number.ToString(); det.Id.source = ConstructedSource.INCCTransferCopy; det.MultiplicityParams.FA = srtype.DefaultFAFor(); det.MultiplicityParams.gateWidthTics = (ulong)(sr.gate_length * 10.0); // shift down to tics from microseconds det.SRParams.deadTimeCoefficientAinMicroSecs = sr.coeff_a_deadtime; det.SRParams.deadTimeCoefficientBinPicoSecs = sr.coeff_b_deadtime; det.SRParams.deadTimeCoefficientCinNanoSecs = sr.coeff_c_deadtime; det.SRParams.deadTimeCoefficientMultiplicityinNanoSecs = sr.multiplicity_deadtime; det.SRParams.dieAwayTime = sr.die_away_time * 10.0; // shift down to tics from microseconds det.SRParams.doublesGateFraction = sr.doubles_gate_fraction; det.SRParams.efficiency = sr.efficiency; det.SRParams.gateLength = (ulong)(sr.gate_length * 10.0); // shift down to tics from microseconds //det.SRParams.gateLength2 = sr.gate_length2; det.SRParams.highVoltage = sr.high_voltage; det.SRParams.predelay = (ulong)(sr.predelay * 10.0); // shift down to tics from microseconds det.SRParams.triplesGateFraction = sr.triples_gate_fraction; // = sr.sr_type , sr.sr_port_number, sr.sr_detector_id these are in the Id now, not the SRparams, but they travel together. if (NC.App.AppContext.OverwriteImportedDefs) DB.Detectors.Replace(det); else DB.Detectors.AddOnlyIfNotThere(det); DetectorIndex = DB.Detectors.Count - 1; BackgroundParameters bkg = new BackgroundParameters(); bkg.DeadtimeCorrectedRates.Singles.v = bkh.curr_passive_bkg_singles_rate; bkg.DeadtimeCorrectedRates.Doubles.v = bkh.curr_passive_bkg_doubles_rate; bkg.DeadtimeCorrectedRates.Triples.v = bkh.curr_passive_bkg_triples_rate; bkg.DeadtimeCorrectedRates.Singles.err = bkh.curr_passive_bkg_singles_err; bkg.DeadtimeCorrectedRates.Doubles.err = bkh.curr_passive_bkg_doubles_err; bkg.DeadtimeCorrectedRates.Triples.err = bkh.curr_passive_bkg_triples_err; bkg.Scaler1.v = bkh.curr_passive_bkg_scaler1_rate; bkg.Scaler2.v = bkh.curr_passive_bkg_scaler2_rate; bkg.INCCActive.Singles.v = bkh.curr_active_bkg_singles_rate; bkg.INCCActive.Singles.err = bkh.curr_active_bkg_singles_err; bkg.INCCActive.Scaler1Rate = bkh.curr_active_bkg_scaler1_rate; bkg.INCCActive.Scaler2Rate = bkh.curr_active_bkg_scaler2_rate; bkg.TMBkgParams.Singles.v = tmbkg.tm_singles_bkg; bkg.TMBkgParams.Ones.v = tmbkg.tm_ones_bkg; bkg.TMBkgParams.Twos.v = tmbkg.tm_twos_bkg; bkg.TMBkgParams.Zeros.v = tmbkg.tm_zeros_bkg; bkg.TMBkgParams.Singles.err = tmbkg.tm_singles_bkg_err; bkg.TMBkgParams.Ones.err = tmbkg.tm_ones_bkg_err; bkg.TMBkgParams.Twos.err = tmbkg.tm_twos_bkg_err; bkg.TMBkgParams.Zeros.err = tmbkg.tm_zeros_bkg_err; bkg.TMBkgParams.ComputeTMBkg = (tmbkg.tm_bkg == 0 ? false : true); if (DB.BackgroundParameters.Get(det.Id.DetectorName) == null) { DB.BackgroundParameters.GetMap().Add(det, bkg); // saved to DB at below } else if (overwrite) { bkg.modified = true; NC.App.DB.BackgroundParameters.GetMap().Remove(det); NC.App.DB.BackgroundParameters.GetMap().Add(det, bkg); NC.App.DB.BackgroundParameters.Set(det, bkg); } // save the params listed here using the detector as the key NormParameters normp = new NormParameters(); normp.acceptanceLimitPercent = norm.acceptance_limit_percent; normp.acceptanceLimitStdDev = norm.acceptance_limit_std_dev; normp.amliRefSinglesRate = norm.amli_ref_singles_rate; normp.biasMode = OldToNewBiasTestId(norm.bias_mode); normp.biasPrecisionLimit = norm.bias_precision_limit; normp.biasTestAddasrcPosition = norm.bias_test_addasrc_position; normp.biasTestUseAddasrc = (norm.bias_test_use_addasrc == 0 ? false : true); normp.cf252RefDoublesRate.v = norm.cf252_ref_doubles_rate; normp.currNormalizationConstant.v = norm.curr_normalization_constant; normp.currNormalizationConstant.err = norm.curr_normalization_constant_err; normp.initSrcPrecisionLimit = norm.init_src_precision_limit; normp.measRate.v = norm.meas_rate; normp.measRate.err = norm.meas_rate_err; normp.refDate = INCC.DateFrom(TransferUtils.str(norm.ref_date, INCC.DATE_TIME_LENGTH)); normp.sourceId = TransferUtils.str(norm.source_id, INCC.SOURCE_ID_LENGTH); normp.yieldRelativeToMrc95 = norm.yield_relative_to_mrc_95; if (DB.NormParameters.Get(det.Id.DetectorName) == null) { DB.NormParameters.GetMap().Add(det, normp); // saved to DB at end } else if (overwrite) { normp.modified = true; DB.NormParameters.GetMap().Remove(det); DB.NormParameters.GetMap().Add(det, normp); // the in-memory map DB.NormParameters.Set(det, normp); // the DB table } AddASourceSetup aassp = new AddASourceSetup(); aassp.type = OldToNewAASId(aass.ad_type); aassp.port_number = aass.ad_port_number; aassp.forward_over_travel = aass.ad_forward_over_travel; aassp.reverse_over_travel = aass.ad_reverse_over_travel; aassp.number_positions = aass.ad_number_positions; aassp.dist_to_move = TransferUtils.Copy(aass.ad_dist_to_move, INCC.MAX_ADDASRC_POSITIONS); aassp.cm_steps_per_inch = aass.cm_steps_per_inch; aassp.cm_forward_mask = aass.cm_forward_mask; aassp.cm_reverse_mask = aass.cm_reverse_mask; aassp.cm_axis_number = aass.cm_axis_number; aassp.cm_over_travel_state = aass.cm_over_travel_state; aassp.cm_step_ratio = aass.cm_step_ratio; aassp.cm_slow_inches = aass.cm_slow_inches; aassp.plc_steps_per_inch = aass.plc_steps_per_inch; aassp.scale_conversion_factor = aass.scale_conversion_factor; aassp.cm_rotation = (aass.cm_rotation == 0 ? false : true); if (!DB.AASSParameters.GetMap().ContainsKey(det)) { DB.AASSParameters.GetMap().Add(det, aassp); } else if (overwrite) { aassp.modified = true; DB.AASSParameters.GetMap().Remove(det); DB.AASSParameters.GetMap().Add(det, aassp); // todo: in-memory and db } if (!DB.UnattendedParameters.GetMap().ContainsKey(det)) { DB.UnattendedParameters.GetMap().Add(det, new UnattendedParameters()); } else if (overwrite) { DB.UnattendedParameters.GetMap().Remove(det); DB.UnattendedParameters.GetMap().Add(det, new UnattendedParameters()); } // the alpha beta arrays must be sized here, for first use by the calc_alpha_beta code in the cycle conditioning code Multiplicity mkey = new Multiplicity(srtype.DefaultFAFor()); mkey.SR = new ShiftRegisterParameters(det.SRParams); MultiplicityCountingRes mcr = new MultiplicityCountingRes(srtype.DefaultFAFor(), 0); ABKey abkey = new ABKey(mkey, 512); // NEXT: maxbins is arbitrary LMRawAnalysis.SDTMultiplicityCalculator.SetAlphaBeta(abkey, det.AB); mcr.AB.TransferIntermediates(det.AB); } catch (Exception e) { mlogger.TraceEvent(LogLevels.Warning, 34064, "Detector transfer processing error {0} {1} ({2})", det.Id.DetectorName, e.Message, System.IO.Path.GetFileName(iddf.Path)); } }
public static Measurement BuildMeasurementTemp(AcquireParameters acq, Detector det, AssaySelector.MeasurementOption mo, TestParameters tp, BackgroundParameters bkg, NormParameters np, AnalysisDefs.Isotopics iso, HVCalibrationParameters hvp) { // gather it all together MeasurementTuple mt = new MeasurementTuple(new DetectorList(det), tp, np, bkg, iso, acq, hvp); det.Id.source = acq.data_src; // set the detector overall data source value here // create the context holder for the measurement. Everything is rooted here ... Measurement meas = new Measurement(mt, mo); FillInMeasurementDetails(meas); // ready for insertion of methods and processing start return(meas); }
private void getSection(BackgroundParameters parameters) { if (siPacket == null) { siPacket = getPacket(true); if (siPacket == null) { return; } if (parameters.Table != 0xff && parameters.Table != siPacket.ByteData[siPacket.DataIndex]) { siPacket = null; return; } packetIndex = siPacket.DataIndex; } if (packetIndex > siPacket.ByteData.Length - 1) { siPacket = getPacket(false); if (siPacket == null) { Thread.Sleep(500); return; } packetIndex = siPacket.DataIndex; } byte table = siPacket.ByteData[packetIndex]; if (table == 0xff) { siPacket = null; return; } if (packetIndex == siPacket.ByteData.Length - 1) { siPacket = getPacket(false); if (siPacket == null) { Thread.Sleep(500); return; } packetIndex = siPacket.Index; } else { packetIndex++; } byte lengthByte1 = siPacket.ByteData[packetIndex]; if (packetIndex == siPacket.ByteData.Length - 1) { siPacket = getPacket(false); if (siPacket == null) { Thread.Sleep(500); return; } packetIndex = siPacket.Index; } else { packetIndex++; } byte lengthByte2 = siPacket.ByteData[packetIndex]; packetIndex++; int length = ((lengthByte1 & 0x0f) * 256) + lengthByte2; mpeg2Section = new Mpeg2Section(); mpeg2Section.Data = new byte[length + 3]; mpeg2Section.Length = length + 3; mpeg2Section.Data[0] = table; mpeg2Section.Data[1] = lengthByte1; mpeg2Section.Data[2] = lengthByte2; for (int index = 3; index < length + 3; index++) { if (packetIndex == siPacket.ByteData.Length) { siPacket = getPacket(false); if (siPacket == null) { Thread.Sleep(500); return; } packetIndex = siPacket.Index; } mpeg2Section.Data[index] = siPacket.ByteData[packetIndex]; packetIndex++; } if ((mpeg2Section.Data[1] & 0x80) == 1) { bool checkCRC = mpeg2Section.CheckCRC(); if (!checkCRC) { return; } } Logger.Instance.Dump("MPEG2 Section", mpeg2Section.Data, mpeg2Section.Data.Length); Lock("GetSection"); if (Sections.Count < parameters.MaxSections) { Sections.Add(mpeg2Section); } Release("GetSection"); }
private void getSection( BackgroundWorker worker, BackgroundParameters parameters) { Collection<Mpeg2Section> mpeg2Sections = null; try { mpeg2Sections = getNextSection(); if (mpeg2Sections == null) return; } catch (ArgumentOutOfRangeException) { return; } Lock("GetSection"); if (Sections.Count >= parameters.MaxSections) { bool waitOver = false; do { Release("GetSectionA"); if (worker.CancellationPending) return; Thread.Sleep(100); Lock("GetSectionB"); waitOver = Sections.Count < parameters.MaxSections; } while (!waitOver); } foreach (Mpeg2Section mpeg2Section in mpeg2Sections) { if (tables == null || (tables != null && tables.Contains((byte)mpeg2Section.Table))) { /*if (Sections.Count < parameters.MaxSections)*/ Sections.Add(mpeg2Section); } /*else Logger.Instance.Write("Section rejected: PID 0x" + mpeg2Section.PID.ToString("X") + " table 0x" + mpeg2Section.Table.ToString("X"));*/ } Release("GetSection"); }
private void getSection(BackgroundParameters parameters) { if (siPacket == null) { siPacket = getPacket(true); if (siPacket == null) { Thread.Sleep(500); return; } packetIndex = siPacket.DataIndex; } if (packetIndex > siPacket.ByteData.Length - 1) { siPacket = null; return; } byte table = siPacket.ByteData[packetIndex]; if (table == 0xff) { siPacket = null; return; } if (packetIndex == siPacket.ByteData.Length - 1) { siPacket = getPacket(false); if (siPacket == null) { Thread.Sleep(500); return; } packetIndex = siPacket.Index; } else packetIndex++; byte lengthByte1 = siPacket.ByteData[packetIndex]; if (packetIndex == siPacket.ByteData.Length - 1) { siPacket = getPacket(false); if (siPacket == null) { Thread.Sleep(500); return; } packetIndex = siPacket.Index; } else packetIndex++; byte lengthByte2 = siPacket.ByteData[packetIndex]; packetIndex++; int length = ((lengthByte1 & 0x0f) * 256) + lengthByte2; if (length < 2) { packetIndex += length; return; } if (tables != null && !tables.Contains(table)) { packetIndex += length; return; } mpeg2Section = new Mpeg2Section(); mpeg2Section.Data = new byte[length + 3]; mpeg2Section.Length = length + 3; mpeg2Section.Data[0] = table; mpeg2Section.Data[1] = lengthByte1; mpeg2Section.Data[2] = lengthByte2; for (int index = 3; index < length + 3; index++) { if (packetIndex == siPacket.ByteData.Length) { siPacket = getPacket(false); if (siPacket == null) { Thread.Sleep(500); return; } packetIndex = siPacket.Index; } mpeg2Section.Data[index] = siPacket.ByteData[packetIndex]; packetIndex++; } if ((mpeg2Section.Data[1] & 0x80) == 1) { bool checkCRC = mpeg2Section.CheckCRC(); if (!checkCRC) return; } Lock("GetSection"); if (Sections.Count < parameters.MaxSections) Sections.Add(mpeg2Section); Release("GetSection"); }
public static BackgroundParameters GetCurrentBackgroundParams(Detector det) { BackgroundParameters bp = new BackgroundParameters(); if ((det != null) && (CentralizedState.App.DB.BackgroundParameters.Get(det.Id.DetectorName) != null)) bp.Copy(CentralizedState.App.DB.BackgroundParameters.Map[det]); return bp; }
/// <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 * */ }
public override void DrawBackground(BackgroundParameters parms) { float[] rgba = parms.Color.GetNormalizedValues(); _openGL.ClearColor(rgba[0], rgba[1], rgba[2], rgba[3]); _openGL.Clear(OpenGL.GL_COLOR_BUFFER_BIT); }