Пример #1
0
        /// <summary>
        /// 取り込み完了後の後処理
        /// </summary>
        public void Release()
        {
            if (SampleGrabber == null)
            {
                throw new DSLab.CxDSException(HRESULT.E_FAIL);
            }
            if (GraphBuilder == null)
            {
                throw new DSLab.CxDSException(HRESULT.E_FAIL);
            }

            // 1) 周期処理の停止.
            SampleGrabberCB.Enable = false;

            // 2) 待機.
            {
                CxStopwatch watch = new CxStopwatch();
                watch.Start();
                while (SampleGrabberCB.IsBusy)
                {
                    watch.Stop();
                    if (m_Timeout <= watch.Elapsed)
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(1);
                }
            }

            // 3) 解放.
            if (SampleGrabberCB.IsBusy == false)
            {
                SampleGrabberCB.Buffer.Clear();
            }
        }
Пример #2
0
        /// <summary>
        /// 1フレーム取り込み完了待機
        /// </summary>
        /// <param name="timeout">タイムアウト (msec) [範囲:-1=無限、0~=有限]</param>
        /// <returns>
        ///		1フレームの取り込みが完了するまで処理をブロックします。<br/>
        ///		取り込みが完了した場合は取り込み完了後のフレーム指標を返します。<br/>
        ///		それ以外は例外を発行します。<br/>
        /// </returns>
        public TxFrameIndex WaitFrame(int timeout)
        {
            if (SampleGrabber == null)
            {
                throw new DSLab.CxDSException(HRESULT.E_FAIL);
            }
            if (GraphBuilder == null)
            {
                throw new DSLab.CxDSException(HRESULT.E_FAIL);
            }

            TxFrameIndex current = SampleGrabberCB.FrameIndex;

            if (SampleGrabberCB.FrameIndex.Flag == 1)
            {
                // Continuous != true:
                //

                return(current);                // reached
            }
            else
            {
                // Continuous == true:
                //

                CxStopwatch watch = new CxStopwatch();
                watch.Start();
                while (true)
                {
                    if (SampleGrabberCB.FrameIndex.Frame != current.Frame)
                    {
                        return(current);                        // reached
                    }

                    // interrupt (stop or abort)
                    if (SampleGrabberCB.Enable == false)
                    {
                        throw new CxException(ExStatus.Interrupted);
                    }

                    watch.Stop();
                    if (0 <= timeout && timeout <= watch.Elapsed)
                    {
                        throw new CxException(ExStatus.Interrupted);
                    }

                    System.Threading.Thread.Sleep(1);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 1フレーム取り込み完了待機
        /// </summary>
        /// <param name="timeout">タイムアウト (msec) [範囲:-1=無限、0~=有限]</param>
        /// <returns>
        ///		1フレームの取り込みが完了するまで処理をブロックします。<br/>
        ///		取り込みが完了した場合は取り込み完了後のフレーム指標を返します。<br/>
        ///		それ以外は例外を発行します。<br/>
        /// </returns>
        public TxFrameIndex WaitFrame(int timeout)
        {
            if (SampleGrabber == null)
                throw new DSLab.CxDSException(HRESULT.E_FAIL);
            if (GraphBuilder == null)
                throw new DSLab.CxDSException(HRESULT.E_FAIL);

            TxFrameIndex current = SampleGrabberCB.FrameIndex;

            if (SampleGrabberCB.FrameIndex.Flag == 1)
            {
                // Continuous != true:
                //

                return current;	// reached
            }
            else
            {
                // Continuous == true:
                //

                CxStopwatch watch = new CxStopwatch();
                watch.Start();
                while (true)
                {
                    if (SampleGrabberCB.FrameIndex.Frame != current.Frame)
                    {
                        return current;	// reached
                    }

                    // interrupt (stop or abort)
                    if (SampleGrabberCB.Enable == false)
                        throw new CxException(ExStatus.Interrupted);

                    watch.Stop();
                    if (0 <= timeout && timeout <= watch.Elapsed)
                        throw new CxException(ExStatus.Interrupted);

                    System.Threading.Thread.Sleep(1);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 取り込み完了後の後処理
        /// </summary>
        public void Release()
        {
            if (SampleGrabber == null)
                throw new DSLab.CxDSException(HRESULT.E_FAIL);
            if (GraphBuilder == null)
                throw new DSLab.CxDSException(HRESULT.E_FAIL);

            // 1) 周期処理の停止.
            SampleGrabberCB.Enable = false;

            // 2) 待機.
            {
                CxStopwatch watch = new CxStopwatch();
                watch.Start();
                while (SampleGrabberCB.IsBusy)
                {
                    watch.Stop();
                    if (m_Timeout <= watch.Elapsed) break;
                    System.Threading.Thread.Sleep(1);
                }
            }

            // 3) 解放.
            if (SampleGrabberCB.IsBusy == false)
                SampleGrabberCB.Buffer.Clear();
        }