This class is not yet implemented!
Наследование: Composite
Пример #1
0
        static void Main(string[] args)
        {
            _pseq = new TreeSharp.Parallel(
                new Decorator(canRun => test1,
                              new TreeSharp.Action(delegate { Console.WriteLine("Action0"); })),
                new Decorator(canRun => test1,
                              new TreeSharp.Action(delegate { Console.WriteLine("Action1"); return(RunStatus.Running); })),
                new Decorator(canRun => test2,
                              new TreeSharp.Action(delegate { Console.WriteLine("Action2"); }))
                );

            _ps = new Sequence(_pseq);

            object context = new object();

            _ps.Start(context);

            while (true && Console.NumberLock != false)
            {
                //   Console.WriteLine();
                var input = Console.ReadLine();

                if (input == "1")
                {
                    test1 = !test1;
                }
                if (input == "2")
                {
                    test2 = !test2;
                }

                //Pulse the tree
                //_ps.Tick(context);


                _ps.Tick(context);
                // If the last status wasn't running, stop the tree, and restart it.
                if (_ps.LastStatus == RunStatus.Running)
                {
                    _ps.Stop(context);
                    _ps.Start(context);
                }
            }
        }
Пример #2
0
        public void Init()
        {
             c1 = new IterComp(0, RunStatus.Success);
             c2 = new IterComp(1, RunStatus.Success);
             c1Failure = new IterComp(0, RunStatus.Failure);
             c2Failure = new IterComp(1, RunStatus.Failure);
             cCont1 = new IterComp(5, RunStatus.Success);
             cCont2 = new IterComp(10, RunStatus.Success);

             p1 = new Parallel(Policy.ALL_MET, Policy.ALL_MET, c1, c2);
             empty = new Parallel(Policy.ALL_MET, Policy.ALL_MET);
             single = new Parallel(Policy.ALL_MET, Policy.ALL_MET, c2);

             pSuccessOne = new Parallel(Policy.ALL_MET, Policy.ONE_MET, c1, c2);
             pFailureOne = new Parallel(Policy.ONE_MET, Policy.ALL_MET, c1Failure, c2Failure);
             pFailureAll = new Parallel(Policy.ALL_MET, Policy.ALL_MET, c1Failure, c2Failure);
             pContinuous = new Parallel(Policy.ALL_MET, Policy.ALL_MET, cCont1, cCont2);
             pContinousStop = new Parallel(Policy.ALL_MET, Policy.ONE_MET, cCont1);
        }