/// <summary>
        /// when Client Try to connect server
        /// </summary>
        /// <param name="o"></param>
        private void Acceptor(IAsyncResult o)
        {
            TcpListener server = o.AsyncState as TcpListener;

            try
            {
                PLCClient newClient = new PLCClient();
                newClient.NetWork = server.EndAcceptTcpClient(o);
                lstClient.Add(newClient);
                LogerHelper2.ToLog("Robot PLC " + newClient.Name + " is connected now.", 0);
                RobotPLCStatus.UpdateRobotPLCStatus("Connected");
                isPLConLine = true;
                newClient.NetWork.GetStream().BeginRead(newClient.buffer, 0, newClient.buffer.Length, new AsyncCallback(TCPCallBack), newClient);
                server.BeginAcceptTcpClient(new AsyncCallback(Acceptor), server);//continue listening

                //send F999 to active PLC QueryMessageListAndRunFirstMessage("DUTSTATUS");
                byte[] tempdata = Encoding.ASCII.GetBytes("F999");
                MessageReceived.BeginInvoke("", MainPLCMessage.ConvertByteToMessage(tempdata), null, null);//async data output
                //Server. QueryMessageListAndRunFirstMessage("DUTSTATUS");
            }
            catch (Exception ex)
            {
                LogerHelper2.ToLog("test method PLCServers.Acceptor catch exception" + ex.Message, 3);
            }
        }
        /// <summary>
        /// move DUT away from test station
        /// </summary>
        /// server PC function
        /// <param name="stationID"></param>
        public void MoveDUTFromTester(string stationID, string testResult)
        {
            string message = null;

            stationID = CommonMethod.ChangeOneBitToTwoBit(stationID);
            message   = MainPLCMessage.MoveDUTFromStation + stationID + testResult;
            SendMessage(message);
            RobotPLCStatus.UpdateRobotPLCStatus("T" + stationID + " -> " + (testResult == "00" ? "OK" : "NG"));
        }
        /// <summary>
        /// move DUT to test station
        /// </summary>
        /// server PC function
        /// <param name="stationID"></param>
        public void MoveDUTtoTester(string stationID)
        {
            string message = null;

            stationID = CommonMethod.ChangeOneBitToTwoBit(stationID);
            message   = MainPLCMessage.MoveDUTToStation + stationID;
            SendMessage(message);
            RobotPLCStatus.UpdateRobotPLCStatus("Buf -> T" + stationID);
        }
        /// <summary>
        /// PLC Client send message to server
        /// </summary>
        /// <param name="ar"></param>
        private void TCPCallBack(IAsyncResult ar)
        {
            PLCClient client = (PLCClient)ar.AsyncState;

            try
            {
                if (client.NetWork.Connected)
                {
                    NetworkStream ns      = client.NetWork.GetStream();
                    byte[]        recdata = new byte[ns.EndRead(ar)];
                    if (recdata.Length > 0)
                    {
                        Array.Copy(client.buffer, recdata, recdata.Length);
                        if (MessageReceived != null)
                        {
                            MessageReceived.BeginInvoke(client.Name, MainPLCMessage.ConvertByteToMessage(recdata), null, null);//async data output
                        }
                        ns.BeginRead(client.buffer, 0, client.buffer.Length, new AsyncCallback(TCPCallBack), client);
                    }
                    else
                    {
                        client.DisConnect();
                        LogerHelper2.ToLog("plc is disconnected now", 2);
                        plcHeartBeatTimer.Stop();
                        RobotPLCStatus.UpdateRobotPLCStatus("Disconnected");
                        isPLConLine = false;
                        lstClient.Remove(client);
                    }
                }
            }
            catch (Exception ex)
            {
                LogerHelper2.ToLog("testmothod TCPCallBack catch exception " + ex.Message, 3);
                RobotPLCStatus.UpdateRobotPLCStatus("Disconnected");
                plcHeartBeatTimer.Stop();
                client.DisConnect();
                isPLConLine = false;
                lstClient.Remove(client);
            }
        }
 /// <summary>
 /// while the server didn't receive the  feedback for move command from plc, then show the warning
 /// </summary>
 /// <param name="source"></param>
 /// <param name="e"></param>
 public void plcCommandOnTimedShow(object source, ElapsedEventArgs e)
 {
     LogerHelper2.ToLog("Server does not receive the PLC command feedback in time", 3);
     RobotPLCStatus.UpdateRobotPLCStatus("Timeout");
 }
 /// <summary>
 /// while the server didn't receive the heartbeat from plc, then show the warning
 /// </summary>
 /// <param name="source"></param>
 /// <param name="e"></param>
 public void OnTimedShow(object source, ElapsedEventArgs e)
 {
     hertbeatCount = 0;
     LogerHelper2.ToLog("Server does not receive the PLC Heartbeat in time", 3);
     RobotPLCStatus.UpdateRobotPLCStatus("Disconnected");
 }