#pragma warning restore public void Evaluate(int SpreadMax) { SpreadMax = FInput.IsAnyInvalid() ? 0 : FInput.SliceCount; if (SpreadMax <= 0) { FOutput.FlushNil(); return; } var keepOnly = new HashSet <string>(FFilter); foreach (var message in FInput) { foreach (var fieldName in message.Fields.ToArray()) { if (!keepOnly.Contains(fieldName)) { message.Remove(fieldName); } } } if (FRemoveEmpty[0]) { FOutput.FlushResult(FInput.Where(message => !message.IsEmpty)); } else { FOutput.FlushResult(FInput); } }
public void Evaluate(int SpreadMax) { if (FInput.IsAnyInvalid()) { if (FOutput.SliceCount > 0) { FOutput.FlushNil(); return; } else { return; } } if (FRemove.IsAnyInvalid()) { FOutput.FlushResult(FInput); return; } if ((!FInput.IsChanged && !FRemove.IsChanged)) { return; } var remains = from msg in FInput where !FRemove.Contains(msg) select msg; FOutput.FlushResult(remains); }
private bool RemoveOld() { var validTime = Time.Time.CurrentTime() - new TimeSpan(0, 0, 0, (int)Math.Floor(FTime[0]), (int)Math.Floor((FTime[0] * 1000) % 1000)); if (FTime[0] > 0) { DeadMessages = DeadMessages.Concat( from message in Keep.ToList() where message.TimeStamp < validTime let removed = Keep.Remove(message) select message ).ToList(); } if (FRemovedMessages.SliceCount > 0 || DeadMessages.Count() > 0) { FRemovedMessages.FlushResult(DeadMessages); DeadMessages.Clear(); return(true); } else { // output still empty, no need to flush return(false); } }
public override void Evaluate(int SpreadMax) { if (Default != null && !FInput.IsChanged) { return; } if (FInput.IsAnyInvalid()) { if (Default == null) { NewDefault(); } FOutput.SliceCount = 1; Default.Topic = FTopic[0]; FOutput[0] = Default; FOutput.Flush(); } else { FOutput.FlushResult(FInput); } }
public void Evaluate(int SpreadMax) { if (!FInput.IsChanged && !FFilter.IsChanged) { return; } if (FInput.IsAnyInvalid()) { if (FOutput.SliceCount > 0) { FOutput.FlushNil(); } return; } foreach (var message in FInput) { foreach (var fieldName in message.Fields.ToArray()) { if (FFilter.Contains(fieldName)) { message.Remove(fieldName); } } } FOutput.FlushResult(FInput); }
//called when data for any output pin is requested public void Evaluate(int SpreadMax) { // save some performance when no work necessary if (FInput.IsAnyInvalid()) { if (FOutput.SliceCount > 0) { FOutput.FlushNil(); } return; } if (!FInput.IsChanged && !FFilter.IsChanged) { return; } // start working it out var result = from message in FInput let bin = message["MyField"] as Bin <string> // identify as string where bin != null where !bin.IsAnyInvalid() && !FFilter.IsAnyInvalid() // safe against nil where FFilter.Contains(bin.First) select message; // publish data back to vvvv FOutput.FlushResult(result); }
#pragma warning restore public void Evaluate(int SpreadMax) { if (FInput.IsAnyInvalid()) { SpreadMax = 0; } else { SpreadMax = FInput.SliceCount; } if (SpreadMax == 0) { FOutput.FlushNil(); return; } if (!FInput.IsChanged) { return; } var result = FInput.OrderBy(message => message.TimeStamp.UniversalTime); FOutput.FlushResult(result); }
#pragma warning restore public void Evaluate(int SpreadMax) { if ((!FInput.IsChanged && !FRemove.IsChanged)) { return; } if ((FRemove.IsAnyInvalid() || FInput.IsAnyInvalid())) { if (FOutput.SliceCount > 0) { FOutput.FlushResult(FInput); return; } else { return; } } SpreadMax = FInput.SliceCount; FOutput.SliceCount = SpreadMax; for (int i = 0; i < SpreadMax; i++) { var remains = from msg in FInput[i] where !FRemove.Contains(msg) select msg; FOutput[0].SliceCount = 0; FOutput[0].AssignFrom(remains); } FOutput.Flush(); }
#pragma warning restore public void Evaluate(int SpreadMax) { var flow = FFlowControl[0]; FChange.SliceCount = 0; switch (flow) { case FlowControlEnum.Block: FChange.AssignFrom(Enumerable.Repeat(false, 1)); break; case FlowControlEnum.Default: if (FInput.IsChanged && !FInput.IsAnyInvalid()) { FOutput.FlushResult(FInput); FChange.AssignFrom(Enumerable.Repeat(true, 1)); } else { FChange.AssignFrom(Enumerable.Repeat(false, 1)); } break; case FlowControlEnum.Inspect: var change = FInput.Select(message => message.IsChanged); if (FInput.IsChanged || change.Any()) { FOutput.FlushResult(FInput); FChange.AssignFrom(change); } else { FChange.AssignFrom(Enumerable.Repeat(false, 1)); } break; case FlowControlEnum.Force: FOutput.FlushResult(FInput); FChange.AssignFrom(Enumerable.Repeat(true, 1)); break; default: FChange.AssignFrom(Enumerable.Repeat(false, 1)); break; } }
#pragma warning restore public override void Evaluate(int SpreadMax) { if (FInput.IsAnyInvalid()) { SpreadMax = 0; } else { SpreadMax = FInput.SliceCount; } if (SpreadMax == 0) { FOutput.FlushNil(); return; } if (!FInput.IsChanged && !FUseFields.IsChanged) { return; } FOutput.SliceCount = 0; var fieldNames = FUseFields[0]; if (fieldNames.IsAnyInvalid()) { FOutput.FlushResult(FInput); } else { var ordered = FInput.OrderBy(message => message[fieldNames[0].Name][0]); for (int i = 1; i < fieldNames.SliceCount; i++) { ordered = ordered.ThenBy(message => message[fieldNames[i].Name][0]); } FOutput.FlushResult(ordered); } }
#pragma warning restore public void Evaluate(int SpreadMax) { if (FInput.IsChanged) { var clones = from message in FInput where message != null select message.Clone() as Message; FOutput.FlushResult(clones); } }
public void Evaluate(int SpreadMax) { if (FInput.IsAnyInvalid()) { SpreadMax = 0; } else { SpreadMax = FInput.SliceCount; } if (SpreadMax == 0) { if (FOutput.SliceCount != 0) { FOutput.FlushNil(); FEditCount.FlushNil(); } return; } if (!FInput.IsChanged && !FModifier.IsChanged) { return; } FEditCount.SliceCount = SpreadMax; for (int i = 0; i < SpreadMax; i++) { FEditCount[i] = 0; var message = FInput[i]; var targets = from mod in FModifier where mod != null where mod.Topic == message.Topic select mod; foreach (var mod in targets) { message.InjectWith(mod, FDeepInspection[0]); FEditCount[i]++; } } FOutput.FlushResult(FInput); FEditCount.Flush(); }
public void Evaluate(int SpreadMax) { var output = new List <Message>(); var data = (from pin in FInputs select !pin.IOObject.IsAnyInvalid() ).Any(d => d); if (!data) { FOutput.FlushNil(); return; } var changed = ( from pin in FInputs let spread = pin.IOObject where spread.IsChanged where !(FPinEmpty[spread] && spread.IsAnyInvalid()) // if IS emtpy and WAS empty, don't bother select true ).Any(); if (!changed) { return; } var doDistinct = FDistinct[0]; for (int i = 0; i < FInputCount[0]; i++) { var inputSpread = FInputs[i].IOObject; FPinEmpty[inputSpread] = inputSpread.IsAnyInvalid(); if (!inputSpread.IsAnyInvalid()) { var filtered = from m in inputSpread where m != null where !m.IsEmpty where !doDistinct || !output.Contains(m) select m; output.AddRange(filtered); } } FOutput.FlushResult(output); }
public void Evaluate(int SpreadMax) { if (FInput.IsChanged) { LastFrame.AssignFrom(FInput); } if (!FClear.IsAnyInvalid() && FClear[0]) { FOutput.FlushNil(); } else { FOutput.FlushResult(LastFrame); } }
public void Evaluate(int SpreadMax) { if (FInit[0]) { FOutput.FlushNil(); return; } _lastFrame.Clear(); if (FInput.IsChanged && !FInput.IsAnyInvalid()) { _lastFrame.AddRange(FInput); FOutput.FlushResult(_lastFrame); } }
#pragma warning restore public void Evaluate(int SpreadMax) { SpreadMax = FInput.IsAnyInvalid() ? 0 : FInput.SliceCount; if (SpreadMax <= 0) { FOutput.FlushNil(); return; } var translate = new Dictionary <string, string>(); var max = FNew.CombineWith(FOld); for (int i = 0; i < max; i++) { var n = FNew[i].Trim(); var o = FOld[i].Trim(); if (string.IsNullOrWhiteSpace(n) || string.IsNullOrWhiteSpace(o) || !n.IsValidFieldName()) { throw new ParseFormularException("\"" + n + "\" is not a valid name for a Message's field. Only use alphanumerics, dots, hyphens and underscores. "); } translate[o] = n; } foreach (var message in FInput) { foreach (var fieldName in message.Fields.ToArray()) { if (translate.ContainsKey(fieldName)) { var success = message.Rename(fieldName, translate[fieldName], FOverwrite[0]); if (!success) { FLogger.Log(LogType.Error, "Cannot rename " + fieldName + " to " + translate[fieldName] + " because it already exists."); } } } } FOutput.FlushResult(FInput); }
public void Evaluate(int SpreadMax) { if ((!FInput.IsChanged)) { return; } if (FInput.IsAnyInvalid()) { FOutput.FlushNil(); return; } var remains = from msg in FInput where msg != null where !msg.IsEmpty select msg; FOutput.FlushResult(remains); }
public void Evaluate(int SpreadMax) { if (!FInput.IsChanged && !FTopic.IsChanged && !(FUpdate.IsChanged && FUpdate.Any()) ) { return; } SpreadMax = FInput.IsAnyInvalid() ? 0 : FInput.SliceCount; for (int i = 0; i < SpreadMax; i++) { // double check if topic change needs to occur, because setting it will mark the message as dirty if (FUpdate[i] && !FInput[i].Topic.Equals(FTopic[i])) { FInput[i].Topic = FTopic[i]; } } FOutput.FlushResult(FInput); }
#pragma warning restore public void Evaluate(int SpreadMax) { SpreadMax = FInput.IsAnyInvalid() ? 0 : FInput.SliceCount; if (SpreadMax <= 0) { FOutput.FlushNil(); return; } foreach (var message in FInput) { foreach (var fieldName in message.Fields.ToArray()) { if (message[fieldName].Count <= 0) { message.Remove(fieldName); } } } FOutput.FlushResult(FInput); }
public override void Evaluate(int SpreadMax) { if (FInput.IsAnyInvalid()) { if (FOutput.SliceCount > 0) { FOutput.FlushNil(); } return; } SpreadMax = FInput.SliceCount; if (!FInput.IsChanged && !FUseFields.IsChanged && !FDescending.IsChanged) { return; } if (FUseFields.IsAnyInvalid()) { FOutput.FlushResult(FInput); return; } // flatten, to ignore binsize. optimize potential! List <EnumEntry> fieldNames = new List <EnumEntry>(); foreach (var bin in FUseFields) { foreach (var entry in bin) { if (entry != null && !fieldNames.Contains(entry)) { fieldNames.Add(entry); } } } IOrderedEnumerable <Message> ordered = FInput.OrderBy(message => 1); // noop sort to "cast" into interface for (int i = 0; i < fieldNames.Count; i++) { var fieldName = fieldNames[i].Name; Func <Message, object> deleg; switch (fieldName) { case "Topic": deleg = message => message.Topic; break; case "TimeStamp": deleg = message => message.TimeStamp.UniversalTime; break; default: // todo: retrieve a proper default for this typed field object fallBack = 1; // noop, when not possible deleg = message => message[fieldName].IsAnyInvalid() ? fallBack : message[fieldName][0]; break; } if (FDescending[i]) { ordered = ordered.ThenByDescending(deleg); } else { ordered = ordered.ThenBy(deleg); } } FOutput.FlushResult(ordered); }
public void Evaluate(int SpreadMax) { var flow = FFlowControl[0]; FChange.SliceCount = 0; SpreadMax = FInput.SliceCount; if (FForce[0]) { flow = FlowControlEnum.Force; } switch (flow) { case FlowControlEnum.Default: if (FInput.IsChanged && !FInput.IsAnyInvalid()) { FOutput.FlushResult(FInput); FChange.FlushItem(true); } else { FChange.FlushItem(false); } break; case FlowControlEnum.Inspect: if (FInput.IsAnyInvalid()) { FChange.FlushItem(false); break; } var change = FInput.Select(message => message.IsChanged); if (FInput.IsChanged || change.Any()) { if (FFilter[0]) { FOutput.FlushResult(FInput.Where(message => message.IsChanged)); } else { FOutput.FlushResult(FInput); } FChange.FlushResult(change); } else { FChange.FlushResult(Enumerable.Repeat(false, SpreadMax)); } break; case FlowControlEnum.SinceLastFrame: if (FInput.IsAnyInvalid()) { FChange.FlushItem(false); break; } var changed = FInput.Select(message => message.HasRecentCommit()); if (FInput.IsChanged || changed.Any()) { if (FFilter[0]) { FOutput.FlushResult(FInput.Where(message => message.HasRecentCommit())); } else { FOutput.FlushResult(FInput); } FChange.FlushResult(changed); } else { FChange.FlushResult(Enumerable.Repeat(false, SpreadMax)); } break; case FlowControlEnum.Block: FChange.FlushItem(false); break; case FlowControlEnum.Force: FOutput.FlushResult(FInput); FChange.FlushResult(Enumerable.Repeat(true, SpreadMax)); break; default: // all bases covered? FChange.FlushItem <bool>(false); break; } }