Пример #1
0
        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);
        }
Пример #2
0
        protected override void OnProcess <T>(Processor p, ProcessingNode <T> node)
        {
            var data = GetDataValueOrDefault <string>(1);

            Console.WriteLine(data);
            base.OnProcess(p, node);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
 protected override void OnProcessData <T>(Processor p, ProcessingNode <T> node)
 {
     if (Value != null)
     {
         SetData(0, new DataContainer(Value));
     }
 }
Пример #9
0
        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);
        }
Пример #10
0
        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));
        }
Пример #11
0
        protected override void OnProcess<T>(Processor p, ProcessingNode<T> node)
        {
            RenderingEngine.RequestRedraw();

            SetData(1, new DataContainer(GetData(1)?.Value));

            base.OnProcess(p, node);
        }
Пример #12
0
        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));
        }
Пример #13
0
 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();
 }
Пример #14
0
        protected override void OnProcessData <T>(Processor p, ProcessingNode <T> node)
        {
            var result = !GetDataValueOrDefault <bool>(0);

            SetData(0, new DataContainer(result));

            base.OnProcess(p, node);
        }
Пример #15
0
        protected override void OnProcessData <T>(Processor p, ProcessingNode <T> node)
        {
            var t = DateTime.Now;

            SetData(0, new DataContainer {
                Value = t
            });
        }
Пример #16
0
        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);
        }
Пример #17
0
        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));
        }
Пример #18
0
        protected override void OnProcessData <T>(Processor p, ProcessingNode <T> node)
        {
            foreach (var o in Outputs)
            {
                SetData(o.Index, GetData(0));
            }

            base.OnProcessData(p, node);
        }
Пример #19
0
        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);
        }
Пример #20
0
        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);
        }
Пример #21
0
        protected override void OnCleanUp <T>(Processor p, ProcessingNode <T> node)
        {
            if (_reader != null)
            {
                _reader.Close();
                _reader = null;
            }

            base.OnCleanUp(p, node);
        }
Пример #22
0
        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);
        }
Пример #23
0
        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);
        }
Пример #24
0
        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));
        }
Пример #25
0
        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);
        }
Пример #26
0
        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));
        }
Пример #27
0
        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()));
        }
Пример #28
0
        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);
        }
Пример #29
0
        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));
        }
Пример #30
0
        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));
            }
        }