Exemplo n.º 1
0
        private void ConvertApdSamplesHandler()
        {
            int           xSampleCountPerLine      = m_config.GetScanXPoints();
            int           imageSampleCountPerFrame = m_config.GetScanXPoints() * m_config.GetScanYPoints();
            int           scanRows     = m_config.GetScanStrategy() == SCAN_STRATEGY.Z_BIDIRECTION ? m_params.ScanRows * 2 : m_params.ScanRows;
            SCAN_STRATEGY scanStrategy = m_config.GetScanStrategy();

            int sourceIndex;

            int[] data = new int[xSampleCountPerLine];

            while (m_scanning)
            {
                if (!m_scanData.DequeueApdSample(out ApdSampleData sample))
                {
                    continue;
                }

                // 采集数据转换
                // 去背景噪声
                sample.Convert();

                // 如果是双向扫描,且当前是奇数行,则该行的数据需要反转
                // 根据错位补偿参数,完成相应的截断
                if (scanStrategy == SCAN_STRATEGY.Z_BIDIRECTION)
                {
                    if ((sample.Line & 0x01) == 0x01)   // 奇数行,需要反转
                    {
                        sourceIndex = m_config.GetScanPixelCompensation() / 2 + m_config.GetScanPixelCalibration();
                        Array.Reverse(sample.NSamples);
                        Array.Copy(sample.NSamples, sourceIndex, data, 0, xSampleCountPerLine);
                    }
                    else
                    {
                        sourceIndex = m_config.GetScanPixelCompensation() / 2 + m_config.GetScanPixelOffset();
                        Array.Copy(sample.NSamples, sourceIndex, data, 0, xSampleCountPerLine);
                    }
                }
                else
                {
                    sourceIndex = m_config.GetScanPixelCompensation() / 2 + m_config.GetScanPixelOffset();
                    Array.Copy(sample.NSamples, sourceIndex, data, 0, xSampleCountPerLine);
                }

                ApdSampleData convertData = new ApdSampleData(data, sample.Frame, sample.Line, sample.ChannelIndex);
                m_scanData.EnqueueApdConvertData(convertData);

                if (convertData.Line + 1 == scanRows)
                {
                    Logger.Info(string.Format("channel[{0}] convert info: frame[{1}], line[{2}].", convertData.ChannelIndex, convertData.Frame, convertData.Line));
                }

                data = new int[xSampleCountPerLine];
            }

            Logger.Info(string.Format("scan task[{0}|{1}] stop, finish convert samples.", m_taskId, m_taskName));
        }
Exemplo n.º 2
0
        private void ApdReceiveSamples(object sender, int channelIndex, int[] samples)
        {
            ApdSampleData sample = new ApdSampleData(samples, m_scanInfo.GetFrame(channelIndex), m_scanInfo.GetLine(channelIndex), channelIndex);

            m_scanData.EnqueueApdSample(sample);

            //if (m_config.Debugging)
            //{
            //    double timeSpan = (DateTime.Now - m_scanInfo.StartTime).TotalSeconds;
            //    double timePerLine = m_scanInfo.TimeSpan / (m_config.GetScanYPoints() * m_scanInfo.GetFrame(channelIndex) + m_scanInfo.GetLine(channelIndex) + 1);
            //    Logger.Info(string.Format("scan info: channel[{0}], frame[{1}], line[{2}], number of samples[{3}], time per line:[{4}].",
            //        channelIndex, m_scanInfo.GetFrame(channelIndex), m_scanInfo.GetLine(channelIndex), samples.Length, timePerLine));
            //}

            m_scanInfo.UpdateScanInfo(channelIndex);
        }
Exemplo n.º 3
0
 public bool DequeueApdConvertData(out ApdSampleData convertData)
 {
     return(m_apdConvertQueue.Dequeue(out convertData));
 }
Exemplo n.º 4
0
 public void EnqueueApdConvertData(ApdSampleData convertData)
 {
     m_apdConvertQueue.Enqueue(convertData);
 }
Exemplo n.º 5
0
 public bool DequeueApdSample(out ApdSampleData sampleData)
 {
     return(m_apdSampleQueue.Dequeue(out sampleData));
 }
Exemplo n.º 6
0
 public void EnqueueApdSample(ApdSampleData sampleData)
 {
     m_apdSampleQueue.Enqueue(sampleData);
 }