Exemple #1
0
        public void Dispose()
        {
            if (FInternalNodeListener != null)
            {
                FInternalNodeListener.Dispose();
                FInternalNodeListener = null;
            }

            if (FPins != null)
            {
                foreach (Pin pin in FPins)
                {
                    pin.Dispose();
                }
                FPins.Clear();
            }

            if (FLabelPin != null)
            {
                FLabelPin.Changed -= HandleLabelPinChanged;
            }

            if (FNodes != null)
            {
                foreach (Node childNode in FNodes)
                {
                    childNode.Dispose();
                }
                FNodes.Clear();
            }

            FNodeInfoFactory.NodeInfoUpdated -= HandleNodeInfoUpdated;
        }
        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();
            }
        }
Exemple #3
0
        public override void Evaluate(int SpreadMax)
        {
            if (RemovePinsFirst)
            {
                RetryConfig();
            }

            SpreadMax = FSpreadCount.IsAnyInvalid() || FTopic.IsAnyInvalid() ? 0 : FSpreadCount[0];
            SpreadMax = Math.Max(SpreadMax, 0); // safeguard against negative binsizes

//          Reset?
            var anyUpdate = ResetNecessary;

            var forceUpdate = !FAutoSense[0] || FAutoSense.IsChanged;

            var newData = FPins.Any(x => x.Value.ToISpread().IsChanged); // changed pins

            newData |= forceUpdate;                                      // if update is forced, then predent it is new Data

            var newTopic = FTopic.IsChanged;

            newTopic |= forceUpdate; // if update is forced, then pretend it is a new Topic

//          remove superfluous entries
            if (SpreadMax < Keep.Count)
            {
                anyUpdate = true;
                Keep.RemoveRange(SpreadMax, Keep.Count - SpreadMax);
            }

//          add new entries
            for (int i = Keep.Count; i < SpreadMax; i++)
            {
                anyUpdate = true; // new entry in Keep will require data

                newData  = true;
                newTopic = true;

                var message = new Message(Formular);
                message.Topic = FTopic[i];
                Keep.Add(message);
            }

//          check update pin
            anyUpdate |= FUpdate.Any();

            if (anyUpdate && (newData || newTopic))
            {
                // ...and start filling messages
                int messageIndex = 0;
                foreach (var message in Keep)
                {
                    // only copy, when Update is true for this message
                    if (newData && FUpdate[messageIndex] && CopyFromPins(message, messageIndex, !forceUpdate))
                    {
                        anyUpdate = true;
                    }

                    if (newTopic && FUpdate[messageIndex] && message.Topic != FTopic[messageIndex])
                    {
                        message.Topic = FTopic[messageIndex];
                        anyUpdate     = true;
                    }
                    messageIndex++;
                }
            }

            if (Keep.IsChanged)
            {
                UpKeep(anyUpdate);
            }
            else  // no change, so make sure, none is reported
            {
                if (FChangeOut.SliceCount > 0)
                {
                    FChangeOut.SliceCount      = 0;
                    FChangeIndexOut.SliceCount = 0;
                }
            }
        }
        public override void Evaluate(int SpreadMax)
        {
            InitDX11Graph();

            bool warnPinSafety = false;

            if (RemovePinsFirst)
            {
                warnPinSafety = !RetryConfig();                  // defer PinConnectionException until end of method, if not successful
            }
            SpreadMax = FSpreadCount.IsAnyInvalid() || FTopic.IsAnyInvalid() ? 0 : FSpreadCount[0];
            SpreadMax = Math.Max(SpreadMax, 0); // safeguard against negative binsizes

//          Reset?
            var anyUpdate   = FResetNecessary;
            var forceUpdate = FForce[0] || FForce.IsChanged;

            var newData = FPins.Any(x => x.Value.ToISpread().IsChanged); // changed pins

            newData |= forceUpdate;                                      // if update is forced, then predent it is new Data
            var newTopic = FTopic.IsChanged;

            newTopic |= forceUpdate; // if update is forced, then pretend it is a new Topic

//          remove superfluous entries
            if (SpreadMax < Keep.Count)
            {
                anyUpdate = true;
                Keep.RemoveRange(SpreadMax, Keep.Count - SpreadMax);
            }

//          add new entries
            for (int i = Keep.Count; i < SpreadMax; i++)
            {
                anyUpdate = true; // new entry in Keep will require data

                newData  = true;
                newTopic = true;

                var message = new Message(Formular);
                message.Topic = FTopic[i];
                Keep.Add(message);
            }

//          check update pin
            anyUpdate |= FUpdate.Any();

            if (anyUpdate && (newData || newTopic))
            {
                // ...and start filling messages
                int messageIndex = 0;
                foreach (var message in Keep)
                {
                    // only copy, when Update is true for this message
                    if (newData && FUpdate[messageIndex] && CopyFromPins(message, messageIndex, !forceUpdate))
                    {
                        anyUpdate = true;
                    }

                    if (newTopic && FUpdate[messageIndex] && message.Topic != FTopic[messageIndex])
                    {
                        message.Topic = FTopic[messageIndex];
                        anyUpdate     = true;
                    }
                    messageIndex++;
                }
            }

            if (Keep.IsChanged || Keep.Any(m => m.HasRecentCommit(Keep)))
            {
                UpKeep(anyUpdate);
            }
            else  // no change, so make sure, none is reported
            {
                if (FChangeOut.SliceCount > 0)
                {
                    FChangeOut.FlushNil();
                    FChangeIndexOut.FlushNil();
                }
            }

            if (warnPinSafety)
            {
                throw new PinConnectionException("Manually remove unneeded links first! [ConfigKeep]. ID = [" + PluginHost.GetNodePath(false) + "]");
            }
        }
        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) + "]");
            }
        }