private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) //串口接收事件 { string dataRe; string pramRe; byte[] byteRead = new byte[serialPort.BytesToRead]; //BytesToRead获取接收缓冲区中数据的字节数。 RevData receivedata = new RevData(UpdateTextbox); //实例化委托 RevPram receivepram = new RevPram(UpdateWavePram); serialPort.Read(byteRead, 0, byteRead.Length); //串口缓冲区存入数组中 pramRe = System.Text.Encoding.Default.GetString(byteRead); txtFeq.Invoke(receivepram, byteRead); if (this.radioHexDisplay.Checked) //HEX显示 { for (int i = 0; i < byteRead.Length; i++) { byte temp = byteRead[i]; dataRe = temp.ToString("X") + " "; txbRevData.Invoke(receivedata, dataRe); } } if (this.radioCharDisplay.Checked) //字符串显示 { dataRe = System.Text.Encoding.Default.GetString(byteRead); txbRevData.Invoke(receivedata, dataRe); } }
private void button3_Click_1(object sender, EventArgs e) { string dataRe; string pramRe; byte[] byteRead = new byte[serialPort.BytesToRead]; //BytesToRead获取接收缓冲区中数据的字节数。 RevData receivedata = new RevData(UpdateTextbox); //实例化委托 serialPort.Read(byteRead, 0, byteRead.Length); //串口缓冲区存入数组中 pramRe = System.Text.Encoding.Default.GetString(byteRead); dataRe = System.Text.Encoding.Default.GetString(byteRead); textBox2.Invoke(receivedata, dataRe); }
void IRev.onRevData(RevData data) { if (null == data) { return; } if (0 == data.msglen) { return; } string str = Encoding.Default.GetString(data.recvBytes, 0, data.msglen); Console.WriteLine(str); }
private void LoadFromStream(IXDocument doc) { using (var stream = doc.TryOpenStream(STREAM_NAME, AccessType_e.Read)) { if (stream != null) { var xmlSer = new XmlSerializer(typeof(RevData)); m_RevData = xmlSer.Deserialize(stream) as RevData; //m_App.ShowMessageBox($"Revision data of {doc.Title}: {m_RevData.Revision} - {m_RevData.RevisionStamp}"); } else { //m_App.ShowMessageBox($"No revision data stored in {doc.Title}"); } } }
private void SaveToStream(IXDocument doc) { using (var stream = doc.OpenStream(STREAM_NAME, AccessType_e.Write)) { var xmlSer = new XmlSerializer(typeof(RevData)); if (m_RevData == null) { m_RevData = new RevData(); } m_RevData.Revision = m_RevData.Revision + 1; m_RevData.RevisionStamp = Guid.NewGuid(); xmlSer.Serialize(stream, m_RevData); } }
private void LoadFromStream() { using (var streamHandler = Model.Access3rdPartyStream(STREAM_NAME, false)) { if (streamHandler.Stream != null) { using (var str = streamHandler.Stream) { var xmlSer = new XmlSerializer(typeof(RevData)); m_RevData = xmlSer.Deserialize(str) as RevData; ShowMessage($"Revision data of {Model.GetTitle()}: {m_RevData.Revision} - {m_RevData.RevisionStamp}"); } } else { ShowMessage($"No revision data stored in {Model.GetTitle()}"); } } }
private void SaveToStream() { using (var streamHandler = Model.Access3rdPartyStream(STREAM_NAME, true)) { using (var str = streamHandler.Stream) { var xmlSer = new XmlSerializer(typeof(RevData)); if (m_RevData == null) { m_RevData = new RevData(); } m_RevData.Revision = m_RevData.Revision + 1; m_RevData.RevisionStamp = Guid.NewGuid(); xmlSer.Serialize(str, m_RevData); } } }