コード例 #1
0
        private static void OnMessageReceived(IMessage message)
        {
            try
            {
                OpenRailBytesMessage oMessage = null;
                if (message is IBytesMessage msgBytes)
                {
                    oMessage = new OpenRailBytesMessage(msgBytes.Content);
                }

                if (oMessage == null)
                {
                    return;
                }
                _miMessageCount++;
                if (_miMessageCount % 25 != 0)
                {
                    return;
                }
                var oPPort            = DarwinMessageHelper.GetMessageAsObjects(oMessage.Bytes);
                var sMessageType      = DarwinMessageHelper.GetMessageDescription(oPPort);
                var iSequenceNumber   = Convert.ToInt64(message.Properties["SequenceNumber"]);
                var iPushPortSequence = Convert.ToInt64(message.Properties["PushPortSequence"]);
                Console.WriteLine($"{DateTime.Now:HH:mm:ss.fff}: Total Messages Received = {_miMessageCount}: Last Message = {sMessageType}, SeqNum = {iSequenceNumber}, PPSeqNum = {iPushPortSequence}");
            }
            catch (Exception oException)
            {
                Console.WriteLine("MESSAGE ERROR:  " + oException.GetType().FullName);
                Console.WriteLine(oException.Message);
            }
        }
コード例 #2
0
        private static void OnMessageReceived(IMessage message)
        {
            try
            {
                OpenRailBytesMessage oMessage = null;
                IBytesMessage        msgBytes = message as IBytesMessage;
                if (msgBytes != null)
                {
                    oMessage = new OpenRailBytesMessage(message.NMSTimestamp, msgBytes.Content);
                }

                if (oMessage != null)
                {
                    miMessageCount++;
                    if ((miMessageCount % 25) == 0)
                    {
                        Pport  oPPort       = DarwinMessageHelper.GetMessageAsObjects(oMessage.Bytes);
                        string sMessageType = DarwinMessageHelper.GetMessageDescription(oPPort);
                        Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + ": Total Messages Received = " + miMessageCount.ToString() + ": Last Message = " + sMessageType);
                    }
                }
            }
            catch (Exception oException)
            {
                Console.WriteLine("MESSAGE ERROR:  " + oException.GetType().FullName);
                Console.WriteLine(oException.Message);
            }
        }