Exemple #1
0
        public override void OnInputPacket(PacketObject input, ref List <PacketObject> output)
        {
            var packet_new = new PacketBuilder(input);

            foreach (var data in input.Data)
            {
                if ((data >= ext_target_min_) && (data <= ext_target_max_))
                {
                    packet_new.AddData(ext_code_);
                    packet_new.AddData((byte)(data & ext_mask_));
                }
                else
                {
                    packet_new.AddData(data);
                }
            }

            output.Add(packet_new.Compile());
        }
        public override void OnInputPacket(PacketObject input, ref List <PacketObject> output)
        {
            var packet_new = new PacketBuilder(input);
            var fxext      = false;

            foreach (var data in input.Data)
            {
                if (fxext)
                {
                    packet_new.AddData((byte)(data | ext_mask_));
                    fxext = false;
                }
                else if (data == ext_code_)
                {
                    fxext = true;
                }
                else
                {
                    packet_new.AddData(data);
                }
            }

            output.Add(packet_new.Compile());
        }
        protected override void OnInputPacket(PacketObject input, ref List <PacketObject> output)
        {
            /* パターンが正しくない場合はスルー */
            if (match_interval_ < 0)
            {
                output.Add(input);
            }

            /* 収集開始 */
            if (packet_busy_ == null)
            {
                packet_busy_ = new PacketBuilder(input);

                /* 受信開始時刻を記憶 */
                dt_base_ = input.MakeTime;
            }

            /* 最終受信パケットを記憶 */
            packet_last_ = input;

            /* データ収集 */
            packet_busy_.AddData(input.Data);

            /* 入力パケット時刻が基準時刻を超えていない場合は無視 */
            if (input.MakeTime < dt_base_)
            {
                return;
            }

            /* 時間が経過したかどうかを確認 */
            if ((input.MakeTime - dt_base_).TotalMilliseconds < match_interval_)
            {
                return;
            }

            /* 最新パケットで生成 */
            var packet_new = packet_busy_.Compile(packet_last_);

            if (packet_new != null)
            {
                output.Add(packet_new);
            }

            packet_busy_ = null;
        }
Exemple #4
0
        protected override void OnInputPacket(PacketObject input, ref List <PacketObject> output)
        {
            /* パターンが正しくない場合は無視 */
            if (match_length_ < 0)
            {
                output.Add(input);
                return;
            }

            /* 収集開始 */
            if (packet_busy_ == null)
            {
                packet_busy_ = new PacketBuilder(input);
            }

            /* 最終受信パケットを記憶 */
            packet_last_ = input;

            var packets    = new Queue <PacketObject>();
            var packet_new = (PacketObject)null;

            /* データ収集 */
            foreach (var data in input.Data)
            {
                /* 仮想パケットにデータを追加 */
                packet_busy_.AddData(data);

                /* データ長が指定長以上になるまで無視 */
                if (packet_busy_.DataLength < match_length_)
                {
                    continue;
                }

                /* パケット生成 */
                packet_new = packet_busy_.Compile(input);

                if (packet_new != null)
                {
                    output.Add(packet_new);
                }

                /* 新しいパケットの収集を開始 */
                packet_busy_ = new PacketBuilder(input);
            }
        }
Exemple #5
0
        protected override void OnInputPacket(PacketObject input, ref List <PacketObject> output)
        {
            /* パターンが正しくない場合はスルー */
            if (match_interval_ < 0)
            {
                output.Add(input);
                return;
            }

            /* 最後に受信した時刻から一定時間経過しているかどうか */
            if ((packet_busy_ != null) &&
                (input.MakeTime > dt_base_) &&
                ((input.MakeTime - dt_base_).TotalMilliseconds >= match_interval_)
                )
            {
                /* 最新パケットで生成 */
                var packet_new = packet_busy_.Compile(packet_last_);

                if (packet_new != null)
                {
                    output.Add(packet_new);
                }

                packet_busy_ = null;
            }

            /* 収集開始 */
            if (packet_busy_ == null)
            {
                packet_busy_ = new PacketBuilder(input);
            }

            /* 最終受信パケットを記憶 */
            packet_last_ = input;

            /* データ収集 */
            packet_busy_.AddData(input.Data);

            /* 最終受信時刻を記憶 */
            dt_base_ = input.MakeTime;
        }
        protected override void OnInputPacket(PacketObject input, ref List <PacketObject> output)
        {
            /* パターンが設定されていない場合はスルー */
            if ((match_objs_ == null) || (match_objs_.Length == 0))
            {
                output.Add(input);
                return;
            }

            /* 収集開始 */
            if (packet_busy_ == null)
            {
                packet_busy_ = new PacketBuilder(input);

                foreach (var obj in match_objs_)
                {
                    obj.Reset();
                }
            }

            /* 最終受信パケットを記憶 */
            packet_last_ = input;

            var packet_new = (PacketObject)null;
            var match_ok   = false;

            /* データ収集 */
            foreach (var data in input.Data)
            {
                /* 仮想パケットにデータを追加 */
                packet_busy_.AddData(data);

                /* 全マッチオブジェクトにデータセット */
                foreach (var obj in match_objs_)
                {
                    if (obj.Input(data))
                    {
                        match_ok = true;
                        break;
                    }
                }

                /* どれか1つでもパターンが一致すればOK */
                if (!match_ok)
                {
                    continue;
                }

                /* 全マッチオブジェクトを初期化 */
                match_ok = false;
                foreach (var obj in match_objs_)
                {
                    obj.Reset();
                }

                /* パケット生成 */
                packet_new = packet_busy_.Compile(packet_last_);
                if (packet_new != null)
                {
                    output.Add(packet_new);
                }

                /* 新しいパケットの収集を開始 */
                packet_busy_ = new PacketBuilder(input);
            }
        }