Ejemplo n.º 1
0
        // Draw the UI
        private void runUIThread()
        {
            ThreadPool.RunAsync(async(s) =>
            {
                while (!stopThread)
                {
                    var puckPosition = robot.AI.GetPuckPosition();

                    clearLines();
                    //drawDot(puckPosition);
                    if (puckPosition != CoordinateHelper.INVALID_POINT)
                    {
                        drawPuck(puckPosition);
                    }

                    drawMallet(robot.GetOffsets());
                    drawCenterOfMass(robot.AI.GetPuckCenterOfMass());

                    // Draw line from mallet to destination
                    drawLine(MotorHelper.GetCoordinatesFromOffset(robot.GetOffsets()),
                             MotorHelper.GetCoordinatesFromOffset(new Point(robot.StepperX.TargetPosition, robot.StepperY.TargetPosition)));

                    var bouncePts = robot.AI.GetPreviousBouncePoints();

                    if (bouncePts != null && bouncePts.Count > 0)
                    {
                        // Draw lines for bounces
                        drawBounces(puckPosition, bouncePts);
                    }
                    else if (robot.AI.GetPreviousTrajectory() != CoordinateHelper.INVALID_POINT)
                    {
                        // Draw line for trajectory
                        drawTrajectory(puckPosition, robot.AI.GetPreviousTrajectory());
                    }

                    setOutputText("Speed: " + robot.AI.GetPuckSpeed());

                    await Task.Delay(1);
                }
            });
        }