Exemple #1
0
        private void teraEtalonMapComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox cb = sender as ComboBox;

            if (cb.SelectedIndex == -1 || (this.mainForm.TeraEtalonMaps.Length == 0))
            {
                return;
            }
            this.measure.EtalonMap = this.mainForm.TeraEtalonMaps[cb.SelectedIndex];
            comboBoxResistance.Items.Clear();
            if (this.measure.Type == MEASURE_TYPE.CALIBRATION)
            {
                int range = 0;
                foreach (int i in this.measure.EtalonMap.CalibrationEtalonNumbers)
                {
                    range++;
                    comboBoxResistance.Items.Add(String.Format("{0} Диапазон ({1})", range, MeasureResultTera.AbsResultViewWithMeasure((double)this.measure.EtalonMap.Etalons[i] / 1000)));
                }
            }
            else
            {
                foreach (int i in this.measure.EtalonMap.Etalons)
                {
                    comboBoxResistance.Items.Add(MeasureResultTera.AbsResultViewWithMeasure((double)i / (double)1000));
                }
            }
            comboBoxResistance.SelectedIndex = 0;
        }
Exemple #2
0
        private void measure()
        {
            resetTime();
            MeasureResultTera result;

            this.MeasureStatus = MEASURE_STATUS.IS_GOING;
            do
            {
                this.teraDevice.DeviceForm.updateResultField();
                Thread.Sleep(700);
                result = new MeasureResultTera(this, this.teraDevice);
                this.teraDevice.DoMeasure(ref result);
                if (!result.IsCompleted)
                {
                    TeraMeasure.measureError("Превышено время ожидания результата"); break;
                }
                result.SecondsFromStart = measSeconds;
                if (result.Status > 0)
                {
                    break;
                }

                ResultCollectionsList.Add(result);


                if (StatCycleNumber < this.AveragingTimes)
                {
                    StatCycleNumber++; continue;
                }                                                                           //Если статистическое испытание, то уходим на следующий подциклa
                this.teraDevice.DeviceForm.updateResultField();
                if (!this.IsCyclicMeasure && this.CycleNumber == this.CycleTimes)
                {
                    break;
                }
                this.CycleNumber++;
            } while (true);

            if (result.Status != TERA_RESULT_STATUS.SUCC && result.Status != TERA_RESULT_STATUS.INTERRUPTED && result.Status != TERA_RESULT_STATUS.STATUS_VOLTAGE_SOURCE_IS_OFF)
            {
                string errMessage = "Неизвестная ошибка измерения";
                if (result.Status == TERA_RESULT_STATUS.INTEGRATOR_IS_ON_NEGATIVE)
                {
                    errMessage = "Интегратор находится в отрицательной области";
                }
                else if (result.Status == TERA_RESULT_STATUS.LOST_CIRCUIT_CORR_ERR_CODE)
                {
                    errMessage = "Не удалось произвести коррекцию токов утечки";
                }
                else if (result.Status == TERA_RESULT_STATUS.SHORT_CIRCUIT)
                {
                    errMessage = "Подключенный образец имеет слишком маленькое сопротивление.";
                }
                System.Windows.Forms.MessageBox.Show(errMessage, "Ошибка измерения", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            else if (result.Status == TERA_RESULT_STATUS.INTERRUPTED || result.Status == TERA_RESULT_STATUS.STATUS_VOLTAGE_SOURCE_IS_OFF)
            {
                this.MeasureStatus = MEASURE_STATUS.STOPED;
            }
        }
        public void DoMeasure(ref MeasureResultTera result)
        {
            this.StartIntegrator();
            int maxMeasTime = 400;
            int time        = 0;

            do
            {
                if (!Properties.Settings.Default.IsTestApp)
                {
                    if (this.DevicePort.BytesToRead == 8)
                    {
                        result.StatusId     = 0x0F & this.DevicePort.ReadByte();
                        result.Range        = this.DevicePort.ReadByte();
                        result.MeasureTime  = this.DevicePort.ReadByte() + this.DevicePort.ReadByte() * 256;
                        result.FirstMeasure = this.DevicePort.ReadByte() + this.DevicePort.ReadByte() * 256;
                        result.LastMeasure  = this.DevicePort.ReadByte() + this.DevicePort.ReadByte() * 256;
                    }
                }
                else
                {
                    Random r = new Random();
                    result.StatusId    = 0;
                    result.Range       = 2;
                    result.MeasureTime = r.Next(130, 133);
                    Thread.Sleep(50);
                    result.FirstMeasure = r.Next(46, 48);
                    Thread.Sleep(50);
                    result.LastMeasure = r.Next(500, 510);
                    Thread.Sleep(50);
                }
                if (result.IsCompleted)
                {
                    break;
                }
                Thread.Sleep(100);
                time++;
            } while (time < maxMeasTime);
        }
Exemple #4
0
 private string deegreeResultView(double r)
 {
     return(MeasureResultTera.DegResultViewWithMeasure(r) + getBringingName());
 }
Exemple #5
0
 public string absoluteResultView(double r)
 {
     return(MeasureResultTera.AbsResultViewWithMeasure(r) + getBringingName());
 }
Exemple #6
0
 public void updateResultField() //Для обновления поля результата из другого потока в котором проходит испытание
 {
     if (InvokeRequired)
     {
         BeginInvoke(new updateResultFieldDelegate(updateResultField));
         return;
     }
     else
     {
         MeasureResultCollection resultList = this.measure.ResultCollectionsList;
         //refreshResultsPage();
         resultForm.refreshResultsPage(resultList);
         this.cycleCounterLbl.Text = String.Format("{0}  Цикл {1}", resultList.Name, this.measure.CycleNumber);
         //Отрисовка для статистических испытаний
         if (measure.IsStatistic)
         {
             this.statMeasNumbOfLbl.Text = String.Format("измерено {0} из {1}", measure.StatCycleNumber, measure.AveragingTimes);
             if (resultList.Count > 0)
             {
                 MeasureResultTera result = resultList.Last() as MeasureResultTera;
                 this.midStatMeasValLbl.Text = String.Format("промежуточное значение: {0}", !isDegreeViewCheckBox.Checked ? absoluteResultView(result.BringingResult) : deegreeResultView(result.BringingResult));
                 if (result.StatCycleNumber == measure.AveragingTimes)
                 {
                     double avVal = resultList.AverageBringing();
                     if (isDegreeViewCheckBox.Checked)
                     {
                         this.updateResultFieldText(deegreeResultView(avVal));
                     }
                     else
                     {
                         this.updateResultFieldText(absoluteResultView(avVal));
                     }
                 }
                 else
                 {
                     this.measureResultLbl.Text = "подождите...";
                 }
             }
         }
         else
         //для обычных испытаний
         {
             if (resultList.Count > 0)
             {
                 MeasureResultTera result = resultList.Last() as MeasureResultTera;
                 if (result.StatCycleNumber == this.measure.AveragingTimes)
                 {
                     if (this.measure.Type == MEASURE_TYPE.CALIBRATION || this.measure.Type == MEASURE_TYPE.VERIFICATION)
                     {
                         this.updateResultFieldText(absoluteResultView(result.BringingResult)); //absoluteResultView(result);
                         this.normaLbl.Text = (this.measure.NormaValue > 0) ? "эталон: " + absoluteResultView((double)this.measure.NormaValue / 1000) + " " + result.DeviationPercent.ToString() + "%" : "";
                     }
                     else
                     {
                         if (isDegreeViewCheckBox.Checked)
                         {
                             this.updateResultFieldText(deegreeResultView(result.BringingResult)); //absoluteResultView(result);
                             this.normaLbl.Text = (this.measure.NormaValue > 0) ? "норма: " + deegreeResultView((double)this.measure.NormaValue / 1000) : "";
                         }
                         else
                         {
                             this.updateResultFieldText(absoluteResultView(result.BringingResult)); //absoluteResultView(result);
                             this.normaLbl.Text = (this.measure.NormaValue > 0) ? "норма: " + absoluteResultView((double)this.measure.NormaValue / 1000) : "";
                         }
                     }
                 }
                 else
                 {
                     this.measureResultLbl.Text = "подождите...";
                 }
             }
         }
     }
 }