Example #1
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 Execute(IEnumerable <InstructionCNC> plan, bool duplicateUV = true)
 {
     if (duplicateUV)
     {
         var builder = new PlanBuilder();
         builder.Add(plan);
         builder.DuplicateXYtoUV();
         _cnc.SEND(builder.Build());
     }
     else
     {
         _cnc.SEND(plan);
     }
 }
Example #3
0
        public void SetPosition(int newPosition)
        {
            var steps = newPosition - _currentPosition;

            var builder = new Planning.PlanBuilder();

            //builder.AddRampedSteps(steps, Constants.FastestDeltaT);
            builder.AddConstantSpeedTransitionXY(steps, steps, Configuration.ReverseSafeSpeed);
            builder.DuplicateXYtoUV();
            _cnc.SEND(builder.Build());

            //position setting is blocking for now
            while (_cnc.IncompleteInstructionCount > 0)
            {
                System.Threading.Thread.Sleep(1);
            }

            _currentPosition = newPosition;
        }
        private void sendNewPlan()
        {
            if (_currentDeltaT != _desiredDeltaT)
            {
                _currentDeltaT = _desiredDeltaT;
            }

            var stepCount     = (Int16)(Math.Max(2, 20000 / _currentDeltaT));
            var sendStepCount = Direction ? (Int16)(-stepCount) : stepCount;
            var remainder     = (UInt16)(_desiredDeltaRemainder * stepCount);
            var instruction   = new ConstantInstruction(sendStepCount, _currentDeltaT, remainder);

            _cnc.SEND(Axes.UVXY(instruction, instruction, instruction, instruction));

            var plannedTime = stepCount * _currentDeltaT;

            _plannedTimeTotal += plannedTime;
            _plannedTimes.Enqueue(plannedTime);
        }
        private void sendInstruction(StepInstrution planeInstruction1, StepInstrution planeInstruction2)
        {
            StepInstrution u, v, x, y;

            u = v = x = y = null;

            if (_moveUV)
            {
                u = planeInstruction1;
                v = planeInstruction2;
            }

            if (_moveXY)
            {
                x = planeInstruction1;
                y = planeInstruction2;
            }

            _cnc.SEND(Axes.UVXY(u, v, x, y));
        }