Пример #1
0
            public RootReporting(TimeContextManager manager, bool makeDomain, bool makeInline, bool doAggregate)
            {
                if (makeDomain)
                {
                    domainReportingIngress = manager.InternalComputation.NewInput <string>();
                    domainReporter         = new RootStatisticsStage(
                        manager.MakeRawContextForScope <Epoch>("Domain Root"), "Domain Root Statistics", "rtdomain.txt");
                    domainReporter.ConnectInline(domainReportingIngress.Stream);
                }
                else
                {
                    domainReportingIngress = null;
                    domainReporter         = null;
                }

                if (makeInline)
                {
                    inlineReporter = new RootStatisticsStage(
                        manager.MakeRawContextForScope <Epoch>("Inline Root"), "Inline Root Statistics", "rtinline.txt");

                    doingAggregate = doAggregate;
                }
                else
                {
                    inlineReporter = null;
                    doingAggregate = false;
                }
            }
Пример #2
0
        static void Main(string[] args)
        {
            var input  = new InputStage();
            var inputQ = input.CreateQueue <int>();

            inputQ.Post(input.GetNumbers());

            var outstage = new OutpuStage();
            var outQ     = outstage.PrintConsole();

            var fr = new FragmentStage(inputQ, outQ);

            fr.Process();

            var completion = outQ.Completion.ContinueWith(delegate { Console.WriteLine(); });

            completion.Wait();

            // var outstage = new OutpuStage();
            // var outQ = outstage.PrintConsole();

            // var fr = new FragmentStage(inputQ, outQ);

            // var linkOptions = new DataflowLinkOptions { PropagateCompletion = true };

            // inputQ.LinkTo(frQ, linkOptions);
            // frQ.LinkTo(outQ, linkOptions);

            // inputQ.Post(input.GetNumbers());

            // inputQ.Complete();

            // outQ.Completion.Wait();
        }
    static void Main(string[] args)
    {
        //Create everything
        Data            data          = new Data();
        InputStage      inputControl  = new InputStage();
        SimulationStage simControl    = new SimulationStage();
        OutputStage     outputControl = new OutputStage();

        //Perform initialization
        data.Initialize();

        //Input Program
        inputControl.Initialize(data);
        do
        {
            data.PreUpdate();
            if (data.Input.EscapeKeyPressed)
            {
                return;
            }
            inputControl.PreUpdate(data);
            inputControl.Update();
            data.PostUpdate();
        } while (!inputControl.transitionToNextStage());
        inputControl.Finalize(data);

        //Simulation Program
        simControl.Initialize(data);
        do
        {
            data.PreUpdate();
            if (data.Input.EscapeKeyPressed)
            {
                return;
            }
            simControl.PreUpdate(data);
            simControl.Update();
            data.PostUpdate();
        } while (!simControl.transitionToNextStage());
        simControl.Finalize(data);

        //Output Program
        outputControl.Initialize(data);
        do
        {
            data.PreUpdate();
            if (data.Input.EscapeKeyPressed)
            {
                return;
            }
            outputControl.PreUpdate(data);
            outputControl.Update();
            data.PostUpdate();
        } while (!simControl.transitionToNextStage());
        outputControl.Finalize(data);
    }
Пример #4
0
        public void AssignInput(InputStage stage, ref bool left, ref bool right, ref bool cannon)
        {
            //Reset input if within freeze time
            if (GameController.game != null &&
                (GameManager.instance.freezeTimer > 0) || (GameManager.instance.roundState == GameManager.RoundState.PAUSED)
                )
            {
                left = right = cannon = false;
                return;
            }

            if (inputType == Control.InputType.CONTROLLER)
            {
                GamePad.Index idx = 0;
                if (controller == 1)
                {
                    idx = GamePad.Index.One;
                }
                else if (controller == 2)
                {
                    idx = GamePad.Index.Two;
                }
                else if (controller == 3)
                {
                    idx = GamePad.Index.Three;
                }
                else if (controller == 4)
                {
                    idx = GamePad.Index.Four;
                }
                switch (stage)
                {
                case InputStage.DOWN:
                    left   = GamePad.GetButtonDown(GamePad.Button.LeftShoulder, idx);
                    right  = GamePad.GetButtonDown(GamePad.Button.RightShoulder, idx);
                    cannon = GamePad.GetButtonDown(GamePad.Button.X, idx);
                    break;

                case InputStage.HELD:
                    left   = GamePad.GetButton(GamePad.Button.LeftShoulder, idx);
                    right  = GamePad.GetButton(GamePad.Button.RightShoulder, idx);
                    cannon = GamePad.GetButton(GamePad.Button.X, idx);
                    break;

                case InputStage.UP:
                    left   = GamePad.GetButtonUp(GamePad.Button.LeftShoulder, idx);
                    right  = GamePad.GetButtonUp(GamePad.Button.RightShoulder, idx);
                    cannon = GamePad.GetButtonUp(GamePad.Button.X, idx);
                    break;

                default: return;
                }
            }
            else
            {
                GetKeyboardInput getInput;
                switch (stage)
                {
                case InputStage.DOWN:
                    getInput = Input.GetKeyDown;
                    break;

                case InputStage.HELD:
                    getInput = Input.GetKey;
                    break;

                case InputStage.UP:
                    getInput = Input.GetKeyUp;
                    break;

                default: return;
                }


                left   = getInput(leftKey);
                right  = getInput(rightKey);
                cannon = getInput(cannonKey);
            }
        }