Skip to content

dummy

frog.hardware.plugins.stepper_motor.dummy ¤

Code for a fake stepper motor device.

Classes¤

DummyStepperMotor(steps_per_rotation=3600, move_duration=0.0) ¤

Bases: StepperMotorBase

A fake stepper motor device used for testing the GUI without the hardware.

This class uses a simple timer to notify when the move is complete after a fixed amount of time. It is not sophisticated enough to handle multiple queued moves as the ST10 controller does.

Create a new DummyStepperMotor.

Parameters:

Name Type Description Default
steps_per_rotation int

Number of motor steps for an entire rotation (360°)

3600
move_duration float

Amount of time taken for each move

0.0
Source code in frog/hardware/plugins/stepper_motor/dummy.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
def __init__(
    self, steps_per_rotation: int = 3600, move_duration: float = 0.0
) -> None:
    """Create a new DummyStepperMotor.

    Args:
        steps_per_rotation: Number of motor steps for an entire rotation (360°)
        move_duration: Amount of time taken for each move
    """
    if steps_per_rotation < 1:
        raise ValueError("steps_per_rotation must be at least one")
    if move_duration < 0.0:
        raise ValueError("move_duration cannot be negative")

    self._move_end_timer = QTimer()
    self._move_end_timer.setSingleShot(True)
    self._move_end_timer.setInterval(round(move_duration * 1000))
    self._move_end_timer.timeout.connect(self._on_move_end)

    self._steps_per_rotation = steps_per_rotation
    self._step = self._new_step = 0

    super().__init__()
Attributes¤
is_moving property ¤

Whether the motor is currently moving.

step property writable ¤

The current state of the device's step counter.

steps_per_rotation property ¤

The number of steps that correspond to a full rotation.

Functions¤
stop_moving() ¤

Immediately stop moving the motor.

Source code in frog/hardware/plugins/stepper_motor/dummy.py
77
78
79
80
81
def stop_moving(self) -> None:
    """Immediately stop moving the motor."""
    logging.info("Stopping motor")
    self._move_end_timer.stop()
    self._on_move_end()