ASCOM Relative Focuser and MaxIncrement

Issue #1261 resolved
GeneN created an issue

When using ASCOM interface with a Relative Focuser the MaxIncrement provided by the driver is not honored.

https://ascom-standards.org/Help/Developer/html/M_ASCOM_DriverAccess_Focuser_Move.htm

“If the Absolute property is False, then this is a relative positioning focuser. The Move command tells the focuser to move in a relative direction, and the Position parameter of the Move method (in this case, step distance) is an integer between minus MaxIncrement and plus MaxIncrement.”

ASCOM log:

07:50:53.615 Absolute Get GET Absolute - COM
07:50:53.615 Absolute Get False

07:50:53.623 MaxIncrement Get 20

07:51:01.656 Move Start
07:51:01.656 Move Parameter: 250
07:51:01.656 Move Calling Move - it is a COM object

Source code affected:

AscomFocuser.cs

moveAmount = Math.Min(MaxStep, Math.Abs(relativeOffsetRemaining));

Does not account for MaxIncrement only MaxStep

    public Task Move(int position, CancellationToken ct, int waitInMs = 1000) {
        if (_isAbsolute) {
            return MoveInternalAbsolute(position, ct, waitInMs);
        } else {
            return MoveInternalRelative(position, ct, waitInMs);
        }
    }


    private async Task MoveInternalRelative(int position, CancellationToken ct, int waitInMs = 1000) {
        if (Connected) {
            var reEnableTempComp = TempComp;
            if (reEnableTempComp) {
                TempComp = false;
            }

            var relativeOffsetRemaining = position - this.Position;
            while (relativeOffsetRemaining != 0 && !ct.IsCancellationRequested) {
            var moveAmount = Math.Min(MaxStep, Math.Abs(relativeOffsetRemaining));
                if (relativeOffsetRemaining < 0) {
                    moveAmount *= -1;
                }
                device.Move(moveAmount);

Comments (4)

  1. Stefan B repo owner

    Thank you for the report. Looks like MaxStep just has to be replaced with MaxIncrement, as MaxStep is handled outside of the move method already.

  2. Log in to comment