Пример #1
0
        void SetGauge(Simova s)
        {
            if (aGauge1.Value > s.Average || aGauge1.Value < s.Average)
            {
                float diff = s.Average - aGauge1.Value;

                if (Math.Abs(diff) < 2)
                {
                    aGauge1.Value += Math.Sign(diff) * (float)0.001 * trackBar1.Value;
                }
                else if (Math.Abs(diff) < 5)
                {
                    aGauge1.Value += Math.Sign(diff) * (float)0.005 * trackBar1.Value;
                }
                else if (Math.Abs(diff) < 10)
                {
                    aGauge1.Value += Math.Sign(diff) * (float)0.01 * trackBar1.Value;
                }
                else if (Math.Abs(diff) < 50)
                {
                    aGauge1.Value += Math.Sign(diff) * (float)0.05 * trackBar1.Value;
                }
                //else if(Math.Abs(diff) > trackBar1.Value * 0.1)
                //{
                // aGauge1.Value += trackBar1.Value * Math.Sign(diff) * (float)0.1;
                //}
                else
                {
                    aGauge1.Value += diff;
                }
            }
        }
        public LevelMeterPanel(ISharpControl control)
        {
            InitializeComponent();

            _controlInterface = control;

            ToolWin = new LevelMeterTool();
            ToolWin = new LevelMeterTool();
            ToolWin.Show();
            ToolWin.Visible = false;
            OnLevelUpdateEvent = new OnLevelUpdate(ToolWin.OnLevelUpdate);

            _fft_buffer = new byte[_controlInterface.FFTResolution];

               _smaTunedFrequecy = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
               _smaTunedBandwidth = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
               _smaTunedPeakPowerBandwidth  = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);

               trackBar1.Value = 100;

            UpdateTimer = new Timer();
            UpdateTimer.Interval = _UPDATE_TIMER_INTERVALL;
            UpdateTimer.Tick += new EventHandler(UpdateTimer_Tick);

            MeasureTimer = new Timer();
            MeasureTimer.Interval = _MEASURE_TIMER_INTERVALL;
            MeasureTimer.Tick += new EventHandler(MeasureTimer_Tick);

            Init();
        }
Пример #3
0
        public LevelMeterPanel(ISharpControl control)
        {
            InitializeComponent();

            _controlInterface = control;

            ToolWin = new LevelMeterTool();
            ToolWin = new LevelMeterTool();
            ToolWin.Show();
            ToolWin.Visible    = false;
            OnLevelUpdateEvent = new OnLevelUpdate(ToolWin.OnLevelUpdate);

            _fft_buffer = new byte[_controlInterface.FFTResolution];

            _smaTunedFrequecy           = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
            _smaTunedBandwidth          = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
            _smaTunedPeakPowerBandwidth = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);

            trackBar1.Value = 100;


            UpdateTimer          = new Timer();
            UpdateTimer.Interval = _UPDATE_TIMER_INTERVALL;
            UpdateTimer.Tick    += new EventHandler(UpdateTimer_Tick);


            MeasureTimer          = new Timer();
            MeasureTimer.Interval = _MEASURE_TIMER_INTERVALL;
            MeasureTimer.Tick    += new EventHandler(MeasureTimer_Tick);

            Init();
        }
Пример #4
0
        void MeasureTimer_Tick(object sender, EventArgs e)
        {
            if (!_controlInterface.IsPlaying)
            {
                if (_smaTunedFrequecy.IsValid)
                {
                    _smaTunedFrequecy           = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
                    _smaTunedBandwidth          = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
                    _smaTunedPeakPowerBandwidth = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
                }
                return;
            }

            _controlInterface.GetSpectrumSnapshot(_fft_buffer, POWERLEVEL_MIN, 0);

            _smaTunedFrequecy.Add(GetPowerTunedFreq());
            _smaTunedBandwidth.Add(GetPowerTunedBandwith());
            _smaTunedPeakPowerBandwidth.Add(GetPeakPowerTunedBandwith());
        }
Пример #5
0
        public LevelMeterPanel(ISharpControl control)
        {
            InitializeComponent();

            _controlInterface = control;

            InitToolWindow();

            LoadOptions();

            _fft_buffer = new float[_controlInterface.FFTResolution];

            _smaTunedFrequecy           = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
            _smaTunedBandwidth          = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
            _smaTunedPeakPowerBandwidth = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);

            UpdateTimerInit();

            MeasureTimerInit();

            GuiInit();
        }
        public LevelMeterPanel(ISharpControl control)
        {
            InitializeComponent();

              _controlInterface = control;

              InitToolWindow();

              LoadOptions();

              _fft_buffer = new float[_controlInterface.FFTResolution];

              _smaTunedFrequecy = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
              _smaTunedBandwidth = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
              _smaTunedPeakPowerBandwidth  = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);

              UpdateTimerInit();

              MeasureTimerInit();

              GuiInit();
        }
Пример #7
0
        void GetPowerThreadFunc(object parameter)
        {
            while (true)
            {
                if (!_controlInterface.IsPlaying)
                {
                    if (_smaTunedFrequecy.IsValid)
                    {
                        _smaTunedFrequecy           = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
                        _smaTunedBandwidth          = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
                        _smaTunedPeakPowerBandwidth = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
                    }
                    return;
                }

                _controlInterface.GetSpectrumSnapshot(_fft_buffer, POWERLEVEL_MIN, 0);

                _smaTunedFrequecy.Add(MyLib.GetPowerTunedFreq());
                _smaTunedBandwidth.Add(MyLib.GetPowerTunedBandwith());
                _smaTunedPeakPowerBandwidth.Add(MyLib.GetPeakPowerTunedBandwith());

                Thread.Sleep(_MEASURE_TIMER_INTERVALL);
            }
        }
        void SetGauge(Simova s)
        {
            if (aGauge1.Value > s.Average || aGauge1.Value < s.Average)
              {
            float diff = s.Average - aGauge1.Value;

            if ( Math.Abs(diff) < 2 )
            {
              aGauge1.Value += Math.Sign(diff) * (float)0.001 * trackBar1.Value;
            }
            else if (Math.Abs(diff) < 5)
            {
              aGauge1.Value += Math.Sign(diff) * (float)0.005 * trackBar1.Value;
            }
            else if (Math.Abs(diff) < 10)
            {
              aGauge1.Value += Math.Sign(diff) * (float)0.01 * trackBar1.Value;
            }
            else if (Math.Abs(diff) < 50)
            {
              aGauge1.Value += Math.Sign(diff) * (float)0.05 * trackBar1.Value;
            }
            //else if(Math.Abs(diff) > trackBar1.Value * 0.1)
            //{
             // aGauge1.Value += trackBar1.Value * Math.Sign(diff) * (float)0.1;
            //}
            else
            {
               aGauge1.Value += diff;
            }
              }
        }
        void MeasureTimer_Tick(object sender, EventArgs e)
        {
            if (!_controlInterface.IsPlaying)
              {
            if (_smaTunedFrequecy.IsValid)
            {
              _smaTunedFrequecy = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
              _smaTunedBandwidth = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
              _smaTunedPeakPowerBandwidth = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
            }
            return;
              }

              _controlInterface.GetSpectrumSnapshot(_fft_buffer);

              _smaTunedFrequecy.Add(GetPowerTunedFreq());
              _smaTunedBandwidth.Add(GetPowerTunedBandwith());
              _smaTunedPeakPowerBandwidth.Add(GetPeakPowerTunedBandwith());
        }
Пример #10
0
        public void TestThis()
        {
            Simova Sma = new Simova(5, 0);

            Console.WriteLine(Sma.Add(1).ToString());
            Console.WriteLine(Sma.BufferToString());
            Console.WriteLine(Sma.Add(2).ToString());
            Console.WriteLine(Sma.BufferToString());
            Console.WriteLine(Sma.Add(3).ToString());
            Console.WriteLine(Sma.BufferToString());
            Console.WriteLine(Sma.Add(4).ToString());
            Console.WriteLine(Sma.BufferToString());
            Console.WriteLine(Sma.Add(5).ToString());
            Console.WriteLine(Sma.BufferToString());
            Console.WriteLine(Sma.Add(6).ToString());
            Console.WriteLine(Sma.BufferToString());
            Console.WriteLine(Sma.Add(7).ToString());
            Console.WriteLine(Sma.BufferToString());

            if (Sma.Add(8) != 6)
            {
              throw new Exception("Simova selftest failed!");
            }
        }
        void SetGauge(Simova s)
        {
            if (aGauge1.Value > s.Average || aGauge1.Value < s.Average)
              {
            float diff = s.Average - aGauge1.Value;

            if (Math.Abs(diff) < 2)
            {
              aGauge1.Value += Math.Sign(diff) * (float)0.001 * tbSmoothing.Value;
            }
            else if (Math.Abs(diff) < 5)
            {
              aGauge1.Value += Math.Sign(diff) * (float)0.005 * tbSmoothing.Value;
            }
            else if (Math.Abs(diff) < 10)
            {
              aGauge1.Value += Math.Sign(diff) * (float)0.01 * tbSmoothing.Value;
            }
            else if (Math.Abs(diff) < 50)
            {
              aGauge1.Value += Math.Sign(diff) * (float)0.05 * tbSmoothing.Value;
            }
            else
            {
              aGauge1.Value += diff;
            }
              }
        }
        void GetPowerThreadFunc(object parameter)
        {
            while (true)
                    {
                        if (!_controlInterface.IsPlaying)
                        {
                            if (_smaTunedFrequecy.IsValid)
                            {
                                _smaTunedFrequecy = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
                                _smaTunedBandwidth = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
                                _smaTunedPeakPowerBandwidth = new Simova(_SIMPLE_AVERAGE_SAMPLE_CNT, _SIMPLE_AVERAGE_MIN);
                            }
                            return;
                        }

                        _controlInterface.GetSpectrumSnapshot(_fft_buffer, POWERLEVEL_MIN, 0);

                        _smaTunedFrequecy.Add(MyLib.GetPowerTunedFreq());
                        _smaTunedBandwidth.Add(MyLib.GetPowerTunedBandwith());
                        _smaTunedPeakPowerBandwidth.Add(MyLib.GetPeakPowerTunedBandwith());

                        Thread.Sleep(_MEASURE_TIMER_INTERVALL);
                    }
        }