protected override void OnProcess <T>(Processor p, ProcessingNode <T> node) { if (_currentEnumerable == null) { var data = GetData(1); if (data?.Value is IEnumerable) { _currentEnumerable = (IEnumerable)data.Value; _currentEnumerator = _currentEnumerable.GetEnumerator(); } } if (_currentEnumerable != null) { if (_currentEnumerator.MoveNext()) { SetData(1, new DataContainer(_currentEnumerator.Current)); node.Repeat = true; node.Skip = new SkipNode(2); } else { node.Skip = new SkipNode(0); _currentEnumerable = null; _currentEnumerator = null; } } base.OnProcess(p, node); }
protected override void OnProcess <T>(Processor p, ProcessingNode <T> node) { var data = GetDataValueOrDefault <string>(1); Console.WriteLine(data); base.OnProcess(p, node); }
protected override void OnProcess <T>(Processor p, ProcessingNode <T> node) { var data = GetDataValueOrDefault <int>(1); if (index < data) { index++; node.Repeat = true; node.Skip = new SkipNode(2); } else { index = 0; node.Skip = new SkipNode(0); } SetData(1, new DataContainer(index - 1)); //if (RenderingEngine.DebugMode) //{ // Name = $"For (i={index} < {data})"; //} base.OnProcess(p, node); }
protected override void OnProcess <T>(Processor p, ProcessingNode <T> node) { string folderPath = GetDataValueOrDefault <string>(1); string fileFilter = GetDataValueOrDefault <string>(2); string outputFile = GetDataValueOrDefault <string>(3); HashSet <string> set = new HashSet <string>(); var files = Directory.GetFiles(folderPath, fileFilter, SearchOption.TopDirectoryOnly); foreach (var file in files) { using (StreamReader sr = new StreamReader(file)) { while (!sr.EndOfStream) { var line = sr.ReadLine(); set.Add(line); } } } using (StreamWriter sw = new StreamWriter(outputFile)) { foreach (var line in set) { sw.WriteLine(line); } } base.OnProcess(p, node); }
protected override void OnProcess <T>(Processor p, ProcessingNode <T> node) { if (node.InputIndex == 0) { if (info == null) { info = new DownloadInfo(); } if (!info.IsDownloading) { info.IsDownloading = true; Task.Factory.StartNew(() => { while (info.IsDownloading) { Thread.Sleep(500); info.Status++; if (info.Status >= 100) { info.Status = 100; info.IsDownloading = false; } } }); } } base.OnProcess(p, node); }
public override bool Process(AStarContext context) { PathFindingRequest request = context.Request as PathFindingRequest; ProcessingNode startNode = context.GetStartNode(); ProcessingNode endNode = context.GetTargetNode(); if (startNode == null || endNode == null) { return(false); } FindPath(startNode, endNode, context); List <Int3> path = context.rawPathPoints; if (path.Count > 0) { // set the first and last point to 'from' and 'to'. path[0] = request.fromPosition; path[path.Count - 1] = request.toPosition; // then optimize NavMeshPathOptimizer.Optimize(ref context.rawPathNodeCache, ref path); } return(context.rawPathPoints.Count >= 2); }
protected override void OnProcess <T>(Processor p, ProcessingNode <T> node) { if (_reader == null) { string filePath = GetDataValueOrDefault <string>(1); _reader = new StreamReader(filePath); } if (_reader != null) { if (!_reader.EndOfStream) { SetData(1, new DataContainer(_reader.ReadLine())); node.Repeat = true; node.Skip = new SkipNode(2); } else { node.Skip = new SkipNode(0); _reader.Close(); _reader = null; } } base.OnProcess(p, node); }
protected override void OnProcessData <T>(Processor p, ProcessingNode <T> node) { if (Value != null) { SetData(0, new DataContainer(Value)); } }
protected override void OnProcess <T>(Processor p, ProcessingNode <T> node) { string file = GetDataValueOrDefault <string>(1); string lineRegex = GetDataValueOrDefault <string>(2); string outputFile = GetDataValueOrDefault <string>(3); List <string> resultFile = new List <string>(); Regex regex = new Regex(lineRegex); using (StreamReader sr = new StreamReader(file)) { while (!sr.EndOfStream) { var line = sr.ReadLine(); if (line != null && regex.IsMatch(line)) { resultFile.Add(line); } } } using (StreamWriter sw = new StreamWriter(outputFile)) { foreach (var line in resultFile) { sw.WriteLine(line); } } base.OnProcess(p, node); }
protected override void OnProcess <T>(Processor p, ProcessingNode <T> node) { var value = GetDataValueOrDefault <int>(1); base.OnProcess(p, node); p.Wait(new TimeSpan(0, 0, 0, 0, value)); }
protected override void OnProcess<T>(Processor p, ProcessingNode<T> node) { RenderingEngine.RequestRedraw(); SetData(1, new DataContainer(GetData(1)?.Value)); base.OnProcess(p, node); }
protected override void OnProcess <T>(Processor p, ProcessingNode <T> node) { //KrakenExchange kraken = new KrakenExchange(new ExchangeManager()); //var price = kraken.RequestTicker(kraken.PairManager.GetPair(PairBase.BTCEUR)); //SetData(0,new DataContainer((double)price.LastPrice)); }
private ComputationGraph(IComputationGraphNode root, IReadOnlyList <IComputationGraphNode> nodes, ProcessingNode output, IReadOnlyList <ProcessingNode> trainingOutputs) { Root = root is InputNode input ? input : throw new ArgumentException("The root node isn't valid"); Nodes = nodes; OutputNode = output; TrainingOutputNodes = trainingOutputs; ProcessingNodes = Nodes.Pick <IComputationGraphNode, ProcessingNode>().ToArray(); }
protected override void OnProcessData <T>(Processor p, ProcessingNode <T> node) { var result = !GetDataValueOrDefault <bool>(0); SetData(0, new DataContainer(result)); base.OnProcess(p, node); }
protected override void OnProcessData <T>(Processor p, ProcessingNode <T> node) { var t = DateTime.Now; SetData(0, new DataContainer { Value = t }); }
protected override void OnProcess <T>(Processor p, ProcessingNode <T> node) { base.OnProcess(p, node); var eventName = GetDataValueOrDefault <string>(1); RenderingEngine.EventManager.Run(EventTypeBase.StartSingle, eventName); }
protected override int CalCostH(ProcessingNode node, AStarContext context) { float heuristicScale = 1.0f; NavMeshNode calNode = node.astarNode as NavMeshNode; NavMeshNode targetNode = context.GetTargetNode().astarNode as NavMeshNode; int dist = (calNode.position - targetNode.position).costMagnitude; return(UnityEngine.Mathf.RoundToInt(dist * heuristicScale)); }
protected override void OnProcessData <T>(Processor p, ProcessingNode <T> node) { foreach (var o in Outputs) { SetData(o.Index, GetData(0)); } base.OnProcessData(p, node); }
protected override void OnProcessData <T>(Processor p, ProcessingNode <T> node) { var a = GetDataValueOrDefault <int>(0); var b = GetDataValueOrDefault <int>(1); SetData(0, new DataContainer(a > b)); base.OnProcess(p, node); }
protected override void OnProcessData <T>(Processor p, ProcessingNode <T> node) { var text = GetDataValueOrDefault <string>(0); var splitter = GetDataValueOrDefault <string>(1); var result = text.Split(new string[] { splitter }, StringSplitOptions.RemoveEmptyEntries); SetData(0, result); }
protected override void OnCleanUp <T>(Processor p, ProcessingNode <T> node) { if (_reader != null) { _reader.Close(); _reader = null; } base.OnCleanUp(p, node); }
protected override int CalCostG(ProcessingNode prevNode, ProcessingNode currentNode, AStarContext context) { Grid2DNode pre = (Grid2DNode)(prevNode.astarNode); Grid2DNode cur = (Grid2DNode)(currentNode.astarNode); int dx = Math.Abs(pre.x - cur.x); int dy = Math.Abs(pre.y - cur.y); int dist = dx > dy ? 14 * dy + 10 * (dx - dy) : 14 * dx + 10 * (dy - dx); return(prevNode.g + dist); }
protected override int CalCostH(ProcessingNode node, AStarContext context) { Grid2DNode endNode = context.GetTargetNode().astarNode as Grid2DNode; Grid2DNode nd = (Grid2DNode)(node.astarNode); int dx = Math.Abs(endNode.x - nd.x); int dy = Math.Abs(endNode.y - nd.y); int dist = dx > dy ? 14 * dy + 10 * (dx - dy) : 14 * dx + 10 * (dy - dx); return(dist); }
protected override void OnProcessData <T>(Processor p, ProcessingNode <T> node) { var array = GetDataValueOrDefault <string[]>(0); var index = GetDataValueOrDefault <int>(1); var entry = array[index]; SetData(0, new DataContainer(entry)); }
protected override void OnProcessData <T>(Processor p, ProcessingNode <T> node) { var path = GetDataValueOrDefault <string>(0); var paths = Directory.GetFiles(path); SetData(0, new DataContainer(paths)); base.OnProcess(p, node); }
protected override void OnProcessData <T>(Processor p, ProcessingNode <T> node) { string currentPath = GetDataValueOrDefault <string>(0); for (int i = 1; i < TotalInputs; i++) { currentPath = Path.Combine(currentPath, GetDataValueOrDefault <string>(i)); } SetData(0, new DataContainer(currentPath)); }
protected override void OnProcessData <T>(Processor p, ProcessingNode <T> node) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < TotalInputs; i++) { sb.Append(GetDataValueOrDefault <string>(i)); } SetData(0, new DataContainer(sb.ToString())); }
protected override void OnProcess <T>(Processor p, ProcessingNode <T> node) { string filePath = GetDataValueOrDefault <string>(1); using (StreamWriter sw = File.AppendText(filePath)) { var line = GetDataValueOrDefault <string>(2); sw.WriteLine(line); } base.OnProcess(p, node); }
protected override void OnProcessData <T>(Processor p, ProcessingNode <T> node) { double sum = 0; for (int i = 0; i < TotalInputs; i++) { sum += GetDataValueOrDefault <double>(i); } SetData(0, new DataContainer(sum)); }
protected override void OnProcess <T>(Processor p, ProcessingNode <T> node) { base.OnProcess(p, node); var data = GetData(1); if (data != null && Variable != null) { Variable.Value = data.Value; SetData(0, new DataContainer(Variable.Value)); } }