private ReceiveResult ReceiveSFOrFF(int hostId, List <byte[]> frames)
        {
            Message message = ReceiveMessage();

            if (message != null)
            {
                byte pci = message.Data[0];
                Debug.Assert(DcmTpProtocalISO15765Packer.IsSingleFrame(pci) ||
                             DcmTpProtocalISO15765Packer.IsFirstFrame(pci), "DcmTpProtocalISO15765Receiver" +
                             "->ReceiveSFOrFF: Not Single Frame Or First Frame");

                frames.Clear();
                frames.Add(message.Data);
                if (DcmTpProtocalISO15765Packer.IsSingleFrame(pci))
                {
                    return(ReceiveSuccess);
                }
                else if (DcmTpProtocalISO15765Packer.IsFirstFrame(pci))
                {
                    HostId = hostId;
                    int totalLen = (((message.Data[0] & 0x0f) << 8) + message.Data[1]);
                    LeftConsecutiveFrameCount = (totalLen - 6) / 7
                                                + ((((totalLen - 6) % 7) != 0) ? 1 : 0);
                    Frames    = frames;
                    WorkState = WorkStateEnum.SendFlowControlFrame;

                    //立即发送流控制帧
                    SendFlowControl();
                }
            }
            return(ReceiveResult.Working);
        }
        // 发送单帧或者第一帧
        private SendResult SendSFOrFF(int canId, List <byte[]> frames)
        {
            Debug.Assert(frames.Count > 0, "DcmTpProtocalISO15765Sender: Invalid SFOrFF");

            byte pci = frames[0][0];

            Debug.Assert(DcmTpProtocalISO15765Packer.IsSingleFrame(pci) ||
                         DcmTpProtocalISO15765Packer.IsFirstFrame(pci));
            var result = SendMessage(canId, frames[0]);

            if (DcmTpProtocalISO15765Packer.IsSingleFrame(pci)) // 单帧
            {
                Reset();
                return(result ? SendResult.Ok : SendResult.Fail);
            }
            else if (DcmTpProtocalISO15765Packer.IsFirstFrame(pci)) //多帧
            {
                if (!result)
                {
                    return(SendFailed);
                }
                else
                {
                    // 进入等待流控制帧状态
                    CanId      = canId;
                    Frames     = frames;
                    WorkState  = WorkStateEnum.WaitFlowControlFrame;
                    FrameIndex = 1;
                    return(SendResult.Working);
                }
            }
            else
            {
                return(SendFailed);
            }
        }