Beispiel #1
0
        public async Task SlewAxisToAsync(MountAxis axis, double targetPosition)
        {
            // Update our stored axes
            await this._mountControl.QueryStatus(axis).ConfigureAwait(false);

            var deltaAngle = targetPosition - this._mountInfo.MountState.AxisPositions[(int)axis];

            var stepsToMove = Conversion.AngleToStep(this._mountInfo.MountState.StepCoefficients[(int)axis].FactorRadToStep, deltaAngle);

            // Nothing to do
            if (stepsToMove == 0)
            {
                return;
            }

            MotionModeHiBitFlags directionOnClock;

            if (stepsToMove > 0)
            {
                directionOnClock = MotionModeHiBitFlags.None;
                this._mountInfo.MountState.AxesStatus[(int)axis].SlewingClockWise = true;
            }
            else
            {
                directionOnClock = MotionModeHiBitFlags.DirectionOnClock;
                this._mountInfo.MountState.AxesStatus[(int)axis].SlewingClockWise = false;
            }

            stepsToMove = Math.Abs(stepsToMove);

            // Check if it's far enough that we should go at ludicrous speed
            if (stepsToMove > this._mountInfo.MountState.StepCoefficients[(int)axis].LowSpeedGotoMargin)
            {
                await this._mountControl.SetMotionMode(axis, MotionModeLoBitFlags.GotoModeFast, directionOnClock).ConfigureAwait(false);

                this._mountInfo.MountState.AxesStatus[(int)axis].HighSpeed = true;
            }
            else
            {
                await this._mountControl.SetMotionMode(axis, MotionModeLoBitFlags.GotoModeSlow, directionOnClock).ConfigureAwait(false);

                this._mountInfo.MountState.AxesStatus[(int)axis].HighSpeed = false;
            }

            await this._mountControl.SetGotoTargetIncrement(axis, stepsToMove).ConfigureAwait(false);

            await this._mountControl.SetBreakPointIncrement(axis, this._mountInfo.MountState.BreakSteps[(int)axis]).ConfigureAwait(false);

            await this._mountControl.StartMotion(axis).ConfigureAwait(false);
        }