herosdevices.hardware.newport.picomotor
=======================================

.. py:module:: herosdevices.hardware.newport.picomotor

.. autoapi-nested-parse::

   HEROS driver for newport picomotors.





Module Contents
---------------

.. py:class:: MotorType

   Bases: :py:obj:`enum.IntEnum`


   Motor types supported by Picomotor controller 8742.


   .. py:attribute:: UNCONNECTED
      :value: 0



   .. py:attribute:: UNKNOWN
      :value: 1



   .. py:attribute:: TINY
      :value: 2



   .. py:attribute:: STANDARD
      :value: 3



.. py:class:: PicomotorController8742(host: str, port: int = 23, timeout: int = 5000)

   Bases: :py:obj:`herosdevices.core.templates.SerialDeviceTemplate`


   HEROS driver for 4-channel picomotor controller 8742.

   :param host: IP address of the controller, e.g. "192.168.1.42".
   :param port: listening port, typically 23.


   .. py:attribute:: MIN_AXIS
      :value: 1



   .. py:attribute:: MAX_AXIS
      :value: 4



   .. py:attribute:: identifier
      :type:  str


   .. py:method:: send_command(command: str, axis: int | None = None, argument: int | str | None = None) -> None

      Send a command to the controller.

      :param command: the command string.
      :param axis: the axis the command is to be executed on. Not required for global commands.
      :param argument: arguments to the command if required.



   .. py:method:: query_for_int(query: str, axis: int | None = None) -> int | None

      Query an integer from the controller.

      :param query: the query command.
      :param axis: the axis the command is to be executed on. Not required for global queries.



   .. py:method:: query_for_string(query: str, axis: int | None = None) -> str

      Query a string from the controller.

      :param query: the query command.
      :param axis: the axis the command is to be executed on. Not required for global queries.



   .. py:method:: query_error() -> tuple[int, str]

      Query the latest error from the controller.

      Upon reading, errors are cleared from the controller's buffer and thus can only be read once.

      :returns: tuple (error code, error message). The first digit of the error code indicates the axis the error has
                occured on.



   .. py:method:: reset() -> None

      Soft reset the controller.

      .. note:: Connection will be interrupted.



   .. py:method:: abort_motion() -> None

      Stop any motion immediately without deceleration.



   .. py:attribute:: address


   .. py:attribute:: connection


.. py:class:: Picomotor(controller: PicomotorController8742, axis: int)

   HEROS driver for a single Picomotor.

   :param controller: RemoteHERO of the controller the motor is attached to.
   :param axis: port of the controller. Available axes are 1,2,3,4.


   .. py:attribute:: MIN_VELOCITY
      :value: 1



   .. py:attribute:: MAX_VELOCITY
      :value: 2000



   .. py:attribute:: MIN_ACCELERATION
      :value: 1



   .. py:attribute:: MAX_ACCELERATION
      :value: 200000



   .. py:attribute:: MIN_STEP_COUNT
      :value: -2147483648



   .. py:attribute:: MAX_STEP_COUNT
      :value: 2147483647



   .. py:attribute:: controller


   .. py:attribute:: axis


   .. py:property:: velocity
      :type: int


      Query the velocity.

      :returns: velocity in steps/second.


   .. py:property:: acceleration
      :type: int


      Query the acceleration.

      :returns: acceleration in steps/second².


   .. py:property:: home_position
      :type: int


      Query the home position.

      All absolute moves are relative to "home".

      :returns: step count considered home.


   .. py:property:: motion_done
      :type: bool


      Check if a move is in progress.

      :returns: True when no movement is in progrogress.


   .. py:method:: move_indefinite(direction: int) -> None

      Start a movement.

      The motor will move indefinitely until a :meth:`stop_motion` command is issued.

      :param direction: positive value for increasing step count, negative for decreasing.



   .. py:method:: move_absolute(target_position: int) -> None

      Move to the desired step count.

      :param target_position: absolute position relative to "home" (see :meth:`set_home_position`). Must be within
                              [-2_147_483_648, 2_147_483_647]



   .. py:method:: move_relative(steps: int) -> None

      Move relative by the desired step count.

      :param steps: amount of steps to move by. Must be within [-2_147_483_648, 2_147_483_647].



   .. py:property:: target_position
      :type: int


      Query the target position of the current move.

      :returns: target step count of the current move.


   .. py:property:: actual_position
      :type: int


      Query the position of the motor.

      :returns: current step count of the motor.


   .. py:method:: stop_motion() -> None

      Stop the movement.



   .. py:property:: motor_type
      :type: MotorType


      Query the type of Motor.

      :returns: motor type as specified in :class:`MotorType`


