Пример #1
0
        private void executePlan()
        {
            if (!Cnc.IsHomeCalibrated)
            {
                ShowError("Calibration is required!");
                return;
            }

            disableChanges();

            var state           = Cnc.PlannedState;
            var currentPosition = PlanBuilder3D.GetPosition(state);

            var startPoint = Workspace.EntryPoint;
            var start      = new Point3Dmm(startPoint.PositionX, startPoint.PositionY, _zLevel);
            var aboveStart = new Point3Dmm(start.X, start.Y, currentPosition.Z);

            var builder = new PlanBuilder3D(currentPosition.Z, _zLevel, Workspace.CuttingSpeed, Configuration.MaxPlaneSpeed, Configuration.MaxPlaneAcceleration);

            builder.SetPosition(currentPosition);

            builder.AddRampedLine(aboveStart);

            try
            {
                if (_zLevel <= aboveStart.Z)
                {
                    throw new PlanningException("Level Z is above the current position.");
                }

                Workspace.BuildPlan(builder);
            }
            catch (PlanningException ex)
            {
                planCompleted();
                ShowError(ex.Message);
                return;
            }

            var plan = builder.Build();

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

            CheckEngineDialog.WaitForConfirmation(() =>
            {
                executePlan(builder);
            });
        }
Пример #2
0
        private void GoToZerosXY_Click(object sender, RoutedEventArgs e)
        {
            disableChanges();

            var position = getCurrentPosition();
            var speed    = ControllerCNC.Primitives.Speed.FromMilimetersPerSecond(getCuttingSpeed());
            var builder  = new PlanBuilder3D(position.Z, position.Z, speed, Configuration.MaxPlaneSpeed, Configuration.MaxPlaneAcceleration);

            builder.SetPosition(position);
            builder.AddRampedLine(new Point2Dmm(_positionOffsetX, Workspace.RangeY - _positionOffsetY));

            executePlan(builder);
        }
Пример #3
0
        private void executePlan()
        {
            if (!Cnc.IsHomeCalibrated)
            {
                ShowError("Calibration is required!");
                return;
            }

            disableMotionCommands();
            Workspace.DisableChanges();

            var state           = Cnc.PlannedState;
            var currentPosition = PlanBuilder3D.GetPosition(state);

            var startPoint = Workspace.EntryPoint;
            var start      = new Point3Dmm(startPoint.PositionX, startPoint.PositionY, _zLevel);
            var aboveStart = new Point3Dmm(start.X, start.Y, currentPosition.Z);

            var builder = new PlanBuilder3D(currentPosition.Z, _zLevel, Workspace.CuttingSpeed, Configuration.MaxPlaneSpeed, Configuration.MaxPlaneAcceleration);

            builder.SetPosition(currentPosition);

            builder.AddRampedLine(aboveStart);

            try
            {
                if (_zLevel <= aboveStart.Z)
                {
                    throw new PlanningException("Level Z is above the current position.");
                }

                Workspace.BuildPlan(builder);
            }
            catch (PlanningException ex)
            {
                planCompleted();
                ShowError(ex.Message);
                return;
            }

            var plan = builder.Build();

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

            CheckEngineDialog.WaitForConfirmation(() =>
            {
                /**/
                builder.SetStreamingCuttingSpeed(getCuttingSpeed());
                builder.StreamingIsComplete += planCompleted;/*/
                                                              * Cnc.SEND(plan);
                                                              * Cnc.OnInstructionQueueIsComplete += planCompleted;/**/
                _streamingBuilder            = builder;
                _planStart = DateTime.Now;
                builder.StreamInstructions(Cnc);
                this.Focus();
            });
        }