Example #1
0
        private void ProcSequence()
        {
            if (m_mot != null && m_io != null)
            {
                int listSize = m_listSeq.Count;
                int i = 0, repeat = m_nSeqRepeat;

                while (m_bSequenceLive)
                {
                    SEQ_LIST curr = m_listSeq[i++];
                    try
                    {
                        switch (curr.seq)
                        {
                        case SEQUENCE.Delay:
                            int delay = (int)curr.data;
                            Thread.Sleep(delay);
                            break;

                        case SEQUENCE.IO:
                            SEQ_IO dataIO = (SEQ_IO)curr.data;
                            m_io.WriteOutBit(dataIO.nIoNum, Convert.ToUInt32(dataIO.bOn));
                            break;

                        case SEQUENCE.Motion:
                            SEQ_MOTION dataMot = (SEQ_MOTION)curr.data;
                            m_mot.AxisMove(dataMot.nAxisNum, dataMot.dPos, false);
                            while (m_mot.AxisIsBusy(dataMot.nAxisNum))
                            {
                                Thread.Sleep(1);
                            }
                            break;

                        case SEQUENCE.VisionSnap:

                            m_httpCam = HTTP_Cam.GetInstance();
                            if (!m_httpCam.IsInitialize)
                            {
                                m_httpCam.SetInit();
                            }
                            if (m_httpCam.IsInitialize)
                            {
                                string path   = m_httpCam.SavePath + "\\" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff") + ".bmp";
                                Bitmap bitmap = m_httpCam.SnapShot();
                                bitmap.Save(path);
                            }

                            /*
                             * m_httpCam = HTTP_Cam.GetInstance();
                             * string path = m_httpCam.SavePath + "\\" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff") + ".bmp";
                             *
                             * m_rtspCam = RTSP_Cam.GetInstance();
                             * m_rtspCam.SnapShot();
                             * Bitmap bitmap = m_rtspCam.SnapShot();
                             * bitmap.Save(path);
                             */
                            break;
                        }
                    }
                    catch (Exception E)
                    {
                        LogFile.LogExceptionErr(E.ToString());
                    }

                    if (i >= listSize)
                    {
                        if (m_bSeqContinuous)
                        {
                            i = 0;
                        }
                        else
                        {
                            if (repeat > 1)
                            {
                                repeat--;
                                i = 0;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            }

            m_bSeqContinuous = false;
            m_bSequenceLive  = false;
            m_thSequence     = null;

            return;
        }