Exemple #1
0
        private void mergeFunc()
        {
            int dequeueResult;
            //bool isError;
            bool stop;
            bool isParseSuccess;
            int  endCount;
            MergeInQueueElement outqueueElement;
            QueueData           endQueue;

            //isError = false;
            stop            = false;
            isParseSuccess  = false;
            endCount        = 0;
            outqueueElement = new MergeInQueueElement();
            endQueue        = new QueueData();
            endQueue.isEnd  = true;  //A queue atom represent the end of the input.

            init.handclasp_meet();

            while ((!GlobalQuit.Quit) && (!stop))
            {
                try
                {
                    for (int i = 0; i < mergeInList.Count; i++)
                    {
                        dequeueResult = mergeInList[i].DequeueWithSemaphor(ref outqueueElement, ConstParameter.TimeOutMilliSecondValue);

                        if (dequeueResult == -1)
                        {
                            StackTrace st = new StackTrace(new StackFrame(true));
                            LogHelper.WriteLog("MergeThread timed out when semaphor wait for receiving!", st);
#if USE_WARNING
                            MessageBox.Show("融合线程信号量超时,请马上设置断点检查。位置:MergeThread.mergeFunc");
#endif
                            status = ThreadCondition.error;
                            //isError = true;
                        }
                        else if (dequeueResult == 0)
                        {
                            continue;
                        }
                        else if (dequeueResult == 1)
                        {
                            //if receive the end atom of queue, just break and stop the thread.
                            if (outqueueElement.IsEnd == true)
                            {
                                endCount++;
                                if (endCount == mergeInList.Count)
                                {
                                    endCount = 0;
                                    stop     = true;
                                    break;
                                }
                                else
                                {
                                    continue;
                                }
                            }

                            isParseSuccess = parsePacket(outqueueElement.setPacket, i);
                            if (!isParseSuccess)
                            {
                                StackTrace st = new StackTrace(new StackFrame(true));
                                LogHelper.WriteLog("The format of packet is wrong or MergeThread timed out when Enqueue!", st);
#if USE_WARNING
                                MessageBox.Show("融合线程获取的数据格式错误或入队失败,请马上设置断点检查。位置:MergeThread.mergeFunc");
#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("检测到异常,请马上设置断点检查。位置:MergeThread.mergeFunc");
#endif
                    status = ThreadCondition.error;
                    //isError = true;
                }
            }
            init.handclasp_force();

            measureQueueElement.IsEnd = true;
            measureQueue.Enqueue(measureQueueElement);

            clean.handclasp_meet();

            status = ThreadCondition.exit;
        }
Exemple #2
0
        /**Measure UI thread function.*/
        private void MeasureUIFunc()
        {
            //DEFINATION
            //bool isError;

            bool isDequeSuccess;

            //INIT
            //isError = false;
            isDequeSuccess = false;

            //PROCESSING
            init.handclasp_meet();

            while (!GlobalQuit.Quit)
            {
                try
                {
                    //if (measureUpdateList.Count != mapRowDataList.Count)
                    //bindMeasureDrawEvent();

                    isDequeSuccess = measureQueue.Dequeue(ref measureQueueElement);

                    if (isDequeSuccess)
                    {
                        //if receive the end atom of queue, just break and stop the thread.
                        if (measureQueueElement.IsEnd == true)
                        {
                            break;
                        }

                        if (FormList.FormMeasurement == null)
                        {
                            continue;
                        }

                        if (!MainForm.IsToStop)
                        {
                            FormList.FormMeasurement.addPoints(measureQueueElement);
                            //FormList.FormCalibrate.addPoints(measureQueueElement);
                        }
                    }
                    else
                    {
                        StackTrace st = new StackTrace(new StackFrame(true));
                        LogHelper.WriteLog("MeasureUI thread timed out when Dequeue!", st);
#if USE_WARNING
                        MessageBox.Show("融合显示线程出队超时,请马上设置断点检查。位置:MeasureUIThread.MeasureUIFunc");
#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("检测到异常,请马上设置断点检查。位置:AscanUIThread.AscanUIFunc");
#endif
                    status = ThreadCondition.error;
                    //isError = true;
                }
            }
            init.handclasp_force();

            clean.handclasp_meet();

            status = ThreadCondition.exit;
        }
Exemple #3
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;
        }
Exemple #4
0
        /**UI thread function.*/
        private void UIFunc()
        {
            //DEFINATION
            bool isError;

            int dequeueResult;

            //INIT
            isError = false;

            //PROCESSING
            init.handclasp_meet();

            bindAscanDrawEvent();

            while (!GlobalQuit.Quit)
            {
                try
                {
                    for (int i = 0; i < sessionsAttrs.Count; i++)
                    {
                        dequeueResult = ascanInList[i].DequeueWithSemaphor(ref ascanQueueElement);

                        if (dequeueResult == -1)
                        {
                            StackTrace st = new StackTrace(new StackFrame(true));
                            LogHelper.WriteLog("UI Thread timed out when semaphor wait for receiving!", st);
#if USE_WARNING
                            MessageBox.Show("UI主线程信号量超时,请马上设置断点检查。位置:UIThread.UIFunc");
#endif
                            status  = ThreadCondition.error;
                            isError = true;
                        }
                        else if (dequeueResult == 0)
                        {
                            continue;
                        }
                        else if (dequeueResult == 1)
                        {
                            if (sessionsAttrs[i].myHardInfo.enable)
                            {
                                ascanUpdateList[i].Execute(ascanQueueElement);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    StackTrace st = new StackTrace(new StackFrame(true));
                    LogHelper.WriteLog(e, st);
#if USE_WARNING
                    MessageBox.Show("检测到异常,请马上设置断点检查。位置:UIThread.UIFunc");
#endif
                    status  = ThreadCondition.error;
                    isError = true;
                }
            }

            init.handclasp_force();

            clean.handclasp_meet();

            if (!isError)
            {
                status = ThreadCondition.exit;
            }
        }
Exemple #5
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;
        }
Exemple #6
0
        /**Stop timer.*/

        /*public void stop()
         * {
         *  if (timer.Enabled)
         *      timer.Enabled = false;
         * }*/

        /**Ascan UI timer function.*/
        private void AscanUIFunc()
        {
            //DEFINATION
            bool isError;

            int  dequeueResult;
            int  endCount;
            bool isQuit = false;

            //INIT
            isError  = false;
            endCount = 0;

            //PROCESSING
            init.handclasp_meet();

            DelegateAscanUpdate ascanUpdate = new DelegateAscanUpdate();

            while (!GlobalQuit.Quit && !isQuit)
            {
                try
                {
                    for (int i = 0; i < SessionInfo.sessionNum; i++)
                    {
                        dequeueResult = ascanInList[i].DequeueWithSemaphor(ref ascanQueueElement, ConstParameter.TimeOutMilliSecondValue);

                        if (dequeueResult == -1)
                        {
                            StackTrace st = new StackTrace(new StackFrame(true));
                            LogHelper.WriteLog("Ascan UI Thread timed out when semaphor wait for receiving!", st);
#if USE_WARNING
                            MessageBox.Show("A扫UI线程信号量超时,请马上设置断点检查。位置:AscanUIThread.AscanUIFunc");
#endif
                            status = ThreadCondition.error;
                            //isError = true;
                        }
                        else if (dequeueResult == 0)
                        {
                            continue;
                        }
                        else if (dequeueResult == 1)
                        {
                            if (ascanQueueElement.IsEnd)
                            {
                                endCount++;
                                if (endCount == ascanInList.Count)
                                {
                                    endCount = 0;
                                    isQuit   = true;
                                    //timer.Enabled = false;
                                    break;
                                }
                                else
                                {
                                    continue;
                                }
                            }

                            if (!MainForm.IsToStop)
                            {
                                if (i == SelectAscan.userIndex && (int)ascanQueueElement.getPort() == SelectAscan.port)
                                {
                                    MainForm.syncContext.Post(FormList.MDIChild.updateAscan, (Object)ascanQueueElement);
                                    //FormList.MDIChild.updateAscan(ascanQueueElement);
                                    //ascanUpdate.Execute(ascanQueueElement);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    StackTrace st = new StackTrace(new StackFrame(true));
                    LogHelper.WriteLog(ex, st);
#if USE_WARNING
                    MessageBox.Show("检测到异常,请马上设置断点检查。位置:AscanUIThread.AscanUIFunc");
#endif
                    status = ThreadCondition.error;
                    //isError = true;
                }
            }
            init.handclasp_force();

            clean.handclasp_meet();

            status = ThreadCondition.exit;
        }