コード例 #1
0
        /// <summary>
        /// override the ToString method
        /// </summary>
        /// <returns>String that includes timestamp, message header, and message body in hex string.</returns>
        public override String ToString()
        {
            String strHeader;

            if ((m_TimeStamp != null) && (m_TimeStamp.Length > 0))
            {
                String[] msgs = { m_TimeStamp, m_Perfix, ((MsgHeader != null) ? MsgHeader.ToString() : "") };
                strHeader = String.Format("{0}, {1}: {2}", msgs);
            }
            else
            {
                strHeader = String.Format("{0}: {1}", m_Perfix, ((MsgHeader != null) ? MsgHeader.ToString() : ""));
            }

            String strBody;

            if (m_HartCmdSize > 0)
            {
                strBody = String.Format(", TranId: {0}, ByteCount: {1}, Data: ", m_TransactionId, m_HartCmdSize);
            }
            else
            {
                strBody = String.Format(", TranId: {0}, ByteCount: {1}", m_TransactionId, m_HartCmdSize);
            }

            for (int i = 0; i < m_HartCmdSize; i++)
            {
                strBody += (String.Format("{0:X2} ", m_HartCmd[i]));
            }
            return(strHeader + strBody);
        }