private void addSerialPacketFieldMachine(SerialComm.Packet_t packet) { switch (cmbxProcessLevel.SelectedIndex) { case 1: // raw packet byte[] arr = packet.ToRawArray(); SerialRawPacketField srpf = new SerialRawPacketField(arr, arr.Length); flowMachine.Controls.Add(srpf); flowMachine.Controls.SetChildIndex(srpf, 0); srpf.Show(); break; case 0: // processed packet default: SerialPacketField spf = new SerialPacketField(); spf.showTime(); spf.telegram.FromPacket(packet); spf.showTelegram(); flowMachine.Controls.Add(spf); flowMachine.Controls.SetChildIndex(spf, 0); spf.Show(); break; } }
/// <summary> /// Show a packet in the incoming part of the view. /// </summary> /// <param name="p">packet containing the information</param> private void fillInDetails(SerialComm.Packet_t p) { string s = ""; eApi.Analyzer.TelegramStructure telegram = new eApi.Analyzer.TelegramStructure(); telegram.FromPacket(p); txtInEOT.Text = "04"; txtInSOH.Text = "01"; txtInPIP.Text = String.Format("{0:x2}", telegram.pip).ToUpper(); txtInPIE.Text = String.Format("{0:x2}", telegram.pie).ToUpper(); txtInPN.Text = String.Format("{0:x2}", telegram.pn).ToUpper(); txtInSA.Text = String.Format("{0:x2}", telegram.sa).ToUpper(); txtInDA.Text = String.Format("{0:x2}", telegram.da).ToUpper(); if (!telegram.isAckNack) { txtInMI.Text = String.Format("{0:x2}", telegram.mi).ToUpper(); txtInMP.Text = String.Format("{0:x4}", telegram.mp).ToUpper(); txtInDL.Text = String.Format("{0:x4}", telegram.dl).ToUpper(); txtInCRC.Text = String.Format("{0:x4}", telegram.crc).ToUpper(); } else { txtInMI.Text = "--"; txtInMP.Text = "--"; txtInDL.Text = "--"; txtInCRC.Text = "----"; } // Data for (int i = 0; i < p.dataLength; i++) { s += "0x" + String.Format("{0:X02}", ((byte)p.data[i])) + ", "; } if (s == "") { s = "no data"; } txtInData.Text = s; s = ""; // Raw byte[] buffer = p.ToRawArray(); for (int i = 0; i < buffer.Length; i++) { s += "0x" + String.Format("{0:X02}", ((byte)buffer[i])) + ", "; } if (s == "") { s = "no data"; } txtInRawData.Text = s; }