示例#1
0
        protected virtual bool UpKeep(bool force = false)
        {
            if (!force && !Keep.IsChanged)
            {
                if (!Keep.QuickMode && FChangeIndexOut.SliceCount != 0)
                {
                    FChangeIndexOut.FlushNil();
                    FChangeOut.FlushNil();
                }
                return(false);
            }

            if (Keep.QuickMode)
            {
                Keep.Sync();
            }
            else
            {
                IEnumerable <Message> changes;
                IEnumerable <int>     indexes;
                changes = Keep.Sync(out indexes);

                FChangeIndexOut.FlushResult(indexes);
                FChangeOut.FlushResult(changes);
            }

            FOutput.FlushResult(Keep);
            FCountOut.FlushInt(Keep.Count);

            return(true);
        }
示例#2
0
        public override void Evaluate(int SpreadMax)
        {
            if (FInput.IsAnyInvalid())
            {
                FOutput.FlushNil();
                return;
            }

            bool doFlush = false;

            // is any Update slice checked?
            var anyUpdate = FUpdate.Any();

            // Flush upstream changes through the plugin
            if (FInput.IsChanged)
            {
                FOutput.SliceCount = 0;
                FOutput.AssignFrom(FInput); // push change from upstream if valid
                doFlush = true;
            }
            else if (!anyUpdate)
            {
                return;                                                               // if no update and no change, no need to flush!
            }
            bool newData = FPins.Any(pinName => pinName.Value.ToISpread().IsChanged); // changed pins

            newData |= !FAutoSense[0];                                                // assume newData, if AutoSense is off.

            if (anyUpdate && newData)
            {
                int messageIndex = 0;
                foreach (var message in FInput)
                {
                    if (FUpdate[messageIndex])
                    {
                        doFlush |= CopyFromPins(message, messageIndex, FAutoSense[0]);
                    }

                    messageIndex++;
                }
            }

            if (doFlush)
            {
                FOutput.Flush();
            }


            if (RemovePinsFirst)
            {
                RetryConfig();
            }
        }
        // copy and paste from AbstractMessageKeepNode.cs
        protected virtual bool UpKeep(bool force = false)
        {
            if (!force && !Keep.IsChanged)
            {
                if (!Keep.QuickMode && FChangeOut.SliceCount != 0)
                {
                    FChangeOut.FlushNil();
                    FChangeIndexOut.FlushNil();
                }

                var recentCommits = from message in Keep
                                    where message.HasRecentCommit()
                                    select message;

                foreach (var message in recentCommits)
                {
                    message.Commit(Keep);
                }
                return(false);
            }

            if (Keep.QuickMode)
            {
                Keep.Sync();
            }
            else
            {
                IEnumerable <int> indexes;
                var changes = Keep.Sync(out indexes);

                FChangeIndexOut.FlushResult(indexes);
                FChangeOut.FlushResult(changes);
            }

            FOutput.FlushResult(Keep);
            FCountOut.FlushItem <int>(Keep.Count);
            return(true);
        }
示例#4
0
        public void Evaluate(int SpreadMax)
        {
            SpreadMax = FInput.IsAnyInvalid() ? 0 : FInput.SliceCount;

            if (SpreadMax == 0)
            {
                if (FOutput.SliceCount != 0)
                {
                    FOutput.FlushNil();
                    FTimeStamp.FlushNil();
                    FTopic.FlushNil();
                    FConfigOut.FlushNil();
                }
                return;
            }

            if (!FInput.IsChanged)
            {
                return;
            }

            FOutput.SliceCount            =
                FTopic.SliceCount         =
                    FConfigOut.SliceCount = SpreadMax;

            var timeConnected = FTimeStamp.IsConnected; // treat the time pin a little different, because it can be quite slow. time type is a struct that gets copied within the pin

            FTimeStamp.SliceCount = timeConnected? SpreadMax : 0;

            for (int i = 0; i < SpreadMax; i++)
            {
                Message m = FInput[i];
                FOutput[i] = m.ToString();
                FTopic[i]  = m.Topic;
                if (timeConnected)
                {
                    FTimeStamp[i] = m.TimeStamp;
                }
                ;

                FConfigOut[i] = FInput[i].Formular.Configuration;

                if (FPrint[i])
                {
                    //StringBuilder sb = new StringBuilder();
                    //sb.AppendLine("\t === \t ["+i+"]\t ===");
                    //sb.AppendLine(FInput[i].ToString());
                    //sb.AppendLine();
                    //FLogger.Log(LogType.Message, sb.ToString());

                    FLogger.Log(LogType.Message, "\t === \t [" + i + "]\t ===");
                    FLogger.Log(LogType.Message, JsonConvert.SerializeObject(FInput[i], FJsonSettings));
                }
            }

            if (timeConnected)
            {
                FTimeStamp.Flush();
            }

            FTopic.Flush();
            FOutput.Flush();
            FConfigOut.Flush();
        }
示例#5
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();
        }
        public override void Evaluate(int SpreadMax)
        {
            InitDX11Graph();

            bool warnPinSafety = false;

            if (RemovePinsFirst)
            {
                warnPinSafety = RetryConfig();
            }

            if (FInput.IsAnyInvalid())
            {
                FOutput.FlushNil();

                if (warnPinSafety)
                {
                    throw new PinConnectionException("Manually remove unneeded links first! [Edit]. ID = [" + PluginHost.GetNodePath(false) + "]");
                }
                return;
            }

            bool doFlush = false;

            // is any Update slice checked?
            var anyUpdate = FUpdate.Any();

            // Flush upstream changes through the plugin
            if (FInput.IsChanged)
            {
                FOutput.SliceCount = 0;
                FOutput.AssignFrom(FInput); // push change from upstream if valid
                doFlush = true;
            }
            else if (!anyUpdate)
            {
                if (warnPinSafety)
                {
                    throw new PinConnectionException("Manually remove unneeded links first! [Edit]. ID = [" + PluginHost.GetNodePath(false) + "]");
                }

                return; // if no update and no change, no need to flush!
            }

            bool newData = FPins.Any(pinName => pinName.Value.ToISpread().IsChanged); // changed pins

            newData |= FForce[0];                                                     // assume newData, if AutoSense is off.

            if (anyUpdate && newData)
            {
                int messageIndex = 0;
                foreach (var message in FInput)
                {
                    if (FUpdate[messageIndex])
                    {
                        doFlush |= CopyFromPins(message, messageIndex, !FForce[0]);
                    }

                    messageIndex++;
                }
            }

            if (doFlush)
            {
                FOutput.Flush();
            }

            if (warnPinSafety)
            {
                throw new PinConnectionException("Manually remove unneeded links first! [Edit]. ID = [" + PluginHost.GetNodePath(false) + "]");
            }
        }