Beispiel #1
0
        public void AddNullMonitor(SpectrConditionCompiledLine line)
        {
            WaitForMeasuringEnd();
            NullMeasuringPause = true;

            NulDatas nd = new NulDatas(line);

            nd.Dev = this;
            NulStorage.Add(nd);
            NullMeasuringPause = false;
        }
Beispiel #2
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();
            }
        public List <SpectrConditionCompiledLine> GetNullList()
        {
            List <SpectrConditionCompiledLine> ret = new List <data.SpectrConditionCompiledLine>();

            for (int i = 0; i < Data.CommonInformation.WorkingCond.Lines.Count; i++)
            {
                SpectrConditionCompiledLine l = Data.CommonInformation.WorkingCond.Lines[i];
                if (l.IsActive == false && l.Type == SpectrCondition.CondTypes.Exposition)
                {
                    ret.Add(l);
                }
            }
            return(ret);
        }
Beispiel #4
0
        public short[][] GetNull(SpectrConditionCompiledLine line, out short[][] blank_start, out short[][] blank_end)
        {
            if (Common.Conf.UseGoodNul != false)
            {
                blank_start = null;
                blank_end   = null;
                for (int i = 0; i < NulStorage.Count; i++)
                {
                    if (NulStorage[i].Line.IsExpositionEqual(line, false))
                    {
                        return(NulStorage[i].GetData(out blank_start, out blank_end));
                    }
                }
            }
            int common;

            int[] exps;
            DevReg.SimpleTimeCorrection(Common.Dev, line.CommonTime,
                                        line.Expositions, out common, out exps);
            return(RegFrame(common, exps, out blank_start, out blank_end));
        }
Beispiel #5
0
        public void AddAfter(int line)
        {
            SpCondSENewLineTypeSelector sel = new SpCondSENewLineTypeSelector();
            DialogResult dr = sel.ShowDialog(Editor);

            if (dr != DialogResult.OK)
            {
                return;
            }
            string code = "";

            SpectrCondition.CondTypes type = SpectrCondition.CondTypes.Comment;
            switch (sel.LineType)
            {
            case 0:
                code = "#";
                break;

            case 1:
                code = "p: 1 On()";
                type = SpectrCondition.CondTypes.Prespark;
                break;

            case 2:
                if (Cond.Lines[line].Type == SpectrCondition.CondTypes.Exposition)
                {
                    code = Cond.Lines[line].SourceCode;
                    int on_index  = code.ToLower().IndexOf("on");
                    int off_index = code.ToLower().IndexOf("off");
                    if (off_index > 0)
                    {
                        code = code.Substring(0, off_index) + "on()";
                    }
                }
                else
                {
                    code = "e: 1 (";
                    int[] ss = Common.Dev.Reg.GetSensorSizes();
                    for (int i = 0; i < ss.Length; i++)
                    {
                        code += "0.1";
                        if (i < ss.Length - 1)
                        {
                            code += ";";
                        }
                    }
                    code += ") On()";
                }
                type = SpectrCondition.CondTypes.Exposition;
                break;

            case 3:
                if (Cond.Lines[line].Type == SpectrCondition.CondTypes.Exposition)
                {
                    code = Cond.Lines[line].SourceCode;
                    int on_index  = code.ToLower().IndexOf("on");
                    int off_index = code.ToLower().IndexOf("off");
                    if (on_index > 0)
                    {
                        code = code.Substring(0, on_index) + "off()";
                    }
                }
                else
                {
                    code = "e: 1 (";
                    int[] ss = Common.Dev.Reg.GetSensorSizes();
                    for (int i = 0; i < ss.Length; i++)
                    {
                        code += "0.1";
                        if (i < ss.Length - 1)
                        {
                            code += ";";
                        }
                    }
                    code += ") Off()";
                }
                type = SpectrCondition.CondTypes.Exposition;
                break;

            case 4:
                code = "f:Off";
                type = SpectrCondition.CondTypes.FillLight;
                break;
            }
            line++;
            bool fl = false;
            SpectrConditionCompiledLine cond =
                new SpectrConditionCompiledLine(type, code, line, 0, ref fl);

            if (line < Lines.Count)
            {
                Lines.Insert(line, new SpCondLineEditor(cond, this, line));
            }
            else
            {
                Lines.Add(new SpCondLineEditor(cond, this, line));
            }
            Save();
            ReInitList();
        }
Beispiel #6
0
        public SpCondLineEditor(SpectrConditionCompiledLine line,
                                SpectrCondSimpleEditor editor, int line_index)
        {
            Editor    = editor;
            LineIndex = line_index;

            GenOnStr  = Common.MLS.Get(MLSConst, "Спектр");
            GenOffStr = Common.MLS.Get(MLSConst, "Ноль...");
            OnStr     = Common.MLS.Get(MLSConst, "Вкл");
            OffStr    = Common.MLS.Get(MLSConst, "Выкл");

            Line      = line;
            BackColor = SystemColors.ControlDark;
            switch (Line.Type)
            {
            default:
                Fields        = new object[1];
                Fields[0]     = Line.SourceCode;
                FieldHelps    = new string[1];
                FieldHelps[0] = Common.MLS.Get(MLSConst, "Это просто текст");
                FieldTypes    = new FTypes[1];
                FieldTypes[0] = FTypes.String;
                break;

            case SpectrCondition.CondTypes.Prespark:
                Fields        = new object[1];
                Fields[0]     = Line.CommonTime;
                FieldHelps    = new string[1];
                FieldHelps[0] = Common.MLS.Get(MLSConst, "Время обжига образца без регитрации спектра.");
                FieldTypes    = new FTypes[1];
                FieldTypes[0] = FTypes.CommonTime;
                break;

            case SpectrCondition.CondTypes.Exposition:
                Fields        = new object[2 + Line.Expositions.Length];
                FieldTypes    = new FTypes[Fields.Length];
                FieldHelps    = new string[Fields.Length];
                FieldHelps[0] = Common.MLS.Get(MLSConst, "Общее время измерения сперктра.");
                FieldTypes[0] = FTypes.CommonTime;
                Fields[0]     = Line.CommonTime;
                for (int i = 0; i < Line.Expositions.Length; i++)
                {
                    Fields[1 + i]     = Line.Expositions[i];
                    FieldTypes[1 + i] = FTypes.Exposition;
                    FieldHelps[1 + i] = Common.MLS.Get(MLSConst, "Длительность экспонирования линейки №") + (i + 1);
                }
                Fields[1 + Line.Expositions.Length]     = Line.IsGenOn;
                FieldTypes[1 + Line.Expositions.Length] = FTypes.GeneratorState;
                FieldHelps[1 + Line.Expositions.Length] = Common.MLS.Get(MLSConst, "Экспонируется линейка или калибруются нулевой уровень. Что-бы изменить нажмите клавишу ВВЕРХ/ВНИЗ.");
                break;

            case SpectrCondition.CondTypes.FillLight:
                Fields        = new object[1];
                Fields[0]     = Line.IsFillLight;
                FieldHelps    = new string[1];
                FieldHelps[0] = Common.MLS.Get(MLSConst, "Состояние источника заливающего света");
                FieldTypes    = new FTypes[1];
                FieldTypes[0] = FTypes.OnOffState;
                break;
            }
            XFrom  = new int[Fields.Length];
            XTo    = new int[Fields.Length];
            Paint += new PaintEventHandler(SpCondLineEditor_Paint);
            //Validating += new CancelEventHandler(SpCondLineEditor_Validating);
            MouseUp   += new MouseEventHandler(SpCondLineEditor_MouseUp);
            ActiveText = new TextBox();
            Controls.Add(ActiveText);
            ActiveText.SetBounds(-100, -100, 10, 10);
            ActiveText.TextChanged += new EventHandler(ActiveText_TextChanged);
            ActiveText.KeyUp       += new KeyEventHandler(ActiveText_KeyUp);
            //PreviewKeyDown += new PreviewKeyDownEventHandler(SpCondLineEditor_PreviewKeyDown);
            //Leave += new EventHandler(SpCondLineEditor_Leave);
            ActiveText.Leave += new EventHandler(ActiveText_Leave);
        }
Beispiel #7
0
 public void CorrectExposition(SpectrConditionCompiledLine line,
                               out int common_i, out int[] exps_i)
 {
     DevReg.SimpleTimeCorrection(this, line.CommonTime, line.Expositions, out common_i, out exps_i);
 }
        private void btCycleMeasuring_ThreadTech()
        {
            bool   prev_gen = IsGenOn, prev_fl = IsFillLightOn;
            Spectr sp = Control.GetSelectedSpectrCT();

            if (sp == null)
            {
                return;
            }
            SpectrConditionCompiledLine con  = null;
            SpectrCondition             cond = CCond;//sp.GetMeasuringCondition();
            int sp_index = 0;

            for (int i = 0; i < cond.Lines.Count; i++)
            {
                if (cond.Lines[i].Type == SpectrCondition.CondTypes.Exposition &&
                    cond.Lines[i].IsActive)
                {
                    con      = cond.Lines[i];
                    sp_index = con.SpectrViewIndex;
                    break;
                }
            }
            if (con == null)
            {
                return;
            }

            Common.Dev.CheckConnection();
            Common.Dev.BeforeMeasuring();

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

            int common_time_i;

            int[] exps_i;
            Common.Dev.CorrectExposition(con, out common_time_i, out exps_i);
            short[][] bb, be;
            while (CycleThread != null && Common.IsRunning)
            {
                try
                {
                    short[][] datas = Common.Dev.Reg.RegFrame(common_time_i, exps_i, out bb, out be);

                    float[][] data = new float[datas.Length][];
                    for (int s = 0; s < datas.Length; s++)
                    {
                        int size = datas[s].Length;
                        data[s] = new float[size];
                        for (int j = 0; j < size; j++)
                        {
                            data[s][j] = datas[s][j];
                        }
                    }
                    SpectrDataView cur_spview = new SpectrDataView(new SpectrCondition(Common.Dev.Tick, con),
                                                                   data, bb, be,
                                                                   Common.Dev.Reg.GetMaxValue(),
                                                                   Common.Dev.Reg.GetMaxLinarValue());

                    sp.Set(cur_spview, sp_index);

                    SpView.ReLoadSpectr(sp, 0);
                    SpView.ReDraw();

                    if (prev_fl != IsFillLightOn)
                    {
                        prev_fl = IsFillLightOn;
                        Common.Dev.Fill.SetFillLight(chbFillLight.Checked);
                    }
                    if (prev_gen != IsGenOn)
                    {
                        prev_gen = IsGenOn;
                        Common.Dev.Gen.SetStatus(chbGenOn.Checked);
                    }
                    Thread.Sleep(500);
                }
                catch (Exception ex)
                {
                    Common.Log(ex);
                    break;
                }
            }
            sp.Save();
        }