Exemplo n.º 1
0
        private void редактированиеПрофилейИзмеренийToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormMeasureProfileSelect form = FormMeasureProfileSelect.getInstance(Program.Presets.CurrentProfile == null ? -1 : Program.Presets.CurrentProfile.ID);

            comboBoxProfiles.Enabled = false;
            form.AdjustForTask(false);
            form.ShowDialog();
        }
Exemplo n.º 2
0
        private void новоеИзмерениеToolStripMenuItem_Click(object sender, EventArgs e)
        {
            comboBoxProfiles.Enabled = false;
            FormMeasureProfileSelect form = FormMeasureProfileSelect.getInstance(Program.Presets.CurrentProfile == null ? -1 : Program.Presets.CurrentProfile.ID);

            form.AdjustForTask(true);
            MeasureProfile applied;

            bool           start = false;
            MeasureProfile p     = Program.Presets.CurrentProfile;

            bool ok = true;


            if (form.ShowDialog() == DialogResult.OK)
            {
                start = true;
            }

            if (start)
            {
                ok = true;

                try
                {
                    if (p != null)
                    {
                        DateTime min, max;
                        Dictionary <Sensor, List <PointD> > toCheck = Program.Service.WinToData(Program.nose.getWindow(), Program.Presets.CurrentProfile, out min, out max);

                        foreach (Sensor key in toCheck.Keys)
                        {
                            ok &= Program.Service.checkOk(key, toCheck[key].ToArray()) == Program.Service.CHECK_STABLE;
                        }
                    }
                }
                catch (Exception ex) { Error.Log(ex); }

                if (ok || MessageBox.Show("Не все сенсоры стабильны. Вы всё равно хотите начать измерение?", "Нестабильность", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Dictionary <DateTime, double[]> win = null;
                    if (Program.nose != null)
                    {
                        win = Program.nose.getWindow();
                    }

                    if (win == null || win.Count == 0)
                    {
                        MessageBox.Show("Неизвестная ошибка: всё пропало");
                        comboBoxProfiles.Enabled = true;
                        return;
                    }

                    applied = form.usedProfile;


                    #region init values

                    /*
                     * double[] init = new double[Program.nose.SensorCount];
                     * int count = win.Count;
                     * DateTime[] times = new DateTime[count];
                     * win.Keys.CopyTo(times, 0);
                     * DateTime last = times[times.Length - 1];
                     *
                     * for (int i = 0; i < init.Length; i++) init[i] = 0d;
                     *
                     * int c = 0;
                     * ///!!!!! ТОНКО ТУТ ЕСЛИ НЕПРАВИЛЬНО - ФИКСИТЬ!!!!
                     * for (int i = times.Length - 1; i >= 0 && (0d + last.Ticks - times[i].Ticks) / 1e7d < Program.Presets.stableTime; c++, i--)
                     *  for (int j = 0; j < Program.nose.SensorCount; j++)
                     *      init[j] += win[times[i]][j];
                     *
                     * if (c > 0)
                     *  for (int i = 0; i < init.Length; i++) init[i] /= c;
                     *
                     * double[] theinit = new double[applied.Settings.Count];
                     *
                     * int ii = 0;
                     * foreach (int pos in applied.Settings.Keys)
                     *  theinit[ii++] = (int)init[pos];
                     */
                    #endregion

                    double[] theinit = Program.Service.getInitValues(win, applied);

                    double len = (int)form.numericUpDownTime.Value;
                    string txt = form.textBoxName.Text;

                    FormMeasure meas = new FormMeasure(len, txt, applied, theinit, form.comboBoxMasks.SelectedItem as Mask, form.lng, form.ltt);
                    meas.ShowDialog();
                    measureTree.ShowMeasures = measureTree.ShowMeasures;
                }
            }
            refreshComboProfiles();
            comboBoxProfiles.Enabled = true;
        }