Exemplo n.º 1
0
        protected override void ProcessConversation()
        {
            if (this.CurrentConversation == null)
            {
                return;
            }

            var stream = this.CurrentConversation.Key.IsSet
                ? new PDUDecrypterBase(this.CurrentConversation, EfcPDUProviderType.ContinueInterlay): new PDUStreamBasedProvider(this.CurrentConversation, EfcPDUProviderType.ContinueInterlay);

            // ASCII encoding
            //var reader = new PDUStreamReader(stream, Encoding.GetEncoding(437));
            var reader = new PDUStreamReader(stream, Encoding.ASCII, true);

            if (!this.ExportBaseDirectory.Exists)
            {
                this.ExportBaseDirectory.Create();
            }

            do
            {
                // Parse message
                this.OnBeforeProtocolParsing();
                var msg = new MQTTMsg(reader);
                if (msg.InvalidReason != null)
                {
                    var description = "Parsing of MQTT message failed";
                    if (msg.Frames != null)
                    {
                        description += ", frame numbers: " + string.Join(",", msg.Frames);
                    }
                    if (msg.InvalidReason != null)
                    {
                        description += ", reason: " + msg.InvalidReason;
                    }

                    this.SnooperExport.TimeStampFirst = msg.TimeStamp;
                    this.SnooperExport.AddExportReport(ExportReport.ReportLevel.Warn, this.Name, description, msg.ExportSources);
                    continue;
                }
                this.OnAfterProtocolParsing();

                // Export message
                this.OnBeforeDataExporting();

                this.SnooperExport.AddExportObject(msg);
                this.OnAfterDataExporting();
            } while(reader.NewMessage());

            // Sort messages in time
            //this.SnooperExport.ExportObjects.Sort((e1, e2) => DateTime.Compare(e1.TimeStamp, e2.TimeStamp));
        }
Exemplo n.º 2
0
        public void ArrayWithSettingsPrepare_EmptyArrayAndnumerciValue_ArrayWithZeros()
        {
            //Arrange
            var mqttConnect = new MQTTMsg();

            //Act
            var testSettings = new Settings();

            //byte[] testArray = new byte[0];
            //int testValue = 0;
            //var result = mqttConnect.AddToArray(testArray, testValue);

            //Assert
            byte[] testArray = new byte[0];
            //Assert.AreEqual
        }