pnpq.devices package

Contents

pnpq.devices package#

Submodules#

pnpq.devices.odl_ozoptics_650ml module#

class pnpq.devices.odl_ozoptics_650ml.OdlOzOptics(serial_port=None, serial_number=None)#

Bases: OpticalDelayLine

Parameters:
  • serial_port (str | None)

  • serial_number (str | None)

connect()#
Return type:

None

echo(on_off)#
Parameters:

on_off (int)

Return type:

str

forward()#
Return type:

str

get_device_info()#
Return type:

tuple[str, str]

get_mfg_date()#
Return type:

str

get_serial()#
Return type:

str

get_step()#
Return type:

int

home()#
Return type:

str

move(dist)#
Parameters:

dist (float)

Return type:

None

oz_mode(on_off)#
Parameters:

on_off (int)

Return type:

str

read_key(key, retries=5)#
Parameters:
  • key (str)

  • retries (int)

Return type:

str

readall()#
Return type:

tuple[bool, str]

reset()#
Return type:

str

resolution#

32768 steps per motor revolution(5.08 mm = 2xDistance Travel or mirror travel per pitch 0.1 inch)

reverse()#
Return type:

str

serial_close()#
Return type:

None

serial_command(serial_cmd)#
Parameters:

serial_cmd (str)

Return type:

str

serial_read()#
Return type:

str

serial_send(serial_cmd)#
Parameters:

serial_cmd (str)

Return type:

None

set_step(value)#
Parameters:

value (int)

Return type:

str

start_burn_in(parameter)#
Parameters:

parameter (int)

Return type:

str

stop()#
Return type:

str

write_hw_version(parameter)#
Parameters:

parameter (int)

Return type:

str

write_mfg_date(parameter)#
Parameters:

parameter (int)

Return type:

str

write_name(parameter)#
Parameters:

parameter (int)

Return type:

str

write_serial(parameter)#
Parameters:

parameter (int)

Return type:

str

write_to_flash()#
Return type:

str

pnpq.devices.odl_thorlabs_kbd101 module#

class pnpq.devices.odl_thorlabs_kbd101.AbstractOpticalDelayLineThorlabsKBD101#

Bases: ABC

abstract get_homeparams()#

Request home parameters from the device.

Return type:

OpticalDelayLineHomeParams

abstract get_jogparams()#

Request jog parameters from the device.

Return type:

OpticalDelayLineJogParams

abstract get_status()#

Request the latest status message from the device.

Return type:

AptMessage_MGMSG_MOT_GET_USTATUSUPDATE

abstract get_velparams()#

Request velocity parameters from the device.

Return type:

OpticalDelayLineVelocityParams

abstract home()#

Move the device to home position.

Return type:

None

abstract identify()#

Identifies the device represented by this instance by flashing the light on the device.

Parameters:

chan_ident – The motor channel to identify.

Return type:

None

abstract jog(jog_direction)#

Jog the device in a certain direction.

Parameters:

jog_direction (JogDirection) – The direction to jog in.

Return type:

None

abstract move_absolute(position)#

Move the device to the specified position.

Parameters:

position (Quantity) – The angle to move to.

Return type:

None

abstract set_homeparams(home_direction=None, limit_switch=None, home_velocity=None, offset_distance=None)#

Set home parameters on the device.

Parameters:
  • home_direction (None | HomeDirection) – The home direction.

  • limit_switch (None | LimitSwitch) – The limit switch.

  • home_velocity (None | Quantity) – The home velocity.

  • offset_distance (None | Quantity) – The offset distance.

Return type:

None

abstract set_jogparams(jog_mode=None, jog_step_size=None, jog_minimum_velocity=None, jog_acceleration=None, jog_maximum_velocity=None, jog_stop_mode=None)#

Set jog parameters on the device.

Parameters:
  • jog_mode (JogMode | None) – The jog mode.

  • jog_step_size (Quantity | None) – The jog step size.

  • jog_minimum_velocity (Quantity | None) – The minimum velocity.

  • jog_acceleration (Quantity | None) – The acceleration.

  • jog_maximum_velocity (Quantity | None) – The maximum velocity.

  • jog_stop_mode (StopMode | None) – The stop mode.

Return type:

None

abstract set_velparams(minimum_velocity=None, acceleration=None, maximum_velocity=None)#

Set velocity parameters on the device.

Parameters:
  • minimum_velocity (None | Quantity) – The minimum velocity. According to the documentation, this should always be 0. Therefore this parameter can be left unused.

  • acceleration (None | Quantity) – The acceleration.

  • maximum_velocity (None | Quantity) – The maximum velocity.

Return type:

None

class pnpq.devices.odl_thorlabs_kbd101.OpticalDelayLineHomeParams#

Bases: TypedDict

TypedDict for ODL home parameters. Used in the get_homeparams method.

home_direction: HomeDirection#
home_velocity: Quantity#

Dimensionality must be ([length] / time) or kbd101_velocity

limit_switch: LimitSwitch#

The limit switch associated with the home position

offset_distance: Quantity#

Dimensionality must be [length] or kbd101_position

class pnpq.devices.odl_thorlabs_kbd101.OpticalDelayLineJogParams#

Bases: TypedDict

TypedDict for optical delay line jog parameters. Used in the get_jogparams method.

jog_acceleration: Quantity#

Dimensionality must be ([length] / [time] ** 2) or kbd101_acceleration

jog_maximum_velocity: Quantity#

Dimensionality must be ([length] / [time]) or kbd101_velocity

jog_minimum_velocity: Quantity#

Dimensionality must be ([length] / [time]) or kbd101_velocity

jog_mode: JogMode#

Jog mode can be continuous jogging or single step jogging.

jog_step_size: Quantity#

Dimensionality must be [length] or kbd101_position

jog_stop_mode: StopMode#

Stop mode can be immediate (abrupt) stop or profiled stop (with controlled deceleration)

class pnpq.devices.odl_thorlabs_kbd101.OpticalDelayLineThorlabsKBD101(*, connection: pnpq.apt.connection.AptConnection, home_on_init: bool = True, tx_poller_thread_lock: _thread.lock = <factory>)#

Bases: AbstractOpticalDelayLineThorlabsKBD101

Parameters:
  • connection (AptConnection)

  • home_on_init (bool)

  • tx_poller_thread_lock (lock)

connection: AptConnection#
get_homeparams()#

Request home parameters from the device.

Return type:

OpticalDelayLineHomeParams

get_jogparams()#

Request jog parameters from the device.

Return type:

OpticalDelayLineJogParams

get_status()#

Request the latest status message from the device.

Return type:

AptMessage_MGMSG_MOT_GET_USTATUSUPDATE

get_velparams()#

Request velocity parameters from the device.

Return type:

OpticalDelayLineVelocityParams

home()#

Move the device to home position.

Return type:

None

home_on_init: bool = True#
identify()#

Identifies the device represented by this instance by flashing the light on the device.

Parameters:

chan_ident – The motor channel to identify.

Return type:

None

jog(jog_direction)#

Jog the device in a certain direction.

Parameters:

jog_direction (JogDirection) – The direction to jog in.

Return type:

None

log = <BoundLoggerLazyProxy(logger=None, wrapper_class=None, processors=None, context_class=None, initial_values={}, logger_factory_args=())>#
move_absolute(position)#

Move the device to the specified position.

Parameters:

position (Quantity) – The angle to move to.

Return type:

None

set_channel_enabled(enabled)#
Parameters:

enabled (bool)

Return type:

None

set_homeparams(home_direction=None, limit_switch=None, home_velocity=None, offset_distance=None)#

Set home parameters on the device.

Parameters:
  • home_direction (None | HomeDirection) – The home direction.

  • limit_switch (None | LimitSwitch) – The limit switch.

  • home_velocity (None | Quantity) – The home velocity.

  • offset_distance (None | Quantity) – The offset distance.

Return type:

None

set_jogparams(jog_mode=None, jog_step_size=None, jog_minimum_velocity=None, jog_acceleration=None, jog_maximum_velocity=None, jog_stop_mode=None)#

Set jog parameters on the device.

Parameters:
  • jog_mode (JogMode | None) – The jog mode.

  • jog_step_size (Quantity | None) – The jog step size.

  • jog_minimum_velocity (Quantity | None) – The minimum velocity.

  • jog_acceleration (Quantity | None) – The acceleration.

  • jog_maximum_velocity (Quantity | None) – The maximum velocity.

  • jog_stop_mode (StopMode | None) – The stop mode.

Return type:

None

set_velparams(minimum_velocity=None, acceleration=None, maximum_velocity=None)#

Set velocity parameters on the device.

Parameters:
  • minimum_velocity (None | Quantity) – The minimum velocity. According to the documentation, this should always be 0. Therefore this parameter can be left unused.

  • acceleration (None | Quantity) – The acceleration.

  • maximum_velocity (None | Quantity) – The maximum velocity.

Return type:

None

tx_poll()#
Return type:

None

tx_poller_thread: Thread#
tx_poller_thread_lock: lock#
class pnpq.devices.odl_thorlabs_kbd101.OpticalDelayLineVelocityParams#

Bases: TypedDict

TypedDict for ODL velocity parameters. Used in get_velparams method.

acceleration: Quantity#

Dimensionality must be ([length] / [time] ** 2) or kbd101_acceleration

maximum_velocity: Quantity#

Dimensionality must be ([length] / [time]) or kbd101_velocity

minimum_velocity: Quantity#

Dimensionality must be ([length] / [time]) or kbd101_velocity

pnpq.devices.odl_thorlabs_kbd101_stub module#

class pnpq.devices.odl_thorlabs_kbd101_stub.OpticalDelayLineThorlabsKBD101Stub#

Bases: AbstractOpticalDelayLineThorlabsKBD101

current_home_params: OpticalDelayLineHomeParams#
current_jog_params: OpticalDelayLineJogParams#
current_state: dict[ChanIdent, Quantity]#
current_velocity_params: OpticalDelayLineVelocityParams#
get_homeparams()#

Request home parameters from the device.

Return type:

OpticalDelayLineHomeParams

get_jogparams()#

Request jog parameters from the device.

Return type:

OpticalDelayLineJogParams

get_status()#

Request the latest status message from the device.

Return type:

AptMessage_MGMSG_MOT_GET_USTATUSUPDATE

get_velparams()#

Request velocity parameters from the device.

Return type:

OpticalDelayLineVelocityParams

home()#

Move the device to home position.

Return type:

None

identify()#

Identifies the device represented by this instance by flashing the light on the device.

Parameters:

chan_ident – The motor channel to identify.

Return type:

None

jog(jog_direction)#

Jog the device in a certain direction.

Parameters:

jog_direction (JogDirection) – The direction to jog in.

Return type:

None

log = <BoundLoggerLazyProxy(logger=None, wrapper_class=None, processors=None, context_class=None, initial_values={}, logger_factory_args=())>#
move_absolute(position)#

Move the device to the specified position.

Parameters:

position (Quantity) – The angle to move to.

Return type:

None

set_homeparams(home_direction=None, limit_switch=None, home_velocity=None, offset_distance=None)#

Set home parameters on the device.

Parameters:
  • home_direction (HomeDirection | None) – The home direction.

  • limit_switch (LimitSwitch | None) – The limit switch.

  • home_velocity (Quantity | None) – The home velocity.

  • offset_distance (Quantity | None) – The offset distance.

Return type:

None

set_jogparams(jog_mode=None, jog_step_size=None, jog_minimum_velocity=None, jog_acceleration=None, jog_maximum_velocity=None, jog_stop_mode=None)#

Set jog parameters on the device.

Parameters:
  • jog_mode (JogMode | None) – The jog mode.

  • jog_step_size (Quantity | None) – The jog step size.

  • jog_minimum_velocity (Quantity | None) – The minimum velocity.

  • jog_acceleration (Quantity | None) – The acceleration.

  • jog_maximum_velocity (Quantity | None) – The maximum velocity.

  • jog_stop_mode (StopMode | None) – The stop mode.

Return type:

None

set_velparams(minimum_velocity=None, acceleration=None, maximum_velocity=None)#

Set velocity parameters on the device.

Parameters:
  • minimum_velocity (None | Quantity) – The minimum velocity. According to the documentation, this should always be 0. Therefore this parameter can be left unused.

  • acceleration (None | Quantity) – The acceleration.

  • maximum_velocity (None | Quantity) – The maximum velocity.

Return type:

None

pnpq.devices.optical_delay_line module#

class pnpq.devices.optical_delay_line.OpticalDelayLine(port=None, serial_number=None)#

Bases: object

represents optical delay line devices. all ODL classes must inherit this class.

Parameters:
  • port (str | None)

  • serial_number (str | None)

conn: Serial#

represents a Serial connection

device_sn: str | None#

device’s serial number

name: str#
port: str | None#

initialize ODL class

pnpq.devices.polarization_controller_thorlabs_mpc module#

class pnpq.devices.polarization_controller_thorlabs_mpc.AbstractPolarizationControllerThorlabsMPC#

Bases: ABC

abstract get_params()#

Get the parameters of the device represented by this instance.

Returns:

The set of parameters in a dictionary defined in PolarizationControllerParams.

Return type:

PolarizationControllerParams

abstract get_status(chan_ident)#

Fetch the status of a single channel.

Parameters:

chan_ident (ChanIdent) – The motor channel to fetch status for.

Returns:

The message returned by the device, in AptMessage_MGMSG_MOT_GET_USTATUSUPDATE

Return type:

AptMessage_MGMSG_MOT_GET_USTATUSUPDATE

abstract get_status_all()#

Fetch the latest status of all channels on the device.

Returns:

A tuple of AptMessage_MGMSG_MOT_GET_USTATUSUPDATE, one for each channel.

Return type:

tuple[AptMessage_MGMSG_MOT_GET_USTATUSUPDATE, …]

abstract home(chan_ident)#

Move the device to home position.

The home position can be customized using the set_params() function.

Parameters:

chan_ident (ChanIdent) – The motor channel to set to home.

Return type:

None

abstract identify(chan_ident)#

Identifies the device represented by this instance by flashing the LED light on the device.

Parameters:

chan_ident (ChanIdent) – The motor channel to identify.

Return type:

None

abstract jog(chan_ident, jog_direction)#

Jogs the device forward or backwards in small steps. Experimentally, jog steps of 50 or greater seem to work the best.

The specific number of steps per jog can be set via the set_params() function.

Parameters:
  • chan_ident (ChanIdent) – The motor channel to jog.

  • jog_direction (JogDirection) – The direction the paddle should move in.

Return type:

None

abstract move_absolute(chan_ident, position)#

Move the device to an absolute position.

Parameters:
  • chan_ident (ChanIdent) – The motor channel to move.

  • position (Quantity) – The angle to move the device. The unit must be in mpc320_step or in a compatible angle unit. The move position must be within 0 and 170 degrees (or equivalent).

Return type:

None

abstract set_channel_enabled(chan_ident, enabled)#

Enables or disables the specified motor channel. End users will not typically use this command. Instead, commands that require a channel to be enabled will automatically enable the channel before executing, and disable the channel when complete.

Parameters:
  • chan_ident (ChanIdent) – The motor channel to enable.

  • enabled (bool) – Set to True to enable the channel, or False to disable.

Return type:

None

abstract set_params(velocity=None, home_position=None, jog_step_1=None, jog_step_2=None, jog_step_3=None)#

Update the parameters of the device.

All parameters of this function are optional. Only fields with values are updated on the device.

Parameters:
  • velocity (None | Quantity) – The rotational velocity. Applies to all channels. Unit must be convertible to mpc320_velocity.

  • home_position (None | Quantity) – The position where the device will move to when the home() function is called. Unit must be convertible to mpc320_step.

  • jog_step_1 (None | Quantity) – The amount which the jog function will move for channel 1. Unit must be convertible to mpc320_step.

  • jog_step_2 (None | Quantity) – The amount which the jog function will move for channel 2. Unit must be convertible to mpc320_step.

  • jog_step_3 (None | Quantity) – The amount which the jog function will move for channel 3. Unit must be convertible to mpc320_step.

Return type:

None

class pnpq.devices.polarization_controller_thorlabs_mpc.PolarizationControllerParams#

Bases: TypedDict

home_position: Quantity#

Dimensionality must be [angle] or mpc320_step

jog_step_1: Quantity#

Dimensionality must be [angle] or mpc320_step

jog_step_2: Quantity#

Dimensionality must be [angle] or mpc320_step

jog_step_3: Quantity#

Dimensionality must be [angle] or mpc320_step

velocity: Quantity#

Dimensionality must be ([angle] / [time]) or mpc320_velocity

class pnpq.devices.polarization_controller_thorlabs_mpc.PolarizationControllerThorlabsMPC(*, connection: pnpq.apt.connection.AptConnection, tx_poller_thread_lock: _thread.lock = <factory>, available_channels: frozenset[pnpq.apt.protocol.ChanIdent] = frozenset())#

Bases: AbstractPolarizationControllerThorlabsMPC

Parameters:
available_channels: frozenset[ChanIdent] = frozenset({})#
connection: AptConnection#
get_params()#

Get the parameters of the device represented by this instance.

Returns:

The set of parameters in a dictionary defined in PolarizationControllerParams.

Return type:

PolarizationControllerParams

get_status(chan_ident)#

Fetch the status of a single channel.

Parameters:

chan_ident (ChanIdent) – The motor channel to fetch status for.

Returns:

The message returned by the device, in AptMessage_MGMSG_MOT_GET_USTATUSUPDATE

Return type:

AptMessage_MGMSG_MOT_GET_USTATUSUPDATE

get_status_all()#

Fetch the latest status of all channels on the device.

Returns:

A tuple of AptMessage_MGMSG_MOT_GET_USTATUSUPDATE, one for each channel.

Return type:

tuple[AptMessage_MGMSG_MOT_GET_USTATUSUPDATE, …]

home(chan_ident)#

Move the device to home position.

The home position can be customized using the set_params() function.

Parameters:

chan_ident (ChanIdent) – The motor channel to set to home.

Return type:

None

identify(chan_ident)#

Identifies the device represented by this instance by flashing the LED light on the device.

Parameters:

chan_ident (ChanIdent) – The motor channel to identify.

Return type:

None

jog(chan_ident, jog_direction)#

Jogs the device forward or backwards in small steps. Experimentally, jog steps of 50 or greater seem to work the best.

The specific number of steps per jog can be set via the set_params() function.

Parameters:
  • chan_ident (ChanIdent) – The motor channel to jog.

  • jog_direction (JogDirection) – The direction the paddle should move in.

Return type:

None

log = <BoundLoggerLazyProxy(logger=None, wrapper_class=None, processors=None, context_class=None, initial_values={}, logger_factory_args=())>#
move_absolute(chan_ident, position)#

Move the device to an absolute position.

Parameters:
  • chan_ident (ChanIdent) – The motor channel to move.

  • position (Quantity) – The angle to move the device. The unit must be in mpc320_step or in a compatible angle unit. The move position must be within 0 and 170 degrees (or equivalent).

Return type:

None

set_channel_enabled(chan_ident, enabled)#

Enables or disables the specified motor channel. End users will not typically use this command. Instead, commands that require a channel to be enabled will automatically enable the channel before executing, and disable the channel when complete.

Parameters:
  • chan_ident (ChanIdent) – The motor channel to enable.

  • enabled (bool) – Set to True to enable the channel, or False to disable.

Return type:

None

set_params(velocity=None, home_position=None, jog_step_1=None, jog_step_2=None, jog_step_3=None)#

Update the parameters of the device.

All parameters of this function are optional. Only fields with values are updated on the device.

Parameters:
  • velocity (None | Quantity) – The rotational velocity. Applies to all channels. Unit must be convertible to mpc320_velocity.

  • home_position (None | Quantity) – The position where the device will move to when the home() function is called. Unit must be convertible to mpc320_step.

  • jog_step_1 (None | Quantity) – The amount which the jog function will move for channel 1. Unit must be convertible to mpc320_step.

  • jog_step_2 (None | Quantity) – The amount which the jog function will move for channel 2. Unit must be convertible to mpc320_step.

  • jog_step_3 (None | Quantity) – The amount which the jog function will move for channel 3. Unit must be convertible to mpc320_step.

Return type:

None

tx_poll()#
Return type:

None

tx_poller_thread: Thread#
tx_poller_thread_lock: lock#
class pnpq.devices.polarization_controller_thorlabs_mpc.PolarizationControllerThorlabsMPC220(*, connection: pnpq.apt.connection.AptConnection, tx_poller_thread_lock: _thread.lock = <factory>, available_channels: frozenset[pnpq.apt.protocol.ChanIdent] = frozenset({<ChanIdent.CHANNEL_1: 1>, <ChanIdent.CHANNEL_2: 2>}))#

Bases: PolarizationControllerThorlabsMPC

Parameters:
available_channels: frozenset[ChanIdent] = frozenset({<ChanIdent.CHANNEL_1: 1>, <ChanIdent.CHANNEL_2: 2>})#
class pnpq.devices.polarization_controller_thorlabs_mpc.PolarizationControllerThorlabsMPC320(*, connection: pnpq.apt.connection.AptConnection, tx_poller_thread_lock: _thread.lock = <factory>, available_channels: frozenset[pnpq.apt.protocol.ChanIdent] = frozenset({<ChanIdent.CHANNEL_1: 1>, <ChanIdent.CHANNEL_2: 2>, <ChanIdent.CHANNEL_3: 4>}))#

Bases: PolarizationControllerThorlabsMPC

Parameters:
available_channels: frozenset[ChanIdent] = frozenset({<ChanIdent.CHANNEL_1: 1>, <ChanIdent.CHANNEL_2: 2>, <ChanIdent.CHANNEL_3: 4>})#

pnpq.devices.polarization_controller_thorlabs_mpc_stub module#

class pnpq.devices.polarization_controller_thorlabs_mpc_stub.PolarizationControllerThorlabsMPC320Stub(*, available_channels: frozenset[pnpq.apt.protocol.ChanIdent] = frozenset({<ChanIdent.CHANNEL_1: 1>, <ChanIdent.CHANNEL_2: 2>, <ChanIdent.CHANNEL_3: 4>}))#

Bases: AbstractPolarizationControllerThorlabsMPC

Parameters:

available_channels (frozenset[ChanIdent])

available_channels: frozenset[ChanIdent] = frozenset({<ChanIdent.CHANNEL_1: 1>, <ChanIdent.CHANNEL_2: 2>, <ChanIdent.CHANNEL_3: 4>})#
current_params: PolarizationControllerParams#
current_state: dict[ChanIdent, Quantity]#
get_params()#

Get the parameters of the device represented by this instance.

Returns:

The set of parameters in a dictionary defined in PolarizationControllerParams.

Return type:

PolarizationControllerParams

get_status(chan_ident)#

Fetch the status of a single channel.

Parameters:

chan_ident (ChanIdent) – The motor channel to fetch status for.

Returns:

The message returned by the device, in AptMessage_MGMSG_MOT_GET_USTATUSUPDATE

Return type:

AptMessage_MGMSG_MOT_GET_USTATUSUPDATE

get_status_all()#

Fetch the latest status of all channels on the device.

Returns:

A tuple of AptMessage_MGMSG_MOT_GET_USTATUSUPDATE, one for each channel.

Return type:

tuple[AptMessage_MGMSG_MOT_GET_USTATUSUPDATE, …]

home(chan_ident)#

Move the device to home position.

The home position can be customized using the set_params() function.

Parameters:

chan_ident (ChanIdent) – The motor channel to set to home.

Return type:

None

identify(chan_ident)#

Identifies the device represented by this instance by flashing the LED light on the device.

Parameters:

chan_ident (ChanIdent) – The motor channel to identify.

Return type:

None

jog(chan_ident, jog_direction)#

Jogs the device forward or backwards in small steps. Experimentally, jog steps of 50 or greater seem to work the best.

The specific number of steps per jog can be set via the set_params() function.

Parameters:
  • chan_ident (ChanIdent) – The motor channel to jog.

  • jog_direction (JogDirection) – The direction the paddle should move in.

Return type:

None

log = <BoundLoggerLazyProxy(logger=None, wrapper_class=None, processors=None, context_class=None, initial_values={}, logger_factory_args=())>#
move_absolute(chan_ident, position)#

Move the device to an absolute position.

Parameters:
  • chan_ident (ChanIdent) – The motor channel to move.

  • position (Quantity) – The angle to move the device. The unit must be in mpc320_step or in a compatible angle unit. The move position must be within 0 and 170 degrees (or equivalent).

Return type:

None

set_channel_enabled(chan_ident, enabled)#

Enables or disables the specified motor channel. End users will not typically use this command. Instead, commands that require a channel to be enabled will automatically enable the channel before executing, and disable the channel when complete.

Parameters:
  • chan_ident (ChanIdent) – The motor channel to enable.

  • enabled (bool) – Set to True to enable the channel, or False to disable.

Return type:

None

set_params(velocity=None, home_position=None, jog_step_1=None, jog_step_2=None, jog_step_3=None)#

Update the parameters of the device.

All parameters of this function are optional. Only fields with values are updated on the device.

Parameters:
  • velocity (None | Quantity) – The rotational velocity. Applies to all channels. Unit must be convertible to mpc320_velocity.

  • home_position (None | Quantity) – The position where the device will move to when the home() function is called. Unit must be convertible to mpc320_step.

  • jog_step_1 (None | Quantity) – The amount which the jog function will move for channel 1. Unit must be convertible to mpc320_step.

  • jog_step_2 (None | Quantity) – The amount which the jog function will move for channel 2. Unit must be convertible to mpc320_step.

  • jog_step_3 (None | Quantity) – The amount which the jog function will move for channel 3. Unit must be convertible to mpc320_step.

Return type:

None

pnpq.devices.switch_stub module#

class pnpq.devices.switch_stub.Switch#

Bases: object

Stub Switch Device Class

bar_state()#

Sets the optical switch’s state to 1 (bar state)

Return type:

None

connect()#

Establish connection to the device

Return type:

None

cross()#

Sets the optical switch’s state to 2 (cross state)

Return type:

None

log = <BoundLoggerLazyProxy(logger=None, wrapper_class=None, processors=None, context_class=None, initial_values={}, logger_factory_args=())>#

pnpq.devices.switch_thorlabs_osw1310e module#

class pnpq.devices.switch_thorlabs_osw1310e.Switch(serial_port=None, serial_number=None)#

Bases: object

Parameters:
  • serial_port (str | None)

  • serial_number (str | None)

bar_state()#
Return type:

None

connect()#
Return type:

None

cross()#
Return type:

None

pnpq.devices.utils module#

exception pnpq.devices.utils.TimeoutException#

Bases: Exception

pnpq.devices.utils.check_usb_hub_connected()#
Return type:

bool

pnpq.devices.utils.get_available_port(device_serial_number)#
Parameters:

device_serial_number (str)

Return type:

str | None

pnpq.devices.utils.timeout(timeout_seconds)#

Context manager that yields a function that returns True if the timeout has not been exceeded and throws TimeoutException otherwise, making it suitable for use in loops.

timeout_seconds: float length of timeout, in seconds

Parameters:

timeout_seconds (float)

Return type:

Iterator[Callable[[], bool]]

pnpq.devices.waveplate_thorlabs_k10cr1 module#

class pnpq.devices.waveplate_thorlabs_k10cr1.AbstractWaveplateThorlabsK10CR1#

Bases: ABC

abstract get_homeparams()#

Request home parameters from the device.

Return type:

WaveplateHomeParams

abstract get_jogparams()#

Request jog parameters from the device.

Return type:

WaveplateJogParams

abstract get_velparams()#

Request velocity parameters from the device.

Return type:

WaveplateVelocityParams

abstract home()#

Move the waveplate to its home position.

Return type:

None

abstract identify()#

Identify the device by blinking its LED.

Return type:

None

abstract is_homed()#

Check if the device is homed. Sends the REQ_STATUSUPDATE message and checks the HOMED status bit.

Returns True if the device is homed, False otherwise.

Return type:

bool

abstract jog(jog_direction)#

Jog the waveplate in a certain direction.

Parameters:

jog_direction (JogDirection) – The direction to jog in.

Return type:

None

abstract move_absolute(position)#

Move the waveplate to a certain angle.

Parameters:

position (Quantity) – The angle to move to.

Return type:

None

abstract set_homeparams(home_direction=None, limit_switch=None, home_velocity=None, offset_distance=None)#

Set home parameters on the device.

Parameters:
  • home_direction (None | HomeDirection) – The home direction.

  • limit_switch (None | LimitSwitch) – The limit switch.

  • home_velocity (None | Quantity) – The home velocity.

  • offset_distance (None | Quantity) – The offset distance.

Return type:

None

abstract set_jogparams(jog_mode=None, jog_step_size=None, jog_minimum_velocity=None, jog_acceleration=None, jog_maximum_velocity=None, jog_stop_mode=None)#

Set jog parameters on the device.

Parameters:
  • jog_mode (None | JogMode) – The jog mode.

  • jog_step_size (None | Quantity) – The jog step size.

  • jog_minimum_velocity (None | Quantity) – The minimum velocity.

  • jog_acceleration (None | Quantity) – The acceleration.

  • jog_maximum_velocity (None | Quantity) – The maximum velocity.

  • jog_stop_mode (None | StopMode) – The stop mode.

Return type:

None

abstract set_velparams(minimum_velocity=None, acceleration=None, maximum_velocity=None)#

Set velocity parameters on the device.

Parameters:
  • minimum_velocity (None | Quantity) – The minimum velocity. According to the documentation, this should always be 0. Therefore this parameter can be left unused.

  • acceleration (None | Quantity) – The acceleration.

  • maximum_velocity (None | Quantity) – The maximum velocity.

Return type:

None

class pnpq.devices.waveplate_thorlabs_k10cr1.WaveplateHomeParams#

Bases: TypedDict

home_direction: HomeDirection#
home_velocity: Quantity#
limit_switch: LimitSwitch#
offset_distance: Quantity#
class pnpq.devices.waveplate_thorlabs_k10cr1.WaveplateJogParams#

Bases: TypedDict

jog_acceleration: Quantity#
jog_maximum_velocity: Quantity#
jog_minimum_velocity: Quantity#
jog_mode: JogMode#
jog_step_size: Quantity#
jog_stop_mode: StopMode#
class pnpq.devices.waveplate_thorlabs_k10cr1.WaveplateThorlabsK10CR1(*, connection: pnpq.apt.connection.AptConnection, home_on_init: bool = True, tx_poller_thread_lock: _thread.lock = <factory>)#

Bases: AbstractWaveplateThorlabsK10CR1

Parameters:
  • connection (AptConnection)

  • home_on_init (bool)

  • tx_poller_thread_lock (lock)

connection: AptConnection#
get_homeparams()#

Request home parameters from the device.

Return type:

WaveplateHomeParams

get_jogparams()#

Request jog parameters from the device.

Return type:

WaveplateJogParams

get_velparams()#

Request velocity parameters from the device.

Return type:

WaveplateVelocityParams

home()#

Move the waveplate to its home position.

Return type:

None

home_on_init: bool = True#
identify()#

Identify the device by blinking its LED.

Return type:

None

is_homed()#

Check if the device is homed. Sends the REQ_STATUSUPDATE message and checks the HOMED status bit.

Returns True if the device is homed, False otherwise.

Return type:

bool

jog(jog_direction)#

Jog the waveplate in a certain direction.

Parameters:

jog_direction (JogDirection) – The direction to jog in.

Return type:

None

log = <BoundLoggerLazyProxy(logger=None, wrapper_class=None, processors=None, context_class=None, initial_values={}, logger_factory_args=())>#
move_absolute(position)#

Move the waveplate to a certain angle.

Parameters:

position (Quantity) – The angle to move to.

Return type:

None

set_channel_enabled(enabled)#
Parameters:

enabled (bool)

Return type:

None

set_homeparams(home_direction=None, limit_switch=None, home_velocity=None, offset_distance=None)#

Set home parameters on the device.

Parameters:
  • home_direction (HomeDirection | None) – The home direction.

  • limit_switch (LimitSwitch | None) – The limit switch.

  • home_velocity (Quantity | None) – The home velocity.

  • offset_distance (Quantity | None) – The offset distance.

Return type:

None

set_jogparams(jog_mode=None, jog_step_size=None, jog_minimum_velocity=None, jog_acceleration=None, jog_maximum_velocity=None, jog_stop_mode=None)#

Set jog parameters on the device.

Parameters:
  • jog_mode (JogMode | None) – The jog mode.

  • jog_step_size (Quantity | None) – The jog step size.

  • jog_minimum_velocity (Quantity | None) – The minimum velocity.

  • jog_acceleration (Quantity | None) – The acceleration.

  • jog_maximum_velocity (Quantity | None) – The maximum velocity.

  • jog_stop_mode (StopMode | None) – The stop mode.

Return type:

None

set_velparams(minimum_velocity=None, acceleration=None, maximum_velocity=None)#

Set velocity parameters on the device.

Parameters:
  • minimum_velocity (None | Quantity) – The minimum velocity. According to the documentation, this should always be 0. Therefore this parameter can be left unused.

  • acceleration (None | Quantity) – The acceleration.

  • maximum_velocity (None | Quantity) – The maximum velocity.

Return type:

None

tx_poll()#
Return type:

None

tx_poller_thread: Thread#
tx_poller_thread_lock: lock#
class pnpq.devices.waveplate_thorlabs_k10cr1.WaveplateVelocityParams#

Bases: TypedDict

TypedDict for waveplate velocity parameters. Used in get_velparams method.

acceleration: Quantity#

Dimensionality must be ([angle] / [time] ** 2) or k10cr1_acceleration

maximum_velocity: Quantity#

Dimensionality must be ([angle] / [time]) or k10cr1_velocity

minimum_velocity: Quantity#

Dimensionality must be ([angle] / [time]) or k10cr1_velocity

pnpq.devices.waveplate_thorlabs_k10cr1_stub module#

class pnpq.devices.waveplate_thorlabs_k10cr1_stub.WaveplateThorlabsK10CR1Stub#

Bases: AbstractWaveplateThorlabsK10CR1

current_home_params: WaveplateHomeParams#
current_jog_params: WaveplateJogParams#
current_state: dict[ChanIdent, Quantity]#
current_velocity_params: WaveplateVelocityParams#
get_homeparams()#

Request home parameters from the device.

Return type:

WaveplateHomeParams

get_jogparams()#

Request jog parameters from the device.

Return type:

WaveplateJogParams

get_velparams()#

Request velocity parameters from the device.

Return type:

WaveplateVelocityParams

home()#

Move the waveplate to its home position.

Return type:

None

homed: bool = False#
identify()#

Identify the device by blinking its LED.

Return type:

None

is_homed()#

Check if the device is homed. Sends the REQ_STATUSUPDATE message and checks the HOMED status bit.

Returns True if the device is homed, False otherwise.

Return type:

bool

jog(jog_direction)#

Jog the waveplate in a certain direction.

Parameters:

jog_direction (JogDirection) – The direction to jog in.

Return type:

None

log = <BoundLoggerLazyProxy(logger=None, wrapper_class=None, processors=None, context_class=None, initial_values={}, logger_factory_args=())>#
move_absolute(position)#

Move the waveplate to a certain angle.

Parameters:

position (Quantity) – The angle to move to.

Return type:

None

set_homeparams(home_direction=None, limit_switch=None, home_velocity=None, offset_distance=None)#

Set home parameters on the device.

Parameters:
  • home_direction (None | HomeDirection) – The home direction.

  • limit_switch (None | LimitSwitch) – The limit switch.

  • home_velocity (None | Quantity) – The home velocity.

  • offset_distance (None | Quantity) – The offset distance.

Return type:

None

set_jogparams(jog_mode=None, jog_step_size=None, jog_minimum_velocity=None, jog_acceleration=None, jog_maximum_velocity=None, jog_stop_mode=None)#

Set jog parameters on the device.

Parameters:
  • jog_mode (None | JogMode) – The jog mode.

  • jog_step_size (None | Quantity) – The jog step size.

  • jog_minimum_velocity (None | Quantity) – The minimum velocity.

  • jog_acceleration (None | Quantity) – The acceleration.

  • jog_maximum_velocity (None | Quantity) – The maximum velocity.

  • jog_stop_mode (None | StopMode) – The stop mode.

Return type:

None

set_velparams(minimum_velocity=None, acceleration=None, maximum_velocity=None)#

Set velocity parameters on the device.

Parameters:
  • minimum_velocity (None | Quantity) – The minimum velocity. According to the documentation, this should always be 0. Therefore this parameter can be left unused.

  • acceleration (None | Quantity) – The acceleration.

  • maximum_velocity (None | Quantity) – The maximum velocity.

Return type:

None

Module contents#