Beispiel #1
0
        //thread function
        private void captureFunc2()
        {
            //DEFINATION
            //last one element
            CaptureOutQueueElement cFlush; //last element

            //queue capcity
            int numCapBufs;

            //caputure element
            CaptureOutQueueElement ce;

            //driver element
            DrvQueueElement de;

            //
            uint boardStatus;

            //daq return
            int errCode;


            //CHECK INPUTS
            //none.

            //INIT
            cFlush       = new CaptureOutQueueElement(false);
            cFlush.isEnd = true;

            //MAIN PROCESSING
            try
            {
                //check board is normal?
                errCode = DAQ.get(boardId, AttrbuteType.DAQ_ATTR_BOARD_STATUS_MACHINE, ref boardStatus, (uint)DAQ_TYPE.DAQ_UINT_TYPE);
                if (errCode != (int)DAQErr.Success)
                {
                    throw new Exception("daq err return");
                }
                if (boardStatus != (uint)DAQ_BOARD_STATUS_MACHINE.DAQ_BOARD_STATUS_MACHINE_IDLE)
                {
                    throw new Exception("daq not correct board status");
                }

                //wait init Rendezvous
                init.handclasp_meet();

                //thread function
                while ((quit = Gbl.GetQuit()) != true)
                {
                    //new ce read from tsq interface, if timeout, throw error

                    //check output queue is full? if not full,
                    //
                } //end while(...
            }     //end try
            catch (Exception e)
            {
                MessageShow.show("Error of " + index.ToString() + "# capture thread!", index.ToString() + "#capture thread!" + e.ToString());
            }//end catch
        }
Beispiel #2
0
        /**Parse thread function.*/
        private void parseFunc()
        {
            //DEFINATION
            bool isDequeSuccess;
            bool isParseSuccess;
            //bool isError;
            CaptureOutQueueElement outqueueElement;
            //A queue atom represent the end of the ascan queue.
            AscanQueueElement ascanEndElement;
            //A queue atom represent the end of the mergein queue.
            MergeInQueueElement mergeInEndElement;

            //INIT
            isDequeSuccess = false;
            isParseSuccess = false;
            //isError = false;
            outqueueElement         = new CaptureOutQueueElement();
            ascanEndElement         = new AscanQueueElement();
            ascanEndElement.IsEnd   = true;
            mergeInEndElement       = new MergeInQueueElement();
            mergeInEndElement.IsEnd = true;

            //PROCESSING
            init.handclasp_meet();

            while (!GlobalQuit.Quit)
            {
                try
                {
                    isDequeSuccess = inputQueue.Dequeue(ref outqueueElement);

                    if (isDequeSuccess)
                    {
                        //if receive the end atom of queue, just break and stop the thread.
                        if (outqueueElement.IsEnd == true)
                        {
                            break;
                        }
                        // LogFile.write("开始分发");
                        isParseSuccess = parsePacket(outqueueElement.setPacket);
                        //  LogFile.write("分发结束");
                        if (!isParseSuccess)
                        {
                            StackTrace st = new StackTrace(new StackFrame(true));
                            LogHelper.WriteLog("The format of packet is wrong or ParseThread timed out when Enqueue!", st);
#if USE_WARNING
                            MessageBox.Show("分发线程获取的数据格式错误或入队失败,请马上设置断点检查。位置:ParseThread.parseFunc");
#endif
                            status = ThreadCondition.error;
                            //isError = true;
                        }
                    }
                    else
                    {
                        StackTrace st = new StackTrace(new StackFrame(true));
                        LogHelper.WriteLog("ParseThread timed out when Dequeue!", st);
#if USE_WARNING
                        MessageBox.Show("分发线程出队超时,请马上设置断点检查。位置:ParseThread.parseFunc");
#endif
                        status = ThreadCondition.error;
                        // isError = true;
                    }
                }
                catch (Exception e)
                {
                    StackTrace st = new StackTrace(new StackFrame(true));
                    LogHelper.WriteLog(e, st);
#if USE_WARNING
                    MessageBox.Show("检测到异常,请马上设置断点检查。位置:ParseThread.parseFunc");
#endif
                    status = ThreadCondition.error;
                    //isError = true;
                }
            }

            init.handclasp_force();

            //ascanQueue.EnqueueWithSemaphor(ascanEndElement);
            //mergeInQueue.EnqueueWithSemaphor(mergeInEndElement);

            clean.handclasp_meet();

            status = ThreadCondition.exit;
        }
Beispiel #3
0
        /**Capture thread funcion.*/
        private void captureFunc()
        {
            CaptureOutQueueElement outQueueElement;
            //A queue atom represent the end of the input.
            CaptureOutQueueElement queueFlush;
            int  readResult;
            bool isEnqueue;

            outQueueElement  = new CaptureOutQueueElement();
            queueFlush       = new CaptureOutQueueElement();
            queueFlush.IsEnd = true;
            readResult       = 0;
            //isError = false;
            isEnqueue = false;

            init.handclasp_meet();

            while (!GlobalQuit.Quit)
            {
                try
                {
                    readResult = GetPDAQ.daqRead(boardId, ref outQueueElement.setPacket);
                    //outQueueElement.setPacket.id = 512;
                    if (0 == readResult)
                    {
                        //LogFile.write("收到采集信号");
                        //the receiver count++
                        pkgCounter++;

                        //enqueue
                        isEnqueue = outputQueue.Enqueue(outQueueElement);
                        //LogFile.write("采集入队成功");
                        if (!isEnqueue)
                        {
                            StackTrace st = new StackTrace(new StackFrame(true));
                            LogHelper.WriteLog(boardId + "# CaptureThread timed out when Enqueue!", st);
#if USE_WARNING
                            MessageBox.Show("采集线程入队超时,请马上设置断点检查。位置:CaptureThread.captureFunc");
#endif
                            status = ThreadCondition.error;
                            //isError = true;
                        }
                    }
                    //A symbol for the last one
                    else if (1 == readResult)
                    {
                        outputQueue.Enqueue(queueFlush);
                        break;
                    }
                    else
                    {
                        StackTrace st = new StackTrace(new StackFrame(true));
                        LogHelper.WriteLog("Can't read from DAQ. ErrorCoed = " + readResult, st);
#if USE_WARNING
                        MessageBox.Show("采集线程读取DAQ数据错误,请马上设置断点检查。位置:CaptureThread.captureFunc, " + boardId.ToString() + "#采集线程错误!");
#endif
                        status = ThreadCondition.error;
                        //isError = true;
                    }
                }
                catch (Exception e)
                {
                    StackTrace st = new StackTrace(new StackFrame(true));
                    LogHelper.WriteLog(e, st);
#if USE_WARNING
                    MessageBox.Show("检测到异常,请马上设置断点检查。位置:CaptureThread.captureFunc, " + boardId.ToString() + "#采集线程异常!");
#endif
                    status = ThreadCondition.error;
                    //isError = true;
                }
            }
            init.handclasp_force();

            //outputQueue.Enqueue(queueFlush);
            clean.handclasp_meet();

            status = ThreadCondition.exit;
        }