Source code for device.magnets_motors

from . import base


[docs] class MagnetsMotors(base.ArduinoMotorsBase): def __init__(self, calibfile, buses=None, limits_enabled=True, **kwargs): super().__init__(calibfile, buses, limits_enabled, **kwargs) # ==== Inherited abstract methods ==== def _defaultstate(self): self._position = {key: 0 for key in self._ardu} def _disconnect(self): super()._disconnect() # Overriding parent function - There are no sensors of position so we need # to manage the self._position property manually. @base.compound_command def _move(self, motor_id, distance, check_limits=True): super()._move(motor_id, distance, check_limits) self._position[motor_id] += distance # Overriding parent function - --""--
[docs] @base.compound_command def homing(self): """Execute homing procedure for each of the motors.""" super().homing() for motor_id in self._ardu: self._position[motor_id] = 0
# ==== Private commands ==== # ==== Commands ====
[docs] @base.compound_command def wire_moveto(self, position): """Move WIRE to position [mm].""" self.moveto("D", position)
[docs] @base.compound_command def probe_moveto(self, position): """Move motorized PROBE to position [mm].""" self.moveto("C", position)
# ==== Related to DeviceClient ====
[docs] def update_frontend(self, device_client): for key, name in [("D", "Wire"), ("C", "Probe")]: self._idleupdate_position(key) # This serves no purpose (no position sensors) value = self._position[key] device_client.emit("value", { "value": value, "formatted": "{:.2f} mm".format(value), "label": name, "min": min(self.limits(key)), "max": max(self.limits(key)), "id": "position_" + key })