예제 #1
0
        #pragma warning restore

        public void Evaluate(int SpreadMax)
        {
            if (FInput.IsAnyInvalid())
            {
                SpreadMax = 0;
                if (FOutput.SliceCount != 0)
                {
                    FOutput.SliceCount = 0;
                    FOutput.Flush();
                }
                return;
            }
            else
            {
                SpreadMax = FInput.SliceCount;
            }

            if (!FInput.IsChanged && !FTopicAdd.IsChanged && !FContract.IsChanged)
            {
                return;
            }

            FOutput.SliceCount = 0;

            for (int i = 0; i < SpreadMax; i++)
            {
                Message message = OSCExtensions.FromOSC(FInput[i], FExtendedMode[0], FTopicAdd[0], FContract[0]);
                if (message != null)
                {
                    FOutput.Add(message);
                }
            }
            FOutput.Flush();
        }
예제 #2
0
#pragma warning restore

        public override void Evaluate(int SpreadMax)
        {
            if (FInput.IsAnyInvalid())
            {
                SpreadMax = 0;
                FOutput.FlushNil();
                FSuccess.FlushBool(false);
                FMatch.FlushNil();

                return;
            }
            else
            {
                SpreadMax = FInput.SliceCount;
            }

            var update = false;

            if (FTopic.IsChanged || FExtendedMode.IsChanged || FUseFields.IsChanged || Parser == null)
            {
                if (Parser == null)
                {
                    Parser = new Dictionary <string, IEnumerable <FormularFieldDescriptor> >();
                }
                else
                {
                    Parser.Clear();
                }

                for (int i = 0; i < FTopic.SliceCount; i++)
                {
                    var fields = (
                        from f in FUseFields[i]
                        select Formular[f.Name]
                        ).ToList();
                    Parser[FTopic[i]] = fields;
                }
                update = true;
            }

            if (!update && !FInput.IsChanged)
            {
                return;
            }

            FSuccess.SliceCount = SpreadMax;
            FOutput.SliceCount  = 0;
            FMatch.SliceCount   = 0;

            for (int i = 0; i < SpreadMax; i++)
            {
                var stream = FInput[i];
                stream.Position = 0;

                var address = OSCExtensions.PeekAddress(stream);
                stream.Position = 0;

                var isMatch = (
                    from a in FTopic
                    where address == a
                    select true
                    ).Any();

                Message message = isMatch? OSCExtensions.FromOSC(stream, Parser, FExtendedMode[0]) : null;

                if (message != null)
                {
                    FOutput.Add(message);
                    FSuccess[i] = true;
                    FMatch.Add(FTopic.IndexOf(address));
                }
                else
                {
                    FSuccess[i] = false;
                }
            }
            FOutput.Flush();
            FSuccess.Flush();
            FMatch.Flush();
        }