コード例 #1
0
 /// <summary>
 /// 停止计时
 /// </summary>
 public void Stop()
 {
     if (_timer == null)
     {
         return;
     }
     _timer.Stop();
     TimeEnd?.Invoke(this, null);
 }
コード例 #2
0
 public void Change(float value)
 {
     time += value;
     if (time <= 0)
     {
         time = 0;
         TimeEnd?.Invoke();
     }
     TimeChangeEvent?.Invoke(time);
 }
コード例 #3
0
        public void Polling(int ThreadId)
        {
            ShowPollingStatus();
            if (DataMeasuringState == DataMeasuringState.Start)
            {
                _LocalIntervalCount = 0;

                ShowPollingStatus();
                WriteThreadId?.Invoke(ThreadId);
                TimeStart?.Invoke();
                //количество интервалов измерений
                int countInt = 0;
                foreach (var interval in Experiment.Intervals.Where(p => p.isActive))
                {
                    countInt += interval.CenterFrequencys.Count;
                }
                pBarMax?.Invoke(countInt);
                int Value = 0;
                //StateButtunChart?.Invoke(false);  //деактивация кнопок График
                foreach (Interval currentInterval in Experiment.Intervals)
                {
                    if (currentInterval.isActive)
                    {
                        ShowPollingStatus();

                        ShowIntervalMessage(currentInterval.IntervalSettings);

                        if (DataMeasuringType == DataMeasuringType.Signal)
                        {
                            currentInterval.SignalClear();
                        }
                        else
                        {
                            currentInterval.NoiseClear();
                        }

                        currentInterval.Frequencys.Clear();
                        //количество центральных частот в текущем интервале(>1, точек измерения получается больше, чем может отобразить прибор)
                        _LocalIntervalFrequencys = currentInterval.CenterFrequencys.Count;
                        _LocalPointCount         = 0;
                        if (currentInterval.CenterFrequencys.Count == 0)
                        {
                            MessageBox.Show("Не возможно выполнить измерения." + Environment.NewLine + "Вероятно Вы забыли нажать кнопку 'РАССЧИТАТЬ'");
                            DataMeasuringState = DataMeasuringState.Clear;
                            return;
                        }
                        StateButtunChart?.Invoke(false, (ParametersCtrl)currentInterval.IntervalSettings.LinkToVisualControl);  //деактивация кнопок График
                        //pBarMax?.Invoke(Experiment.Intervals.Where(p => p.isActive).Count() * currentInterval.CenterFrequencys.Count);
                        foreach (long currentFrequency in currentInterval.CenterFrequencys)
                        {
                            ShowPollingStatus();

                            while (DataMeasuringState == DataMeasuringState.Pause)
                            {
                                if (DataMeasuringState == DataMeasuringState.Interrupted)
                                {
                                    if (DataMeasuringType == DataMeasuringType.Signal)
                                    {
                                        currentInterval.SignalClear();
                                    }
                                    else
                                    {
                                        currentInterval.NoiseClear();
                                    }

                                    ShowPollingStatus();
                                    return;
                                }

                                ShowPollingStatus();
                                Thread.Sleep(100);
                            }

                            if (DataMeasuringState == DataMeasuringState.Interrupted)
                            {
                                if (DataMeasuringType == DataMeasuringType.Signal)
                                {
                                    currentInterval.SignalClear();
                                }
                                else
                                {
                                    currentInterval.NoiseClear();
                                }

                                ShowPollingStatus();
                                return;
                            }

                            bool dataReady = false;

                            if (DataMeasuringType == DataMeasuringType.Signal)
                            {
                                dataReady = ReadSignal(currentFrequency,
                                                       currentInterval.IntervalSettings.BandWidth,
                                                       currentInterval.IntervalSettings.Span,
                                                       currentInterval.IntervalSettings.Band,
                                                       currentInterval.IntervalSettings.isManuaSWPTime,
                                                       currentInterval.IntervalSettings.ManuaSWPTime);

                                if (dataReady)
                                {
                                    if (currentInterval.Frequencys.Count != 0)
                                    {
                                        double[] tmpX = new double[ResultsX.Length - 1];
                                        Array.Copy(ResultsX, 1, tmpX, 0, ResultsX.Length - 1);

                                        double[] tmpY = new double[ResultsY.Length - 1];
                                        Array.Copy(ResultsY, 1, tmpY, 0, ResultsY.Length - 1);

                                        currentInterval.Frequencys.AddRange(tmpX);
                                        currentInterval.OriginalSignal.AddRange(tmpY);
                                    }
                                    else
                                    {
                                        currentInterval.Frequencys.AddRange(ResultsX);
                                        currentInterval.OriginalSignal.AddRange(ResultsY);
                                    }
                                }
                            }
                            else
                            {
                                dataReady = ReadNoise(currentFrequency,
                                                      currentInterval.IntervalSettings.BandWidth,
                                                      currentInterval.IntervalSettings.Span,
                                                      currentInterval.IntervalSettings.Band,
                                                      currentInterval.IntervalSettings.isManuaSWPTime,
                                                      currentInterval.IntervalSettings.ManuaSWPTime);

                                if (dataReady)
                                {
                                    if (currentInterval.Frequencys.Count != 0)
                                    {
                                        double[] tmpX = new double[ResultsX.Length - 1];
                                        Array.Copy(ResultsX, 1, tmpX, 0, ResultsX.Length - 1);

                                        double[] tmpY = new double[ResultsY.Length - 1];
                                        Array.Copy(ResultsY, 1, tmpY, 0, ResultsY.Length - 1);

                                        currentInterval.Frequencys.AddRange(tmpX);
                                        currentInterval.OriginalNoise.AddRange(tmpY);
                                    }
                                    else
                                    {
                                        currentInterval.Frequencys.AddRange(ResultsX);
                                        currentInterval.OriginalNoise.AddRange(ResultsY);
                                    }
                                }
                            }

                            _LocalPointCount++;
                            Value++;
                            pBarValue?.Invoke(Value);
                        }

                        if (currentInterval.IntervalSettings.isAuto) //только для СС
                        {
                            currentInterval.Computer();              //обработка полученных сигналов измерения
                        }
                        else
                        {
                            currentInterval.Restore(); //для СС. Копирование ориг. значений без обработки
                        }
                        //сигнал, меньший шума, подтянем до уровня шума
                        if (currentInterval.Signal.Count != 0 && currentInterval.Noise.Count != 0)
                        {
                            for (int i = 0; i < currentInterval.Frequencys.Count; i++)
                            {
                                if (currentInterval.Signal[i] < currentInterval.Noise[i])
                                {
                                    currentInterval.Signal[i] = currentInterval.Noise[i];
                                }
                            }
                        }

                        _LocalIntervalCount++;
                        StateButtunChart?.Invoke(true, (ParametersCtrl)currentInterval.IntervalSettings.LinkToVisualControl);
                    }
                }
                TimeEnd?.Invoke();
                DataMeasuringState = DataMeasuringState.Finish;
                ShowPollingStatus();

                if (DataMeasuringType == DataMeasuringType.Signal)
                {
                    SignalReadyIntervalEvent?.Invoke();
                    MessageBox.Show(Experiment.ExperimentSettings.HardwareSettings.HardwareType
                                    + "- -СЪЕМ СИГНАЛА ЗАВЕРШЕН" + Environment.NewLine
                                    + "Поток - " + ThreadId.ToString());
                }
                if (DataMeasuringType == DataMeasuringType.Noise)
                {
                    MessageBox.Show(Experiment.ExperimentSettings.HardwareSettings.HardwareType
                                    + " - СЪЕМ ШУМА ЗАВЕРШЕН" + Environment.NewLine
                                    + "Поток - " + ThreadId.ToString());
                    NoiseReadyIntervalEvent?.Invoke();
                }
                pBarValue?.Invoke(0);
                pBarMax?.Invoke(0);
                //  StateButtunChart?.Invoke(true);  //активация кнопок График
            }
        }