public DataFrameEventArgs(bool NeedACK, SerialPortFrame.FrameState FrameState, string NodeMAC, ushort FrameCounter, byte[] DataByte, SerialPortFrame.Type Type) { this.NeedACK = NeedACK; this.FrameState = FrameState; this.NodeMAC = NodeMAC; this.FrameCounter = FrameCounter; this.DataByte = DataByte; this.type = Type; }
/// <summary> /// 速率测试中,用于发送数据帧 /// </summary> /// <param name="destinationMac"></param> /// <param name="needACK"></param> /// <param name="mode"></param> /// <param name="state"></param> /// <param name="count"></param> /// <param name="dataPayload"></param> /// <returns></returns> public static byte[] SendCommand_68_SeriData(string destinationMac, bool needACK, SerialPortFrame.Communication mode, SerialPortFrame.FrameState state, ushort count, byte[] dataPayload) { #region 构建串口帧 SerialPortFrame frame = new SerialPortFrame(dataPayload, Convert.ToByte(dataPayload.Length)); frame.ConcentratorMac = ConcentratorMac; if (destinationMac == ConcentratorMac)//目标是集中器 { frame.NodeMac = "0000"; frame.CommunicationWay = SerialPortFrame.Communication.InnerNet; } else//目标是节点 { frame.NodeMac = destinationMac; frame.CommunicationWay = mode; } frame.TransferState = state; frame.NeedAnswer = needACK; frame.FrameCount = count; byte[] serialPortFrame = frame.Send();//形成串口通信帧 #endregion #region 构建网络通信帧 /* 构建网络通信帧 */ NetCommunicationFrame netFrame = new NetCommunicationFrame(serialPortFrame, Convert.ToByte(serialPortFrame.Length)); netFrame.Encryption = false; netFrame.NeedAnswer = false; netFrame.FrameFormat = NetCommunicationFrame.FrameType.DataFrame; receiveByte(); netFrame.MobilePhoneMAC = PhoneMAC; netFrame.GatewayClassification = GatewayType; netFrame.GatewayMAC = GatewayMAC; netFrame.FrameCount = 0; if (packetFrameType == FrameType.OutterNet) { netFrame.TransferDirection = NetCommunicationFrame.Direction.MobilePhone2Server2Gateway; netFrame.ServerIP = SeverIp; } if (packetFrameType == FrameType.InnerNet) { netFrame.TransferDirection = NetCommunicationFrame.Direction.Mobile2Gateway; } if (packetFrameType == FrameType.Serial) { netFrame.TransferDirection = NetCommunicationFrame.Direction.Computer2Gateway; } return(netFrame.Send()); #endregion }