コード例 #1
0
        void AcqProc()
        {
            reqStopStreaming.Reset();

            Trace.TraceInformation("Setting up 'frame start' output signal lines");
            SetupOutputSignal_FrameStart(rtsiLine: 0);
            //session.SignalEvents.AddSignal("Frame done",
            //    new ImaqSignalEventDescriptor(ImaqSignalStatus.FrameDone,
            //        ImaqSignalState.High));

            RectSize size           = PostBinningRoiSize;
            bool     recycleBuffers = (buffers != null) &&
                                      (buffers.Count == nDriverFrameBuffers) &&
                                      (bufferSize == size);

            if (!recycleBuffers)
            {
                Trace.TraceInformation("Allocating {0} buffers...", nDriverFrameBuffers);
                buffers = session.CreateBufferCollection(nDriverFrameBuffers,
                                                         ImaqBufferCollectionType.PixelValue2D);
                bufferSize = size;
                Trace.TraceInformation("Setting up buffer ring...");
                session.RingSetup(buffers, 0, false);
            }

            Trace.TraceInformation("Starting acquisition...");
            session.Start();


            int frameIndex = -1;

            startedStreaming.Set();
            while (!reqStopStreaming.WaitOne(0))
            {
                uint extractedBufferIndex;

                ImaqBuffer buf = session.Acquisition.Extract(
                    (uint)(frameIndex + 1), out extractedBufferIndex);

                if (extractedBufferIndex != frameIndex + 1)
                {
                    Trace.TraceWarning("Skipped from frame {0} to frame {1}",
                                       frameIndex, extractedBufferIndex);
                }

                frameIndex = (int)extractedBufferIndex;

                RingBufferForOutput.TryCopyIn <NF, VideoFrame>(frameCopierDelegate,
                                                               new NF(frameIndex, buf));


                Action a = Interlocked.Exchange(ref pauseAndExecute, null);
                if (a != null)
                {
                    Trace.TraceInformation("Pausing acquisition to execute an interrupt....");
                    session.Stop();
                    Trace.TraceInformation("Executing...");
                    a();
                    Trace.TraceInformation("Restarting acquisition...");
                    session.Start();
                }
            }

            session.Stop();
        }
コード例 #2
0
ファイル: FakeHAL.cs プロジェクト: chenw11/acq
        void QueueFrame()
        {
            int myId = Interlocked.Increment(ref counter);

            RingBufferForOutput.TryCopyIn <int, VideoFrame>(CopyInNewData, myId);
        }