Ejemplo n.º 1
0
        public void OnUpdateSpectrumPointData(long pFreqIndex, SpectrumPointData pPointData)
        {
            Action <long, SpectrumPointData> handler = UpdateSpectrumPointData;

            if (handler != null)
            {
                handler(pFreqIndex, pPointData);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取频率范围内最小谱图点数据
        /// </summary>
        /// <param name="pStartFreq">起始频率</param>
        /// <param name="pStopFreq">终止频率</param>
        /// <returns>谱图点数据</returns>
        public SpectrumPointData?GetMinSpectrumPointData(double pStartFreq, double pStopFreq)
        {
            long sIndex = GetIndex(pStartFreq) + 1;
            long eIndex = GetIndex(pStopFreq) - 1;
            long count  = eIndex - sIndex;

            if (count <= 0)
            {
                return(null);
            }
            var sp = new SpectrumPointData();

            lock (_lockObj)
            {
                double minDubv = 0;
                for (long i = sIndex; i < eIndex; i++)
                {
                    long offset = i * _dataStructSize;
                    if (offset > _stream.Length)
                    {
                        return(null);
                    }
                    _stream.Seek(offset, SeekOrigin.Begin);
                    _stream.Read(_buffer, 0, _dataStructSize);
                    double freqV = BitConverter.ToDouble(_buffer, 0);
                    short  dbuv  = BitConverter.ToInt16(_buffer, 8);
                    if (dbuv < minDubv)
                    {
                        minDubv = dbuv;
                        sp.Dbuv = dbuv;
                        sp.Freq = freqV;
                    }
                }
            }
            return(sp);
        }