Skip to content

Commit f3e19ec

Browse files
committed
Simplify nResponses calculation in Motor class
Replaced multiple type checks for axisToMove with a single calculation using the length of payload['motor'] to determine nResponses. This streamlines the code and improves maintainability.
1 parent d19e8b5 commit f3e19ec

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

uc2rest/motor.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -549,14 +549,7 @@ def move_stepper(self, steps=(0,0,0,0), speed=(1000,1000,1000,1000), is_absolute
549549
self.isRunning = True
550550
is_blocking = not self._parent.is_wifi and is_blocking and self._parent.serial.is_connected
551551
timeout = timeout if is_blocking else 0
552-
if type(axisToMove) == list:
553-
nResponses = len(axisToMove)+1 # we get the command received flag + a return for every axis
554-
elif type(axisToMove) == tuple:
555-
nResponses = axisToMove[0].shape[0]+1
556-
elif type(axisToMove) == np.ndarray:
557-
nResponses = axisToMove.shape[0] +1
558-
else:
559-
nResponses = 2
552+
nResponses = len(payload["motor"])+1
560553
# if we get a return, we will receive the latest position feedback from the driver by means of the axis that moves the longest
561554
r = self._parent.post_json(path, payload, getReturn=is_blocking, timeout=timeout, nResponses=nResponses)
562555

0 commit comments

Comments
 (0)