/// <summary>
        /// 关闭端口
        /// </summary>
        /// <param name="remoteIP"></param>
        /// <param name="remotePort"></param>
        /// <returns>返回端口号;为了兼容</returns>
        public void ScreenClose(string remoteIP, int remotePort)
        {
            ScreenTcpClient ScreenTcpClient         = null;
            bool            bContainScreenTcpClient = ContainTcpClient(remoteIP, remotePort, out ScreenTcpClient);

            if (bContainScreenTcpClient)
            {
                ScreenTcpClient.Stop();
            }
        }
        /// <summary>
        /// 从队列中读取Screen数据,然后发送到屏
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="port"></param>
        /// <param name="buf"></param>
        /// <param name="frameMaxLen"></param>
        /// <returns></returns>
        void ScreenDataSend()
        {
            TCPMessage screenMsgModel = null;

            while (true)
            {
                try
                {
                    screenMsgModel = null;
                    Thread.Sleep(5);//稍作停留
                    if (sendQueue.Count > 0)
                    {
                        lock (sendQueue)
                        {
                            screenMsgModel = sendQueue.Dequeue();
                        }
                    }

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

                        if (bContainScreenTcpClient)
                        {
                            ScreenTcpClient.Send(screenMsgModel.TcpData);
                        }
                    }
                }
                catch (Exception ex)
                {
                    InternalLogger.Log.Error("循环读取发送队列并发送数据到屏端出错:" + ex.Message);
                }
            }
        }
        /// <summary>
        /// 打开screen连接;存在就直接打开,不存在就新建再打开
        /// </summary>
        /// <param name="remoteIP">ip</param>
        /// <param name="remotePort">端口号</param>
        /// <returns>返回端口号;为了兼容</returns>
        public bool ScreenOpen(string remoteIP, int remotePort)
        {
            ScreenTcpClient screenTcpClient         = null;
            bool            bContainScreenTcpClient = ContainTcpClient(remoteIP, remotePort, out screenTcpClient);

            if (!bContainScreenTcpClient)
            {
                screenTcpClient               = new ScreenTcpClient(remoteIP, remotePort);
                screenTcpClient.Connected    += ScreenTcpClient_Connected;
                screenTcpClient.Disconnected += ScreenTcpClient_Disconnected;
                screenTcpClient.DataReceived += ScreenTcpClient_DataReceived;
            }
            else
            {
                screenTcpClient.Stop();//每次打开前,先关闭一下
            }

            if (screenTcpClient.Start())
            {
                if (!bContainScreenTcpClient)
                {
                    lstScreenTcpClient.Add(screenTcpClient);
                }
            }

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

            return(false);
        }
        private bool ContainTcpClient(string remoteIP, int remotePort, out ScreenTcpClient ScreenTcpClient)
        {
            try
            {
                for (int i = 0; i < lstScreenTcpClient.Count; i++)
                {
                    int port = lstScreenTcpClient[i].ServerPort;
                    if (lstScreenTcpClient[i].ServerIp.Trim().Equals(remoteIP) &&
                        port == remotePort)
                    {
                        ScreenTcpClient = lstScreenTcpClient[i];
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                InternalLogger.Log.Error(String.Format("判断screen连接表中是否包含{0}:{1}出错.{2}",
                                                       remoteIP, remotePort, ex.Message));
            }

            ScreenTcpClient = null;
            return(false);
        }