/// <summary>
        /// 打开display连接;存在就直接打开,不存在就新建再打开
        /// </summary>
        /// <param name="remoteIP">ip</param>
        /// <param name="remotePort">端口号</param>
        /// <returns>返回端口号;为了兼容</returns>
        public bool DisplayOpen(string remoteIP, int remotePort)
        {
            DisplayTcpClient displayTcpClient         = null;
            bool             bContainDisplayTcpClient = ContainTcpClient(remoteIP, remotePort, out displayTcpClient);

            if (!bContainDisplayTcpClient)
            {
                displayTcpClient               = new DisplayTcpClient(remoteIP, remotePort);
                displayTcpClient.Connected    += DisplayTcpClient_Connected;
                displayTcpClient.Disconnected += DisplayTcpClient_Disconnected;
            }
            else
            {
                displayTcpClient.Stop();//每次打开前,先关闭一下
            }

            if (displayTcpClient.Start())
            {
                if (!bContainDisplayTcpClient)
                {
                    lstDisplayTcpClient.Add(displayTcpClient);
                }
            }

            try
            {
                if (moxaOpenAutoResetEvent.WaitOne(600))
                {
                    return(true);
                }
            }
            catch {}

            return(false);
        }
        /// <summary>
        /// 关闭端口
        /// </summary>
        /// <param name="remoteIP"></param>
        /// <param name="remotePort"></param>
        /// <returns>返回端口号;为了兼容</returns>
        public void DisplayClose(string remoteIP, int remotePort)
        {
            DisplayTcpClient displayTcpClient         = null;
            bool             bContainDisplayTcpClient = ContainTcpClient(remoteIP, remotePort, out displayTcpClient);

            if (bContainDisplayTcpClient)
            {
                displayTcpClient.Stop();
            }
        }
        /// <summary>
        /// 从队列中读取display数据,然后发送到屏
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="port"></param>
        /// <param name="buf"></param>
        /// <param name="frameMaxLen"></param>
        /// <returns></returns>
        void DisplayDataSend()
        {
            TCPMessageEx displayMsgModel = null;

            while (true)
            {
                try
                {
                    displayMsgModel = null;
                    Thread.Sleep(6);//屏硬件要求,发完一帧要间隔6毫秒左右(一般5即可,这里做预留)
                    if (displayQueue.Count > 0)
                    {
                        lock (displayQueue)
                        {
                            displayMsgModel = displayQueue.Dequeue();
                        }
                    }

                    //从连接列表中找到tcp对象,调用send方法,发送
                    DisplayTcpClient displayTcpClient = null;
                    if (displayMsgModel != null)
                    {
                        bool bContainDisplayTcpClient = ContainTcpClient(displayMsgModel.ServerIp,
                                                                         displayMsgModel.ServerPort, out displayTcpClient);

                        if (bContainDisplayTcpClient)
                        {
                            displayTcpClient.Send(displayMsgModel.TcpData);
                        }
                    }
                }
                catch (Exception ex)
                {
                    InternalLogger.Log.Error("循环读取display数据出错:" + ex.Message);
                }
            }
        }
        private bool ContainTcpClient(string remoteIP, int remotePort, out DisplayTcpClient displayTcpClient)
        {
            try
            {
                for (int i = 0; i < lstDisplayTcpClient.Count; i++)
                {
                    int port = lstDisplayTcpClient[i].ServerPort;
                    if (lstDisplayTcpClient[i].ServerIp.Trim().Equals(remoteIP) &&
                        port == remotePort)
                    {
                        displayTcpClient = lstDisplayTcpClient[i];
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                InternalLogger.Log.Error(String.Format("判断Display连接表中是否包含{0}:{1}出错.{2}",
                                                       remoteIP, remotePort, ex.Message));
            }

            displayTcpClient = null;
            return(false);
        }