public override void Evaluate(int SpreadMax)
        {
            var update = CheckReset();

            if (FInput.IsChanged && !FInput.IsAnyInvalid())
            {
                Keep.AssignFrom(FInput);
                update = true;
            }

            if (UpKeep())
            {
                update = true;
            }

            if (FHold.IsChanged)
            {
                update = true;
            }
            if (FHold[0] == HoldEnum.Index && FIndex.IsChanged)
            {
                update = true;
            }

            if (update)
            {
                switch (FHold[0])
                {
                case HoldEnum.All:
                    FOutput.SliceCount = 0;
                    FOutput.AssignFrom(Keep);
                    break;

                case HoldEnum.Index:
                    if (Keep.Count == 0)
                    {
                        FOutput.SliceCount = 0;
                    }
                    else
                    {
                        FOutput.SliceCount = FIndex.SliceCount;
                        for (int i = 0; i < FIndex.SliceCount; i++)
                        {
                            var index = VMath.Zmod(FIndex[i], Keep.Count);
                            FOutput[i] = Keep[index];
                        }
                    }
                    break;
                }
                FOutput.Flush();
            }
        }
Example #2
0
        public override void Evaluate(int SpreadMax)
        {
            if (!FInput.IsChanged && !FEndian.IsChanged)
            {
                return;
            }

            FOutput.SliceCount = SpreadMax;

            for (int i = 0; i < SpreadMax; i++)
            {
                var config = new Options(FInput[i]);
                config.Endian = FEndian[i] ? Endianness.Little : Endianness.Big;
                FOutput[i]    = config;
            }

            FOutput.Flush();
        }
Example #3
0
        public override void Evaluate(int SpreadMax)
        {
            FInput.Dispose();



            for (int i = 0; i < SpreadMax; i++)
            {
                Agent agent = FInput[i];
                foreach (string name in FPins.Keys)
                {
                    var pin = ((ISpread <ISpread>)FPins[name].RawIOObject)[i];
                    agent.Assign(name, pin);
                }
            }

            FOutput.AssignFrom(FInput);
            FOutput.Flush();
        }
Example #4
0
        public override void Evaluate(int SpreadMax)
        {
            if (!FInput.IsChanged && !FLinger.IsChanged)
            {
                return;
            }

            FOutput.SliceCount = SpreadMax;

            for (int i = 0; i < SpreadMax; i++)
            {
                var config = new Options(FInput[i]);

                config.Linger = FLinger[i];

                FOutput[i] = config;
            }

            FOutput.Flush();
        }
Example #5
0
        public override void Evaluate(int SpreadMax)
        {
            if (!FInput.IsChanged && !SendHighWatermark.IsChanged && !ReceiveHighWatermark.IsChanged)
            {
                return;
            }

            FOutput.SliceCount = SpreadMax;

            for (int i = 0; i < SpreadMax; i++)
            {
                var config = new Options(FInput[i]);

                config.SendHighWatermark    = SendHighWatermark[i];
                config.ReceiveHighWatermark = ReceiveHighWatermark[i];

                FOutput[i] = config;
            }

            FOutput.Flush();
        }
Example #6
0
        public override void Evaluate(int SpreadMax)
        {
            if (!FInput.IsChanged && !FTcpKeepAlive.IsChanged && !FTcpKeepAliveIdle.IsChanged && !FTcpKeepAliveInterval.IsChanged)
            {
                return;
            }

            FOutput.SliceCount = SpreadMax;
            //         var Default = Options.Default();

            for (int i = 0; i < SpreadMax; i++)
            {
                var config = new Options(FInput[i]);

                config.TcpKeepalive         = FTcpKeepAlive[i];
                config.TcpKeepaliveIdle     = FTcpKeepAliveIdle[i];
                config.TcpKeepaliveInterval = FTcpKeepAliveInterval[i];

                FOutput[i] = config;
            }

            FOutput.Flush();
        }
Example #7
0
        public override void Evaluate(int SpreadMax)
        {
            if (FInput.IsAnyInvalid())
            {
                FOutput.FlushNil();
                return; // if no input, no further calculation.
            }

            bool doFlush = false;

            // any of the update slices is true -> update the plugin.
            var anyUpdate = FUpdate.Any();

            // Flush upstream changes through the plugin
            if (FInput.IsChanged)
            {
                FOutput.SliceCount = 0;
                FOutput.AssignFrom(FInput);
                doFlush = true;
            }
            else if (!anyUpdate)
            {
                return;
            }

            var keyCount    = FKey.SliceCount;
            var ValueSpread = FValue.ToISpread();

            bool newData = ValueSpread.IsChanged; // changed pin

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

            if (anyUpdate && newData)
            {
                SpreadMax = FInput.SliceCount;
                doFlush   = true;

                for (int i = 0; i < SpreadMax; i++)
                {
                    Message message = FInput[i];

                    var keyIndex = 0;
                    foreach (var key in FKey)
                    {
                        var fieldIndex = i * keyCount + keyIndex;
                        keyIndex++;

                        if (!FUpdate[fieldIndex])
                        {
                            continue;
                        }

                        if (!message.Fields.Contains(key))
                        {
                            message[key] = BinFactory.New(TargetDynamicType);
                        }
                        var value = ValueSpread[fieldIndex] as ISpread;

                        if (value.SliceCount > 0)
                        {
                            if (message[key].GetInnerType().IsAssignableFrom(TargetDynamicType))
                            {
                                // check if any relevant change occurred
                                if (!message[key].Equals(value as IEnumerable))
                                {
                                    message.AssignFrom(key, value);
                                }
                            }
                            else
                            {
                                var casted = from slice in value as IEnumerable <object>
                                             let targetType = message[key].GetInnerType()
                                                              select Convert.ChangeType(slice, targetType);

                                if (!message[key].Equals(casted))
                                {
                                    message.AssignFrom(key, casted);
                                }
                            }
                        }
                        else
                        {
                            message[key].Clear();
                        }
                    }
                }
            }

            if (doFlush)
            {
                FOutput.Flush();
            }
        }
Example #8
0
        public override void Evaluate(int SpreadMax)
        {
            InitDX11Graph();

            if (FInput.IsAnyInvalid())
            {
                FOutput.FlushNil();
                return; // if no input, no further calculation.
            }

            bool doFlush = false;

            // any of the update slices is true -> update the plugin.
            var anyUpdate = FUpdate.Any();

            // Flush upstream changes through the plugin
            if (FInput.IsChanged)
            {
                FOutput.SliceCount = 0;
                FOutput.AssignFrom(FInput);
                doFlush = true;
            }
            else if (!anyUpdate)
            {
                return;
            }

            var dataSpread = FValue.ToISpread();

            bool newData = dataSpread.IsChanged; // changed pin

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

            if (anyUpdate && newData)
            {
                // Update and Force not included in spreading.
                SpreadMax = dataSpread.SliceCount.CombineWith(FKey).CombineWith(FInput);
                if (FUpdate.IsAnyInvalid() || FForce.IsAnyInvalid())
                {
                    SpreadMax = 0;
                }

                FIterations[0] = SpreadMax;

                doFlush = true;

                var fieldIndex = 0;
                for (int i = 0; i < SpreadMax; i++) // iterate spreaded (except update, which gets cut short)
                {
                    Message message = FInput[i];

                    for (int j = 0; j < FKey[i].SliceCount; j++, fieldIndex++) // iterate all relevant fields for each message
                    {
                        if (!FUpdate[fieldIndex])
                        {
                            continue;                       // update is per-field
                        }
                        var key    = FKey[i][j];
                        var spread = dataSpread[fieldIndex] as ISpread;

                        LazyInsert(message, key, spread);
                    }
                }
            }

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