//读取下一条报文 private bool GetSendMsg() { try { CMessage sSend = new CMessage(); SID++; if (CommStateE == ECommSatate.Failure) { LastSendMsg = (CMessage)SendMsgHands; SendMsgHandsNum++; //Debug.WriteLine(SendMsgHandsNum.ToString()); if (LastSendMsg.sSendMsg.Length > 25) { LastSendMsg.sSendMsg.DataBuffer[25] = SID; } Write(LastSendMsg.sSendMsg); return(true); } lock (this) { if (ListImmSendMsg.Count > 0) { LastSendMsg = (CMessage)ListImmSendMsg[0]; if (LastSendMsg.sSendMsg.Length > 25) { LastSendMsg.sSendMsg.DataBuffer[25] = SID; } Write(LastSendMsg.sSendMsg); ListImmSendMsg.RemoveAt(0); //Debug.WriteLine(DateTime.Now.ToLongTimeString() + "CommTimerCall:GetSendMsg:ListImmSendMsg"); return(true); } } sSend = GetNextLoopMsg(); if (sSend.sSendMsg.Length > 0) { LastSendMsg = sSend; if (LastSendMsg.sSendMsg.Length > 25) { LastSendMsg.sSendMsg.DataBuffer[25] = SID; } Write(LastSendMsg.sSendMsg); } } catch (Exception e) { Debug.WriteLine("CProtcolFINS.GetSendMsg" + e.Message); } return(true); }
private bool GetSendMsg() { try { CMessage sSend = new CMessage(); iSendNum++; lock (this) { if (ListImmSendMsg.Count > 0) { LastSendMsg = (CMessage)ListImmSendMsg[0]; LastSendMsg.sSendMsg.DataBuffer[0] = (Byte)(iSendNum >> 8); LastSendMsg.sSendMsg.DataBuffer[1] = (Byte)iSendNum; Write(); ListImmSendMsg.RemoveAt(0); return(true); } } sSend = GetNextLoopMsg(); if (sSend.sSendMsg.Length > 0) { LastSendMsg = sSend; LastSendMsg.sSendMsg.DataBuffer[0] = (Byte)(iSendNum >> 8); LastSendMsg.sSendMsg.DataBuffer[1] = (Byte)iSendNum; Write(); } } catch (Exception e) { Debug.WriteLine("CProtcolModbusTCP.GetSendMsg" + e.Message); } return(true); }