//___________________________________________________________________________ private void BConnect_Click(object sender, EventArgs e) { if (CBPort.Text.Length == 0) { MessageBox.Show("Не задан порт"); CBPort.Focus(); } else { if (ComPort == null) { ComPort = new COMPort(MessShow, DHandlingRecieve); } if (ComPort.PortIsOpen()) { ComPort.ClosePort(); TBOut.AppendText(string.Format("Порт [{0}] закрыт\n", ComPort.PortName())); BConnect.Text = "Открыть"; } else { if (ComPort.OpenPort(CBPort.Text, CBBaud.Text) != null) { BConnect.Text = CBPort.Text; TBOut.AppendText(string.Format("Порт [{0}] открыт\n", ComPort.PortName())); } } } }
//_________________________________________________________________________ public void Inv_OutMess(string asMess, bool bDateOut = true) { DateTime DT = DateTime.Now; string asDT = bDateOut ? $"{DT:ddMMyy HH:mm:ss}.{DT.Millisecond:000}" : ""; DOutMess OutMess = (m, DateOut) => TBOut.AppendText($"[{asDT}] {asMess}{Environment.NewLine}"); Invoke(OutMess, asMess /*, asDelimiter*/, bDateOut); }
//_________________________________________________________________________ private void Server2_GetData(object Buf, object SizeBuf) { EvSendDataToDev?.Invoke(Buf, SizeBuf); TBOut.AppendText($"{CBIP2.Text}: {Global.ByteArToStr ((byte[])Buf, 0, (int)SizeBuf)}"); }
private void OutToTB(string asMess, bool bTateTimeShow) { TBOut.AppendText(AddDTtoMessage(asMess, bTateTimeShow) + Environment.NewLine); }