コード例 #1
0
        private void Reader_OnRead(object sender, IntensityReader.DataChunk e)
        {
            // how many measurement values we have.
            int count    = e.IsCounterData ? e.CounterData.GetLength(1) : e.AnalogData.GetLength(1);
            int avgCount = Convert.ToInt32(Math.Floor(IntergrationSpan.TotalSeconds * Reader.SamplingFrequency));

            lock (m_dataCollector)
            {
                for (int i = 0; i < count; i++)
                {
                    m_curData         += e.CounterData[0, i];
                    m_curDataAvgCount += 1;
                    if (m_curDataAvgCount >= avgCount)
                    {
                        EnqueueNext(m_curData * Reader.SamplingFrequency / m_curDataAvgCount);
                        m_curData         = 0;
                        m_curDataAvgCount = 0;
                    }
                }
            }

            LastDataPoint = e.CounterData[0, count - 1];
        }
コード例 #2
0
        private void Reader_OnRead(object sender, IntensityReader.DataChunk data)
        {
            if (!IsScanning)
            {
                return;
            }

            if (WaitingForScan)
            {
                return;
            }

            // Calculate the time of the start using the current reader count.
            double seconds = (data.ReadStartOffset - ScanStartReaderTimeOffset).TotalSeconds;

            // Error check.
            if (seconds < 0)
            {
                ScanTimerError = true;
                return;
            }

            ScanTimerError = false;

            // end error check.

            for (int i = 0; i < data.DataCount; i++)
            {
                //double currentSecond = secs + i / CurrentScan.SamplingFrequency;
                //double timePerPixel = CurrentScan.TicksPerPixel / CurrentScan.SamplingFrequency;
                CurStreamIndex += 1;
                if (CurStreamIndex < 0)
                {
                    continue;
                }

                int xyIndex = CurStreamIndex / CurrentScan.TicksPerPixel;
                if (xyIndex >= CurrentScan.YPixels * CurrentScan.XPixels)
                {
                    if (!IsScanning)
                    {
                        return;
                    }

                    WaitingForScan = false;
                    IsRecording    = false;
                    Abort();
                    Task.Run(() =>
                    {
                        if (OnComplete != null)
                        {
                            OnComplete(this, null);
                        }
                    });

                    if (CurrentScan.SetXYVolAfterScan)
                    {
                        Writer.SetPosition(CurrentScan.XVolAfterScan, CurrentScan.YVolAfterScan);
                    }

                    return;
                }

                //int xidx = xyIndex % CurrentScan.YPixels;
                //int yidx = (xyIndex - xidx) / CurrentScan.XPixels;
                int xidx = 0;
                int yidx = 0;
                CurrentScan.PositionFromPixelIndex(xyIndex, out xidx, out yidx);

                Image[xidx, yidx] += data.IsCounterData ? data.CounterData[0, i] : data.AnalogData[0, i];
                LastRecordingTime  = DateTime.Now;
                //need to insert a parameter to record last data point in datacount use that as the differential for the next buffer reading
            }
        }