예제 #1
0
 public void SpectrSaved(Spectr sp)
 {
     /*string path = sp.GetPath();
      * for (int i = 0; i < SpectrCash.Count; i++)
      *  if (SpectrCash[i].Sp.GetPath().Equals(path))
      *      SpectrCash.RemoveAt(i);*/
 }
예제 #2
0
        void CheckSelection()
        {
            Spectr sp;

            spView.ClearSpectrList();
            pPlainSpectrView.ClearSpectrList();
            int n = 0;

            if (SelectedSpectrPath != null)
            {
                sp = new Spectr(SelectedSpectrPath);
                spView.AddSpectr(sp, FormatSpectrPath(SelectedSpectrPath));
                pPlainSpectrView.AddSpectr(sp, FormatSpectrPath(SelectedSpectrPath));
                n++;
            }
            foreach (string path in CheckedList)
            {
                if (path.Equals(SelectedSpectrPath))
                {
                    continue;
                }
                sp = new Spectr(path);
                if (n < 6)
                {
                    n++;
                    spView.AddSpectr(sp, FormatSpectrPath(path));
                }
                pPlainSpectrView.AddSpectr(sp, FormatSpectrPath(path));
            }
            spView.ReDraw();
            pPlainSpectrView.ReDraw();
        }
예제 #3
0
        public Spectr GetCorrectedSpectr(Spectr nul, Spectr sig)
        {
            Spectr sp = new Spectr(sig.GetMeasuringCondition(), new Dispers(), new OpticFk(), "SensTest");

            short[][] data;
            int[]     ss = sig.GetCommonDispers().GetSensorSizes();
            data = new short[ss.Length][];

            List <SpectrDataView> vnul = nul.GetViewsSet();
            List <SpectrDataView> vsig = sig.GetViewsSet();

            for (int s = 0; s < ss.Length; s++)
            {
                data[s] = new short[ss[s]];
                for (int i = 0; i < ss[s]; i++)
                {
                    data[s][i] = (short)(GetK(vnul, vsig, s, i) * K[s][i]);
                }
            }

            SpectrDataView view = new SpectrDataView(sig.GetMeasuringCondition(), data, short.MaxValue, short.MaxValue);

            sp.Add(view);

            return(sp);
        }
예제 #4
0
        private void btMeasuringNewSpectr_Click_Final(List <SpectrDataView> rez, SpectrCondition cond)
        {
            try
            {
                //string sel = (string)LastName.Clone();
                Spectr sp = new Spectr(cond, Common.Env.DefaultDisp, Common.Env.DefaultOpticFk, "ChangeSpectrCollectionControl");
                for (int i = 0; i < rez.Count; i++)
                {
                    sp.Add(rez[i]);
                }

                //string path = Folder.CreateRecordPath(sel);

                sp.SaveAs(CurTag.GetPath());
                ReLoadList();
                //SelectSpectr(sel);
                if (AfterMeasuringProc != null)
                {
                    AfterMeasuringProc();
                }

                //SpView.ReDrawNow();
                //SpView.Invalidate();
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }
        public double RateSpectrDataView(Spectr sp, SpectrDataView sig, SpectrDataView nul)
        {
            if (chbEnabled.Checked == false)
            {
                return(-1);
            }
            List <double> rate = new List <double>();

            for (int i = 0; i < Data.Count; i++)
            {
                double r = Data[i].RateSpectrDataView(sp, sig, nul);
                if (serv.IsValid(r) == false)
                {
                    continue;
                }
                rate.Add(r);
            }
            if (rate.Count == 0)
            {
                return(-1);
            }
            double ever = analit.Stat.GetEver(rate);

            return(ever);
        }
예제 #6
0
        private void MMStructDelMeasuring_Click(object sender, EventArgs e)
        {
            try
            {
                string base_path = MeasuringFile;//(string)(tvDirView.SelectedNode.Tag);

                int ind = base_path.IndexOf(".ss");
                if (ind < 0)
                {
                    MessageBox.Show(MainForm.MForm, "Выберите спектр для удаления",
                                    "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                base_path = base_path.Substring(0, ind);

                DialogResult dr = MessageBox.Show(MainForm.MForm,
                                                  "Вы хотите удалить спектр:" + base_path, "Предупреждение",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr != DialogResult.Yes)
                {
                    return;
                }

                Spectr.RemoveSpectr(base_path);
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }
예제 #7
0
        private void btReMeasuringSpectr_Click_Final(List <SpectrDataView> rez, SpectrCondition cond)
        {
            try
            {
                Spectr sp = CurSp;// new Spectr(Folder, LastName);

                sp.SetMeasuringCondition(cond);

                sp.Clear();
                for (int i = 0; i < rez.Count; i++)
                {
                    sp.Add(rez[i]);
                }

                sp.SetDispers(Common.Env.DefaultDisp);
                sp.OFk = Common.Env.DefaultOpticFk;

                sp.Save();
                ReLoadList();

                if (AfterMeasuringProc != null)
                {
                    AfterMeasuringProc();
                }

                SpView.ReDrawNow();
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }
예제 #8
0
        Spectr Measuring(int sp_num, float common)
        {
            Common.Dev.CheckConnection();

            SpectrCondition cond = new SpectrCondition(Common.Dev.Tick,
                                                       SpectrCondition.GetDefaultCondition(false, false, (float)nmExpFrom.Value, (float)nmExpTo.Value, (float)(nmExpFrom.Value + nmExpTo.Value) * 9, 10));

            Common.Dev.Measuring(cond, null);

            Dispers disp = new Dispers();
            OpticFk fk   = new OpticFk();
            Spectr  sp   = new Spectr(cond, disp, fk, "SensTest");

            for (int i = 0; i < Common.Dev.LetestResult.Count; i++)
            {
                sp.Add(Common.Dev.LetestResult[i]);
            }

            Sp[sp_num] = sp;

            string file_name = GetSpectrName(sp_num);

            Sp[sp_num].SaveAs(file_name);

            Common.Log(Common.MLS.Get(MLSConst, "Done..."));
            return(sp);
        }
예제 #9
0
            public Data(Spectr sp, float con, double ly, bool from_next)
            {
                Sp  = sp;
                Con = con;
                Dispers    disp = sp.GetCommonDispers();
                List <int> snl  = disp.FindSensors(ly);
                int        sn;

                if (from_next)
                {
                    sn = snl[1];
                }
                else
                {
                    sn = snl[0];
                }
                int pixel = (int)disp.GetLocalPixelByLy(sn, ly);

                int[] sh_indexes = sp.GetShotIndexes();
                Analit = new double[sh_indexes.Length];
                Comp   = new double[sh_indexes.Length];
                List <SpectrDataView> views = sp.GetViewsSet();

                for (int i = 0; i < Analit.Length; i++)
                {
                    float[] sig     = views[sh_indexes[i]].GetSensorData(sn);
                    float[] nul     = sp.GetNullFor(sh_indexes[i]).GetSensorData(sn);
                    float[] sig_nul = new float[sig.Length];
                    for (int j = 0; j < sig.Length; j++)
                    {
                        sig_nul[j] = sig[j] - nul[j];
                    }
                    Analit[i] = CalcAnalit(sig_nul, pixel);
                }
            }
예제 #10
0
        public override Spectr[] GetSpectrResults(out string[] names, out int view_type)
        {
            view_type = 0;
            DbFolder folder = Common.Db.GetFolder(Common.DbNameTestingFolder);
            Spectr   sp;

            try
            {
                sp = new Spectr(folder, FileName);
            }
            catch
            {
                sp = null;
            }
            if (sp == null)
            {
                names = null;
                return(null);
            }
            else
            {
                names    = new string[1];
                names[0] = Common.MLS.Get(MLSConst, "Темновой снимок");
                Spectr[] spr = new Spectr[1];
                spr[0] = sp;
                return(spr);
            }
        }
예제 #11
0
        //List<SpectrCashRecord> SpectrCash = new List<SpectrCashRecord>();
        public Spectr LoadSpectr(string path)
        {
            /*
             * for (int i = 0; i < SpectrCash.Count; i++)
             *  if (SpectrCash[i].Sp.GetPath().Equals(path))
             *  {
             *      SpectrCash[i].Accessed = DateTime.Now.Ticks;
             *      return SpectrCash[i].Sp;
             *  }
             * Spectr sp = Spectr.GetSpectr_Call_Only_Db_Method(path);//new Spectr(path);
             * SpectrCashRecord r = new SpectrCashRecord(sp);
             * SpectrCash.Add(r);
             * if (SpectrCash.Count > 20)
             * {
             *  for (int at = 0; at < 2; at++)
             *  {
             *      long min_time = DateTime.Now.Ticks;
             *      int found = -1;
             *      for (int i = 0; i < SpectrCash.Count; i++)
             *          if (SpectrCash[i].Accessed < min_time)
             *          {
             *              min_time = SpectrCash[i].Accessed;
             *              found = i;
             *          }
             *      if ((DateTime.Now.Ticks - min_time) < 60 * 10000000)
             *          break;
             *      SpectrCash.RemoveAt(found);
             *  }
             * }//*/
            Spectr sp = new Spectr(path);

            return(sp);
        }
예제 #12
0
        private void btMeasuringNewSpectr_Click_Final(List <SpectrDataView> rez, SpectrCondition cond)
        {
            try
            {
                Spectr sp = new Spectr(cond, Common.Env.DefaultDisp, Common.Env.DefaultOpticFk, "SortCalibr");
                for (int i = 0; i < rez.Count; i++)
                {
                    sp.Add(rez[i]);
                }

                sp.SaveAs(MeasuringFile);

                LoadTree();
                int ind = MeasuringFile.Length - 3;
                if (MeasuringFile[ind] != '.' ||
                    MeasuringFile[ind] != 's' ||
                    MeasuringFile[ind] != 's')
                {
                    MeasuringFile += ".ss";
                }
                Select(tvDirView.Nodes, MeasuringFile);
                sortProbProperty1.Save();
                //sortProbProperty1.InitByPath((string)e.Node.Tag);
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }
예제 #13
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            try
            {
                String   base_path   = "Тестовые измерения спектров\\Ire 30-20-10-0\\";
                String[] t_names     = { "m20_", "m10_", "0_", "10_", "20_", "30_" };
                String[] exp_names   = { " 0,5c", " 1c", " 2c", " 4c" };
                int[]    exp_index_f = { 2, 3, 4, 5 };
                int[]    exp_index_s = { 10, 11, 12, 13 };
                for (int exp_index = 0; exp_index < exp_index_f.Length; exp_index++)
                {
                    for (int temp = 0; temp < t_names.Length; temp++)
                    {
                        for (int sp_index = 1; sp_index <= 8; sp_index++)
                        {
                            try
                            {
                                String path = base_path + t_names[temp] + sp_index;
                                Spectr sp   = new Spectr(path);
                                List <SpectrDataView> dv    = sp.GetViewsSet();
                                SpectrDataView        view1 = dv[exp_index_f[exp_index]];
                                SpectrDataView        view2 = dv[exp_index_s[exp_index]];
                                float[] data1 = getData(view1);
                                float[] data2 = getData(view2);

                                float sko1, sko2;
                                LevelTestResult[exp_index, temp, (sp_index - 1) * 2]              = testCalcLevel(data1, out sko1, out sko2);
                                LevelTestResultSKOAnalog[exp_index, temp, (sp_index - 1) * 2]     = sko1;
                                LevelTestResultSKOSignal[exp_index, temp, (sp_index - 1) * 2]     = sko2;
                                LevelTestResult[exp_index, temp, (sp_index - 1) * 2 + 1]          = testCalcLevel(data2, out sko1, out sko2);
                                LevelTestResultSKOAnalog[exp_index, temp, (sp_index - 1) * 2 + 1] = sko1;
                                LevelTestResultSKOSignal[exp_index, temp, (sp_index - 1) * 2 + 1] = sko2;

                                NoiseTestResult[exp_index, temp, (sp_index - 1)] = testCalcNoise(data1, data2);

                                StepsTestResult[exp_index, temp, (sp_index - 1) * 2]     = testCalcSteps(data1);
                                StepsTestResult[exp_index, temp, (sp_index - 1) * 2 + 1] = testCalcSteps(data2);
                            }
                            catch (Exception ex)
                            {
                                Common.Log(ex);
                                return;
                            }
                        }
                    }
                }
                saveAsCSV("подставка", exp_names, LevelTestResult, 4, 6, 16);
                saveAsCSV("подставка СКО ацп", exp_names, LevelTestResultSKOAnalog, 4, 6, 16);
                saveAsCSV("подставка СКО шума", exp_names, LevelTestResultSKOSignal, 4, 6, 16);
                saveAsCSV("шум", exp_names, NoiseTestResult, 4, 6, 8);
                saveAsCSV("ступеньки", exp_names, StepsTestResult, 4, 6, 16);
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }
예제 #14
0
        public StandartHistory(Spectr s)
        {
            string path = s.GetPath();

            path = path.Substring(0, path.LastIndexOf('_'));
            Path = path + ".history";
            //DataBase.CheckPath(ref path);
            Load();
        }
예제 #15
0
        public Spectr GetSpectr()
        {
            string path = Folder.GetPath() + SpName;

            if (Spectr.IsFileExists(path))
            {
                return(new Spectr(path));
            }
            return(null);
        }
예제 #16
0
        public Spectr GetLetestDataAsSpectr()
        {
            Spectr sp = new Spectr(Cond, Common.Env.DefaultDisp, Common.Env.DefaultOpticFk, Common.Dev.GetMeasuringLog());

            for (int i = 0; i < LetestResult.Count; i++)
            {
                sp.Add(LetestResult[i]);
            }
            return(sp);
        }
예제 #17
0
        public void btReMeasuringSpectr_Click(object sender, EventArgs e)
        {
            try
            {
                if (Selected == null)
                {
                    MessageBox.Show(MainForm.MForm,
                                    Common.MLS.Get(MLSConst, "Выберите спектр который нужно перемерить"),
                                    Common.MLS.Get(MLSConst, "Предупреждение"),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning
                                    );
                    return;
                }

                //LastName = (string)Selected.Text;
                LastPath = SelectedTag.GetPath();
                //LastName

                DialogResult dr = MessageBox.Show(MainForm.MForm,
                                                  Common.MLS.Get(MLSConst, "Вы действительно хотите перемерить спектр: ") + LastPath,
                                                  Common.MLS.Get(MLSConst, "Осторожно!!!"),
                                                  MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Warning);

                if (dr == DialogResult.No)
                {
                    return;
                }

                CurSp = new Spectr(LastPath);//(Folder, LastName);

                SpectrCondition cond;
                if (DefaultCondition == null)
                {
                    SpectrCondition spc = CurSp.GetMeasuringCondition();
                    cond = SpectrCondEditor.GetCond(MainForm.MForm, spc);
                    if (cond == null)
                    {
                        return;
                    }
                }
                else
                {
                    cond = DefaultCondition;
                }

                Dev.MeasuringResultFinalCall final_call = new Dev.MeasuringResultFinalCall(btReMeasuringSpectr_Click_Final);
                Common.Dev.Measuring(cond, final_call);
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }
예제 #18
0
        Spectr GetSpectr(int index)
        {
            string[] names = Folder.GetRecordList("ss");
            if (index > names.Length || index < 0)
            {
                return(null);
            }
            Spectr sp = new Spectr(Folder, names[index]);

            return(sp);
        }
예제 #19
0
        private void clSpList_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (ReLoading)
                {
                    return;
                }
                SpView.ClearSpectrList();
                List <TreeNode> list     = GetItemsList();
                List <TreeNode> selected = new List <TreeNode>();
                if (Selected != null)
                {
                    selected.Add(Selected);
                }
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].Checked && list[i].FullPath.Equals(Selected.FullPath) == false)
                    {
                        selected.Add(list[i]);
                    }
                }
                for (int i = 0; i < selected.Count; i++)
                {
                    CSTreeNodeTag tag = (CSTreeNodeTag)selected[i].Tag;
                    Spectr        sp  = tag.GetSpectr();
                    if (sp != null)
                    {
                        SpView.AddSpectr(sp, selected[i].Text);
                    }
                }

                /*LastName = (string)clSpList.SelectedItem;
                 * if (LastName != null)
                 * {
                 *  Spectr sp = new Spectr(Folder, LastName);
                 *  SpView.AddSpectr(sp, (string)clSpList.SelectedItem);
                 *  for (int i = 0; i < clSpList.Items.Count; i++)
                 *  {
                 *      if (clSpList.GetItemChecked(i) &&
                 *          clSpList.Items[i] != clSpList.SelectedItem)
                 *      {
                 *          sp = new Spectr(Folder, (string)clSpList.Items[i]);
                 *          SpView.AddSpectr(sp, (string)clSpList.Items[i]);
                 *      }
                 *  }
                 * }*/
                SpView.ReDraw();
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }
예제 #20
0
        public static List <MethodData> getData(MethodSimple method, int element, int formula, bool use_all, out int used)
        {
            MethodSimpleElementFormula msef = method.GetElHeader(element).Formula[formula];

            bool[]            used_frames = msef.Formula.GetUsedFrames();
            List <MethodData> ret         = new List <MethodData>();
            int prob_count = method.GetProbCount();

            used = 0;
            for (int pr = 0; pr < prob_count; pr++)
            {
                MethodSimpleProb m_prob = method.GetProbHeader(pr);
                MethodSimpleCell m_cell = method.GetCell(element, pr);
                double           con    = m_cell.Con;
                if (con < 0)
                {
                    continue;
                }
                int sub_prob_count = method.GetSubProbCount(pr);
                for (int sub_pr = 0; sub_pr < sub_prob_count; sub_pr++)
                {
                    MethodSimpleProbMeasuring m_prob_measuring = m_prob.MeasuredSpectrs[sub_pr];
                    Spectr sp = m_prob_measuring.Sp;
                    if (sp == null)
                    {
                        continue;
                    }
                    bool en = m_cell.GetData(sub_pr, formula).Enabled;
                    if (use_all == true)
                    {
                        en = true;
                    }
                    int   short_count = sp.GetShotCount();
                    int[] shorts      = sp.GetShotIndexes();
                    for (int short_index = 0; short_index < shorts.Length; short_index++)
                    {
                        bool fl = en & used_frames[short_index];
                        if (fl)
                        {
                            used++;
                        }
                        MethodData md = new MethodData(con, fl, pr, sub_pr, short_index,
                                                       sp.GetViewsSet()[shorts[short_index]],
                                                       sp.GetNullFor(shorts[short_index]), sp.GetCommonDispers());
                        ret.Add(md);
                    }
                }
            }
            if (ret.Count == 0)
            {
                return(null);
            }
            return(ret);
        }
예제 #21
0
 private void btMeasuringSp3_Click(object sender, EventArgs e)
 {
     try
     {
         Spectr sp = Measuring(3, CommonTime);
         ReLoadSpView();
     }
     catch (Exception ex)
     {
         Common.Log(ex);
     }
 }
예제 #22
0
        public void ShowSearchDlg(TaskMethodSimple tms, MethodSimpleElementFormula formula,
                                  MethodSimple method, SpectrView spv, string element_name, int el_index, int sel_col)
        {
            ElementIndex = el_index;
            ElementName  = element_name;
            TMS          = tms;
            Method       = method;
            Formula      = formula;
            Spv          = spv;
            SelectedCol  = sel_col;
            Sp           = spv.GetSpectr(0);
            if (Sp == null)
            {
                MessageBox.Show(MainForm.MForm, Common.MLS.Get(MLSConst, "Необходимо выбрать спектры по котором будет производится привязка к профилю..."),
                                Common.MLS.Get(MLSConst, "Предупреждение"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            btSearchStart.Text = Common.MLS.Get(MLSConst, MLSStartButtonText);
            Saved = new MemoryStream();
            BinaryWriter bw = new BinaryWriter(Saved);

            try
            {
                Formula.Save(bw);
            }
            catch (Exception ex)
            {
                Common.LogNoMsg(ex);
                MessageBox.Show(MainForm.MForm, Common.MLS.Get(MLSConst, "Нельзя подбирать линии для незаконченной формулы..."),
                                Common.MLS.Get(MLSConst, "Предупреждение"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (Formula.Formula.SeachBuffer != null)
            {
                MemoryStream ms  = new MemoryStream(Formula.Formula.SeachBuffer);
                BinaryReader br  = new BinaryReader(ms);
                int          ver = br.ReadInt32();
                if (ver == 1)
                {
                    int size = br.ReadInt32();
                    for (int i = 0; i < size; i++)
                    {
                        Results.Add(new CalcResult(br));
                    }
                    br.Close();
                    ReloadResultList();
                }
            }

            this.ShowDialog(MainForm.MForm);
        }
예제 #23
0
        private void MMMeasuringReMeasuring_Click(object sender, EventArgs e)
        {
            try
            {
                string bpath = Common.Db.GetFoladerPath(Common.DbNameProbSort) + "\\условия.bin";
                if (File.Exists(bpath) == false)
                {
                    MMMeasuringExp_Click(sender, e);
                }
                if (File.Exists(bpath) == false)
                {
                    return;
                }
                SpectrCondition cond;
                FileStream      fs = new FileStream(bpath, FileMode.Open, FileAccess.Read);
                BinaryReader    br = new BinaryReader(fs);
                cond = new SpectrCondition(br);
                br.Close();

                if (tvDirView.SelectedNode == null)
                {
                    return;
                }

                string base_path = (string)(tvDirView.SelectedNode.Tag);
                int    ind       = base_path.IndexOf(".ss");
                if (ind < 0)
                {
                    MessageBox.Show(MainForm.MForm,
                                    "Выбранный элемент не является спектром. Перемерить невозможно",
                                    "Предупреждение",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Hand);
                    return;
                }
                else
                {
                    base_path = base_path.Substring(0, ind);
                }

                Spectr.RemoveSpectr(base_path);

                MeasuringFile = base_path;

                Dev.MeasuringResultFinalCall final_call = new Dev.MeasuringResultFinalCall(btMeasuringNewSpectr_Click_Final);
                Common.Dev.Measuring(cond, final_call);
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }
        public double[] RateSpectr(Spectr sp)
        {
            int[]    shot_index       = sp.GetShotIndexes();
            double[] ret              = new double[shot_index.Length];
            List <SpectrDataView> spv = sp.GetViewsSet();

            for (int i = 0; i < ret.Length; i++)
            {
                SpectrDataView sig = spv[shot_index[i]];
                SpectrDataView nul = sp.GetNullFor(shot_index[i]);
                ret[i] = RateSpectrDataView(sp, sig, nul);
            }
            return(ret);
        }
예제 #25
0
        private void mmCommonAddLinkToAtlass_Click(object sender, EventArgs e)
        {
            try
            {
                /*
                 * Common.Env.DefaultDisp = Disp;
                 * Common.Env.DefaultDispText = (string)tbLinks.Text.Clone();
                 * //string name = (string)clSpList.Items[0];
                 * string name = BaseMatrixName;
                 * Spectr sp = new Spectr(Folder, name);
                 * DbFolder fl = Common.Db.GetFolder(Common.DbNameSystemFolder);
                 * sp.SaveAs(fl.GetRecordPath(Common.DbObjectNamesLinkMatrixFile));
                 */
                DialogResult dr = MessageBox.Show(MainForm.MForm,
                                                  Common.MLS.Get(MLSConst, "Добавить текущую матрицу привязок к эталону длин волн?"),//"Apply new linking matrix?"),
                                                  Common.MLS.Get(MLSConst, "Обновление эталона длин волн."),
                                                  MessageBoxButtons.OKCancel, MessageBoxIcon.Stop);
                if (dr != DialogResult.OK)
                {
                    return;
                }

                string name = BaseMatrixName;
                Spectr sp   = new Spectr(Folder, name);
                int[]  ss   = Disp.GetSensorSizes();
                try
                {
                    for (int s = 0; s < ss.Length; s++)
                    {
                        float[] data = sp.GetDefultView().GetSensorData(s);
                        Common.SpectrAtlas.AddRange(data, s, Disp);
                    }
                }
                catch
                {
                    for (int s = ss.Length - 1; s >= 0; s--)
                    {
                        float[] data = sp.GetDefultView().GetSensorData(s);
                        Common.SpectrAtlas.AddRange(data, s, Disp);
                    }
                }

                Common.SpectrAtlas.Save();
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }
예제 #26
0
        public LDbQuery()
        {
            InitializeComponent();
            Common.Reg(this, "LDbQu");
            ESelector.SelectorListener += new ElementSelectorAction(ElSelListener);
            DialogResult = DialogResult.Cancel;
            Common.SetupFont(this);//Font = Common.GetDefaultFont(Font);
            IntensTypeCbx.SelectedIndex = Common.Env.DefaultLineDb;
            Spectr  sp   = SpectroWizard.gui.tasks.TaskCheckDev.getLinkingMatrixSpectr();
            Dispers disp = sp.GetDispers();

            LyFromFld.Value = (decimal)disp.GetLyByLocalPixel(0, 0);
            int[] ss = disp.GetSensorSizes();
            LyToFld.Value = (decimal)disp.GetLyByLocalPixel(ss.Length - 1, ss[ss.Length - 1]);
        }
예제 #27
0
        private void btCycleMeasuring_Click(object sender, EventArgs e)
        {
            try
            {
                if (CycleThread == null && sender != null)
                {
                    Spectr sp = Control.GetSelectedSpectrCT();
                    if (sp == null)
                    {
                        return;
                    }

                    SpectrCondition spc = sp.GetMeasuringCondition();
                    CCond = SpectrCondEditor.GetCond(MainForm.MForm, spc);
                    if (CCond == null)
                    {
                        return;
                    }

                    CycleThread = new Thread(btCycleMeasuring_Thread);
                    CycleThread.Start();
                    PrevName = btCycleMeasuring.Text;
                    btCycleMeasuring.Text = Common.MLS.Get(MLSConst, "Остановить");

                    MainForm.MForm.EnableToolExit(false, null);
                    btCycleMeasuring.Enabled = true;
                }
                else
                {
                    CycleThread           = null;
                    btCycleMeasuring.Text = PrevName;
                    MainForm.MForm.EnableToolExit(true, null);
                    if (chbGenOn.Checked)
                    {
                        chbGenOn.Checked = false;
                    }
                    if (chbFillLight.Checked)
                    {
                        chbFillLight.Checked = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }
예제 #28
0
        void miCopySpectr_Click(object sender, EventArgs e)
        {
            try
            {
                if (Selected == null)
                {
                    MessageBox.Show(MainForm.MForm,
                                    Common.MLS.Get(MLSConst, "Выберите спектр который нужно перемерить"),
                                    Common.MLS.Get(MLSConst, "Предупреждение"),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning
                                    );
                    return;
                }

                LastPath = SelectedTag.GetPath();

                /*DialogResult dr = MessageBox.Show(MainForm.MForm,
                 *      Common.MLS.Get(MLSConst, "Вы действительно хотите перемерить спектр: ") + LastPath,
                 *      Common.MLS.Get(MLSConst, "Осторожно!!!"),
                 *      MessageBoxButtons.YesNo,
                 *      MessageBoxIcon.Warning);
                 *
                 * if (dr == DialogResult.No)
                 *  return;*/

                string name = util.StringDialog.GetString(MainForm.MForm,
                                                          Common.MLS.Get(MLSConst, "Копирование пробы"),
                                                          Common.MLS.Get(MLSConst, "Введите имя для копии пробы:") + LastPath,
                                                          "", true);

                if (name == null)
                {
                    return;
                }

                Spectr sp       = new Spectr(LastPath);
                int    path_ind = LastPath.LastIndexOf('\\');
                string path     = LastPath.Substring(0, path_ind + 1);
                sp.SaveAs(path + name);
                ReLoadList();
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }
        public double RateSpectrDataView(Spectr sp, SpectrDataView sig, SpectrDataView nul)
        {
            if (Enabled == false)
            {
                return(-1);
            }
            List <GLogRecord>     log   = new List <GLogRecord>();
            List <SpectrDataView> sig_l = new List <SpectrDataView>();

            sig_l.Add(sig);
            List <SpectrDataView> nul_l = new List <SpectrDataView>();

            nul_l.Add(nul);
            List <double> analit = new List <double>();
            List <double> aq     = new List <double>();
            //bool is_too_low = false;
            CalcLineAtrib attr = new CalcLineAtrib();
            bool          rez  = Params.Calc(log, LogSectionName, "",
                                             //null,
                                             sig_l, nul_l, sp,
                                             analit, aq, ref attr, false);

            if (rez == false)
            {
                return(-1);
            }
            if (analit[0] == 0 ||
                serv.IsValid(analit[0]) == false)
            {
                return(-1);
            }
            double lim;

            if (analit[0] > AnalitEver)
            {
                lim = AnalitTo;
            }
            else
            {
                lim = AnalitFrom;
            }
            return(Math.Abs(analit[0] - AnalitEver) /
                   Math.Abs(AnalitEver - lim));
        }
예제 #30
0
 void ReloadData()
 {
     try
     {
         string path = Common.DbNameSienceSensFolder + "\\null_noise_test.csv";
         DataBase.CheckPath(ref path);
         if (File.Exists(path))
         {
             Csv.AddFile(path);
         }
         dgvData.DataSource = GetData();
         for (int i = 0; i < Times.Length; i++)
         {
             if (i >= dgvData.Rows.Count)
             {
                 break;
             }
             dgvData.Rows[i].HeaderCell.Value = "" + Times[i];
         }
     }
     catch (Exception ex)
     {
         Common.Log(ex);
     }
     for (int i = 0; i < Times.Length; i++)
     {
         try
         {
             string path = Common.DbNameSienceSensFolder + "\\null_noise_test" + Times[i] + ".csv";
             if (Spectr.IsFileExists(path) == false)
             {
                 continue;
             }
             Sp[i] = new Spectr(path);
             spView.AddSpectr(Sp[i], "" + Times[i]);
         }
         catch (Exception ex)
         {
             Common.LogNoMsg(ex);
         }
     }
 }