コード例 #1
0
ファイル: RouterPanel.xaml.cs プロジェクト: xiaodelea/FullCNC
        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 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();
            });
        }