Пример #1
0
        private void GoToZeros_Click(object sender, RoutedEventArgs e)
        {
            var state = Cnc.PlannedState;
            var stepsU = _positionOffsetU - state.U;
            var stepsV = _positionOffsetV - state.V;
            var stepsX = _positionOffsetX - state.X;
            var stepsY = _positionOffsetY - state.Y;

            var planner = new PlanBuilder();
            planner.AddRampedLineUVXY(stepsU, stepsV, stepsX, stepsY, Constants.MaxPlaneAcceleration, Constants.MaxPlaneSpeed);
            Cnc.SEND(planner.Build());
        }
Пример #2
0
        private void executePlan()
        {
            if (!Cnc.IsHomeCalibrated)
            {
                ShowError("Calibration is required!");
                return;
            }

            disableMotionCommands();
            Workspace.DisableChanges();

            var builder = new PlanBuilder();
            var point   = Workspace.EntryPoint;

            var state = Cnc.PlannedState;
            var initU = point.PositionC1 - state.U;
            var initV = point.PositionC2 - state.V;
            var initX = point.PositionC1 - state.X;
            var initY = point.PositionC2 - state.Y;


            builder.AddRampedLineUVXY(initU, initV, initX, initY, Configuration.MaxPlaneAcceleration, getTransitionSpeed());
            try
            {
                Workspace.BuildPlan(builder);
            }
            catch (PlanningException ex)
            {
                planCompleted();
                ShowError(ex.Message);
                return;
            }
            //builder.AddRampedLineUVXY(-initU, -initV, -initX, -initY, Constants.MaxPlaneAcceleration, getTransitionSpeed());

            var plan = builder.Build();

            if (!Cnc.SEND(plan))
            {
                planCompleted();
                ShowError("Plan overflows the workspace!");
                return;
            }

            Cnc.OnInstructionQueueIsComplete += planCompleted;
            _planStart     = DateTime.Now;
            _isPlanRunning = true;

            if (!plan.Any())
            {
                planCompleted();
            }
        }
        private void setElevation(CenterCutState newState)
        {
            if (_state == newState)
            {
                //there is nothing to do
                return;
            }

            var elevationFactor = _state - newState;

            _state = newState;

            refreshStateButtons();

            var elevation      = double.Parse(Elevation.Text);
            var elevationSteps = (int)Math.Round(elevation / Configuration.MilimetersPerStep) * elevationFactor;

            var builder = new PlanBuilder();

            builder.AddRampedLineUVXY(elevationSteps, 0, -elevationSteps, 0, Configuration.MaxPlaneAcceleration, Configuration.MaxPlaneSpeed);
            var plan = builder.Build();

            _panel.Cnc.SEND(plan);
        }