protected bool HasLink(IIOContainer pinContainer) { try { var connected = pinContainer.GetPluginIO().IsConnected; foreach (var associated in pinContainer.AssociatedContainers) { connected |= associated.GetPluginIO().IsConnected; } return(connected); } catch (InvalidComObjectException) { // [Import]s not yet ready. try another time. // its safe to assume that no pins have been created yet. FLogger.Log(LogType.Warning, "Not fully initialized [" + this.GetType().Name + "]."); return(false); } catch (Exception) { string nodePath = PluginHost.GetNodePath(false); FLogger.Log(LogType.Error, "Failed to protect a " + this.GetType().Name + " node: " + nodePath); return(false); } }
public override void Evaluate(int SpreadMax) { // quit early. this will keep the last valid output until situation is resolved if (RemovePinsFirst) { if (!RetryConfig()) { throw new PinConnectionException("Manually remove unneeded links first! [Split]. ID = [" + PluginHost.GetNodePath(false) + "]"); } else { LayoutChanged = true; } } if (!FInput.IsChanged && !LayoutChanged) { return; } SpreadMax = FInput.IsAnyInvalid() ? 0 : FInput.SliceCount; if (SpreadMax <= 0) { foreach (string name in FPins.Keys) { FPins[name].ToISpread().FlushNil(); } FTopic.FlushNil(); FTimeStamp.FlushNil(); return; } FTimeStamp.SliceCount = SpreadMax; FTopic.SliceCount = SpreadMax; foreach (string name in FPins.Keys) { FPins[name].ToISpread().SliceCount = SpreadMax; } for (int i = 0; i < SpreadMax; i++) { Message message = FInput[i]; FTopic[i] = message.Topic; FTimeStamp[i] = message.TimeStamp; foreach (string name in FPins.Keys) { var targetPin = FPins[name].ToISpread(); var targetBin = targetPin[i] as ISpread; Bin sourceBin = message[name]; int count = 0; if (sourceBin as object == null) { if (FVerbose[0]) { FLogger.Log(LogType.Warning, "\"" + Formular[name].Type + " " + name + "\" is not defined in Message [" + message.Topic + "], so skipped its bin at \"" + PluginHost.GetNodePath(false) + "\"."); } } else { count = sourceBin.Count; } targetBin.SliceCount = count; for (int j = 0; j < count; j++) { targetBin[j] = sourceBin[j]; } } } FTimeStamp.Flush(); FTopic.Flush(); foreach (string name in FPins.Keys) { FPins[name].ToISpread().Flush(); } // no need to worry next frame. all's well, because node did not fail early LayoutChanged = false; }
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 (!FNew.Any()) // if none true { FOutput.FlushNil(); return; } SpreadMax = FNew.CombineWith(FTopic); foreach (string name in FPins.Keys) { var pin = FPins[name].ToISpread(); pin.Sync(); SpreadMax = Math.Max(pin.SliceCount, SpreadMax); } FOutput.SliceCount = 0; for (int i = 0; i < SpreadMax; i++) { if (FNew[i]) { var message = new Message(); message.Topic = FTopic[i]; foreach (string name in FPins.Keys) { var pin = FPins[name].ToISpread(); if (pin.SliceCount > 0) { message.AssignFrom(name, pin[i] as ISpread); } else { message[name] = BinFactory.New(Formular[name].Type); // will do empty spreads as well, but ignore faults } } FOutput.Add(message); } } FOutput.Flush(); if (warnPinSafety) { throw new PinConnectionException("Manually remove unneeded links first! [Create]. 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) + "]"); } }