示例#1
0
        /**
         * @brief BackgroundWorker가 Work할 때 사용하는 메서드
         * @author 불명(김효상 확인)
         * @date 불명(2017-1-23 확인)
         */
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            /*string name = (string)obj.getGridView()[1, 0].Value;*/
            obj.getGridView()[1, 0].Value = "";
            while (innerStartAnim && !worker.CancellationPending)
            {
                string   msg;
                msg      currentMessage;
                string[] res = rsv.checkMsg(out msg);
                if (!string.IsNullOrEmpty(msg))
                {
                    lock (key)
                    {
                        receivedMsg = msg;
                    }
                    try
                    {
                        currentMessage = new msg()
                        {
                            msgOrig = res
                        };
                        this.Invoke((MethodInvoker) delegate()
                        {
                            obj.getGridView()[1, 0].Value = obj.ModelName(currentMessage.modelN);
                            obj.getGridView()[1, 1].Value = currentMessage.seqNo;
                            obj.getGridView()[1, 2].Value = currentMessage.X;
                            obj.getGridView()[1, 3].Value = currentMessage.Y;
                            obj.getGridView()[1, 4].Value = currentMessage.R;
                            obj.getGridView()[1, 5].Value = currentMessage.T;
                        });
                    }
                    catch (FormatException)
                    {
                        //작동과 무관함
                    }

                    worker.ReportProgress(1);
                    //큐 데이터가 움직임이다
                    if (!string.IsNullOrEmpty(msg) && msg.Contains(','))
                    {
                        if (animHandler != null)
                        {
                            animHandler.startAnim(new msg()
                            {
                                msgOrig = res
                            });
                        }
                    }
                }
            }
        }
        /**
         * @brief 애니메이션 시작 메소드, 메시지를 받아 모델에 애니메이션 전달
         * @author 박성식([email protected])
         * @date 2016-10-31
         * @param m 전달할 메시지
         */
        public void startAnim(msg m)
        {
            while (!canDoSeq(m.seqNo))
            {
            }                              //시퀀스 넘버를 먼저 확인
            currSeq = m.seqNo;
            try
            {
                while (modelList[m.modelN][0].isDoingAnim)
                {
                }                                            //메시지 해당하는 모델이 애니메이션 중이면 대기

                //모델에 연결된 모든 오브젝트 리스트에 대해서 애니메이션 시작
                for (int i = 0; i < modelList[m.modelN].Count(); i++)
                {
                    modelList[m.modelN][i].startAnim(m.seqNo, m.R, m.X, m.Y, m.T); //애니메이션 시작
                }
            }
            catch (KeyNotFoundException)
            {
                //모든 메시지에 해당하는 모델 번호가 없을 수도 있음. 정상.
            }
        }