Beispiel #1
0
        static private bool Handle(ICommunicationCommand cmd, int waittime = 10)
        {
            bool hassend  = false;
            bool hasrecv  = false;
            int  sendtime = 0;
            int  recvtime = 0;

            while (sendtime < 5)
            {
                if (commanager.Write(cmd) == 0)
                {
                    hassend = true;
                    break;
                }
                sendtime++;
            }
            if (!hassend)
            {
                return(false);
            }
            Thread.Sleep(waittime);
            if (cmd.RecvDataLen == 0)
            {
                return(true);
            }
            while (true)
            {
                if (commanager.Read(cmd) == 0)
                {
                    hasrecv = true;
                    break;
                }
                recvtime++;
            }
            return(hasrecv && cmd.IsComplete && cmd.IsSuccess);
        }