예제 #1
0
 private void btReloadFrom_Click(object sender, EventArgs e)
 {
     try
     {
         DbFolder     fld  = Common.Db.GetFolder(Common.DbNameSystemFolder);
         string       path = fld.CreateRecordPath((string)cbKnownConditions.SelectedItem);
         string       tmp  = path + ".ssc";
         FileStream   fs   = DataBase.OpenFile(ref tmp, FileMode.Open, FileAccess.Read);
         BinaryReader br   = new BinaryReader(fs);
         Cond.Load(br);
         br.Close();
         if (chbShowSourceCode.Checked == false)
         {
             scSimpleEditor.Setup(Cond.SourceCode, this);
         }
         else
         {
             tbSourceCode.Text = Cond.SourceCode;
         }
         cbKnownConditions.SelectedIndex = -1;
     }
     catch (Exception ex)
     {
         Common.Log(ex);
     }
 }
예제 #2
0
        private void btSaveAs_Click(object sender, EventArgs e)
        {
            try
            {
                string name = util.StringDialog.GetString(this,
                                                          Common.MLS.Get(MLSConst, "Запиль условий"),
                                                          Common.MLS.Get(MLSConst, "Введите имя под которым надо сохранить программу измерений"),
                                                          "", true);
                if (name == null)
                {
                    return;
                }

                DbFolder     fld  = Common.Db.GetFolder(Common.DbNameSystemFolder);
                string       path = fld.CreateRecordPath(name);
                string       tmp  = path + ".ssc";
                FileStream   fs   = DataBase.OpenFile(ref tmp, FileMode.Create, FileAccess.Write);
                BinaryWriter bw   = new BinaryWriter(fs);
                Cond.Save(bw);
                bw.Flush();
                bw.Close();

                LoadList();
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }
예제 #3
0
        private void btDeleteSavedCond_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult dr = MessageBox.Show(this,
                                                  Common.MLS.Get(MLSConst, "Удалить ранее записанную программу измерений:") + (string)cbKnownConditions.SelectedItem,
                                                  Common.MLS.Get(MLSConst, "Удаление..."),
                                                  MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Hand);

                if (dr != DialogResult.Yes)
                {
                    return;
                }

                DbFolder fld  = Common.Db.GetFolder(Common.DbNameSystemFolder);
                string   path = fld.CreateRecordPath((string)cbKnownConditions.SelectedItem);
                File.Delete(path + ".ssc");

                LoadList();
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }
예제 #4
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);
            }
        }
        public void Select(TreeNode node, bool select)
        {
            TaskControlContainer tcc = (TaskControlContainer)node.Tag;

            Folder      = tcc.Folder;
            PathLb.Text = Folder.GetPath();
            Node        = node;//tcc.ParentNode;
            ReloadList();
        }
예제 #6
0
        void mk_folder()
        {
            var obj  = this.request_to_json();
            var name = obj["f_nameLoc"].ToString().Trim();
            var pid  = obj["f_pid"].ToString().Trim();

            obj["f_pathRel"] = PathTool.combin(obj["f_pathRel"].ToString(), obj["f_nameLoc"].ToString());

            DbFolder df = new DbFolder();

            if (df.exist_same_folder(name, pid))
            {
                var ret = new JObject {
                    { "ret", false }, { "msg", "已存在同名目录" }
                };
                this.toContent(ret);
                return;
            }

            DBConfig cfg = new DBConfig();
            SqlExec  se  = cfg.se();

            //根目录
            if (string.IsNullOrEmpty(pid))
            {
                obj["f_id"] = Guid.NewGuid().ToString("N");

                se.insert("up6_files", new SqlParam[] {
                    new SqlParam("f_id", obj["f_id"].ToString())
                    , new SqlParam("f_pid", obj["f_pid"].ToString())
                    , new SqlParam("f_uid", int.Parse(obj["uid"].ToString()))
                    , new SqlParam("f_pidRoot", obj["f_pidRoot"].ToString())
                    , new SqlParam("f_nameLoc", obj["f_nameLoc"].ToString())
                    , new SqlParam("f_complete", true)
                    , new SqlParam("f_fdTask", true)
                    , new SqlParam("f_pathRel", obj["f_pathRel"].ToString())
                });
            }//子目录
            else
            {
                obj["f_id"] = Guid.NewGuid().ToString("N");
                se.insert("up6_folders"
                          , new SqlParam[] {
                    new SqlParam("f_id", obj["f_id"].ToString())
                    , new SqlParam("f_pid", obj["f_pid"].ToString())
                    , new SqlParam("f_uid", int.Parse(obj["uid"].ToString()))
                    , new SqlParam("f_pidRoot", obj["f_pidRoot"].ToString())
                    , new SqlParam("f_nameLoc", obj["f_nameLoc"].ToString())
                    , new SqlParam("f_complete", true)
                    , new SqlParam("f_pathRel", obj["f_pathRel"].ToString())
                });
            }

            obj["ret"] = true;
            this.toContent(obj);
        }
예제 #7
0
        /// <summary>
        /// 生成导航路径
        /// </summary>
        void build_path()
        {
            var data = Request.QueryString["data"];

            data = Server.UrlDecode(data);
            var fd = JObject.Parse(data);

            DbFolder df = new DbFolder();

            this.toContent(df.build_path(fd));
        }
예제 #8
0
        void LoadList()
        {
            cbKnownConditions.SelectedIndex = -1;
            cbKnownConditions.Items.Clear();
            DbFolder fld = Common.Db.GetFolder(Common.DbNameSystemFolder);

            string[] list = fld.GetRecordList("ssc");
            for (int i = 0; i < list.Length; i++)
            {
                string tmp = list[i].Substring(0, list[i].Length - 4);
                cbKnownConditions.Items.Add(tmp);
            }
        }
예제 #9
0
            public NulDatas(SpectrConditionCompiledLine line)
            {
                Line = line;
                DevReg.SimpleTimeCorrection(Common.Dev, line.CommonTime,
                                            line.Expositions, out CommonTime, out Exps);
                int common_time = 0;
                int n           = 8;
                int max_exp     = Exps[0];

                for (int i = 1; i < Exps.Length; i++)
                {
                    if (max_exp < Exps[i])
                    {
                        max_exp = Exps[i];
                    }
                }
                common_time = max_exp * n;
                while (common_time < CommonTime)
                {
                    bool is_good = true;
                    for (int i = 0; i < Exps.Length; i++)
                    {
                        if ((common_time % (Exps[i])) != 0)
                        {
                            is_good = false;
                            break;
                        }
                    }
                    if (is_good)
                    {
                        CommonTime = common_time;
                        break;
                    }
                    n++;
                    common_time = max_exp * n;
                }
                DbFolder folder      = Common.Db.GetFolder(Common.DbNameNulFolder);
                string   record_name = line.CommonTime + "[";

                for (int i = 0; i < line.Expositions.Length; i++)
                {
                    if (i != 0)
                    {
                        record_name += " ";
                    }
                    record_name += line.Expositions[i];
                }
                record_name += "]";
                Path         = folder.GetRecordPath(record_name);
                Load();
            }
예제 #10
0
        public TaskLinkingMatrixControl()
        {
            Disp = new Dispers();
            InitializeComponent();
            if (Common.Db != null)
            {
                Folder  = Common.Db.GetFolder(Common.DbNameLinkingFolder);
                Control = new CheckedSpectrCollectionControl(
                    Folder, clSpList, SpView,
                    null,
                    null,
                    null);
                Control.AfterMeasuringProc += new AfterMeasuringDel(AfterMeasuringCall);
                Control.FirstFileName       = BaseMatrixName;
            }
            if (Common.Env != null)
            {
                if (Common.Env.LinkintEditorText == null ||
                    Common.Env.LinkintEditorText.Length == 0)
                {
                    cmtLoadDefaultLinks_Click(null, null);

                    /*string def_d = Common.Dev.DefaultDipsers();
                     * if (def_d == null)
                     *  tbLinks.Text = "#Заготовка" + serv.Endl + serv.Endl +
                     *      "s1:3 #сенс.1 полином3" + serv.Endl +
                     *      "10-2200" + serv.Endl +
                     *      "200-2210" + serv.Endl;
                     * else
                     *  tbLinks.Text = def_d;*/
                }
                else
                {
                    tbLinks.Text = Common.Env.LinkintEditorText;
                }
            }
            try
            {
                tbLinks.Cursor = Common.GetCursor("TextWithMenu.cur");
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
            Common.SetupFont(menuStrip1);
            Log.Reg(MLSConst, menuStrip1);
        }
예제 #11
0
        public override Spectr[] GetSpectrResults(out string[] names, out int view_type)
        {
            view_type = 0;
            DbFolder folder = Common.Db.GetFolder(Common.DbNameTestingFolder);
            Spectr   sp1;
            Spectr   sp2;
            Spectr   sp3;
            Spectr   sp4;
            Spectr   sp5;

            try{ sp1 = new Spectr(folder, FileName); }
            catch { sp1 = null; }
            try{ sp2 = new Spectr(folder, FileNameComp); }
            catch { sp2 = null; }
            try { sp3 = new Spectr(folder, FileNameCompLow); }
            catch { sp3 = null; }
            try { sp4 = new Spectr(folder, FileNameCompM); }
            catch { sp4 = null; }
            try { sp5 = new Spectr(folder, FileNameCompHi); }
            catch { sp5 = null; }
            if (sp1 == null || sp2 == null || sp3 == null || sp4 == null || sp5 == null)
            {
                names = null;
                return(null);
            }
            else
            {
                names    = new string[5];
                names[1] = Common.MLS.Get(MLSConst, "Уровень заливающего света.");
                names[0] = Common.MLS.Get(MLSConst, "Исходный заливающий.");
                names[2] = Common.MLS.Get(MLSConst, "Проверочный пониженный.");
                names[3] = Common.MLS.Get(MLSConst, "Проверочный средний.");
                names[4] = Common.MLS.Get(MLSConst, "Проверочный высокий.");
                Spectr[] spr = new Spectr[5];
                spr[1] = sp1;
                spr[0] = sp2;
                spr[2] = sp3;
                spr[3] = sp4;
                spr[4] = sp5;
                return(spr);
            }
        }
예제 #12
0
        public override Spectr[] GetSpectrResults(out string[] names, out int view_type)
        {
            view_type = 0;
            List <Spectr> sp = new List <Spectr>();
            List <string> nm = new List <string>();

            DbFolder folder = Common.Db.GetFolder(Common.DbNameSystemFolder);
            Spectr   sptmp;

            try
            {
                sptmp = new Spectr(folder, Common.DbObjectNamesLinkMatrixFile);
                sp.Add(sptmp);
                nm.Add(Common.MLS.Get(MLSConst, "base_linking_matrix"));
            }
            catch {}
            folder = Common.Db.GetFolder(Common.DbNameTestingFolder);
            try
            {
                //string path = folder.GetRecordPath();
                sptmp = new Spectr(folder, Common.DbObjectNamesLinkMatrixFile + "_last");
                sp.Add(sptmp);
                nm.Add(Common.MLS.Get(MLSConst, "current_linking_matrix"));
            }
            catch {}
            if (sp.Count == 0)
            {
                names = null;
                return(null);
            }
            names = new string[sp.Count];
            Spectr[] ret = new Spectr[sp.Count];
            for (int i = 0; i < ret.Length; i++)
            {
                names[i] = nm[i];
                ret[i]   = sp[i];
            }
            return(ret);
        }
예제 #13
0
        private void btUseLinks_Click(object sender, EventArgs e)
        {
            try
            {
                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;
                }

                //bool result;
                ApplyDispersDelProc();
                if (ApplyDispResult != 1)//Disp.Compile(tbLinks.Text, true, out result);
                {
                    MessageBox.Show(MainForm.MForm,
                                    Common.MLS.Get(MLSConst, "Ошибка применения матрицы привязок"),//"Apply linking matrix error."),
                                    Common.MLS.Get(MLSConst, "Ошибка"), MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
                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));
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }
예제 #14
0
        public void LoadFiles()
        {
            Queue <BackupFolder> folderQueue = new Queue <BackupFolder>();

            folderQueue.Enqueue(new BackupFolder(Name, Folder));

            while (folderQueue.Count > 0)
            {
                BackupFolder currentFolder = folderQueue.Dequeue();
                if (IsHidden(currentFolder.Directory) ||
                    ExcludePath(currentFolder.Directory.FullName + "\\"))
                {
                    continue;
                }

                DbFolder dbFolder = db.AddFolder(currentFolder.Name, currentFolder.ParentId);
                addedToDbFolders.Add(dbFolder);

                IEnumerable <BackupFolder> folders;
                IEnumerable <BackupFile>   files;
                try
                {
                    switch (currentFolder.SubType)
                    {
                    case SubfolderType.No:
                        folders = new BackupFolder[0];
                        files   = new BackupFile[0];
                        break;

                    case SubfolderType.This:
                        folders = new BackupFolder[0];
                        files   = currentFolder.Directory.GetFiles().Select(f => new BackupFile(dbFolder.ID, f));
                        break;

                    case SubfolderType.All:
                        folders = currentFolder.Directory.GetDirectories()
                                  .Select(d => new BackupFolder(dbFolder.ID, d, SubfolderType.All));
                        files = currentFolder.Directory.GetFiles().Select(f => new BackupFile(dbFolder.ID, f));
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(nameof(currentFolder.SubType), currentFolder.SubType, null);
                    }
                }
                catch
                {
                    folders = new BackupFolder[0];
                    files   = new BackupFile[0];
                }

                foreach (BackupFolder subFolder in folders)
                {
                    folderQueue.Enqueue(subFolder);
                }

                foreach (BackupFile file in files)
                {
                    allFiles.Add(file);
                }
            }
        }
예제 #15
0
 public CSTreeNodeTag(DbFolder folder, string sp_name)
 {
     SpName = sp_name;
     Folder = folder;
 }
예제 #16
0
        protected short[][] MeasuringMonoExp(double common_time, double exp_time,
                                             string file_name, Spectr add_to, bool is_on, out string cond, int split_k)
        {
            float tick = Common.Dev.Tick;
            int   exp  = (int)(exp_time / tick);

            if (exp < 1)
            {
                exp = 1;
            }
            int common = (int)(common_time / exp_time) * exp;

            if (common < exp)
            {
                common = exp;
            }
            cond = "e:" + (common * tick) + "( ";
            int[] exps = Common.Dev.Reg.GetSensorSizes();
            for (int i = 0; i < exps.Length; i++)
            {
                if (i != 0)
                {
                    cond += ';';
                }
                exps[i] = exp;
                cond   += (exps[i] * tick);
            }
            if (is_on)
            {
                cond += ")On()";
            }
            else
            {
                cond += ")Off()";
            }
            int com_i = common / exp;

            if (com_i < 1)
            {
                com_i = 1;
            }
            common = com_i * exp;

            int tmp = common / split_k;

            tmp /= exp;
            if (tmp * exp * split_k != common)
            {
                throw new Exception("Системные проблемы. Экспозиция не кратна общему времени...");
            }

            common /= split_k;

            short[][][]     data = new short[split_k][][];
            short[][]       bs, be;
            SpectrCondition sp_cond = new SpectrCondition(tick, cond);

            for (int att = 0; att < split_k; att++)
            {
                Common.Dev.Gen.SetStatus(false);
                //gui.MainForm.MForm.SetupTimeOut(common * tick);
                Common.Log("Mono exp measuring: " + common + " [" + exp + "]");
                //short[][]
                data[att] = Common.Dev.Reg.RegFrame(common, exps, out bs, out be);
                //gui.MainForm.MForm.SetupTimeOut(0);
            }

            if (split_k > 1)
            {
                double[] buf = new double[split_k];
                for (int sn = 0; sn < data[0].Length; sn++)
                {
                    for (int pix = 0; pix < data[0][sn].Length; pix++)
                    {
                        for (int i = 0; i < split_k; i++)
                        {
                            buf[i] = data[i][sn][pix];
                        }

                        data[0][sn][pix] = (short)SpectroWizard.analit.Stat.GetEver(buf);
                    }
                }
            }

            Spectr   sp;
            DbFolder folder = Common.Db.GetFolder(Common.DbNameTestingFolder);

            if (add_to == null)
            {
                sp = new Spectr(sp_cond, new Dispers(), new OpticFk(), "DevTest");
            }
            else
            {
                sp = add_to;
            }
            sp.Add(new SpectrDataView(sp_cond, data[0], null, null,
                                      Common.Dev.Reg.GetMaxValue(),
                                      Common.Dev.Reg.GetMaxLinarValue()));
            sp.SaveAs(folder.GetRecordPath(file_name));

            return(data[0]);
        }
예제 #17
0
        public override bool RunProc()
        {
            try
            {
                Shifts = null;
                SensK  = null;

                DbFolder folder  = Common.Db.GetFolder(Common.DbNameSystemFolder);
                Spectr   sp_base = new Spectr(folder, Common.DbObjectNamesLinkMatrixFile);

                folder = Common.Db.GetFolder(Common.DbNameTestingFolder);

                Spectr sp_cur;
                if (DevTest.DoNotStart == false)
                {
                    Common.Dev.Measuring(sp_base.GetMeasuringCondition(), null);
                    sp_cur = Common.Dev.GetLetestDataAsSpectr();
                    string path = folder.GetRecordPath(Common.DbObjectNamesLinkMatrixFile + "_last");
                    sp_cur.SaveAs(path);
                }
                else
                {
                    //string path = folder.GetRecordPath(Common.DbObjectNamesLinkMatrixFile + "_last");
                    sp_cur = new Spectr(folder, Common.DbObjectNamesLinkMatrixFile + "_last");
                }

                Res = GetReportPrefix();
                //Res += Common.MLS.Get(MLSConst, "Спектр промерен и сохранён... ")+serv.Endl;

                int[] ss = Common.Dev.Reg.GetSensorSizes();

                sp_cur.OFk.ResetSens();
                sp_cur.ResetDefaultView();

                SpectrDataView base_view = sp_base.GetDefultView();
                SpectrDataView cur_view  = sp_cur.GetDefultView();
                double[]       shifts    = new double[ss.Length];
                int            max_shift = 800;
                Res += Common.MLS.Get(MLSConst, "Проверка сдвижек на сенсоре:") + serv.Endl + "   ";
                for (int s = Common.Conf.ValidSensorFrom - 1;
                     s < ss.Length && s < Common.Conf.ValidSensorTo;
                     s++)
                {
                    //Res += Common.MLS.Get(MLSConst, "Проверка сдвижек на сенсоре #") + (s + 1);

                    float[] input_data = base_view.GetSensorData(s);
                    float[] hi_base    = SpectrFunctions.FoldingGaus(input_data, 1F, 10);
                    float[] rez_data   = cur_view.GetSensorData(s);
                    float[] hi_rez     = SpectrFunctions.FoldingGaus(rez_data, 1F, 10);

                    double crit  = 0;
                    int    shift = 0;
                    for (int sh = -max_shift; sh <= max_shift; sh++)
                    {
                        double cand = SpectrFunctions.CalcCorel(hi_base, hi_rez, sh, max_shift + 10);
                        if (serv.IsValid(cand) == false || cand < 0 || cand > 32000.0 * 32000.0 * hi_rez.Length)
                        {
                            cand = SpectrFunctions.CalcCorel(hi_base, hi_rez, sh, max_shift + 10);
                            continue;
                        }
                        if (cand > crit)
                        {
                            crit  = cand;
                            shift = sh;
                            SpectroWizard.gui.MainForm.MForm.SetupPersents(100.0 * (s * 1001 + sh) / (ss.Length * 1001));
                        }
                    }
                    shifts[s] = -(shift / 10.0);
                    //Res += Common.MLS.Get(MLSConst, " Значение сдвижки:") + shifts[s];
                    Res += "   " + Math.Round(shifts[s], 1) + "   ";
                    if (Math.Abs(shifts[s]) > max_shift / 20)
                    {
                        Res += Common.MLS.Get(MLSConst, " Слишком много!") + serv.Endl;
                        Res += serv.Endl;
                    }
                }

                Res += serv.Endl;

                for (int i = 0; i < Common.Conf.ValidSensorFrom - 1; i++)
                {
                    shifts[i] = shifts[Common.Conf.ValidSensorFrom - 1];
                }

                for (int i = Common.Conf.ValidSensorTo; i < shifts.Length; i++)
                {
                    shifts[i] = shifts[Common.Conf.ValidSensorTo - 1];
                }

                for (int i = 0; i < shifts.Length; i++)
                {
                    if (Math.Abs(shifts[i]) > max_shift / 20)
                    {
                        Res += Common.MLS.Get(MLSConst, "Слишком большие сдвижки.") + serv.Endl;
                        return(false);
                    }
                }

                for (int i = 2; i < shifts.Length; i += 2)
                {
                    if (Math.Abs(shifts[i] - shifts[i - 2]) > Common.Conf.ValidSensorDiff)
                    {
                        Res += Common.MLS.Get(MLSConst, "Слишком большая разница между сдвижками.") + shifts[i] + " " + shifts[i - 2] +
                               Common.MLS.Get(MLSConst, " Допустимый максимум: ") + Common.Conf.ValidSensorDiff + serv.Endl;
                        return(false);
                    }
                }

                for (int i = 3; i < shifts.Length; i += 2)
                {
                    if (Math.Abs(shifts[i] - shifts[i - 2]) > Common.Conf.ValidSensorDiff)
                    {
                        Res += Common.MLS.Get(MLSConst, "Слишком большая разница между сдвижками.") + shifts[i] + " " + shifts[i - 2] +
                               Common.MLS.Get(MLSConst, " Допустимый максимум: ") + Common.Conf.ValidSensorDiff + serv.Endl;
                        return(false);
                    }
                }

                double[] sensk = new double[ss.Length];
                bool     is_ok = true;
                if (Common.Conf.UseLineAmpl)
                {
                    Res += Common.MLS.Get(MLSConst, "Проверка уровня освещённости сенсоров:") + serv.Endl + "   ";

                    List <SpectrDataView> views = sp_base.GetViewsSet();
                    int[] active_indexes        = sp_base.GetShotIndexes();
                    int   use_view = -1;
                    float use_max  = -1;
                    for (int i = 0; i < active_indexes.Length; i++)
                    {
                        SpectrDataView data = views[active_indexes[i]];
                        if (data.GetCondition().Lines[0].CommonTime > use_max)
                        {
                            use_view = active_indexes[i];
                            use_max  = data.GetCondition().Lines[0].CommonTime;
                        }
                    }

                    SpectrDataView base_sig = views[use_view];
                    SpectrDataView base_nul = sp_base.GetNullFor(use_view);

                    views = sp_cur.GetViewsSet();
                    SpectrDataView cur_sig = views[use_view];
                    SpectrDataView cur_nul = sp_cur.GetNullFor(use_view);

                    for (int s = 0; s < ss.Length; s++)
                    {
                        float[] input_data = base_view.GetSensorData(s);
                        float[] rez_data   = cur_view.GetSensorData(s);

                        //double sens = CheckSensK(input_data, rez_data, s, shifts[s]);
                        double sens = CheckSensK(base_sig, base_nul, cur_sig, cur_nul, s, shifts[s]);
                        if (double.IsNaN(sens))
                        {
                            sens = 1;
                            Res += Common.MLS.Get(MLSConst, "Неполучилось сбалансировать линейку №") + (s + 1) + " " +
                                   Common.MLS.Get(MLSConst, "Причина :") + CheckSensKErrors;
                            Res  += serv.Endl;
                            is_ok = false;
                        }
                        else
                        {
                            //Res += " ";
                            Res += "   " + Math.Round(sens, 3) + "   ";
                        }

                        sensk[s] = sens;
                    }

                    if (is_ok == true)
                    {
                        Res += serv.Endl;
                        StatLineBalansCompiler(ref sensk);
                        //sp_cur.ApplyLineLevelK(sensk);
                        //sp_cur.ResetDefaultView();
                    }//*/
                }
                else
                {
                    //Res += Common.MLS.Get(MLSConst, "Проверка уровней засветок не проводилась т.к. данная опция на включена в конфигурации...") + serv.Endl;
                    for (int s = 0; s < ss.Length; s++)
                    {
                        sensk[s] = 1;
                    }
                }

                Res += serv.Endl;
                //for (int s = 0; s < ss.Length; s++)
                //    sp_cur.GetCommonDispers().ApplyShifts(shifts[s], s);
                sp_cur.ApplySifts(shifts);
                sp_cur.Save();

                if (is_ok == true)
                {
                    Shifts = shifts;
                    SensK  = sensk;
                    Common.Env.Store();
                }
                else
                {
                    return(false);
                }


                return(true);
            }
            catch (Exception ex)
            {
                Common.Log(ex);
                Res += Common.MLS.Get(MLSConst, "Критическая ошибка! ") + ex;
                return(false);
            }
            //return true;
        }
예제 #18
0
        public override bool RunProc()
        {
            try
            {
                if (DevTest.DoNotStart == true)
                {
                    Result = TestState.NoRun;
                    return(true);
                }

                Res = GetReportPrefix();
                short[][] sig_data = null;
                //short[][] sig_data1 = null;
                //short[][] sig_data2 = null;
                //float common = 1;
                float test_tick_from = 1;
                float test_tick      = test_tick_from;
                //Common.Dev.Reg.SetFillLightStatus(true);
                if (Common.Dev.Fill.Has() == false)
                {
                    Res += Common.MLS.Get(MLSConst, "В оборудовании нет управляемого источника заливающего света!") + serv.Endl;
                    return(true);
                }
                Common.Dev.Fill.SetFillLight(true);
                System.Threading.Thread.Sleep(1000);
                float  min = float.MaxValue, max = -float.MaxValue, ever = 0;
                bool   found = false;
                string tmp_cond;
                while (test_tick >= Common.Dev.Tick * 5)
                {
                    min  = float.MaxValue;
                    max  = -float.MaxValue;
                    ever = 0;

                    Common.Log(Common.MLS.Get(MLSConst, "Тестовое измерение ." + test_tick + ":" + test_tick));
                    sig_data = MeasuringMonoExp(test_tick, test_tick, FileName, null, true, out tmp_cond);
                    for (int s = 0; s < sig_data.Length; s++)
                    {
                        CheckStat(sig_data[s], ref min, ref max, ref ever);
                    }
                    if (max < Common.Dev.Reg.GetMaxLinarValue())// * 0.6)
                    {
                        found = true;
                        break;
                    }
                    else
                    {
                        test_tick = test_tick * 0.9F;
                    }
                }
                if (found == false)
                {
                    Common.Dev.Fill.SetFillLight(false);
                    Res += Common.MLS.Get(MLSConst, "Освититель слишком интенсивный... Тест невозможен...") + serv.Endl;
                    Common.Log(Common.MLS.Get(MLSConst, "Тест не прошёл."));
                    return(false);
                }
                if (test_tick_from == test_tick)
                {
                    Res += Common.MLS.Get(MLSConst, "Освититель слабоват...") + serv.Endl;
                    Common.Log(Common.MLS.Get(MLSConst, "Освититель слабоват..."));
                }
                Res += Common.MLS.Get(MLSConst, "Выбор рабочей экспозиции...") + test_tick + serv.Endl;
                float test_common = test_tick;
                while (test_common < 20)    /// test_common < 40 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                {
                    test_common = test_common * 2;
                }
                float comm_l = test_tick * 16;
                while (comm_l < 5)
                {
                    comm_l *= 2;
                }

                /*float comm_lh = common * 2;
                 * while (comm_lh < 5)
                 *  comm_lh *= 2;
                 * float comm_mh = common * 3;
                 * while (comm_mh < 5)
                 *  comm_mh *= 2;*/

                float k1 = 10;
                float k2 = 0.7F;
                float k3 = 3;
                Common.Log(Common.MLS.Get(MLSConst, "Измерение заливающего света." + test_common + ":" + test_tick));
                sig_data = MeasuringMonoExp(test_common, test_tick, FileName, null, true, out tmp_cond, 8);
                Common.Log(Common.MLS.Get(MLSConst, "Измерение пониженного заливающего света."));
                MeasuringMonoExp(comm_l, test_tick / k1, FileNameCompLow, null, true, out tmp_cond);
                Common.Log(Common.MLS.Get(MLSConst, "Измерение повышенного заливающего света."));
                MeasuringMonoExp(comm_l, test_tick / k2, FileNameCompHi, null, true, out tmp_cond);
                Res += Common.MLS.Get(MLSConst, "Измерение промежуточного уровня...") + serv.Endl;
                MeasuringMonoExp(comm_l, test_tick / k3, FileNameCompM, null, true, out tmp_cond);

                //Common.Dev.Reg.SetFillLightStatus(false);
                Common.Dev.Fill.SetFillLight(false);
                System.Threading.Thread.Sleep(1000);

                DbFolder folder  = Common.Db.GetFolder(Common.DbNameTestingFolder);
                Spectr   sp_base = new Spectr(folder, FileName);
                Spectr   sp_l    = new Spectr(folder, FileNameCompLow);
                Spectr   sp_h    = new Spectr(folder, FileNameCompHi);
                Spectr   sp_m    = new Spectr(folder, FileNameCompM);
                Common.Log(Common.MLS.Get(MLSConst, "Калибровка нуля." + test_common + ":" + test_tick));
                MeasuringMonoExp(test_common, test_tick, FileName, sp_base, false, out tmp_cond, 8);
                Common.Log(Common.MLS.Get(MLSConst, "Калибровка пониженного нуля."));
                MeasuringMonoExp(comm_l, test_tick / k1, FileNameCompLow, sp_l, false, out tmp_cond);
                Common.Log(Common.MLS.Get(MLSConst, "Калибровка повышенного нуля."));
                MeasuringMonoExp(comm_l, test_tick / k2, FileNameCompHi, sp_h, false, out tmp_cond);
                Common.Log(Common.MLS.Get(MLSConst, "Калибровка среднего нуля."));
                MeasuringMonoExp(comm_l, test_tick / k3, FileNameCompM, sp_m, false, out tmp_cond);

                sp_base.OFk.ResetSens();
                int[] ss = sp_base.GetCommonDispers().GetSensorSizes();
                //float[][] sensK = sp_base.OFk.GetSensKForTesting();// new float[sig_data.Length][];
                //sp_base.OFk.SetSensK(sensK);
                float[][] sensK = new float[ss.Length][];
                for (int s = 0; s < sensK.Length; s++)
                {
                    sensK[s] = new float[ss[s]];
                    //for(int i = 0;i<sensK[s];i++)
                    float[] y = sp_base.GetDefultView().GetSensorData(s);
                    float[] x = new float[y.Length];
                    for (int i = 0; i < x.Length; i++)
                    {
                        x[i] = i;
                    }
                    //k[s] = new float[x.Length];
                    Function fk   = new Function(Function.Types.Polinom2, x, y, false, false, 0);
                    double   mink = double.MaxValue;
                    double   maxk = -double.MaxValue;
                    for (int i = 0; i < x.Length; i++)
                    {
                        sensK[s][i] = (float)(fk.CalcY(i) / y[i]);
                        if (sensK[s][i] < mink)
                        {
                            mink = sensK[s][i];
                        }
                        if (maxk < sensK[s][i])
                        {
                            maxk = sensK[s][i];
                        }
                    }
                    Res += " MinK = " + mink + ", MaxK = " + maxk + serv.Endl;
                }
                Common.Env.DefaultOpticFk = new OpticFk();// sp_base.OFk;
                Common.Env.DefaultOpticFk.SetupK(sensK);
                Common.Env.Store();

                sp_base.OFk.ResetSens();
                sp_base.Save();

                //SpectrDataView corrected_data = sp_base.OFk.GetCorrectedData(sp_base.GetDefultView());
                Spectr rez_sp = new Spectr(sp_base.GetDefultView().GetCondition(),
                                           sp_base.GetCommonDispers(), sp_base.OFk, "DevTestSensCalibr");
                rez_sp.Add(sp_base.GetViewsSet()[0]);// corrected_data);
                rez_sp.Add(sp_base.GetViewsSet()[1]);
                //rez_sp.OFk.ResetSens();
                rez_sp.OFk.SetupK(sensK);
                rez_sp.GetDefultView();
                rez_sp.SaveAs(folder.GetRecordPath(FileNameComp));

                for (int i = 0; i < 3; i++)
                {
                    Spectr sp;
                    string file_name;
                    switch (i)//if (i == 0)
                    {
                    case 0:
                        Res      += Common.MLS.Get(MLSConst, "Коррекция заниженного спектра...") + serv.Endl;
                        file_name = FileNameCompLow;
                        sp        = sp_l;
                        break;

                    case 1:
                        Res      += Common.MLS.Get(MLSConst, "Коррекция завышенного спектра...") + serv.Endl;
                        file_name = FileNameCompHi;
                        sp        = sp_h;
                        break;

                    case 2:
                        Res      += Common.MLS.Get(MLSConst, "Коррекция среднего спектра...") + serv.Endl;
                        file_name = FileNameCompM;
                        sp        = sp_m;
                        break;

                    /*case 3:
                     *  Res += Common.MLS.Get(MLSConst, "Коррекция исходного спектра...") + serv.Endl;
                     *  file_name = FileNameComp;
                     *  sp = sp_base;
                     *  break;*/
                    default:
                        throw new Exception("Unexpected spectr index into test");
                    }

                    //corrected_data = Common.Env.DefaultOpticFk.GetCorrectedData(sp.GetDefultView());
                    rez_sp = new Spectr(sp_base.GetDefultView().GetCondition(),
                                        sp_base.GetCommonDispers(),
                                        sp_base.OFk,
                                        "DevTestSensCalibr");
                    rez_sp.Add(sp.GetViewsSet()[0]);// corrected_data);
                    rez_sp.Add(sp.GetViewsSet()[1]);
                    rez_sp.OFk.SetupK(sensK);
                    rez_sp.GetDefultView();
                    //rez_sp.Add(sp.GetDefultView());
                    //rez_sp.OFk.SetupK(sensK);
                    rez_sp.SaveAs(folder.GetRecordPath(file_name));
                }

                Common.Log(Common.MLS.Get(MLSConst, "Завершено."));

                //sp_base.OFk.ResetSens();
                //sp_base.Save();
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
            try
            {
                //Common.Dev.Reg.SetFillLightStatus(false);
                Common.Dev.Fill.SetFillLight(false);
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
            return(true);
        }
예제 #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string id    = this.reqString("id");
            string uid   = this.reqString("uid");
            string cak   = this.reqString("callback");
            int    cover = this.reqToInt("cover");
            int    ret   = 0;

            if (string.IsNullOrEmpty(id) ||
                uid.Length < 1)
            {
            }
            else
            {
                DbFolder db     = new DbFolder();
                FileInf  folder = db.read(id);
                folder.uid = int.Parse(uid);
                FileInf fdExist = db.read(folder.pathRel, folder.pid, id);
                if (1 == cover && fdExist != null)
                {
                    folder.id      = fdExist.id;
                    folder.pid     = fdExist.pid;
                    folder.pidRoot = fdExist.pidRoot;
                }

                //根节点
                FileInf root = new FileInf();
                root.id  = folder.pidRoot;
                root.uid = folder.uid;
                //当前节点是根节点
                if (string.IsNullOrEmpty(root.id))
                {
                    root.id = folder.id;
                }

                //上传完毕
                DBConfig cfg = new DBConfig();
                DBFile   dbf = cfg.db();
                dbf.fd_complete(id, uid);

                //扫描文件夹结构,
                fd_scan sa = cfg.sa();
                sa.root = root;//

                //清理同名子文件
                if (1 == cover && fdExist != null)
                {
                    //覆盖同名子文件
                    sa.cover(folder, folder.pathSvr);
                }

                //添加文件记录
                sa.scan(folder, folder.pathSvr);

                //更新扫描状态
                dbf.fd_scan(id, uid);

                up6_biz_event.folder_post_complete(id);

                //删除当前目录
                if (1 == cover && fdExist != null)
                {
                    cfg.folder().del(id, int.Parse(uid));
                }

                ret = 1;
            }
            this.toContentJson(cak + "(" + ret + ")");
        }
예제 #20
0
        }//*/

        void UpdateNodeList(TreeNodeCollection nodes, DbFolder folder)
        {
            string[] fnames = folder.GetFolderList();
            for (int i = 0; i < fnames.Length; i++)
            {
                TreeNode cur_node = null;
                for (int j = 0; j < nodes.Count; j++)
                {
                    if (((CSTreeNodeTag)nodes[j].Tag).SpName == null && nodes[j].Text.Equals(fnames[i]))
                    {
                        cur_node = nodes[i];
                        break;
                    }
                }
                if (cur_node == null)
                {
                    cur_node = nodes.Add(fnames[i]);
                }
                cur_node.Tag = new CSTreeNodeTag(new DbFolder(fnames[i], folder), null);
                cur_node.SelectedImageIndex = 1;
                cur_node.StateImageIndex    = 0;
                UpdateNodeList(cur_node.Nodes, new DbFolder(fnames[i], folder));
            }

            string[] names = folder.GetRecordList("ss", true);
            //for (int i = 0; i < names.Length; i++)
            //    names[i] = names[i].Substring(0, names[i].Length - 3);
            for (int i = 0; i < names.Length; i++)
            {
                bool found = false;
                for (int j = 0; j < nodes.Count; j++)
                {
                    if (((CSTreeNodeTag)nodes[j].Tag).SpName != null && nodes[j].Text.Equals(names[i]))
                    {
                        found = true;
                        break;
                    }
                }
                if (found == false)
                {
                    TreeNode nd = nodes.Add(names[i]);
                    nd.Tag = new CSTreeNodeTag(folder, names[i]);
                    nd.SelectedImageIndex = 3;
                    nd.ImageIndex         = 2;
                }
            }

            for (int i = 0; i < nodes.Count; i++)
            {
                bool found = false;
                for (int j = 0; j < fnames.Length; j++)
                {
                    if (fnames[j].Equals(nodes[i].Text) == true)
                    {
                        found = true;
                        break;
                    }
                }
                for (int j = 0; found == false && j < names.Length; j++)
                {
                    if (names[j].Equals(nodes[i].Text) == true)
                    {
                        found = true;
                        break;
                    }
                }
                if (found == false)
                {
                    nodes.RemoveAt(i);
                    i--;
                }
            }
        }
예제 #21
0
        void file_rename()
        {
            bool exist = false;
            var  o     = this.request_to_json();

            DBConfig cfg    = new DBConfig();
            SqlExec  se     = cfg.se();
            bool     fdTask = o["f_fdTask"].ToString() == "true" || o["f_fdTask"].ToString() == "1";

            //根目录
            if (string.IsNullOrEmpty(o["f_pid"].ToString()))
            {
                fdTask = false;
            }

            if (fdTask)
            {
                //同名目录
                var s = se.read("up6_folders", "f_id,f_pathRel"
                                , new SqlParam[] {
                    new SqlParam("f_pid", o["f_pid"].ToString()),
                    new SqlParam("f_nameLoc", o["f_nameLoc"].ToString()),
                });
                exist = s != null;

                if (!exist)
                {
                    s = se.read("up6_folders", "f_pathRel", new SqlParam[] { new SqlParam("f_id", o["f_id"].ToString()) });
                    //更新相对路径
                    var pathRel    = s["f_pathRel"].ToString();
                    var pathRelOld = pathRel;
                    var index      = pathRel.LastIndexOf("/");
                    pathRel  = pathRel.Substring(0, index + 1);
                    pathRel += o["f_nameLoc"].ToString();
                    var pathRelNew = pathRel;

                    se.update("up6_folders"
                              , new SqlParam[] {
                        new SqlParam("f_nameLoc", o["f_nameLoc"].ToString()),
                        new SqlParam("f_pathRel", pathRel)
                    },
                              new SqlParam[] {
                        new SqlParam("f_id", o["f_id"].ToString())
                    });
                    //
                    this.folder_renamed(pathRelOld, pathRelNew);
                }
            }
            else
            {
                DbFolder db = new DbFolder();
                var      s  = db.read(o["f_pid"].ToString(), o["f_nameLoc"].ToString());
                exist = s != null;

                if (!exist)
                {
                    s = se.read("up6_files", "f_pathRel", new SqlParam[] { new SqlParam("f_id", o["f_id"].ToString()) });
                    //更新相对路径
                    var pathRel    = s["f_pathRel"].ToString();
                    var pathRelOld = pathRel;
                    var index      = pathRel.LastIndexOf("/");
                    pathRel  = pathRel.Substring(0, index + 1);
                    pathRel += o["f_nameLoc"].ToString();
                    var pathRelNew = pathRel;

                    se.update("up6_files"
                              , new SqlParam[] {
                        new SqlParam("f_nameLoc", o["f_nameLoc"].ToString()),
                        new SqlParam("f_pathRel", pathRel)
                    },
                              new SqlParam[] {
                        new SqlParam("f_id", o["f_id"].ToString())
                    });

                    this.folder_renamed(pathRelOld, pathRelNew);
                }
            }

            //存在同名项
            if (exist)
            {
                var res = new JObject {
                    { "state", false }, { "msg", "存在同名项" }
                };
                this.toContent(res);
            }
            else
            {
                var ret = new JObject {
                    { "state", true }
                };
                this.toContent(ret);
            }
        }
예제 #22
0
        public CheckedSpectrCollectionControl(DbFolder folder, TreeView sp_list,//CheckedListBox sp_list,
                                              SpectrView sp_view,
                                              ToolStripMenuItem bt_measuring_new_spmi,
                                              ToolStripMenuItem bt_remeas_spmi,
                                              ToolStripMenuItem bt_remove_spmi)
        {
            Folder             = folder;
            clSpList           = sp_list;
            sp_list.CheckBoxes = true;
            //clSpList.SelectedIndexChanged += new EventHandler(clSpList_SelectedIndexChanged);
            clSpList.AfterCheck += new TreeViewEventHandler(clSpList_AfterCheck);
            //clSpList.ItemCheck += new ItemCheckEventHandler(clSpList_ItemCheck);
            clSpList.AfterSelect += new TreeViewEventHandler(clSpList_AfterSelect);
            SpView = sp_view;

            /*if (bt_meas_new_sp != null)
             * {
             *  btMeasuringNewSpectr = bt_meas_new_sp;
             *  btMeasuringNewSpectr.Click += new EventHandler(btMeasuringNewSpectr_Click);
             * }*/
            if (bt_measuring_new_spmi != null)
            {
                //btMeasuringNewSpectr = bt_meas_new_sp;
                bt_measuring_new_spmi.Click += new EventHandler(btMeasuringNewSpectr_Click);
            }

            /*if (bt_remeas_sp != null)
             * {
             *  btReMeasuringSpectr = bt_remeas_sp;
             *  btReMeasuringSpectr.Click += new EventHandler(btReMeasuringSpectr_Click);
             * }*/
            if (bt_remeas_spmi != null)
            {
                //btReMeasuringSpectr = bt_rem eas_sp;
                bt_remeas_spmi.Click += new EventHandler(btReMeasuringSpectr_Click);
            }

            /*if (bt_remove != null)
             * {
             *  btRemoveSpectr = bt_remove;
             *  btRemoveSpectr.Click += new EventHandler(btRemoveSpectr_Click);
             * }*/
            if (bt_remove_spmi != null)
            {
                bt_remove_spmi.Click += new EventHandler(btRemoveSpectr_Click);
            }
            try
            {
                ReLoadList();
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }

            ContextMenu cm = new ContextMenu();
            //cm.MenuItems;
            MenuItem mi = new MenuItem(Common.MLS.Get(MLSConst, "Измерить новый спектр"));

            mi.Click += new EventHandler(btMeasuringNewSpectr_Click);
            cm.MenuItems.Add(mi);
            mi        = new MenuItem(Common.MLS.Get(MLSConst, "Перемерить спектр"));
            mi.Click += new EventHandler(btReMeasuringSpectr_Click);
            cm.MenuItems.Add(mi);
            mi        = new MenuItem(Common.MLS.Get(MLSConst, "Удалить спектр"));
            mi.Click += new EventHandler(btRemoveSpectr_Click);
            cm.MenuItems.Add(mi);

            cm.MenuItems.Add("-");

            mi        = new MenuItem(Common.MLS.Get(MLSConst, "Создать копию спектра"));
            mi.Click += new EventHandler(miCopySpectr_Click);
            cm.MenuItems.Add(mi);

            cm.MenuItems.Add("-");
            mi        = new MenuItem(Common.MLS.Get(MLSConst, "Создать папку"));
            mi.Click += new EventHandler(miAddFolder_Click);
            cm.MenuItems.Add(mi);
            mi        = new MenuItem(Common.MLS.Get(MLSConst, "Удалить папку"));
            mi.Click += new EventHandler(miRemoveFolder_Click);
            cm.MenuItems.Add(mi);

            clSpList.ContextMenu = cm;

            clSpList.MouseUp  += new MouseEventHandler(clSpList_MouseUp);
            clSpList.ImageList = MainForm.MForm.liCheckedTreeImages;
        }