private void HandleFeedback(DirectiveResult recvData, byte[] directiveBytes)
        {
            WaitForFeedBack metadata = null;

            if (!waitForFeedbackDirectives.ContainsKey(recvData.Data.DirectiveId))
            {
                Debug.WriteLine($"waitForFeedbackDirectives not ContainsKey {recvData.Data.DirectiveId}");
                return;
            }

            var feedback = waitForFeedbackDirectives[recvData.Data.DirectiveId];

            //修正同一个指令id,发送和反馈对应的设备不同或者类型不同
            if (feedback?.Directive == null || feedback.Directive.TargetDeviceId != recvData.Data.DeviceId ||
                feedback.Directive.DeviceType != recvData.Data.DeviceType)
            {
                Debug.WriteLine("send and feedback not match");
                return;
            }

            if (waitForFeedbackDirectives.TryRemove(recvData.Data.DirectiveId, out metadata) && null != metadata)
            {
                var args = new SerialPortEventArgs
                {
                    IsSucceed = true,
                    Result    = recvData,
                    Command   = directiveBytes
                };

                OnSerialPortEvent(args);
            }
            else
            {
                Debug.WriteLine($"waitForFeedbackDirectives TryRemove {recvData.Data.DirectiveId} failed");
            }
        }
        //只重发成功发送的指令
        private async Task RetrySend(CancellationToken token)
        {
            try
            {
                token.ThrowIfCancellationRequested();
                while (!cancelTokenSource.IsCancellationRequested)
                {
                    if (waitForFeedbackDirectives.Count != 0)
                    {
                        var waitForFeedback = waitForFeedbackDirectives.Values.FirstOrDefault();
                        if (waitForFeedback != null)
                        {
                            var now = DateTime.Now;
                            if ((now - waitForFeedback.CreatedAt).TotalMilliseconds >= 10)
                            {
                                var p =
                                    Common.BytesToString(
                                        protocolProvider.GenerateDirectiveBuffer(waitForFeedback.Directive));


                                if (waitForFeedback.RetrySendTimes < 10)
                                {
                                    Debug.WriteLine(
                                        $"{waitForFeedback.CreatedAt.ToString("yyyy-MM-dd HH:mm:ss.fff")}<-timeout->{now.ToString("yyyy-MM-dd HH:mm:ss.fff")}");

                                    WaitForFeedBack metadata = null;

                                    if (isRetry)
                                    {
                                        Debug.WriteLine(
                                            $"{waitForFeedbackDirectives.Count}count,{waitForFeedback.RetrySendTimes}times retry ->{p}<- retry end");

                                        PrepareDirective(waitForFeedback.Directive, ++waitForFeedback.RetrySendTimes);
                                    }
                                    else
                                    {
                                        OnSerialPortEvent(new SerialPortEventArgs()
                                        {
                                            IsSucceed = false, Message = waitForFeedback.Directive.TargetDeviceId.ToString()
                                        });
                                    }

                                    waitForFeedbackDirectives.TryRemove(waitForFeedback.Directive.DirectiveId,
                                                                        out metadata);
                                }
                                else
                                {
                                    Debug.WriteLine(
                                        $"{waitForFeedbackDirectives.Count}count,{p}, {waitForFeedback.RetrySendTimes}times retry failed");

                                    OnErrorEvent(new CustomException($"10重试发送指令失败", this.GetType().FullName,
                                                                     ExceptionPriority.Unrecoverable), waitForFeedback.Directive);
                                    return;
                                }
                            }
                        }
                    }

                    await Task.Delay(1500, token);
                }
            }
            catch (TaskCanceledException)
            {
                Debug.WriteLine("RetrySend cancel");
            }
        }