Esempio n. 1
0
        /// <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
             * */
        }
Esempio n. 2
0
 /// <summary>
 /// Set up the meta-data needed for cycle processing.
 /// Important for cycles obtained from files and the database.
 /// </summary>
 /// <param name="data_src">Source of cycle data</param>
 /// <param name="SRType">Expected detector type</param>
 /// <param name="dto">The start DateTimeOffset timestamp of the cycle</param>
 /// <param name="path">Filename of source of cycle, if any</param>
 public void UpdateDataSourceId(ConstructedSource data_src, InstrType SRType, DateTimeOffset dto, string path)
 {
     dsid.source = data_src;
     dsid.SRType = SRType;
     if (!string.IsNullOrEmpty(path))
         dsid.FileName = path;
     dsid.dt = dto;
 }
Esempio n. 3
0
 private void SetPredelayStepConstraint(InstrType t)
 {
     if (t.IsListMode() || t == InstrType.JSR15)
         PredelayTextBox.Steps = -1; // no check
     else
     {
         PredelayTextBox.Steps = 0.25; // traditional step increment
         if ((PredelayTextBox.Value % 0.25) != 0)
         {
             PredelayTextBox.Value = Bounce25Step(PredelayTextBox.Value);
         }
     }
 }