コード例 #1
0
ファイル: Listener.cs プロジェクト: vishalishere/vrs
        /// <summary>
        /// Translates the bytes for an <see cref="AircraftListJson"/> into a list of cooked messages and raises the
        /// appropriate events.
        /// </summary>
        /// <param name="now"></param>
        /// <param name="extractedBytes"></param>
        private void ProcessAircraftListJsonMessageBytes(DateTime now, ExtractedBytes extractedBytes)
        {
            try {
                var jsonText      = Encoding.UTF8.GetString(extractedBytes.Bytes, extractedBytes.Offset, extractedBytes.Length);
                var json          = JsonConvert.DeserializeObject <AircraftListJson>(jsonText, _AircraftListJsonSerialiserSettings);
                var totalMessages = 0;
                foreach (var eventArgs in _AircraftListJsonMessageConverter.ConvertIntoBaseStationMessageEventArgs(json))
                {
                    ++totalMessages;
                    _MessageProcessingAndDispatchQueue.Enqueue(new MessageDispatch()
                    {
                        Port30003MessageEventArgs = eventArgs
                    });
                }

                if (totalMessages != 0)
                {
                    TotalMessages += totalMessages;
                    if (Statistics != null)
                    {
                        Statistics.Lock(r => r.BaseStationMessagesReceived += totalMessages);
                    }
                }
            } catch (Exception) {
                ++TotalBadMessages;
                if (Statistics != null)
                {
                    Statistics.Lock(r => ++ r.BaseStationBadFormatMessagesReceived);
                }
                if (!IgnoreBadMessages)
                {
                    throw;
                }
            }
        }
コード例 #2
0
ファイル: Listener.cs プロジェクト: ts295983632/vrs
 /// <summary>
 /// Translates the bytes for an <see cref="AircraftListJson"/> into a list of cooked messages and raises the
 /// appropriate events.
 /// </summary>
 /// <param name="now"></param>
 /// <param name="extractedBytes"></param>
 private void ProcessAircraftListJsonMessageBytes(DateTime now, ExtractedBytes extractedBytes)
 {
     ProcessJsonMessageBytes <AircraftListJson>(
         now,
         extractedBytes,
         _AircraftListJsonSerialiserSettings,
         (json) => _AircraftListJsonMessageConverter.ConvertIntoBaseStationMessageEventArgs(json)
         );
 }
コード例 #3
0
        public void AircraftListJsonMessageConverter_Never_Sets_IsOutOfBand()
        {
            _AircraftListJson.Aircraft.Add(new AircraftJson()
            {
                Icao24 = "A"
            });

            var eventArgs = _Converter.ConvertIntoBaseStationMessageEventArgs(_AircraftListJson).Single();

            Assert.IsFalse(eventArgs.IsOutOfBand);
        }