Exemple #1
0
        internal void MoveToCompletedLength(double targetLength)
        {
            targetLength = Math.Max(0, targetLength);
            targetLength = Math.Min(_totalLength, targetLength);

            _currentState.MoveToCompletedLength(targetLength);

            if (_timeEstimationState != null)
            {
                var newState = _currentState.CreateBranch();
                _previewTimeEstimationState = newState;
                _estimationSteps.Add(() => setNewTimeEstimationState(newState));
            }
        }
Exemple #2
0
        internal InstructionCNC GenerateNextInstruction(double desiredSpeed, bool stopRemainingTimeLockstep = false)
        {
            if (_currentState == null)
            {
                _currentState = new PlanStreamerState(_workSegments.ToArray());
                if (_estimationSteps != null)
                {
                    _timeEstimationState = _currentState.CreateBranch();
                    var th = new Thread(_runRemainingTicksEstimation);
                    th.Priority     = ThreadPriority.Lowest;
                    th.IsBackground = true;
                    th.Start();
                }

                _workSegments = null; // prevent modifications after generation started
            }

            var instruction = _currentState.GenerateNextInstruction(desiredSpeed);

            if (_timeEstimationState != null && !stopRemainingTimeLockstep)
            {
                if (!_wasEstimationLockstepDisabled && desiredSpeed == _previewEstimationDesiredSpeed)
                {
                    _estimationSteps.Add(() =>
                    {
                        moveEstimationByNextInstruction(desiredSpeed);
                    });
                }
                else
                {
                    _previewEstimationDesiredSpeed = desiredSpeed;
                    var newState = _currentState.CreateBranch();
                    _previewTimeEstimationState = newState;
                    _estimationSteps.Add(() =>
                    {
                        _lastEstimationDesiredSpeed = desiredSpeed;
                        setNewTimeEstimationState(newState);
                    });
                }
            }

            _wasEstimationLockstepDisabled = stopRemainingTimeLockstep;

            return(instruction);
        }
Exemple #3
0
 private void setNewTimeEstimationState(PlanStreamerState state)
 {
     _timeEstimationState = state;
     recalculateRemainingTime();
 }